use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class LiteralsTest method testCreateLiteralObjectDate.
/**
* Test method for
* {@link org.eclipse.rdf4j.model.util.Literals#createLiteral(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
* .
*/
@Test
public void testCreateLiteralObjectDate() throws Exception {
Object obj = new Date();
Literal l = Literals.createLiteral(SimpleValueFactory.getInstance(), obj);
assertNotNull(l);
assertEquals(l.getDatatype(), XMLSchema.DATETIME);
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class LiteralsTest method testCreateLiteralOrFailObjectXMLGregorianCalendar.
/**
* Test method for
* {@link org.eclipse.rdf4j.model.util.Literals#createLiteralOrFail(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
* .
*/
@Test
public void testCreateLiteralOrFailObjectXMLGregorianCalendar() throws Exception {
GregorianCalendar c = new GregorianCalendar();
c.setTime(new Date());
try {
Object obj = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
Literal l = Literals.createLiteralOrFail(SimpleValueFactory.getInstance(), obj);
assertNotNull(l);
assertEquals(l.getDatatype(), XMLSchema.DATETIME);
// TODO check lexical value?
} catch (DatatypeConfigurationException e) {
e.printStackTrace();
fail("Could not instantiate javax.xml.datatype.DatatypeFactory");
}
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class LiteralsTest method testCreateLiteralObjectFloat.
/**
* Test method for
* {@link org.eclipse.rdf4j.model.util.Literals#createLiteral(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
* .
*/
@Test
public void testCreateLiteralObjectFloat() throws Exception {
Object obj = new Float(42);
Literal l = Literals.createLiteral(SimpleValueFactory.getInstance(), obj);
assertNotNull(l);
assertEquals(l.getDatatype(), XMLSchema.FLOAT);
assertEquals(l.getLabel(), "42.0");
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class LiteralsTest method testCreateLiteralOrFailObjectBoolean.
/**
* Test method for
* {@link org.eclipse.rdf4j.model.util.Literals#createLiteralOrFail(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
* .
*/
@Test
public void testCreateLiteralOrFailObjectBoolean() throws Exception {
Object obj = Boolean.TRUE;
Literal l = Literals.createLiteralOrFail(SimpleValueFactory.getInstance(), obj);
assertNotNull(l);
assertEquals(l.getDatatype(), XMLSchema.BOOLEAN);
assertTrue(l.booleanValue());
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class LiteralsTest method testCreateLiteralOrFailObjectString.
/**
* Test method for
* {@link org.eclipse.rdf4j.model.util.Literals#createLiteralOrFail(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
* .
*/
@Test
public void testCreateLiteralOrFailObjectString() throws Exception {
Object obj = "random unique string";
Literal l = Literals.createLiteralOrFail(SimpleValueFactory.getInstance(), obj);
assertNotNull(l);
assertEquals(l.getDatatype(), XMLSchema.STRING);
assertEquals(l.getLabel(), "random unique string");
}
Aggregations