Exemple #1
0
 /** Test method. */
 @Test
 public void textEntry() {
   query(_ZIP_TEXT_ENTRY.args(ZIP, ENTRY1));
   query(_ZIP_TEXT_ENTRY.args(ZIP, ENTRY1, "US-ASCII"));
   error(_ZIP_TEXT_ENTRY.args(ZIP, ENTRY1, "xyz"), Err.ZIP_FAIL);
   // newlines are removed from the result..
   contains(_ZIP_TEXT_ENTRY.args(ZIP, ENTRY1), "aaboutab");
 }
Exemple #2
0
  /**
   * Test method.
   *
   * @throws IOException I/O exception
   */
  @Test
  public void zipFileNS() throws IOException {
    // ZIP namespace must be removed from zipped node
    query(_ZIP_ZIP_FILE.args(params("<entry name='1'><a/></entry>")));
    checkEntry("1", token("<a/>"));
    // ZIP namespace must be removed from zipped node
    query(_ZIP_ZIP_FILE.args(params("<entry name='2'><a b='c'/></entry>")));
    checkEntry("2", token("<a b=\"c\"/>"));
    // ZIP namespace must be removed from zipped node and its descendants
    query(_ZIP_ZIP_FILE.args(params("<entry name='3'><a><b/></a></entry>")));
    checkEntry("3", token("<a>" + Prop.NL + "  <b/>" + Prop.NL + "</a>"));
    // ZIP namespace must be removed from zipped entry
    query(_ZIP_ZIP_FILE.args(params("<entry name='4'><a xmlns=''/></entry>")));
    checkEntry("4", token("<a/>"));

    // ZIP namespace must be removed from zipped entry
    query(_ZIP_ZIP_FILE.args(paramsPrefix("5", "<a/>")));
    checkEntry("5", token("<a/>"));
    query(_ZIP_ZIP_FILE.args(paramsPrefix("6", "<a><b/></a>")));
    checkEntry("6", token("<a>" + Prop.NL + "  <b/>" + Prop.NL + "</a>"));
    query(_ZIP_ZIP_FILE.args(paramsPrefix("7", "<z:a xmlns:z='z'/>")));
    checkEntry("7", token("<z:a xmlns:z=\"z\"/>"));
    query(_ZIP_ZIP_FILE.args(paramsPrefix("8", "<zip:a xmlns:zip='z'/>")));
    checkEntry("8", token("<zip:a xmlns:zip=\"z\"/>"));
    query(_ZIP_ZIP_FILE.args(paramsPrefix("9", "<a xmlns='z'/>")));
    checkEntry("9", token("<a xmlns=\"z\"/>"));
  }
Exemple #3
0
  /** Test method. */
  @Test
  public void updateEntries() {
    String list = query(_ZIP_ENTRIES.args(ZIP));

    // create and compare identical zip file
    query(_ZIP_UPDATE_ENTRIES.args(list, TMPZIP));
    final String list2 = query(_ZIP_ENTRIES.args(TMPZIP));
    assertEquals(list.replaceAll(" href=\".*?\"", ""), list2.replaceAll(" href=\".*?\"", ""));

    // remove one directory
    list = list.replaceAll("<zip:dir name=.test.>.*</zip:dir>", "");
    query(_ZIP_UPDATE_ENTRIES.args(list, TMPZIP));
  }
Exemple #4
0
  /** Test method. */
  @Test
  public void binaryEntry() {
    query(_ZIP_BINARY_ENTRY.args(ZIP, ENTRY1));
    contains("xs:hexBinary(" + _ZIP_BINARY_ENTRY.args(ZIP, ENTRY1) + ")", "610A61626F");

    error(_ZIP_BINARY_ENTRY.args("abc", "xyz"), Err.ZIP_NOTFOUND);
    error(_ZIP_BINARY_ENTRY.args(ZIP, ""), Err.ZIP_NOTFOUND);
  }
Exemple #5
0
  /**
   * Test method.
   *
   * @throws IOException I/O exception
   */
  @Test
  public void zipFile() throws IOException {
    // check first file
    query(_ZIP_ZIP_FILE.args(params("<entry name='one'/>")));
    checkEntry("one", new byte[0]);
    // check second file
    query(_ZIP_ZIP_FILE.args(params("<entry name='two'>!</entry>")));
    checkEntry("two", new byte[] {'!'});
    // check third file
    query(_ZIP_ZIP_FILE.args(params("<entry name='three' encoding='UTF-16'>!</entry>")));
    checkEntry("three", new byte[] {'\0', '!'});
    // check fourth file
    query(_ZIP_ZIP_FILE.args(params("<entry name='four' src='" + TMPFILE + "'/>")));
    checkEntry("four", new byte[] {'!'});
    // check fifth file
    query(_ZIP_ZIP_FILE.args(params("<entry src='" + TMPFILE + "'/>")));
    checkEntry(NAME + ".tmp", new byte[] {'!'});
    // check sixth file
    query(
        _ZIP_ZIP_FILE.args(params("<dir name='a'><entry name='b' src='" + TMPFILE + "'/></dir>")));
    checkEntry("a/b", new byte[] {'!'});

    // error: duplicate entry specified
    error(
        _ZIP_ZIP_FILE.args(
            params("<entry src='" + TMPFILE + "'/>" + "<entry src='" + TMPFILE + "'/>")),
        Err.ZIP_FAIL);
  }
Exemple #6
0
 /** Test method. */
 @Test
 public void entries() {
   query(_ZIP_ENTRIES.args(ZIP));
 }
Exemple #7
0
 /** Test method. */
 @Test
 public void xmlEntry() {
   query(_ZIP_XML_ENTRY.args(ZIP, ENTRY2));
   query(_ZIP_XML_ENTRY.args(ZIP, ENTRY2) + "//title/text()", "XML");
 }