}
public void testListEquals()
{
final Resource nil = model.getResource(RDF.nil.getURI());
final RDFList nilList = nil.as(RDFList.class);
// create a list of foos
final Resource[] r0 = new Resource[] {
model.createResource(TestList.NS + "a"), // canonical
model.createResource(TestList.NS + "b"),
model.createResource(TestList.NS + "c"),
model.createResource(TestList.NS + "d"),
model.createResource(TestList.NS + "e") };
final Resource[] r1 = new Resource[] {
model.createResource(TestList.NS + "a"), // same
model.createResource(TestList.NS + "b"),
model.createResource(TestList.NS + "c"),
model.createResource(TestList.NS + "d"),
model.createResource(TestList.NS + "e") };
final Resource[] r2 = new Resource[] {
model.createResource(TestList.NS + "a"), // one shorter
model.createResource(TestList.NS + "b"),
model.createResource(TestList.NS + "c"),
model.createResource(TestList.NS + "d") };
final Resource[] r3 = new Resource[] {
model.createResource(TestList.NS + "a"), // elements
// swapped
model.createResource(TestList.NS + "b"),
model.createResource(TestList.NS + "d"),
model.createResource(TestList.NS + "c"),
model.createResource(TestList.NS + "e") };
final Resource[] r4 = new Resource[] {
model.createResource(TestList.NS + "a"), // different
// name
model.createResource(TestList.NS + "b"),
model.createResource(TestList.NS + "c"),
model.createResource(TestList.NS + "D"),
model.createResource(TestList.NS + "e") };
final Object[][] testSpec = new Object[][] { { r0, r1, Boolean.TRUE },
{ r0, r2, Boolean.FALSE }, { r0, r3, Boolean.FALSE },
{ r0, r4, Boolean.FALSE }, { r1, r2, Boolean.FALSE },
{ r1, r3, Boolean.FALSE }, { r1, r4, Boolean.FALSE },
{ r2, r3, Boolean.FALSE }, { r2, r4, Boolean.FALSE }, };
for (int i = 0; i < testSpec.length; i++)
{
final RDFList l0 = nilList.append(Arrays.asList(
(Resource[]) testSpec[i][0]).iterator());
final RDFList l1 = nilList.append(Arrays.asList(
(Resource[]) testSpec[i][1]).iterator());
final boolean expected = ((Boolean) testSpec[i][2]).booleanValue();
Assert.assertEquals("sameListAs testSpec[" + i + "] incorrect",
expected, l0.sameListAs(l1));
Assert.assertEquals("sameListAs testSpec[" + i
+ "] (swapped) incorrect", expected, l1.sameListAs(l0));
}
}