use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class XQueryFunctionsTest method exclusiveLock.
@Test
public void exclusiveLock() throws XPathException, XMLDBException {
String query = "let $query1 := (<a/>)\n" + "let $query2 := (2, 3)\n" + "let $a := util:exclusive-lock(//*,($query1, $query2))\n" + "return $a";
ResourceSet result = existEmbeddedServer.executeQuery(query);
assertEquals(3, result.getSize());
String r = (String) result.getResource(0).getContent();
assertEquals("<a/>", r);
r = (String) result.getResource(1).getContent();
assertEquals("2", r);
r = (String) result.getResource(2).getContent();
assertEquals("3", r);
query = "let $query1 := (<a/>)\n" + "let $query2 := (2, 3)\n" + "let $a := util:exclusive-lock((),($query1, $query2))\n" + "return $a";
result = existEmbeddedServer.executeQuery(query);
assertEquals(3, result.getSize());
r = (String) result.getResource(0).getContent();
assertEquals("<a/>", r);
r = (String) result.getResource(1).getContent();
assertEquals("2", r);
r = (String) result.getResource(2).getContent();
assertEquals("3", r);
query = "let $query1 := (<a/>)\n" + "let $query2 := (2, 3)\n" + "let $a := util:exclusive-lock((),($query1, $query2))\n" + "return $a";
result = existEmbeddedServer.executeQuery(query);
assertEquals(3, result.getSize());
r = (String) result.getResource(0).getContent();
assertEquals("<a/>", r);
r = (String) result.getResource(1).getContent();
assertEquals("2", r);
r = (String) result.getResource(2).getContent();
assertEquals("3", r);
query = "let $a := util:exclusive-lock(//*,<root/>)\n" + "return $a";
result = existEmbeddedServer.executeQuery(query);
r = (String) result.getResource(0).getContent();
assertEquals("<root/>", r);
}
use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class XQueryFunctionsTest method sharedLock.
@Test
public void sharedLock() throws XPathException, XMLDBException {
String query = "let $query1 := (<a/>)\n" + "let $query2 := (2, 3)\n" + "let $a := util:shared-lock(//*,($query1, $query2))\n" + "return $a";
ResourceSet result = existEmbeddedServer.executeQuery(query);
assertEquals(3, result.getSize());
String r = (String) result.getResource(0).getContent();
assertEquals("<a/>", r);
r = (String) result.getResource(1).getContent();
assertEquals("2", r);
r = (String) result.getResource(2).getContent();
assertEquals("3", r);
query = "let $query1 := (<a/>)\n" + "let $query2 := (2, 3)\n" + "let $a := util:shared-lock((),($query1, $query2))\n" + "return $a";
result = existEmbeddedServer.executeQuery(query);
assertEquals(3, result.getSize());
r = (String) result.getResource(0).getContent();
assertEquals("<a/>", r);
r = (String) result.getResource(1).getContent();
assertEquals("2", r);
r = (String) result.getResource(2).getContent();
assertEquals("3", r);
query = "let $query1 := (<a/>)\n" + "let $query2 := (2, 3)\n" + "let $a := util:shared-lock((),($query1, $query2))\n" + "return $a";
result = existEmbeddedServer.executeQuery(query);
assertEquals(3, result.getSize());
r = (String) result.getResource(0).getContent();
assertEquals("<a/>", r);
r = (String) result.getResource(1).getContent();
assertEquals("2", r);
r = (String) result.getResource(2).getContent();
assertEquals("3", r);
query = "let $a := util:shared-lock(//*,<root/>)\n" + "return $a";
result = existEmbeddedServer.executeQuery(query);
r = (String) result.getResource(0).getContent();
assertEquals("<root/>", r);
}
use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class XQueryFunctionsTest method data0.
@Test
public void data0() throws XMLDBException {
final String query = "let $a := <a><b>1</b><b>1</b></a> " + "for $b in $a/b[data() = '1'] return $b";
final ResourceSet result = existEmbeddedServer.executeQuery(query);
assertEquals(2, result.getSize());
}
use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class XQueryFunctionsTest method ceiling.
@Test
public void ceiling() throws XMLDBException {
String query = "let $a := <a><b>-1</b><b>-2</b></a> " + "return $a/b[abs(ceiling(.))]";
ResourceSet result = existEmbeddedServer.executeQuery(query);
assertEquals(2, result.getSize());
}
use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class XQueryFunctionsTest method stringJoin.
@Test
public void stringJoin() throws XMLDBException {
String query = "let $s := ('','a','b','') " + "return string-join($s,'/')";
ResourceSet result = existEmbeddedServer.executeQuery(query);
String r = (String) result.getResource(0).getContent();
assertEquals("/a/b/", r);
}
Aggregations