1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.rdf.api;
19
20 import static org.junit.Assert.*;
21
22 import org.junit.Test;
23
24 public class DefaultGraphTest {
25
26 DummyGraph graph = new DummyGraph();
27
28 @Test
29 public void close() throws Exception {
30 graph.close();
31 }
32
33 @SuppressWarnings("deprecation")
34 @Test
35 public void defaultGetTriples() throws Exception {
36 assertFalse(graph.streamCalled);
37 assertFalse(graph.filteredStreamCalled);
38 assertEquals(1L, graph.getTriples().count());
39 assertTrue(graph.streamCalled);
40 assertFalse(graph.filteredStreamCalled);
41 }
42
43 @SuppressWarnings("deprecation")
44 @Test
45 public void defaultGetTriplesFiltered() throws Exception {
46 assertFalse(graph.streamCalled);
47 assertFalse(graph.filteredStreamCalled);
48 assertEquals(1L, graph.getTriples(null,null,null).count());
49 assertFalse(graph.streamCalled);
50 assertTrue(graph.filteredStreamCalled);
51
52 assertEquals(0L, graph.getTriples(new DummyIRI(0),null,null).count());
53 }
54
55 @Test
56 public void defaultIterate() throws Exception {
57 assertFalse(graph.streamCalled);
58 assertFalse(graph.filteredStreamCalled);
59 for (final Triple t : graph.iterate()) {
60 assertEquals(t, new DummyTriple());
61 }
62 assertTrue(graph.streamCalled);
63 assertFalse(graph.filteredStreamCalled);
64 }
65
66 @Test
67 public void defaultFilteredIterate() throws Exception {
68 assertFalse(graph.streamCalled);
69 assertFalse(graph.filteredStreamCalled);
70 for (final Triple t : graph.iterate(null, new DummyIRI(2), null)) {
71 assertEquals(t, new DummyTriple());
72 }
73 assertTrue(graph.filteredStreamCalled);
74 assertFalse(graph.streamCalled);
75 }
76
77 }
78