Search in sources :

Example 11 with XPathAxis

use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.

the class CompAxisTest method testComp.

@Test
public void testComp() throws SirixException {
    final AbstractAxis axis1 = new XPathAxis(holder.getReader(), "1.0 = 1.0");
    assertEquals(true, axis1.hasNext());
    axis1.next();
    assertEquals(true, Boolean.parseBoolean(holder.getReader().getValue()));
    assertEquals(false, axis1.hasNext());
    final AbstractAxis axis2 = new XPathAxis(holder.getReader(), "(1, 2, 3) < (2, 3)");
    assertEquals(true, axis2.hasNext());
    axis2.next();
    assertEquals(true, Boolean.parseBoolean(holder.getReader().getValue()));
    assertEquals(false, axis2.hasNext());
    final AbstractAxis axis3 = new XPathAxis(holder.getReader(), "(1, 2, 3) > (3, 4)");
    assertEquals(true, axis3.hasNext());
    axis3.next();
    assertEquals(false, Boolean.parseBoolean(holder.getReader().getValue()));
    assertEquals(false, axis3.hasNext());
}
Also used : XPathAxis(org.sirix.service.xml.xpath.XPathAxis) AbstractAxis(org.sirix.service.xml.xpath.AbstractAxis) Test(org.junit.Test)

Example 12 with XPathAxis

use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.

the class FunctionAxisTest method testFunctions.

@Test
public void testFunctions() throws SirixException {
    holder.getReader().moveTo(1L);
    final AbstractAxis axis1 = new XPathAxis(holder.getReader(), "fn:count(text())");
    assertEquals(true, axis1.hasNext());
    axis1.next();
    assertEquals(3, Integer.parseInt(holder.getReader().getValue()));
    assertEquals(false, axis1.hasNext());
    final AbstractAxis axis2 = new XPathAxis(holder.getReader(), "fn:count(//node())");
    assertEquals(true, axis2.hasNext());
    axis2.next();
    assertEquals(10, Integer.parseInt(holder.getReader().getValue()));
    assertEquals(false, axis2.hasNext());
    final AbstractAxis axis3 = new XPathAxis(holder.getReader(), "fn:string(//node())");
    assertEquals(true, axis3.hasNext());
    axis3.next();
    assertEquals("oops1 foo oops2 bar oops3 oops1 foo oops2 bar oops3 foo bar", holder.getReader().getValue());
    assertEquals(false, axis3.hasNext());
    final AbstractAxis axis4 = new XPathAxis(holder.getReader(), "fn:string()");
    assertEquals(true, axis4.hasNext());
    axis4.next();
    assertEquals("oops1 foo oops2 bar oops3", holder.getReader().getValue());
    assertEquals(false, axis4.hasNext());
    final AbstractAxis axis5 = new XPathAxis(holder.getReader(), "fn:string(./attribute::attribute())");
    assertEquals(true, axis5.hasNext());
    axis5.next();
    assertEquals("j", holder.getReader().getValue());
    assertEquals(false, axis5.hasNext());
    holder.getReader().moveToAttribute(0);
    final AbstractAxis axis6 = new XPathAxis(holder.getReader(), "fn:string()");
    assertEquals(true, axis6.hasNext());
    axis6.next();
    assertEquals("j", holder.getReader().getValue());
    assertEquals(false, axis6.hasNext());
}
Also used : XPathAxis(org.sirix.service.xml.xpath.XPathAxis) AbstractAxis(org.sirix.service.xml.xpath.AbstractAxis) Test(org.junit.Test)

Example 13 with XPathAxis

use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.

the class FunctionsXMarkTest method testSum.

/**
 * Test function sum().
 *
 * @throws SirixXPathException
 */
@Ignore
@Test
public final void testSum() throws SirixXPathException {
    final String query = "fn:sum(/site/open_auctions/open_auction/bidder/increase/text())";
    final String result = "96496.5";
    XPathStringChecker.testIAxisConventions(new XPathAxis(holder.getReader(), query), new String[] { result });
}
Also used : XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 14 with XPathAxis

use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.

the class FunctionsXMarkTest method testComment.

/**
 * Test comment.
 *
 * @throws SirixXPathException
 */
@Ignore
@Test
public final void testComment() throws SirixXPathException {
    final String query = "2 (: this is a comment :)";
    final String result = "2";
    XPathStringChecker.testIAxisConventions(new XPathAxis(holder.getReader(), query), new String[] { result });
}
Also used : XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 15 with XPathAxis

use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.

the class FunctionsXMarkTest method testSubstringBefore.

/**
 * Test function substring-before().
 *
 * @throws SirixXPathException
 */
@Ignore
@Test
public final void testSubstringBefore() throws SirixXPathException {
    final String query = "fn:substring-before(\"query\", \"r\")";
    final String result = "que";
    XPathStringChecker.testIAxisConventions(new XPathAxis(holder.getReader(), query), new String[] { result });
}
Also used : XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

XPathAxis (org.sirix.service.xml.xpath.XPathAxis)67 Test (org.junit.Test)62 Ignore (org.junit.Ignore)27 AbsAxisTest (org.sirix.axis.AbsAxisTest)18 SirixXPathException (org.sirix.exception.SirixXPathException)12 AbstractAxis (org.sirix.service.xml.xpath.AbstractAxis)12 Axis (org.sirix.api.Axis)6 IOException (java.io.IOException)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 SessionConfiguration (org.sirix.access.conf.SessionConfiguration)3 Database (org.sirix.api.Database)3 NodeReadTrx (org.sirix.api.NodeReadTrx)3 Session (org.sirix.api.Session)3 SirixException (org.sirix.exception.SirixException)3 XPathError (org.sirix.service.xml.xpath.XPathError)3 XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)2 LinkedList (java.util.LinkedList)1 StringTokenizer (java.util.StringTokenizer)1 QName (javax.xml.namespace.QName)1 XMLEvent (javax.xml.stream.events.XMLEvent)1