blob: 04ef81576d2bdc9cef1b18381ff1c2e37aca3311 [file] [log] [blame]
Toshio Koide9d8856e2013-06-12 16:48:11 -07001/**
2 *
3 */
4package net.onrc.onos.util;
5
6import static org.junit.Assert.*;
7
8import net.floodlightcontroller.core.INetMapTopologyObjects.ISwitchObject;
9import net.floodlightcontroller.core.ISwitchStorage.SwitchState;
10import net.floodlightcontroller.core.internal.TestDatabaseManager;
11import net.onrc.onos.util.GraphDBConnection.Transaction;
12
13import org.easymock.EasyMock;
14import org.junit.After;
15import org.junit.AfterClass;
16import org.junit.Before;
17import org.junit.BeforeClass;
18import org.junit.Test;
19import org.junit.runner.RunWith;
20import org.powermock.api.easymock.PowerMock;
21import org.powermock.core.classloader.annotations.PrepareForTest;
22import org.powermock.modules.junit4.PowerMockRunner;
23
24import com.thinkaurelius.titan.core.TitanFactory;
25import com.thinkaurelius.titan.core.TitanGraph;
26
27/**
28 * @author Toshio Koide
29 *
30 */
31@RunWith(PowerMockRunner.class)
32@PrepareForTest({TitanFactory.class})
33public class GraphDBOperationTest {
34 private static TitanGraph titanGraph;
35 private static GraphDBConnection conn;
36 private static GraphDBOperation op;
37
38 /**
39 * @throws java.lang.Exception
40 */
41 @BeforeClass
42 public static void setUpBeforeClass() throws Exception {
43 }
44
45 /**
46 * @throws java.lang.Exception
47 */
48 @AfterClass
49 public static void tearDownAfterClass() throws Exception {
50 }
51
52 /**
53 * @throws java.lang.Exception
54 */
55 @Before
56 public void setUp() throws Exception {
57 TestDatabaseManager.deleteTestDatabase();
58 titanGraph = TestDatabaseManager.getTestDatabase();
59// TestDatabaseManager.populateTestData(titanGraph);
60
61 // replace return value of TitanFactory.open() to dummy DB created above
62 PowerMock.mockStatic(TitanFactory.class);
63 EasyMock.expect(TitanFactory.open((String)EasyMock.anyObject())).andReturn(titanGraph);
64 PowerMock.replay(TitanFactory.class);
65
66 conn = GraphDBConnection.getInstance("/dummy/to/conf");
67 op = new GraphDBOperation(conn);
68 }
69
70 /**
71 * @throws java.lang.Exception
72 */
73 @After
74 public void tearDown() throws Exception {
75 conn.close();
Toshio Koided7b7e102013-06-12 17:13:25 -070076 titanGraph.shutdown();
Toshio Koide9d8856e2013-06-12 16:48:11 -070077 }
78
79 /**
80 * Test method for {@link net.onrc.onos.util.GraphDBOperation#newSwitch(net.onrc.onos.util.GraphDBConnection)}.
81 */
82 @Test
83 public final void testNewSwitch() {
84 Iterable<ISwitchObject> switches;
85
86 switches = op.getAllSwitches();
87 assertFalse(switches.iterator().hasNext());
88
89 ISwitchObject sw = op.newSwitch();
Toshio Koide9d8856e2013-06-12 16:48:11 -070090 sw.setDPID("123");
91 sw.setState(SwitchState.ACTIVE.toString());
92 conn.endTx(Transaction.COMMIT);
93
94 switches = op.getAllSwitches();
95 assertTrue(switches.iterator().hasNext());
96
97 ISwitchObject obtained_sw = switches.iterator().next();
98 String obtained_dpid = obtained_sw.getDPID();
99 assertEquals("123", obtained_dpid);
100 }
101
102 /**
103 * Test method for {@link net.onrc.onos.util.GraphDBOperation#removeSwitch(net.onrc.onos.util.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.ISwitchObject)}.
104 */
105 @Test
106 public final void testRemoveSwitch() {
107 Iterable<ISwitchObject> switches;
108
109 // make sure there is no switch
110 switches = op.getAllSwitches();
111 assertFalse(switches.iterator().hasNext());
Toshio Koide9d8856e2013-06-12 16:48:11 -0700112
113 ISwitchObject sw = op.newSwitch();
Toshio Koide9d8856e2013-06-12 16:48:11 -0700114 sw.setDPID("123");
115 sw.setState(SwitchState.ACTIVE.toString());
116 conn.endTx(Transaction.COMMIT);
Toshio Koide9d8856e2013-06-12 16:48:11 -0700117
Toshio Koided7b7e102013-06-12 17:13:25 -0700118 sw = op.searchSwitch("123");
119 op.removeSwitch(sw);
120
121 assertNull(op.searchSwitch("123"));
Toshio Koide9d8856e2013-06-12 16:48:11 -0700122 }
123
124 /**
125 * Test method for {@link net.onrc.onos.util.GraphDBOperation#searchSwitch(net.onrc.onos.util.GraphDBConnection, java.lang.String)}.
126 */
127 @Test
128 public final void testSearchSwitch() {
129 fail("Not yet implemented");
130 }
131
132 /**
133 * Test method for {@link net.onrc.onos.util.GraphDBOperation#searchDevice(net.onrc.onos.util.GraphDBConnection, java.lang.String)}.
134 */
135 @Test
136 public final void testSearchDevice() {
137 fail("Not yet implemented");
138 }
139
140 /**
141 * Test method for {@link net.onrc.onos.util.GraphDBOperation#searchPort(net.onrc.onos.util.GraphDBConnection, java.lang.String, short)}.
142 */
143 @Test
144 public final void testSearchPort() {
145 fail("Not yet implemented");
146 }
147
148 /**
149 * Test method for {@link net.onrc.onos.util.GraphDBOperation#newPort(net.onrc.onos.util.GraphDBConnection)}.
150 */
151 @Test
152 public final void testNewPort() {
153 fail("Not yet implemented");
154 }
155
156 /**
157 * Test method for {@link net.onrc.onos.util.GraphDBOperation#newDevice(net.onrc.onos.util.GraphDBConnection)}.
158 */
159 @Test
160 public final void testNewDevice() {
161 fail("Not yet implemented");
162 }
163
164 /**
165 * Test method for {@link net.onrc.onos.util.GraphDBOperation#removePort(net.onrc.onos.util.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.IPortObject)}.
166 */
167 @Test
168 public final void testRemovePort() {
169 fail("Not yet implemented");
170 }
171
172 /**
173 * Test method for {@link net.onrc.onos.util.GraphDBOperation#removeDevice(net.onrc.onos.util.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.IDeviceObject)}.
174 */
175 @Test
176 public final void testRemoveDevice() {
177 fail("Not yet implemented");
178 }
179
180 /**
181 * Test method for {@link net.onrc.onos.util.GraphDBOperation#getDevices(net.onrc.onos.util.GraphDBConnection)}.
182 */
183 @Test
184 public final void testGetDevices() {
185 fail("Not yet implemented");
186 }
187
188 /**
189 * Test method for {@link net.onrc.onos.util.GraphDBOperation#searchFlowPath(net.onrc.onos.util.GraphDBConnection, net.floodlightcontroller.util.FlowId)}.
190 */
191 @Test
192 public final void testSearchFlowPath() {
193 fail("Not yet implemented");
194 }
195
196 /**
197 * Test method for {@link net.onrc.onos.util.GraphDBOperation#newFlowPath(net.onrc.onos.util.GraphDBConnection)}.
198 */
199 @Test
200 public final void testNewFlowPath() {
201 fail("Not yet implemented");
202 }
203
204 /**
205 * Test method for {@link net.onrc.onos.util.GraphDBOperation#removeFlowPath(net.onrc.onos.util.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.IFlowPath)}.
206 */
207 @Test
208 public final void testRemoveFlowPath() {
209 fail("Not yet implemented");
210 }
211
212 /**
213 * Test method for {@link net.onrc.onos.util.GraphDBOperation#getFlowPathByFlowEntry(net.onrc.onos.util.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.IFlowEntry)}.
214 */
215 @Test
216 public final void testGetFlowPathByFlowEntry() {
217 fail("Not yet implemented");
218 }
219
220 /**
221 * Test method for {@link net.onrc.onos.util.GraphDBOperation#getAllFlowPaths(net.onrc.onos.util.GraphDBConnection)}.
222 */
223 @Test
224 public final void testGetAllFlowPaths() {
225 fail("Not yet implemented");
226 }
227
228 /**
229 * Test method for {@link net.onrc.onos.util.GraphDBOperation#searchFlowEntry(net.onrc.onos.util.GraphDBConnection, net.floodlightcontroller.util.FlowEntryId)}.
230 */
231 @Test
232 public final void testSearchFlowEntry() {
233 fail("Not yet implemented");
234 }
235
236 /**
237 * Test method for {@link net.onrc.onos.util.GraphDBOperation#newFlowEntry(net.onrc.onos.util.GraphDBConnection)}.
238 */
239 @Test
240 public final void testNewFlowEntry() {
241 fail("Not yet implemented");
242 }
243
244 /**
245 * Test method for {@link net.onrc.onos.util.GraphDBOperation#removeFlowEntry(net.onrc.onos.util.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.IFlowEntry)}.
246 */
247 @Test
248 public final void testRemoveFlowEntry() {
249 fail("Not yet implemented");
250 }
251
252 /**
253 * Test method for {@link net.onrc.onos.util.GraphDBOperation#getAllFlowEntries(net.onrc.onos.util.GraphDBConnection)}.
254 */
255 @Test
256 public final void testGetAllFlowEntries() {
257 fail("Not yet implemented");
258 }
259
260 /**
261 * Test method for {@link net.onrc.onos.util.GraphDBOperation#getAllSwitchNotUpdatedFlowEntries(net.onrc.onos.util.GraphDBConnection)}.
262 */
263 @Test
264 public final void testGetAllSwitchNotUpdatedFlowEntries() {
265 fail("Not yet implemented");
266 }
267
268 /**
269 * Test method for {@link net.onrc.onos.util.GraphDBOperation#getActiveSwitches(net.onrc.onos.util.GraphDBConnection)}.
270 */
271 @Test
272 public final void testGetActiveSwitches() {
273 fail("Not yet implemented");
274 }
275
276 /**
277 * Test method for {@link net.onrc.onos.util.GraphDBOperation#getAllSwitches(net.onrc.onos.util.GraphDBConnection)}.
278 */
279 @Test
280 public final void testGetAllSwitches() {
281 fail("Not yet implemented");
282 }
283
284 /**
285 * Test method for {@link net.onrc.onos.util.GraphDBOperation#getInactiveSwitches(net.onrc.onos.util.GraphDBConnection)}.
286 */
287 @Test
288 public final void testGetInactiveSwitches() {
289 fail("Not yet implemented");
290 }
291
292 /**
293 * Test method for {@link net.onrc.onos.util.GraphDBOperation#searchActiveSwitch(net.onrc.onos.util.GraphDBConnection, java.lang.String)}.
294 */
295 @Test
296 public final void testSearchActiveSwitch() {
297 fail("Not yet implemented");
298 }
299
300}