use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.
the class RyaContextTest method testTripleRowSerialization.
public void testTripleRowSerialization() throws Exception {
RyaURI subj = new RyaURI("urn:test#subj");
RyaURI pred = new RyaURI("urn:test#pred");
RyaType obj = new RyaType("mydata");
RyaStatement statement = new RyaStatement(subj, pred, obj);
RyaTripleContext instance = RyaTripleContext.getInstance(new MockRdfCloudConfiguration());
Map<TABLE_LAYOUT, TripleRow> map = instance.serializeTriple(statement);
TripleRow tripleRow = map.get(TABLE_LAYOUT.SPO);
assertEquals(statement, instance.deserializeTriple(TABLE_LAYOUT.SPO, tripleRow));
}
use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.
the class DateTimeRyaTypeResolverTest method serializeAndDeserialize.
/**
* Serialize a datetime string, then deserialize as a ryaType.
* @param dateTimeString
* @param type if null , use default: XMLSchema.DATETIME
* @return
* @throws RyaTypeResolverException
*/
private RyaType serializeAndDeserialize(String dateTimeString, org.openrdf.model.URI type) throws RyaTypeResolverException {
if (type == null)
type = XMLSchema.DATETIME;
RyaType ryaType = new RyaType(type, dateTimeString);
byte[] serialize = new DateTimeRyaTypeResolver().serialize(ryaType);
return new DateTimeRyaTypeResolver().deserialize(serialize);
}
use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.
the class DateTimeRyaTypeResolverTest method testMilliSecondsNoZone.
@Test
public void testMilliSecondsNoZone() throws Exception {
String beforeDate = "2002-02-02T02:02:02.222";
String afterDate = "2002-02-0(1|2|3)T\\d\\d:\\d\\d:02\\.222.*";
RyaType deserialize = serializeAndDeserialize(beforeDate, XMLSchema.DATETIME);
final String afterActual = deserialize.getData();
assertTrue("Before='" + beforeDate + "'; Expected should match actual regex after='" + afterDate + "' deserialized:" + afterActual, afterActual.matches(afterDate));
assertEquals(XMLSchema.DATETIME, deserialize.getDataType());
}
use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.
the class RyaURIResolverTest method testSerialization.
public void testSerialization() throws Exception {
RyaURI ryaURI = new RyaURI("urn:testdata#data");
byte[] serialize = new RyaURIResolver().serialize(ryaURI);
RyaType deserialize = new RyaURIResolver().deserialize(serialize);
assertEquals(ryaURI, deserialize);
}
use of org.apache.rya.api.domain.RyaType in project incubator-rya by apache.
the class CustomDatatypeResolverTest method testCustomDataTypeSerialization.
public void testCustomDataTypeSerialization() throws Exception {
RyaType ryaType = new RyaType(new URIImpl("urn:test#datatype"), "testdata");
byte[] serialize = new CustomDatatypeResolver().serialize(ryaType);
RyaType deserialize = new CustomDatatypeResolver().deserialize(serialize);
assertEquals(ryaType, deserialize);
}
Aggregations