Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | */ |
Toshio Koide | e32a4ec | 2013-06-27 11:51:21 -0700 | [diff] [blame] | 4 | package net.onrc.onos.graph; |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 5 | |
Jonathan Hart | 56d1577 | 2013-11-03 19:09:59 -0800 | [diff] [blame] | 6 | import static org.junit.Assert.assertArrayEquals; |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 7 | |
Jonathan Hart | 56d1577 | 2013-11-03 19:09:59 -0800 | [diff] [blame] | 8 | import java.util.ArrayList; |
| 9 | import java.util.Arrays; |
| 10 | import java.util.Collections; |
| 11 | import java.util.Iterator; |
| 12 | import java.util.List; |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 13 | |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 14 | import junit.framework.TestCase; |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 15 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject; |
| 16 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry; |
| 17 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath; |
Jonathan Hart | 56d1577 | 2013-11-03 19:09:59 -0800 | [diff] [blame] | 18 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IIpv4Address; |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 19 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject; |
Toshio Koide | b29b9b3 | 2013-06-13 14:37:46 -0700 | [diff] [blame] | 20 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject; |
| 21 | import net.onrc.onos.ofcontroller.core.ISwitchStorage.SwitchState; |
HIGUCHI Yuta | 0813793 | 2013-06-17 14:11:50 -0700 | [diff] [blame] | 22 | import net.onrc.onos.ofcontroller.core.internal.TestDatabaseManager; |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 23 | import net.onrc.onos.ofcontroller.util.FlowEntryId; |
| 24 | import net.onrc.onos.ofcontroller.util.FlowId; |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 25 | |
| 26 | import org.easymock.EasyMock; |
| 27 | import org.junit.After; |
| 28 | import org.junit.AfterClass; |
| 29 | import org.junit.Before; |
| 30 | import org.junit.BeforeClass; |
Jonathan Hart | 56d1577 | 2013-11-03 19:09:59 -0800 | [diff] [blame] | 31 | import org.junit.Ignore; |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 32 | import org.junit.Test; |
| 33 | import org.junit.runner.RunWith; |
| 34 | import org.powermock.api.easymock.PowerMock; |
| 35 | import org.powermock.core.classloader.annotations.PrepareForTest; |
| 36 | import org.powermock.modules.junit4.PowerMockRunner; |
| 37 | |
Jonathan Hart | 56d1577 | 2013-11-03 19:09:59 -0800 | [diff] [blame] | 38 | import com.google.common.net.InetAddresses; |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 39 | import com.thinkaurelius.titan.core.TitanFactory; |
| 40 | import com.thinkaurelius.titan.core.TitanGraph; |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 41 | import com.tinkerpop.blueprints.Vertex; |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * @author Toshio Koide |
| 45 | * |
| 46 | */ |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 47 | |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 48 | @RunWith(PowerMockRunner.class) |
| 49 | @PrepareForTest({TitanFactory.class}) |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 50 | public class GraphDBOperationTest extends TestCase { |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 51 | private static TitanGraph testdb; |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 52 | private static GraphDBOperation op; |
| 53 | |
| 54 | /** |
| 55 | * @throws java.lang.Exception |
| 56 | */ |
| 57 | @BeforeClass |
| 58 | public static void setUpBeforeClass() throws Exception { |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @throws java.lang.Exception |
| 63 | */ |
| 64 | @AfterClass |
| 65 | public static void tearDownAfterClass() throws Exception { |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * @throws java.lang.Exception |
| 70 | */ |
| 71 | @Before |
| 72 | public void setUp() throws Exception { |
| 73 | TestDatabaseManager.deleteTestDatabase(); |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 74 | testdb = TestDatabaseManager.getTestDatabase(); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 75 | // TestDatabaseManager.populateTestData(titanGraph); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 76 | |
| 77 | String dummyPath = "/dummy/to/conf"; |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 78 | // replace return value of TitanFactory.open() to dummy DB created above |
| 79 | PowerMock.mockStatic(TitanFactory.class); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 80 | EasyMock.expect(TitanFactory.open(dummyPath)).andReturn(testdb); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 81 | PowerMock.replay(TitanFactory.class); |
| 82 | |
Toshio Koide | bfe9b92 | 2013-06-18 10:56:05 -0700 | [diff] [blame] | 83 | op = new GraphDBOperation(dummyPath); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | /** |
| 87 | * @throws java.lang.Exception |
| 88 | */ |
| 89 | @After |
| 90 | public void tearDown() throws Exception { |
Toshio Koide | bfe9b92 | 2013-06-18 10:56:05 -0700 | [diff] [blame] | 91 | op.close(); |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 92 | testdb.shutdown(); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 93 | PowerMock.verifyAll(); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 97 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#newSwitch(net.onrc.onos.graph.GraphDBConnection)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 98 | */ |
| 99 | @Test |
| 100 | public final void testNewSwitch() { |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 101 | assertNull(op.searchSwitch("123")); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 102 | |
Toshio Koide | e32a4ec | 2013-06-27 11:51:21 -0700 | [diff] [blame] | 103 | ISwitchObject sw = op.newSwitch("123"); |
| 104 | assertEquals(sw.getDPID(), "123"); |
Toshio Koide | a9a0300 | 2013-06-13 13:10:48 -0700 | [diff] [blame] | 105 | op.commit(); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 106 | |
Toshio Koide | e32a4ec | 2013-06-27 11:51:21 -0700 | [diff] [blame] | 107 | sw = op.searchSwitch("123"); |
| 108 | assertNotNull(sw); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 109 | assertEquals("123", sw.getDPID()); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 113 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#searchSwitch(net.onrc.onos.graph.GraphDBConnection, java.lang.String)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 114 | */ |
| 115 | @Test |
| 116 | public final void testSearchSwitch() { |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 117 | op.newSwitch("123"); |
| 118 | op.newSwitch("456"); |
Toshio Koide | a9a0300 | 2013-06-13 13:10:48 -0700 | [diff] [blame] | 119 | op.commit(); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 120 | |
| 121 | ISwitchObject sw = op.searchSwitch("123"); |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 122 | assertNotNull(sw); |
| 123 | assertEquals("123", sw.getDPID()); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 124 | |
| 125 | sw = op.searchSwitch("789"); |
| 126 | assertNull(sw); |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 130 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#searchActiveSwitch(net.onrc.onos.graph.GraphDBConnection, java.lang.String)}. |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 131 | */ |
| 132 | @Test |
| 133 | public final void testSearchActiveSwitch() { |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 134 | op.newSwitch("111").setState(SwitchState.ACTIVE.toString()); |
| 135 | op.newSwitch("222").setState(SwitchState.INACTIVE.toString()); |
Toshio Koide | a9a0300 | 2013-06-13 13:10:48 -0700 | [diff] [blame] | 136 | op.commit(); |
| 137 | |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 138 | ISwitchObject sw = op.searchActiveSwitch("111"); |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 139 | assertNotNull(sw); |
| 140 | assertEquals("111", sw.getDPID()); |
| 141 | |
| 142 | sw = op.searchActiveSwitch("222"); |
| 143 | assertNull(sw); |
| 144 | } |
| 145 | |
| 146 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 147 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#getActiveSwitches(net.onrc.onos.graph.GraphDBConnection)}. |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 148 | */ |
| 149 | @Test |
| 150 | public final void testGetActiveSwitches() { |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 151 | op.newSwitch("111").setState(SwitchState.ACTIVE.toString()); |
| 152 | op.newSwitch("222").setState(SwitchState.INACTIVE.toString()); |
Toshio Koide | a9a0300 | 2013-06-13 13:10:48 -0700 | [diff] [blame] | 153 | op.commit(); |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 154 | |
| 155 | Iterator<ISwitchObject> i = op.getActiveSwitches().iterator(); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 156 | |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 157 | assertTrue(i.hasNext()); |
| 158 | assertEquals("111", i.next().getDPID()); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 159 | assertFalse(i.hasNext()); |
| 160 | } |
| 161 | |
| 162 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 163 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#getAllSwitches(net.onrc.onos.graph.GraphDBConnection)}. |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 164 | */ |
| 165 | @Test |
| 166 | public final void testGetAllSwitches() { |
| 167 | List<String> dpids = Arrays.asList("111", "222", "333"); |
| 168 | Collections.sort(dpids); |
| 169 | |
| 170 | for (String dpid: dpids) op.newSwitch(dpid); |
| 171 | op.commit(); |
| 172 | |
| 173 | List<String> actual_ids = new ArrayList<String>(); |
| 174 | for (ISwitchObject switchObj: op.getAllSwitches()) actual_ids.add(switchObj.getDPID()); |
| 175 | Collections.sort(actual_ids); |
| 176 | |
| 177 | assertArrayEquals(dpids.toArray(), actual_ids.toArray()); |
| 178 | } |
| 179 | |
| 180 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 181 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#getInactiveSwitches(net.onrc.onos.graph.GraphDBConnection)}. |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 182 | */ |
| 183 | @Test |
| 184 | public final void testGetInactiveSwitches() { |
| 185 | op.newSwitch("111").setState(SwitchState.ACTIVE.toString()); |
| 186 | op.newSwitch("222").setState(SwitchState.INACTIVE.toString()); |
| 187 | op.commit(); |
| 188 | |
| 189 | Iterator<ISwitchObject> i = op.getInactiveSwitches().iterator(); |
| 190 | |
| 191 | assertTrue(i.hasNext()); |
| 192 | assertEquals("222", i.next().getDPID()); |
| 193 | assertFalse(i.hasNext()); |
| 194 | } |
| 195 | |
| 196 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 197 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#getAllSwitchNotUpdatedFlowEntries(net.onrc.onos.graph.GraphDBConnection)}. |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 198 | */ |
| 199 | @Test |
| 200 | public final void testGetAllSwitchNotUpdatedFlowEntries() { |
| 201 | FlowEntryId flowEntryId10 = new FlowEntryId(10); |
| 202 | FlowEntryId flowEntryId20 = new FlowEntryId(20); |
| 203 | IFlowEntry flowEntry10 = op.newFlowEntry(); |
| 204 | IFlowEntry flowEntry20 = op.newFlowEntry(); |
| 205 | flowEntry10.setFlowEntryId(flowEntryId10.toString()); |
| 206 | flowEntry20.setFlowEntryId(flowEntryId20.toString()); |
| 207 | flowEntry10.setSwitchState("FE_SWITCH_NOT_UPDATED"); |
| 208 | flowEntry20.setSwitchState("FE_SWITCH_UPDATED"); |
| 209 | op.commit(); |
| 210 | |
| 211 | Iterator<IFlowEntry> flowEntries = op.getAllSwitchNotUpdatedFlowEntries().iterator(); |
| 212 | assertNotNull(flowEntries); |
| 213 | assertTrue(flowEntries.hasNext()); |
| 214 | assertEquals(flowEntryId10.toString(), flowEntries.next().getFlowEntryId()); |
| 215 | assertFalse(flowEntries.hasNext()); |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 219 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#removeSwitch(net.onrc.onos.graph.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.ISwitchObject)}. |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 220 | */ |
| 221 | @Test |
| 222 | public final void testRemoveSwitch() { |
| 223 | ISwitchObject sw = op.newSwitch("123"); |
Toshio Koide | a9a0300 | 2013-06-13 13:10:48 -0700 | [diff] [blame] | 224 | op.commit(); |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 225 | sw = op.searchSwitch("123"); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 226 | assertNotNull(sw); |
| 227 | |
Toshio Koide | 3c460e1 | 2013-06-13 11:55:12 -0700 | [diff] [blame] | 228 | op.removeSwitch(sw); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 229 | op.commit(); |
| 230 | |
| 231 | assertNull(op.searchSwitch("123")); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 235 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#newPort(net.onrc.onos.graph.GraphDBConnection)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 236 | */ |
| 237 | @Test |
| 238 | public final void testNewPort() { |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 239 | assertFalse(testdb.getVertices("type", "port").iterator().hasNext()); |
| 240 | |
Toshio Koide | e32a4ec | 2013-06-27 11:51:21 -0700 | [diff] [blame] | 241 | IPortObject port = op.newPort("1", (short) 10); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 242 | assertTrue(port.getNumber() == 10); |
| 243 | op.commit(); |
| 244 | |
| 245 | Iterator<Vertex> vertices = testdb.getVertices("type", "port").iterator(); |
| 246 | assertTrue(vertices.hasNext()); |
| 247 | assertEquals(vertices.next().getProperty("number").toString(), "10"); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 251 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#searchPort(net.onrc.onos.graph.GraphDBConnection, java.lang.String, short)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 252 | */ |
| 253 | @Test |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 254 | public final void testSearchPort() { |
| 255 | ISwitchObject sw; |
| 256 | IPortObject port; |
| 257 | |
| 258 | sw = op.newSwitch("1"); |
Toshio Koide | e32a4ec | 2013-06-27 11:51:21 -0700 | [diff] [blame] | 259 | sw.addPort(op.newPort("1", (short) 1)); |
| 260 | sw.addPort(op.newPort("1", (short) 2)); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 261 | |
| 262 | sw = op.newSwitch("2"); |
Toshio Koide | e32a4ec | 2013-06-27 11:51:21 -0700 | [diff] [blame] | 263 | sw.addPort(op.newPort("2", (short) 1)); |
| 264 | sw.addPort(op.newPort("2", (short) 2)); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 265 | |
| 266 | op.commit(); |
| 267 | |
| 268 | assertNull(op.searchPort("3", (short) 1)); |
| 269 | assertNull(op.searchPort("1", (short) 3)); |
| 270 | |
| 271 | port = op.searchPort("1", (short) 1); |
| 272 | assertNotNull(port); |
| 273 | assertTrue(port.getNumber() == 1); |
| 274 | sw = port.getSwitch(); |
| 275 | assertNotNull(sw); |
| 276 | assertEquals("1", sw.getDPID()); |
| 277 | |
| 278 | port = op.searchPort("1", (short) 2); |
| 279 | assertNotNull(port); |
| 280 | assertTrue(port.getNumber() == 2); |
| 281 | sw = port.getSwitch(); |
| 282 | assertNotNull(sw); |
| 283 | assertEquals("1", sw.getDPID()); |
| 284 | |
| 285 | port = op.searchPort("2", (short) 1); |
| 286 | assertNotNull(port); |
| 287 | assertTrue(port.getNumber() == 1); |
| 288 | sw = port.getSwitch(); |
| 289 | assertNotNull(sw); |
| 290 | assertEquals("2", sw.getDPID()); |
| 291 | |
| 292 | port = op.searchPort("2", (short) 2); |
| 293 | assertNotNull(port); |
| 294 | assertTrue(port.getNumber() == 2); |
| 295 | sw = port.getSwitch(); |
| 296 | assertNotNull(sw); |
| 297 | assertEquals("2", sw.getDPID()); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 301 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#removePort(net.onrc.onos.graph.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.IPortObject)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 302 | */ |
| 303 | @Test |
| 304 | public final void testRemovePort() { |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 305 | ISwitchObject sw; |
| 306 | IPortObject port; |
| 307 | |
| 308 | sw = op.newSwitch("1"); |
Toshio Koide | e32a4ec | 2013-06-27 11:51:21 -0700 | [diff] [blame] | 309 | sw.addPort(op.newPort("1", (short) 1)); |
| 310 | sw.addPort(op.newPort("1", (short) 2)); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 311 | |
| 312 | op.commit(); |
| 313 | |
| 314 | port = op.searchPort("1", (short) 1); |
| 315 | assertNotNull(port); |
| 316 | assertNotNull(op.searchPort("1", (short) 2)); |
| 317 | assertNull(op.searchPort("1", (short) 3)); |
| 318 | |
| 319 | op.removePort(port); |
| 320 | op.commit(); |
| 321 | |
| 322 | assertNull(op.searchPort("1", (short) 1)); |
| 323 | port = op.searchPort("1", (short) 2); |
| 324 | assertNotNull(port); |
| 325 | |
| 326 | op.removePort(port); |
| 327 | op.commit(); |
| 328 | |
| 329 | assertNull(op.searchPort("1", (short) 1)); |
| 330 | assertNull(op.searchPort("1", (short) 2)); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 334 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#newDevice(net.onrc.onos.graph.GraphDBConnection)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 335 | */ |
| 336 | @Test |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 337 | public final void testNewDevice() { |
| 338 | assertFalse(testdb.getVertices("type", "device").iterator().hasNext()); |
| 339 | |
| 340 | IDeviceObject device = op.newDevice(); |
| 341 | device.setMACAddress("11:22:33:44:55:66"); |
Jonathan Hart | 56d1577 | 2013-11-03 19:09:59 -0800 | [diff] [blame] | 342 | //device.setIPAddress("192.168.1.1"); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 343 | op.commit(); |
| 344 | |
| 345 | Iterator<Vertex> vertices = testdb.getVertices("type", "device").iterator(); |
| 346 | assertTrue(vertices.hasNext()); |
| 347 | Vertex v = vertices.next(); |
| 348 | assertEquals("11:22:33:44:55:66", v.getProperty("dl_addr").toString()); |
Jonathan Hart | 56d1577 | 2013-11-03 19:09:59 -0800 | [diff] [blame] | 349 | //assertEquals("192.168.1.1", v.getProperty("nw_addr").toString()); |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 353 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#searchDevice(net.onrc.onos.graph.GraphDBConnection, java.lang.String)}. |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 354 | */ |
| 355 | @Test |
| 356 | public final void testSearchDevice() { |
| 357 | assertNull(op.searchDevice("11:22:33:44:55:66")); |
| 358 | assertNull(op.searchDevice("66:55:44:33:22:11")); |
| 359 | |
| 360 | op.newDevice().setMACAddress("11:22:33:44:55:66"); |
| 361 | op.commit(); |
| 362 | |
| 363 | IDeviceObject device = op.searchDevice("11:22:33:44:55:66"); |
| 364 | assertNotNull(device); |
| 365 | assertEquals("11:22:33:44:55:66", device.getMACAddress()); |
| 366 | |
| 367 | assertNull(op.searchDevice("66:55:44:33:22:11")); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 371 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#getDevices(net.onrc.onos.graph.GraphDBConnection)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 372 | */ |
| 373 | @Test |
| 374 | public final void testGetDevices() { |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 375 | List<String> original_macs = Arrays.asList( |
| 376 | "11:11:11:11:11:11", |
| 377 | "22:22:22:22:22:22", |
| 378 | "33:33:33:33:33:33" |
| 379 | ); |
| 380 | |
| 381 | for (String mac: original_macs) op.newDevice().setMACAddress(mac); |
| 382 | op.commit(); |
| 383 | |
| 384 | Iterable<IDeviceObject> devices = op.getDevices(); |
| 385 | List<String> macs = new ArrayList<String>(); |
| 386 | for (IDeviceObject device: devices) macs.add(device.getMACAddress()); |
| 387 | Collections.sort(macs); |
| 388 | assertArrayEquals(original_macs.toArray(), macs.toArray()); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 392 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#removeDevice(net.onrc.onos.graph.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.IDeviceObject)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 393 | */ |
| 394 | @Test |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 395 | public final void testRemoveDevice() { |
| 396 | op.newDevice().setMACAddress("11:22:33:44:55:66"); |
| 397 | op.commit(); |
| 398 | |
| 399 | op.removeDevice(op.searchDevice("11:22:33:44:55:66")); |
| 400 | op.commit(); |
| 401 | assertNull(op.searchDevice("11:22:33:44:55:66")); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 402 | } |
Jonathan Hart | 56d1577 | 2013-11-03 19:09:59 -0800 | [diff] [blame] | 403 | |
| 404 | /** |
| 405 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#newIpv4Address(net.onrc.onos.graph.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.IIpv4Address)}. |
| 406 | */ |
| 407 | @Test |
| 408 | public final void testNewIpv4Address() { |
| 409 | int intIpv4Address = InetAddresses.coerceToInteger(InetAddresses.forString("192.168.10.1")); |
| 410 | |
| 411 | assertFalse(testdb.getVertices("type", "ipv4Address").iterator().hasNext()); |
| 412 | |
| 413 | IIpv4Address ipv4Address = op.newIpv4Address(); |
| 414 | ipv4Address.setIpv4Address(intIpv4Address); |
| 415 | //device.setIPAddress("192.168.1.1"); |
| 416 | op.commit(); |
| 417 | |
| 418 | Iterator<Vertex> vertices = testdb.getVertices("type", "ipv4Address").iterator(); |
| 419 | assertTrue(vertices.hasNext()); |
| 420 | Vertex v = vertices.next(); |
| 421 | assertEquals(intIpv4Address, ((Integer) v.getProperty("ipv4_address")).intValue()); |
| 422 | } |
| 423 | |
| 424 | /** |
| 425 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#searchIpv4Address(net.onrc.onos.graph.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.IIpv4Address)}. |
| 426 | */ |
| 427 | @Test |
| 428 | public final void testSearchIpv4Address() { |
| 429 | int addr1 = InetAddresses.coerceToInteger(InetAddresses.forString("192.168.20.1")); |
| 430 | int addr2 = InetAddresses.coerceToInteger(InetAddresses.forString("59.203.2.15")); |
| 431 | |
| 432 | assertNull(op.searchIpv4Address(addr1)); |
| 433 | assertNull(op.searchIpv4Address(addr2)); |
| 434 | |
| 435 | op.newIpv4Address().setIpv4Address(addr1); |
| 436 | op.commit(); |
| 437 | |
| 438 | IIpv4Address ipv4Address = op.searchIpv4Address(addr1); |
| 439 | assertNotNull(ipv4Address); |
| 440 | assertEquals(addr1, ipv4Address.getIpv4Address()); |
| 441 | |
| 442 | assertNull(op.searchIpv4Address(addr2)); |
| 443 | } |
| 444 | |
| 445 | @Ignore |
| 446 | @Test |
| 447 | public final void testEnsureIpv4Address() { |
| 448 | // TODO not yet implemented |
| 449 | } |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 450 | |
| 451 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 452 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#newFlowPath(net.onrc.onos.graph.GraphDBConnection)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 453 | */ |
| 454 | @Test |
| 455 | public final void testNewFlowPath() { |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 456 | FlowId flowId = new FlowId(10); |
| 457 | IFlowPath flowPath = op.newFlowPath(); |
| 458 | flowPath.setFlowId(flowId.toString()); |
| 459 | op.commit(); |
| 460 | |
| 461 | Iterator<IFlowPath> flows = op.getAllFlowPaths().iterator(); |
| 462 | assertTrue(flows.hasNext()); |
| 463 | assertEquals(flowId.toString(), flows.next().getFlowId()); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 467 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#searchFlowPath(net.onrc.onos.graph.GraphDBConnection, net.floodlightcontroller.util.FlowId)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 468 | */ |
| 469 | @Test |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 470 | public final void testSearchFlowPath() { |
| 471 | FlowId flowId = new FlowId(20); |
| 472 | assertNull(op.searchFlowPath(flowId)); |
| 473 | |
| 474 | op.newFlowPath().setFlowId(flowId.toString()); |
| 475 | op.commit(); |
| 476 | |
| 477 | IFlowPath flowPath = op.searchFlowPath(flowId); |
| 478 | assertNotNull(flowPath); |
| 479 | assertEquals(flowId.toString(), flowPath.getFlowId()); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 483 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#getFlowPathByFlowEntry(net.onrc.onos.graph.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.IFlowEntry)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 484 | */ |
| 485 | @Test |
| 486 | public final void testGetFlowPathByFlowEntry() { |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 487 | FlowId flowId10 = new FlowId(10); |
| 488 | FlowId flowId20 = new FlowId(20); |
| 489 | IFlowPath flowPath10 = op.newFlowPath(); |
| 490 | IFlowPath flowPath20 = op.newFlowPath(); |
| 491 | IFlowEntry flowEntry10 = op.newFlowEntry(); |
| 492 | IFlowEntry flowEntry20 = op.newFlowEntry(); |
| 493 | IFlowEntry flowEntry30 = op.newFlowEntry(); |
| 494 | FlowEntryId flowEntryId10 = new FlowEntryId(10); |
| 495 | FlowEntryId flowEntryId20 = new FlowEntryId(20); |
| 496 | FlowEntryId flowEntryId30 = new FlowEntryId(30); |
| 497 | flowEntry10.setFlowEntryId(flowEntryId10.toString()); |
| 498 | flowEntry20.setFlowEntryId(flowEntryId20.toString()); |
| 499 | flowEntry30.setFlowEntryId(flowEntryId30.toString()); |
| 500 | flowPath10.setFlowId(flowId10.toString()); |
| 501 | flowPath10.addFlowEntry(flowEntry10); |
| 502 | flowPath20.setFlowId(flowId20.toString()); |
| 503 | flowPath20.addFlowEntry(flowEntry20); |
| 504 | op.commit(); |
| 505 | |
| 506 | flowEntry10 = op.searchFlowEntry(flowEntryId10); |
| 507 | IFlowPath obtainedFlowPath = op.getFlowPathByFlowEntry(flowEntry10); |
| 508 | assertNotNull(obtainedFlowPath); |
| 509 | assertEquals(flowId10.toString(), obtainedFlowPath.getFlowId()); |
| 510 | |
| 511 | flowEntry20 = op.searchFlowEntry(flowEntryId20); |
| 512 | obtainedFlowPath = op.getFlowPathByFlowEntry(flowEntry20); |
| 513 | assertNotNull(obtainedFlowPath); |
| 514 | assertEquals(flowId20.toString(), obtainedFlowPath.getFlowId()); |
| 515 | |
| 516 | flowEntry30 = op.searchFlowEntry(flowEntryId30); |
| 517 | obtainedFlowPath = op.getFlowPathByFlowEntry(flowEntry30); |
| 518 | assertNull(obtainedFlowPath); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 522 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#getAllFlowPaths(net.onrc.onos.graph.GraphDBConnection)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 523 | */ |
| 524 | @Test |
| 525 | public final void testGetAllFlowPaths() { |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 526 | List<FlowId> flowids = Arrays.asList( |
| 527 | new FlowId(10), new FlowId(20), new FlowId(30) |
| 528 | ); |
| 529 | |
| 530 | for (FlowId flowId: flowids) |
| 531 | op.newFlowPath().setFlowId(flowId.toString()); |
| 532 | op.commit(); |
| 533 | |
| 534 | List<String> actual_ids = new ArrayList<String>(); |
| 535 | for (IFlowPath flowPath: op.getAllFlowPaths()) actual_ids.add(flowPath.getFlowId()); |
| 536 | Collections.sort(actual_ids); |
| 537 | |
| 538 | List<String> expected_ids = new ArrayList<String>(); |
| 539 | for (FlowId flowid: flowids) expected_ids.add(flowid.toString()); |
| 540 | Collections.sort(expected_ids); |
| 541 | |
| 542 | assertArrayEquals(expected_ids.toArray(), actual_ids.toArray()); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 546 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#removeFlowPath(net.onrc.onos.graph.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.IFlowPath)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 547 | */ |
| 548 | @Test |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 549 | public final void testRemoveFlowPath() { |
| 550 | FlowId flowId10 = new FlowId(10); |
| 551 | FlowId flowId20 = new FlowId(20); |
| 552 | op.newFlowPath().setFlowId(flowId10.toString()); |
| 553 | op.newFlowPath().setFlowId(flowId20.toString()); |
| 554 | op.commit(); |
| 555 | |
| 556 | IFlowPath flowPath = op.searchFlowPath(flowId10); |
| 557 | assertNotNull(flowPath); |
| 558 | op.removeFlowPath(flowPath); |
| 559 | op.commit(); |
| 560 | |
| 561 | assertNull(op.searchFlowPath(flowId10)); |
| 562 | assertNotNull(op.searchFlowPath(flowId20)); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 566 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#newFlowEntry(net.onrc.onos.graph.GraphDBConnection)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 567 | */ |
| 568 | @Test |
| 569 | public final void testNewFlowEntry() { |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 570 | IFlowEntry flowEntry = op.newFlowEntry(); |
| 571 | FlowEntryId flowEntryId = new FlowEntryId(); |
| 572 | flowEntryId.setValue(12345); |
| 573 | flowEntry.setFlowEntryId(flowEntryId.toString()); |
| 574 | op.commit(); |
| 575 | |
| 576 | flowEntry = op.searchFlowEntry(flowEntryId); |
| 577 | assertNotNull(flowEntry); |
| 578 | assertEquals(flowEntry.getFlowEntryId(), flowEntryId.toString()); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 582 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#searchFlowEntry(net.onrc.onos.graph.GraphDBConnection, net.floodlightcontroller.util.FlowEntryId)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 583 | */ |
| 584 | @Test |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 585 | public final void testSearchFlowEntry() { |
| 586 | FlowEntryId flowEntryId10 = new FlowEntryId(); |
| 587 | flowEntryId10.setValue(10); |
| 588 | FlowEntryId flowEntryId20 = new FlowEntryId(); |
| 589 | flowEntryId20.setValue(20); |
| 590 | FlowEntryId flowEntryId30 = new FlowEntryId(); |
| 591 | flowEntryId30.setValue(30); |
| 592 | |
| 593 | op.newFlowEntry().setFlowEntryId(flowEntryId10.toString()); |
| 594 | op.newFlowEntry().setFlowEntryId(flowEntryId20.toString()); |
| 595 | op.commit(); |
| 596 | |
| 597 | assertNull(op.searchFlowEntry(flowEntryId30)); |
| 598 | IFlowEntry flowEntry = op.searchFlowEntry(flowEntryId10); |
| 599 | assertEquals(flowEntry.getFlowEntryId(), flowEntryId10.toString()); |
| 600 | flowEntry = op.searchFlowEntry(flowEntryId20); |
| 601 | assertEquals(flowEntry.getFlowEntryId(), flowEntryId20.toString()); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 605 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#getAllFlowEntries(net.onrc.onos.graph.GraphDBConnection)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 606 | */ |
| 607 | @Test |
| 608 | public final void testGetAllFlowEntries() { |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 609 | List<FlowEntryId> flowEntryIds = Arrays.asList( |
| 610 | new FlowEntryId(10), new FlowEntryId(20), new FlowEntryId(30) |
| 611 | ); |
| 612 | |
| 613 | for (FlowEntryId flowEntryId: flowEntryIds) |
| 614 | op.newFlowEntry().setFlowEntryId(flowEntryId.toString()); |
| 615 | op.commit(); |
| 616 | |
| 617 | List<String> actual_ids = new ArrayList<String>(); |
| 618 | for (IFlowEntry flowEntry: op.getAllFlowEntries()) actual_ids.add(flowEntry.getFlowEntryId()); |
| 619 | Collections.sort(actual_ids); |
| 620 | |
| 621 | List<String> expected_ids = new ArrayList<String>(); |
| 622 | for (FlowEntryId flowEntryId: flowEntryIds) expected_ids.add(flowEntryId.toString()); |
| 623 | Collections.sort(expected_ids); |
| 624 | |
| 625 | assertArrayEquals(expected_ids.toArray(), actual_ids.toArray()); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | /** |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 629 | * Test method for {@link net.onrc.onos.graph.GraphDBOperation#removeFlowEntry(net.onrc.onos.graph.GraphDBConnection, net.floodlightcontroller.core.INetMapTopologyObjects.IFlowEntry)}. |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 630 | */ |
| 631 | @Test |
Toshio Koide | 880f4c7 | 2013-06-17 14:43:11 -0700 | [diff] [blame] | 632 | public final void testRemoveFlowEntry() { |
| 633 | FlowEntryId flowEntryId10 = new FlowEntryId(10); |
| 634 | FlowEntryId flowEntryId20 = new FlowEntryId(20); |
| 635 | op.newFlowEntry().setFlowEntryId(flowEntryId10.toString()); |
| 636 | op.newFlowEntry().setFlowEntryId(flowEntryId20.toString()); |
| 637 | op.commit(); |
| 638 | |
| 639 | IFlowEntry flowEntry = op.searchFlowEntry(flowEntryId10); |
| 640 | assertNotNull(flowEntry); |
| 641 | op.removeFlowEntry(flowEntry); |
| 642 | op.commit(); |
| 643 | |
| 644 | assertNull(op.searchFlowEntry(flowEntryId10)); |
| 645 | assertNotNull(op.searchFlowEntry(flowEntryId20)); |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 646 | } |
| 647 | |
Toshio Koide | 9d8856e | 2013-06-12 16:48:11 -0700 | [diff] [blame] | 648 | } |