RDFImporter importer = new RDFImporter(mc);
SesameInputAdapter.parse(is, importer, "", RDFFormat.TURTLE);
mc.commit();
is.close();
RDFValue head;
Collector<RippleList> created = new Collector<RippleList>();
final Collector<RippleList> allowed = new Collector<RippleList>();
Sink<RippleList> verifySink = new Sink<RippleList>() {
public void put(final RippleList list) throws RippleException {
boolean found = false;
for (Iterator<RippleList> iter = allowed.iterator(); iter.hasNext(); ) {
if (0 == mc.getComparator().compare(iter.next(), list)) {
found = true;
break;
}
}
assertTrue(found);
}
};
RippleValue l1 = mc.valueOf("1", XMLSchema.STRING);
RippleValue l2 = mc.valueOf("2", XMLSchema.STRING);
RippleValue l1a = mc.valueOf("1a", XMLSchema.STRING);
RippleValue l1b = mc.valueOf("1b", XMLSchema.STRING);
RippleValue l2a = mc.valueOf("2a", XMLSchema.STRING);
RippleValue l2b = mc.valueOf("2b", XMLSchema.STRING);
head = new RDFValue(createURI("urn:test.RippleListTest.FromRdfTest#simpleList", mc));
created.clear();
mc.toList(head, created);
assertEquals(1, created.size());
allowed.clear();
allowed.put(mc.list().push(l2).push(l1));
created.writeTo(verifySink);
head = new RDFValue(createURI("urn:test.RippleListTest.FromRdfTest#firstBranchingList", mc));
created.clear();
mc.toList(head, created);
assertEquals(2, created.size());
allowed.clear();
allowed.put(mc.list().push(l2).push(l1a));
allowed.put(mc.list().push(l2).push(l1b));
created.writeTo(verifySink);
head = new RDFValue(createURI("urn:test.RippleListTest.FromRdfTest#restBranchingList", mc));
created.clear();
mc.toList(head, created);
assertEquals(2, created.size());
allowed.clear();
allowed.put(mc.list().push(l2a).push(l1));
allowed.put(mc.list().push(l2b).push(l1));
created.writeTo(verifySink);
head = new RDFValue(createURI("urn:test.RippleListTest.FromRdfTest#firstAndRestBranchingList", mc));
created.clear();
mc.toList(head, created);
assertEquals(4, created.size());
allowed.clear();
allowed.put(mc.list().push(l2a).push(l1a));