use of org.sirix.service.xml.xpath.expr.SequenceAxis in project sirix by sirixdb.
the class MulOpAxisTest method testGetReturnType.
@Test
public final void testGetReturnType() throws SirixException {
AbstractAxis op1 = new SequenceAxis(holder.getReader());
AbstractAxis op2 = new SequenceAxis(holder.getReader());
AbstractObAxis axis = new MulOpAxis(holder.getReader(), op1, op2);
assertEquals(Type.DOUBLE, axis.getReturnType(holder.getReader().keyForName("xs:double"), holder.getReader().keyForName("xs:double")));
assertEquals(Type.DOUBLE, axis.getReturnType(holder.getReader().keyForName("xs:decimal"), holder.getReader().keyForName("xs:double")));
assertEquals(Type.FLOAT, axis.getReturnType(holder.getReader().keyForName("xs:float"), holder.getReader().keyForName("xs:decimal")));
assertEquals(Type.DECIMAL, axis.getReturnType(holder.getReader().keyForName("xs:decimal"), holder.getReader().keyForName("xs:integer")));
// assertEquals(Type.INTEGER,
// axis.getReturnType(holder.getRtx().keyForName("xs:integer"),
// holder.getRtx().keyForName("xs:integer")));
assertEquals(Type.YEAR_MONTH_DURATION, axis.getReturnType(holder.getReader().keyForName("xs:yearMonthDuration"), holder.getReader().keyForName("xs:double")));
assertEquals(Type.YEAR_MONTH_DURATION, axis.getReturnType(holder.getReader().keyForName("xs:integer"), holder.getReader().keyForName("xs:yearMonthDuration")));
assertEquals(Type.DAY_TIME_DURATION, axis.getReturnType(holder.getReader().keyForName("xs:dayTimeDuration"), holder.getReader().keyForName("xs:double")));
assertEquals(Type.DAY_TIME_DURATION, axis.getReturnType(holder.getReader().keyForName("xs:integer"), holder.getReader().keyForName("xs:dayTimeDuration")));
try {
axis.getReturnType(holder.getReader().keyForName("xs:dateTime"), holder.getReader().keyForName("xs:yearMonthDuration"));
fail("Expected an XPathError-Exception.");
} catch (XPathError e) {
assertThat(e.getMessage(), is("err:XPTY0004 The type is not appropriate the expression or the " + "typedoes not match a required type as specified by the matching rules."));
}
try {
axis.getReturnType(holder.getReader().keyForName("xs:dateTime"), holder.getReader().keyForName("xs:double"));
fail("Expected an XPathError-Exception.");
} catch (XPathError e) {
assertThat(e.getMessage(), is("err:XPTY0004 The type is not appropriate the expression or the " + "typedoes not match a required type as specified by the matching rules."));
}
try {
axis.getReturnType(holder.getReader().keyForName("xs:string"), holder.getReader().keyForName("xs:yearMonthDuration"));
fail("Expected an XPathError-Exception.");
} catch (XPathError e) {
assertThat(e.getMessage(), is("err:XPTY0004 The type is not appropriate the expression or the " + "typedoes not match a required type as specified by the matching rules."));
}
try {
axis.getReturnType(holder.getReader().keyForName("xs:yearMonthDuration"), holder.getReader().keyForName("xs:yearMonthDuration"));
fail("Expected an XPathError-Exception.");
} catch (XPathError e) {
assertThat(e.getMessage(), is("err:XPTY0004 The type is not appropriate the expression or the " + "typedoes not match a required type as specified by the matching rules."));
}
}
use of org.sirix.service.xml.xpath.expr.SequenceAxis in project sirix by sirixdb.
the class SubOpAxisTest method testGetReturnType.
@Test
public final void testGetReturnType() throws SirixException {
AbstractAxis op1 = new SequenceAxis(holder.getReader());
AbstractAxis op2 = new SequenceAxis(holder.getReader());
AbstractObAxis axis = new SubOpAxis(holder.getReader(), op1, op2);
assertEquals(Type.DOUBLE, axis.getReturnType(holder.getReader().keyForName("xs:double"), holder.getReader().keyForName("xs:double")));
assertEquals(Type.DOUBLE, axis.getReturnType(holder.getReader().keyForName("xs:decimal"), holder.getReader().keyForName("xs:double")));
assertEquals(Type.FLOAT, axis.getReturnType(holder.getReader().keyForName("xs:float"), holder.getReader().keyForName("xs:decimal")));
assertEquals(Type.DECIMAL, axis.getReturnType(holder.getReader().keyForName("xs:decimal"), holder.getReader().keyForName("xs:integer")));
// assertEquals(Type.INTEGER,
// axis.getReturnType(holder.getRtx().keyForName("xs:integer"),
// holder.getRtx().keyForName("xs:integer")));
assertEquals(Type.YEAR_MONTH_DURATION, axis.getReturnType(holder.getReader().keyForName("xs:yearMonthDuration"), holder.getReader().keyForName("xs:yearMonthDuration")));
assertEquals(Type.DAY_TIME_DURATION, axis.getReturnType(holder.getReader().keyForName("xs:dayTimeDuration"), holder.getReader().keyForName("xs:dayTimeDuration")));
assertEquals(Type.DAY_TIME_DURATION, axis.getReturnType(holder.getReader().keyForName("xs:date"), holder.getReader().keyForName("xs:date")));
assertEquals(Type.DATE, axis.getReturnType(holder.getReader().keyForName("xs:date"), holder.getReader().keyForName("xs:yearMonthDuration")));
assertEquals(Type.DATE, axis.getReturnType(holder.getReader().keyForName("xs:date"), holder.getReader().keyForName("xs:dayTimeDuration")));
assertEquals(Type.DAY_TIME_DURATION, axis.getReturnType(holder.getReader().keyForName("xs:time"), holder.getReader().keyForName("xs:time")));
assertEquals(Type.DATE_TIME, axis.getReturnType(holder.getReader().keyForName("xs:dateTime"), holder.getReader().keyForName("xs:yearMonthDuration")));
assertEquals(Type.DATE_TIME, axis.getReturnType(holder.getReader().keyForName("xs:dateTime"), holder.getReader().keyForName("xs:dayTimeDuration")));
assertEquals(Type.DAY_TIME_DURATION, axis.getReturnType(holder.getReader().keyForName("xs:dateTime"), holder.getReader().keyForName("xs:dateTime")));
try {
axis.getReturnType(holder.getReader().keyForName("xs:string"), holder.getReader().keyForName("xs:yearMonthDuration"));
fail("Expected an XPathError-Exception.");
} catch (XPathError e) {
assertThat(e.getMessage(), is("err:XPTY0004 The type is not appropriate the expression or the " + "typedoes not match a required type as specified by the matching rules."));
}
try {
axis.getReturnType(holder.getReader().keyForName("xs:dateTime"), holder.getReader().keyForName("xs:double"));
fail("Expected an XPathError-Exception.");
} catch (XPathError e) {
assertThat(e.getMessage(), is("err:XPTY0004 The type is not appropriate the expression or the " + "typedoes not match a required type as specified by the matching rules."));
}
try {
axis.getReturnType(holder.getReader().keyForName("xs:string"), holder.getReader().keyForName("xs:yearMonthDuration"));
fail("Expected an XPathError-Exception.");
} catch (XPathError e) {
assertThat(e.getMessage(), is("err:XPTY0004 The type is not appropriate the expression or the " + "typedoes not match a required type as specified by the matching rules."));
}
try {
axis.getReturnType(holder.getReader().keyForName("xs:dateTime"), holder.getReader().keyForName("xs:IDREF"));
fail("Expected an XPathError-Exception.");
} catch (XPathError e) {
assertThat(e.getMessage(), is("err:XPTY0004 The type is not appropriate the expression or the " + "typedoes not match a required type as specified by the matching rules."));
}
}
Aggregations