*/
public class RdfListTest {
@Test
public void listCreationAndAccess() {
TripleCollection tc = new SimpleMGraph();
List<Resource> list = new RdfList(new UriRef("http://example.org/mytest"), tc);
assertEquals(0, list.size());
list.add(new PlainLiteralImpl("hello"));
list.add(new PlainLiteralImpl("world"));
assertEquals(new PlainLiteralImpl("hello"), list.get(0));
assertEquals(new PlainLiteralImpl("world"), list.get(1));
assertEquals(2, list.size());
list.add(new PlainLiteralImpl("welcome"));
assertEquals(3, list.size());
assertEquals(new PlainLiteralImpl("welcome"), list.get(2));
list.add(1, new PlainLiteralImpl("interesting"));
assertEquals(4, list.size());
assertEquals(new PlainLiteralImpl("interesting"), list.get(1));
assertEquals(new PlainLiteralImpl("world"), list.get(2));
assertEquals(new PlainLiteralImpl("welcome"), list.get(3));
list.add(0, new PlainLiteralImpl("start"));
assertEquals(5, list.size());
assertEquals(new PlainLiteralImpl("hello"), list.get(1));
assertEquals(new PlainLiteralImpl("interesting"), list.get(2));
List<Resource> list2 = new RdfList(new UriRef("http://example.org/mytest"), tc);
assertEquals(5, list2.size());
assertEquals(new PlainLiteralImpl("hello"), list2.get(1));
assertEquals(new PlainLiteralImpl("interesting"), list2.get(2));
list2.remove(2);
assertEquals(4, list2.size());
assertEquals(new PlainLiteralImpl("hello"), list2.get(1));
assertEquals(new PlainLiteralImpl("world"), list2.get(2));
while (list2.size() > 0) {
list2.remove(0);
}
assertEquals(1, tc.size()); //list = rdf:nil statement
list2.add(0, new PlainLiteralImpl("restart"));
list2.add(1, new PlainLiteralImpl("over"));
assertEquals(2, list2.size());
list2.add(new PlainLiteralImpl("2"));
list2.add(new PlainLiteralImpl("3"));