Exemplo n.º 1
0
 /**
  * Runs a query with additional serialization parameters.
  *
  * @throws IOException I/O exception
  */
 @Test
 public void querySerial1() throws IOException {
   session.execute("set serializer wrap-prefix=db,wrap-uri=ns");
   final Query query = session.query(WRAPPER + "()");
   assertTrue("Result expected.", query.more());
   assertEqual("<db:results xmlns:db=\"ns\"/>", query.next());
   assertFalse("No result expected.", query.more());
 }
Exemplo n.º 2
0
 /**
  * Queries empty content.
  *
  * @throws IOException I/O exception
  */
 @Test
 public void queryEmptyString() throws IOException {
   final Query q = session.query("'',1");
   assertTrue(q.more());
   assertEqual("", q.next());
   assertTrue(q.more());
   assertEqual("1", q.next());
   assertNull(q.next());
 }
Exemplo n.º 3
0
 /**
  * Queries binary content.
  *
  * @throws IOException I/O exception
  */
 @Test
 public void queryNullBinary() throws IOException {
   session.execute("create db " + NAME);
   session.store("X", new ArrayInput("\0"));
   assertEqual("\0", session.execute("xquery " + RAW + _DB_RETRIEVE.args(NAME, "X")));
   assertEqual("\0", session.query(RAW + _DB_RETRIEVE.args(NAME, "X")).execute());
   final Query q = session.query(RAW + _DB_RETRIEVE.args(NAME, "X"));
   assertTrue(q.more());
   assertEqual("\0", q.next());
   assertFalse(q.more());
 }
Exemplo n.º 4
0
 /**
  * Runs a query and retrieves multiple results as string.
  *
  * @throws IOException I/O exception
  */
 @Test
 public void queryMore() throws IOException {
   final Query query = session.query("1 to 3");
   int c = 0;
   while (query.more()) assertEqual(++c, query.next());
   query.close();
 }
Exemplo n.º 5
0
 /**
  * Runs a query with additional serialization parameters.
  *
  * @throws IOException I/O exception
  */
 @Test
 public void querySerial2() throws IOException {
   final Query query = session.query(WRAPPER + "1 to 2");
   assertTrue("Result expected.", query.more());
   assertEqual(
       "<db:results xmlns:db=\"ns\">  <db:result>1</db:result>"
           + "  <db:result>2</db:result></db:results>",
       query.next());
 }
Exemplo n.º 6
0
 /**
  * Runs a query, using more().
  *
  * @throws IOException I/O exception
  */
 @Test
 public void queryInit() throws IOException {
   final Query query = session.query("()");
   assertFalse("No result was expected.", query.more());
 }
Exemplo n.º 7
0
 /**
  * Runs a query and retrieves the result as string.
  *
  * @throws IOException I/O exception
  */
 @Test
 public void query2() throws IOException {
   final Query query = session.query("1");
   if (!query.more()) fail("No result returned");
   assertEqual("1", query.next());
 }