public void testDateTime_2() { Literal l1 = m.createTypedLiteral("P1Y2M3DT5H0M", XSDDatatype.XSDduration); assertEquals("serialization", "P1Y2M3DT5H", l1.getValue().toString()); } public void testDateTime_3() {
/** * Chek the serialization of the parse of a value. */ public void checkSerialization(String lex, RDFDatatype dtype) { Literal l = m.createTypedLiteral(lex, dtype); assertEquals(l.getValue().toString(), lex); }
public void testDateTime_17() { // Creation of datetime from a date object Calendar ncal = new GregorianCalendar(TimeZone.getTimeZone("GMT")); ncal.set(2003, 11, 8, 10, 50, 42); ncal.set(Calendar.MILLISECOND, 0); Literal l1 = m.createTypedLiteral(ncal); assertEquals("DateTime from date", XSDDatatype.XSDdateTime, l1.getDatatype()); assertEquals("DateTime from date", XSDDateTime.class, l1.getValue().getClass()); assertEquals("DateTime from date", "2003-12-08T10:50:42Z", l1.getValue().toString()); }
public void testDateTime_17() { // Creation of datetime from a date object Calendar ncal = new GregorianCalendar(TimeZone.getTimeZone("GMT")); ncal.set(2003, 11, 8, 10, 50, 42); ncal.set(Calendar.MILLISECOND, 0); Literal l1 = m.createTypedLiteral(ncal); assertEquals("DateTime from date", XSDDatatype.XSDdateTime, l1.getDatatype()); assertEquals("DateTime from date", XSDDateTime.class, l1.getValue().getClass()); assertEquals("DateTime from date", "2003-12-08T10:50:42Z", l1.getValue().toString()); }
/** * Check can legally construct a literal with given lex, value and dtype */ public void checkLegalLiteral(String lex, RDFDatatype dtype, Class<?> jtype, Object value) { Literal l = m.createTypedLiteral(lex, dtype); assertEquals(l.getValue().getClass(), jtype); assertEquals(l.getValue(), value); assertEquals(l.getDatatype(), dtype); }
public void testDateTime_5() { Literal d1 = m.createTypedLiteral("PT1H1M1S", XSDDatatype.XSDduration); Literal d2 = m.createTypedLiteral("PT1H1M1.1S", XSDDatatype.XSDduration); assertTrue("duration compare", !d1.sameValueAs(d2)); XSDDuration dur1 = (XSDDuration)d1.getValue() ; XSDDuration dur2 = (XSDDuration)d2.getValue() ; assertEquals("duration compare order", 1, dur2.compare(dur1)) ; } public void testDateTime_6() {
public void testDateTime_5() { Literal d1 = m.createTypedLiteral("PT1H1M1S", XSDDatatype.XSDduration); Literal d2 = m.createTypedLiteral("PT1H1M1.1S", XSDDatatype.XSDduration); assertTrue("duration compare", !d1.sameValueAs(d2)); XSDDuration dur1 = (XSDDuration)d1.getValue() ; XSDDuration dur2 = (XSDDuration)d2.getValue() ; assertEquals("duration compare order", 1, dur2.compare(dur1)) ; } public void testDateTime_6() {
private void doDateTimeTest(Calendar cal, String lex, double time) { Literal lc4 = m.createTypedLiteral(cal); assertEquals("serialization", lex, lc4.getValue().toString()); assertEquals("calendar ms test", m.createTypedLiteral(lex, XSDDatatype.XSDdateTime), lc4 ); XSDDateTime dt4 = (XSDDateTime)lc4.getValue(); assertTrue("Fraction time check", Math.abs(dt4.getSeconds() - time) < 0.0001); assertEquals(dt4.asCalendar(), cal); }
private void doDateTimeTest(Calendar cal, String lex, double time) { Literal lc4 = m.createTypedLiteral(cal); assertEquals("serialization", lex, lc4.getValue().toString()); assertEquals("calendar ms test", m.createTypedLiteral(lex, XSDDatatype.XSDdateTime), lc4 ); XSDDateTime dt4 = (XSDDateTime)lc4.getValue(); assertTrue("Fraction time check", Math.abs(dt4.getSeconds() - time) < 0.0001); assertEquals(dt4.asCalendar(), cal); }
public void testDateTime_3() { Literal l1 = m.createTypedLiteral("P1Y", XSDDatatype.XSDduration); assertEquals("duration data type", XSDDatatype.XSDduration, l1.getDatatype()); assertEquals("duration java type", XSDDuration.class, l1.getValue().getClass()); assertEquals("duration value", 1, ((XSDDuration)l1.getValue()).getYears()); assertEquals("serialization", "P1Y", l1.getValue().toString()); assertTrue("equality test", l1.sameValueAs( m.createTypedLiteral("P1Y", XSDDatatype.XSDduration) ) ); assertTrue("inequality test", l1 != m.createTypedLiteral("P1Y", XSDDatatype.XSDduration)); } public void testDateTime_4() {
public void testDateTime_16() { Literal l1 = m.createTypedLiteral("---25", XSDDatatype.XSDgDay); assertEquals("dateTime data type", XSDDatatype.XSDgDay, l1.getDatatype()); assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass()); XSDDateTime xdt = (XSDDateTime)l1.getValue(); assertEquals("dateTime value", 25, xdt.getDays()); try { xdt.getMonths(); assertTrue("Failed to prevent illegal access", false); } catch (IllegalDateTimeFieldException e) {} }
public void testDateTime_3() { Literal l1 = m.createTypedLiteral("P1Y", XSDDatatype.XSDduration); assertEquals("duration data type", XSDDatatype.XSDduration, l1.getDatatype()); assertEquals("duration java type", XSDDuration.class, l1.getValue().getClass()); assertEquals("duration value", 1, ((XSDDuration)l1.getValue()).getYears()); assertEquals("serialization", "P1Y", l1.getValue().toString()); assertTrue("equality test", l1.sameValueAs( m.createTypedLiteral("P1Y", XSDDatatype.XSDduration) ) ); assertTrue("inequality test", l1 != m.createTypedLiteral("P1Y", XSDDatatype.XSDduration)); } public void testDateTime_4() {
public void testDateTime_13() { Literal l1 = m.createTypedLiteral("1999", XSDDatatype.XSDgYear); assertEquals("dateTime data type", XSDDatatype.XSDgYear, l1.getDatatype()); assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass()); XSDDateTime xdt = (XSDDateTime)l1.getValue(); assertEquals("dateTime value", 1999, xdt.getYears()); try { xdt.getMonths(); assertTrue("Failed to prevent illegal access", false); } catch (IllegalDateTimeFieldException e) {} // gMonth }
public void testDateTime_13() { Literal l1 = m.createTypedLiteral("1999", XSDDatatype.XSDgYear); assertEquals("dateTime data type", XSDDatatype.XSDgYear, l1.getDatatype()); assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass()); XSDDateTime xdt = (XSDDateTime)l1.getValue(); assertEquals("dateTime value", 1999, xdt.getYears()); try { xdt.getMonths(); assertTrue("Failed to prevent illegal access", false); } catch (IllegalDateTimeFieldException e) {} // gMonth }
public void testDateTime_14() { Literal l1 = m.createTypedLiteral("--05--", XSDDatatype.XSDgMonth); assertEquals("dateTime data type", XSDDatatype.XSDgMonth, l1.getDatatype()); assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass()); XSDDateTime xdt = (XSDDateTime)l1.getValue(); assertEquals("dateTime value", 5, xdt.getMonths()); try { xdt.getYears(); assertTrue("Failed to prevent illegal access", false); } catch (IllegalDateTimeFieldException e) {} }
public void testDateTime_16() { Literal l1 = m.createTypedLiteral("---25", XSDDatatype.XSDgDay); assertEquals("dateTime data type", XSDDatatype.XSDgDay, l1.getDatatype()); assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass()); XSDDateTime xdt = (XSDDateTime)l1.getValue(); assertEquals("dateTime value", 25, xdt.getDays()); try { xdt.getMonths(); assertTrue("Failed to prevent illegal access", false); } catch (IllegalDateTimeFieldException e) {} }
public void testDateTime_4() { Literal l1 = m.createTypedLiteral("-P120D", XSDDatatype.XSDduration); Literal l2 = m.createTypedLiteral( l1.getValue() ); assertEquals("-P120D", l2.getLexicalForm() ); } public void testDateTime_5() {
public void testDateTime_4() { Literal l1 = m.createTypedLiteral("-P120D", XSDDatatype.XSDduration); Literal l2 = m.createTypedLiteral( l1.getValue() ); assertEquals("-P120D", l2.getLexicalForm() ); } public void testDateTime_5() {
public void testDateTime_15() { Literal l1 = m.createTypedLiteral("--05-25", XSDDatatype.XSDgMonthDay); assertEquals("dateTime data type", XSDDatatype.XSDgMonthDay, l1.getDatatype()); assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass()); XSDDateTime xdt = (XSDDateTime)l1.getValue(); assertEquals("dateTime value", 5, xdt.getMonths()); assertEquals("dateTime value", 25, xdt.getDays()); try { xdt.getYears(); assertTrue("Failed to prevent illegal access", false); } catch (IllegalDateTimeFieldException e) {} }
public void testDateTime_15() { Literal l1 = m.createTypedLiteral("--05-25", XSDDatatype.XSDgMonthDay); assertEquals("dateTime data type", XSDDatatype.XSDgMonthDay, l1.getDatatype()); assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass()); XSDDateTime xdt = (XSDDateTime)l1.getValue(); assertEquals("dateTime value", 5, xdt.getMonths()); assertEquals("dateTime value", 25, xdt.getDays()); try { xdt.getYears(); assertTrue("Failed to prevent illegal access", false); } catch (IllegalDateTimeFieldException e) {} }