/** 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); }
/** Test query. */ @Test public void duplicateXMLNamespace() { create(1); query("insert node attribute xml:space { 'preserve' } into /x", ""); query(".", "<x xml:space='preserve'/>"); error("insert node attribute xml:space { 'preserve' } into /x", UPATTDUPL_X); }
/** * 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); }
/** Checks namespace declarations. */ @Test public void renameNSCheck5() { error( "copy $a := <a xmlns:p='A' a='v'/> " + "modify rename node $a/@a as QName('uri', 'p:a') " + "return $a", UPNSCONFL_X_X); }
/** 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"); }
/** Checks namespace declarations. */ @Test public void renameRemoveNS1() { error( "copy $a := <a xmlns='A'><b xmlns='B'/></a> " + "modify for $el in $a/descendant-or-self::element() return " + "rename node $el as QName('',local-name($el)) " + "return $a", UPNSCONFL_X_X); }
@Override protected boolean run() { final String query = find(args[0], context, root); final boolean ok = query(query); final StringBuilder sb = new StringBuilder(); if (prop.is(Prop.QUERYINFO)) { sb.append(NL).append(QUERY_CC).append(NL).append(query).append(NL); } sb.append(info()); error(sb.toString()); return ok; }
/** Test query. */ @Test public void duplicateNamespaces() { query( "copy $c := <a xmlns='X'/> modify (" + " rename node $c as QName('X','b')," + " insert node attribute c{'a'} into $c" + ") return $c", "<b xmlns=\"X\" c=\"a\"/>"); error( "copy $c := <a xmlns='X'/> modify (" + " rename node $c as QName('Y','b')," + " insert node attribute c{'a'} into $c" + ") return $c", UPNSCONFL_X_X); query( "copy $c := <a/> modify (" + " rename node $c as QName('X','b')," + " insert node attribute c{'a'} into $c" + ") return $c", "<b xmlns=\"X\" c=\"a\"/>"); }
/** * Runs the specified command. * * @param c command * @param os output stream * @throws HTTPException HTTP exception */ final void run(final Command c, final OutputStream os) throws HTTPException { final boolean ok = c.run(context, os); error(c.info()); if (!ok) throw HTTPCode.BAD_REQUEST_X.get(c.info()); }