Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.core.internal; |
| 2 | |
| 3 | import static org.easymock.EasyMock.*; |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 4 | import net.onrc.onos.graph.GraphDBConnection; |
| 5 | import net.onrc.onos.graph.GraphDBOperation; |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 6 | import net.onrc.onos.ofcontroller.core.ISwitchStorage; |
| 7 | import net.onrc.onos.ofcontroller.core.ISwitchStorage.SwitchState; |
| 8 | import net.onrc.onos.ofcontroller.core.internal.SwitchStorageImpl; |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 9 | import net.onrc.onos.ofcontroller.core.INetMapStorage.DM_OPERATION; |
| 10 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject; |
| 11 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject; |
Jonathan Hart | fb69851 | 2013-11-19 17:11:29 -0800 | [diff] [blame^] | 12 | |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 13 | import org.easymock.EasyMock; |
| 14 | import org.junit.After; |
| 15 | import org.junit.Before; |
Jonathan Hart | fb69851 | 2013-11-19 17:11:29 -0800 | [diff] [blame^] | 16 | import org.junit.Ignore; |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 17 | import org.junit.Test; |
| 18 | import org.junit.runner.RunWith; |
| 19 | import org.openflow.protocol.OFPhysicalPort; |
| 20 | import org.openflow.protocol.OFPhysicalPort.OFPortState; |
| 21 | import org.powermock.api.easymock.PowerMock; |
| 22 | import org.powermock.core.classloader.annotations.PrepareForTest; |
| 23 | import org.powermock.modules.junit4.PowerMockRunner; |
| 24 | import org.slf4j.LoggerFactory; |
| 25 | |
| 26 | import com.thinkaurelius.titan.core.TitanFactory; |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 27 | |
| 28 | //Add Powermock preparation |
Jonathan Hart | fb69851 | 2013-11-19 17:11:29 -0800 | [diff] [blame^] | 29 | @Ignore //TODO broken 11/19/13, should fix |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 30 | @RunWith(PowerMockRunner.class) |
| 31 | @PrepareForTest({TitanFactory.class, GraphDBConnection.class, GraphDBOperation.class, SwitchStorageImpl.class}) |
| 32 | public class SwitchStorageImplTest { |
| 33 | |
| 34 | protected static org.slf4j.Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class); |
| 35 | |
| 36 | String conf; |
| 37 | private GraphDBConnection mockConn = null; |
| 38 | private GraphDBOperation mockOpe = null; |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 39 | ISwitchStorage swSt = null; |
| 40 | |
| 41 | @Before |
| 42 | public void setUp() throws Exception { |
| 43 | |
| 44 | swSt = new SwitchStorageImpl(); |
| 45 | conf = "/dummy/path/to/db"; |
| 46 | |
| 47 | // Make mock cassandra DB |
| 48 | // Replace TitanFactory.open() to return mock DB |
| 49 | |
| 50 | PowerMock.mockStatic(GraphDBConnection.class); |
| 51 | mockConn = createMock(GraphDBConnection.class); |
| 52 | PowerMock.suppress(PowerMock.constructor(GraphDBConnection.class)); |
| 53 | EasyMock.expect(GraphDBConnection.getInstance((String)EasyMock.anyObject())).andReturn(mockConn); |
| 54 | PowerMock.replay(GraphDBConnection.class); |
| 55 | |
| 56 | PowerMock.mockStatic(GraphDBOperation.class); |
| 57 | mockOpe = PowerMock.createStrictMock(GraphDBOperation.class); |
| 58 | PowerMock.expectNew(GraphDBOperation.class, mockConn).andReturn(mockOpe); |
| 59 | PowerMock.replay(GraphDBOperation.class); |
| 60 | // Replace the conf to dummy conf |
| 61 | // String conf = "/tmp/cassandra.titan"; |
| 62 | |
| 63 | |
| 64 | } |
| 65 | |
| 66 | @After |
| 67 | public void tearDown() throws Exception { |
| 68 | swSt.close(); |
| 69 | swSt = null; |
| 70 | |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Desc: |
| 75 | * Test method for addSwitch method. |
| 76 | * Condition: |
| 77 | * Normal |
| 78 | * Expect: |
| 79 | * Call SwitchStorageImpl.addSwitch func with proper properties. |
| 80 | */ |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 81 | @Test |
| 82 | public void testAddSwitch() { |
| 83 | String dpid = "00:00:00:00:00:00:0a:07"; |
| 84 | String state = "ACTIVE"; |
| 85 | |
| 86 | //Mock Switch |
| 87 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
| 88 | mockISw.setState(state); |
| 89 | replay(mockISw); |
| 90 | |
| 91 | //Expectation of mock operation. |
| 92 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 93 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
| 94 | mockOpe.commit(); |
| 95 | mockOpe.close(); |
| 96 | replay(mockOpe); |
| 97 | |
| 98 | swSt.init(conf); |
| 99 | swSt.addSwitch(dpid); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Desc: |
| 104 | * Test method for addSwitch method. |
| 105 | * Condition: |
| 106 | * The switch is already existing. |
| 107 | * Expect: |
| 108 | * Call SwitchStorageImpl.addSwitch func with proper properties. |
| 109 | */ |
| 110 | //@Ignore |
| 111 | @Test |
| 112 | public void testAddSwitchExisting() { |
| 113 | String dpid = "00:00:00:00:00:00:0a:07"; |
| 114 | String state = "ACTIVE"; |
| 115 | |
| 116 | //Mock Switch |
| 117 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
| 118 | mockISw.setState(state); |
| 119 | mockISw.setState(state); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 120 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 121 | replay(mockISw); |
| 122 | |
| 123 | //Expectation of mock operation. |
| 124 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 125 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
| 126 | mockOpe.commit(); |
| 127 | expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw); |
| 128 | mockOpe.commit(); |
| 129 | mockOpe.close(); |
| 130 | replay(mockOpe); |
| 131 | |
| 132 | swSt.init(conf); |
| 133 | swSt.addSwitch(dpid); |
| 134 | swSt.addSwitch(dpid); |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Desc: |
| 139 | * Test method for addSwitch method. |
| 140 | * Condition: |
| 141 | * The switch construction is fail and return null |
| 142 | * Expect: |
| 143 | * Write the status as info log. |
| 144 | */ |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 145 | @Test |
| 146 | public void testAddSwitchAbnormal() { |
| 147 | String dpid = "00:00:00:00:00:00:0a:07"; |
| 148 | |
| 149 | //Expectation of mock operation. |
| 150 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 151 | expect(mockOpe.newSwitch(dpid)).andReturn(null); |
HIGUCHI Yuta | fabb003 | 2013-06-28 11:31:33 -0700 | [diff] [blame] | 152 | mockOpe.rollback(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 153 | mockOpe.close(); |
| 154 | replay(mockOpe); |
| 155 | |
| 156 | swSt.init(conf); |
| 157 | swSt.addSwitch(dpid); |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Desc: |
| 162 | * Test method for addSwitch method. |
| 163 | * Condition: |
HIGUCHI Yuta | fabb003 | 2013-06-28 11:31:33 -0700 | [diff] [blame] | 164 | * Throw runtimeException. |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 165 | * Expect: |
| 166 | * The rollback method is called. |
| 167 | */ |
| 168 | //@Ignore |
| 169 | @Test |
| 170 | public void testAddSwitchException() { |
| 171 | String dpid = "00:00:00:00:00:00:0a:07"; |
| 172 | String state = "ACTIVE"; |
| 173 | |
| 174 | //Mock Switch |
| 175 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
| 176 | mockISw.setState(state); |
| 177 | replay(mockISw); |
| 178 | |
| 179 | //Expectation of mock operation. |
| 180 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 181 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
| 182 | mockOpe.commit(); |
| 183 | expectLastCall().andThrow(new RuntimeException()); |
| 184 | mockOpe.rollback(); |
| 185 | mockOpe.close(); |
| 186 | replay(mockOpe); |
| 187 | |
| 188 | swSt.init(conf); |
| 189 | swSt.addSwitch(dpid); |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Desc: |
| 194 | * Test method for updateSwitch method. |
| 195 | * Condition: |
| 196 | * SwitchState : INACTIVE |
| 197 | * DMOPERATION : UPDATE |
| 198 | * Expect: |
| 199 | * Should call addSwitch function and commit. |
| 200 | */ |
| 201 | //@Ignore |
| 202 | @Test |
| 203 | public void testUpdateUPDATE() { |
| 204 | String dpid = "00:00:00:00:00:00:0a:07"; |
| 205 | SwitchState stateINACTIVE = SwitchState.INACTIVE; |
| 206 | DM_OPERATION opUPDATE = DM_OPERATION.UPDATE; |
| 207 | |
| 208 | //Mock Switch |
| 209 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 210 | mockISw.setState(stateINACTIVE.toString()); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 211 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 212 | replay(mockISw); |
| 213 | |
| 214 | //Expectation of mock operation. |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 215 | expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw); |
| 216 | mockOpe.commit(); |
| 217 | mockOpe.close(); |
| 218 | replay(mockOpe); |
| 219 | |
| 220 | swSt.init(conf); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 221 | swSt.updateSwitch(dpid, stateINACTIVE, opUPDATE); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | /** |
| 225 | * Desc: |
| 226 | * Test method for updateSwitch method. |
| 227 | * Condition: |
| 228 | * SwitchState : INACTIVE |
| 229 | * DMOPERATION : CREATE |
| 230 | * Expect: |
| 231 | * Should call addSwitch function and commit. |
| 232 | */ |
| 233 | //@Ignore |
| 234 | @Test |
| 235 | public void testUpdateCREATE() { |
| 236 | String dpid = "00:00:00:00:00:00:0a:07"; |
| 237 | SwitchState stateINACTIVE = SwitchState.INACTIVE; |
| 238 | DM_OPERATION opCREATE = DM_OPERATION.CREATE; |
| 239 | |
| 240 | //Mock Switch |
| 241 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
| 242 | mockISw.setState("ACTIVE"); |
| 243 | mockISw.setState(stateINACTIVE.toString()); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 244 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 245 | replay(mockISw); |
| 246 | |
| 247 | //Expectation of mock operation. |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 248 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
| 249 | mockOpe.commit(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 250 | mockOpe.close(); |
| 251 | replay(mockOpe); |
| 252 | |
| 253 | swSt.init(conf); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 254 | swSt.updateSwitch(dpid, stateINACTIVE, opCREATE); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | /** |
| 258 | * Desc: |
| 259 | * Test method for updateSwitch method. |
| 260 | * Condition: |
| 261 | * SwitchState : INACTIVE |
| 262 | * DMOPERATION : INSERT |
| 263 | * Expect: |
| 264 | * Should call addSwitch function and commit. |
| 265 | */ |
| 266 | //@Ignore |
| 267 | @Test |
| 268 | public void testUpdateINSERT() { |
| 269 | String dpid = "00:00:00:00:00:00:0a:07"; |
| 270 | SwitchState stateINACTIVE = SwitchState.INACTIVE; |
| 271 | DM_OPERATION opINSERT = DM_OPERATION.INSERT; |
| 272 | |
| 273 | //Mock Switch |
| 274 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
| 275 | mockISw.setState("ACTIVE"); |
| 276 | mockISw.setState(stateINACTIVE.toString()); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 277 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 278 | replay(mockISw); |
| 279 | |
| 280 | //Expectation of mock operation. |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 281 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
| 282 | mockOpe.commit(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 283 | mockOpe.close(); |
| 284 | replay(mockOpe); |
| 285 | |
| 286 | swSt.init(conf); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 287 | swSt.updateSwitch(dpid, stateINACTIVE, opINSERT); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | /** |
| 291 | * Desc: |
| 292 | * Test method for updateSwitch method. |
| 293 | * Condition: |
| 294 | * SwitchState : ACTIVE |
| 295 | * DMOPERATION : DELETE |
| 296 | * Expect: |
| 297 | * Should call removeSwitch function and commit. |
| 298 | */ |
| 299 | //@Ignore |
| 300 | @Test |
| 301 | public void testUpdateDELETE() { |
| 302 | String dpid = "00:00:00:00:00:00:0a:07"; |
| 303 | SwitchState stateACTIVE = SwitchState.ACTIVE; |
| 304 | DM_OPERATION opDELETE = DM_OPERATION.DELETE; |
| 305 | |
| 306 | //Mock Switch |
| 307 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
| 308 | mockISw.setState(stateACTIVE.toString()); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 309 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 310 | replay(mockISw); |
| 311 | |
| 312 | //Expectation of mock operation. |
| 313 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 314 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
| 315 | mockOpe.commit(); |
| 316 | expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw); |
| 317 | mockOpe.removeSwitch(mockISw); |
| 318 | mockOpe.commit(); |
| 319 | mockOpe.close(); |
| 320 | replay(mockOpe); |
| 321 | |
| 322 | swSt.init(conf); |
| 323 | swSt.addSwitch(dpid); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 324 | swSt.updateSwitch(dpid, stateACTIVE, opDELETE); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | /** |
| 328 | * Desc: |
| 329 | * Test method for deleteSwitch method. |
| 330 | * Condition: |
| 331 | * The switch is existing. |
| 332 | * Expect: |
| 333 | * Should call removeSwitch function and commit. |
| 334 | */ |
| 335 | //@Ignore |
| 336 | @Test |
| 337 | public void testDeleteSwitch() { |
| 338 | String dpid = "00:00:00:00:00:00:0a:07"; |
| 339 | String state = "ACTIVE"; |
| 340 | |
| 341 | //Mock Switch |
| 342 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
| 343 | mockISw.setState(state); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 344 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 345 | replay(mockISw); |
| 346 | |
| 347 | //Expectation of mock operation. |
| 348 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 349 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
| 350 | mockOpe.commit(); |
| 351 | expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw); |
| 352 | mockOpe.removeSwitch(mockISw); |
| 353 | mockOpe.commit(); |
| 354 | mockOpe.close(); |
| 355 | replay(mockOpe); |
| 356 | |
| 357 | swSt.init(conf); |
| 358 | swSt.addSwitch(dpid); |
| 359 | swSt.deleteSwitch(dpid); |
| 360 | |
| 361 | //Iterator<Vertex> it = titanGraph.getVertices("dpid", dpid).iterator(); |
| 362 | //assertFalse(it.hasNext()); |
| 363 | } |
| 364 | |
| 365 | /** |
| 366 | * Desc: |
| 367 | * Test method for deleteSwitch method. |
| 368 | * Condition: |
| 369 | * The commit func throw exception. |
| 370 | * Expect: |
| 371 | * Should call rollback. |
| 372 | */ |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 373 | @Test |
| 374 | public void testDeleteSwitchException() { |
| 375 | String dpid = "00:00:00:00:00:00:0a:07"; |
| 376 | String state = "ACTIVE"; |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 377 | |
| 378 | //Mock Switch |
| 379 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
| 380 | mockISw.setState(state); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 381 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 382 | replay(mockISw); |
| 383 | |
| 384 | //Expectation of mock operation. |
| 385 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 386 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
| 387 | mockOpe.commit(); |
| 388 | expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw); |
Yuta HIGUCHI | b63f94f | 2013-10-14 10:01:45 -0700 | [diff] [blame] | 389 | mockOpe.removeSwitch(mockISw); |
| 390 | mockOpe.commit(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 391 | expectLastCall().andThrow(new RuntimeException()); |
| 392 | mockOpe.rollback(); |
| 393 | mockOpe.close(); |
| 394 | replay(mockOpe); |
| 395 | |
| 396 | swSt.init(conf); |
| 397 | swSt.addSwitch(dpid); |
| 398 | swSt.deleteSwitch(dpid); |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * Desc: |
| 403 | * Test method for addPort method. |
| 404 | * Condition: |
| 405 | * port is existing. |
| 406 | * Expect: |
| 407 | * Should call addPort and commit. |
| 408 | */ |
| 409 | //@Ignore |
| 410 | @Test |
| 411 | public void testAddPort() { |
| 412 | String dpid = "00:00:00:00:00:00:0a:01"; |
| 413 | short portNumber = 5; |
| 414 | String state = "ACTIVE"; |
| 415 | String name = "port 5 at SEA switch"; |
| 416 | |
| 417 | OFPhysicalPort portToAdd = new OFPhysicalPort(); |
| 418 | portToAdd.setName(name); |
| 419 | portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue()); |
| 420 | portToAdd.setPortNumber(portNumber); |
| 421 | portToAdd.setState(OFPortState.OFPPS_STP_FORWARD.getValue()); |
| 422 | |
| 423 | //Expectation of mock Port |
| 424 | IPortObject mockIPort = createMock(IPortObject.class); |
| 425 | mockIPort.setState(state); |
| 426 | mockIPort.setPortState(OFPortState.OFPPS_STP_FORWARD.getValue()); |
| 427 | mockIPort.setDesc(name); |
| 428 | replay(mockIPort); |
| 429 | |
| 430 | //Expectation of mock Switch |
| 431 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
| 432 | mockISw.setState(state); |
| 433 | mockISw.addPort(mockIPort); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 434 | expect(mockISw.getPort(anyShort())).andReturn(null); |
| 435 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 436 | replay(mockISw); |
| 437 | |
| 438 | //Expectation of mock operation. |
| 439 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 440 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
| 441 | mockOpe.commit(); |
| 442 | expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 443 | // expect(mockOpe.searchPort(dpid, portNumber)).andReturn(null); |
Pankaj Berde | bbd3861 | 2013-06-22 05:59:12 -0700 | [diff] [blame] | 444 | expect(mockOpe.newPort(dpid, portNumber)).andReturn(mockIPort); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 445 | mockOpe.commit(); |
| 446 | mockOpe.close(); |
| 447 | replay(mockOpe); |
| 448 | |
| 449 | swSt.init(conf); |
| 450 | swSt.addSwitch(dpid); |
| 451 | swSt.addPort(dpid, portToAdd); |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * Desc: |
| 456 | * Test method for addPort method. |
| 457 | * Condition: |
| 458 | * Port status is down. |
| 459 | * Expect: |
| 460 | * Should call removePort and commit. |
| 461 | */ |
| 462 | //@Ignore |
| 463 | @Test |
| 464 | public void testAddPortWithPortLinkDown() { |
| 465 | String dpid = "00:00:00:00:00:00:0a:01"; |
| 466 | short portNumber = 5; |
Pankaj Berde | ac54a4b | 2013-08-02 15:31:28 -0700 | [diff] [blame] | 467 | String swState = "ACTIVE"; |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 468 | // String portState = "INACTIVE"; |
| 469 | String portId = "5"; |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 470 | String name = "port 5 at SEA switch"; |
| 471 | |
| 472 | OFPhysicalPort portToAdd = new OFPhysicalPort(); |
| 473 | portToAdd.setName(name); |
| 474 | portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue()); |
| 475 | portToAdd.setPortNumber(portNumber); |
| 476 | portToAdd.setState(OFPortState.OFPPS_LINK_DOWN.getValue()); |
| 477 | |
| 478 | //Expectation of mock Port |
| 479 | IPortObject mockIPort = createMock(IPortObject.class); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 480 | expect(mockIPort.getPortId()).andReturn(portId); |
| 481 | // mockIPort.setState(portState); |
| 482 | // mockIPort.setPortState(OFPortState.OFPPS_STP_FORWARD.getValue()); |
| 483 | // mockIPort.setDesc(name); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 484 | replay(mockIPort); |
| 485 | |
| 486 | //Expectation of mock Switch |
| 487 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
Pankaj Berde | ac54a4b | 2013-08-02 15:31:28 -0700 | [diff] [blame] | 488 | mockISw.setState(swState); |
| 489 | // mockISw.removePort(mockIPort); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 490 | expect(mockISw.getPort(anyShort())).andReturn(mockIPort); |
| 491 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 492 | replay(mockISw); |
| 493 | |
| 494 | //Expectation of mock operation. |
| 495 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 496 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 497 | mockOpe.commit(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 498 | expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 499 | // expect(mockOpe.searchPort(dpid, portNumber)).andReturn(mockIPort); |
| 500 | mockOpe.removePort(mockIPort); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 501 | mockOpe.commit(); |
| 502 | mockOpe.close(); |
| 503 | replay(mockOpe); |
| 504 | |
| 505 | swSt.init(conf); |
| 506 | swSt.addSwitch(dpid); |
| 507 | swSt.addPort(dpid, portToAdd); |
| 508 | } |
| 509 | |
| 510 | /** |
| 511 | * Desc: |
| 512 | * Test method for addPort method. |
| 513 | * Condition: |
| 514 | * The switch is not existing. |
| 515 | * Expect: |
| 516 | * Nothing happens. |
| 517 | */ |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 518 | @Test |
| 519 | public void testAddPortAbnormalNoSwitch() { |
| 520 | String dpid = "00:00:00:00:00:00:0a:01"; |
| 521 | short portNumber = 5; |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 522 | String name = "port 5 at SEA switch"; |
| 523 | |
| 524 | OFPhysicalPort portToAdd = new OFPhysicalPort(); |
| 525 | portToAdd.setName(name); |
| 526 | portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue()); |
| 527 | portToAdd.setPortNumber(portNumber); |
| 528 | portToAdd.setState(OFPortState.OFPPS_STP_FORWARD.getValue()); |
| 529 | |
| 530 | //Expectation of mock Port |
| 531 | IPortObject mockIPort = createStrictMock(IPortObject.class); |
| 532 | replay(mockIPort); |
| 533 | |
| 534 | //Expectation of mock Switch |
| 535 | ISwitchObject mockISw = createStrictMock(ISwitchObject.class); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 536 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 537 | replay(mockISw); |
| 538 | |
| 539 | //Expectation of mock operation. |
| 540 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 541 | mockOpe.close(); |
| 542 | replay(mockOpe); |
| 543 | |
| 544 | swSt.init(conf); |
| 545 | swSt.addPort(dpid, portToAdd); |
| 546 | } |
| 547 | |
| 548 | /** |
| 549 | * Desc: |
| 550 | * Test method for addPort method. |
| 551 | * Condition: |
| 552 | * port is not existing. |
| 553 | * Expect: |
| 554 | * Should call addPort and commit. |
| 555 | */ |
| 556 | //@Ignore |
| 557 | @Test |
| 558 | public void testAddPortAbnormalNoPort() { |
| 559 | String dpid = "00:00:00:00:00:00:0a:01"; |
| 560 | short portNumber = 5; |
| 561 | String state = "ACTIVE"; |
| 562 | String name = "port 5 at SEA switch"; |
| 563 | |
| 564 | OFPhysicalPort portToAdd = new OFPhysicalPort(); |
| 565 | portToAdd.setName(name); |
| 566 | portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue()); |
| 567 | portToAdd.setPortNumber(portNumber); |
| 568 | portToAdd.setState(OFPortState.OFPPS_STP_FORWARD.getValue()); |
| 569 | |
| 570 | //Expectation of mock Port |
| 571 | IPortObject mockIPort = createMock(IPortObject.class); |
| 572 | mockIPort.setState(state); |
| 573 | mockIPort.setPortState(OFPortState.OFPPS_STP_FORWARD.getValue()); |
| 574 | mockIPort.setDesc(name); |
| 575 | replay(mockIPort); |
| 576 | |
| 577 | //Expectation of mock Switch |
| 578 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
| 579 | mockISw.setState(state); |
| 580 | mockISw.addPort(mockIPort); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 581 | expect(mockISw.getPort(portNumber)).andReturn(null); |
| 582 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 583 | replay(mockISw); |
| 584 | |
| 585 | //Expectation of mock operation. |
| 586 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 587 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
| 588 | mockOpe.commit(); |
| 589 | expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 590 | // expect(mockOpe.searchPort(dpid, portNumber)).andReturn(null); |
Pankaj Berde | bbd3861 | 2013-06-22 05:59:12 -0700 | [diff] [blame] | 591 | expect(mockOpe.newPort(dpid, portNumber)).andReturn(null); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 592 | mockOpe.rollback(); |
| 593 | mockOpe.close(); |
| 594 | replay(mockOpe); |
| 595 | |
| 596 | swSt.init(conf); |
| 597 | swSt.addSwitch(dpid); |
| 598 | swSt.addPort(dpid, portToAdd); |
| 599 | } |
| 600 | |
| 601 | /** |
| 602 | * Desc: |
| 603 | * Test method for addPort method. |
| 604 | * Condition: |
| 605 | * commit throw the exception. |
| 606 | * Expect: |
| 607 | * Should call rollback. |
| 608 | */ |
| 609 | //@Ignore |
| 610 | @Test |
| 611 | public void testAddPortWithException() { |
| 612 | String dpid = "00:00:00:00:00:00:0a:01"; |
| 613 | short portNumber = 5; |
| 614 | String state = "ACTIVE"; |
| 615 | String name = "port 5 at SEA switch"; |
| 616 | |
| 617 | OFPhysicalPort portToAdd = new OFPhysicalPort(); |
| 618 | portToAdd.setName(name); |
| 619 | portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue()); |
| 620 | portToAdd.setPortNumber(portNumber); |
| 621 | portToAdd.setState(OFPortState.OFPPS_STP_FORWARD.getValue()); |
| 622 | |
| 623 | //Expectation of mock Port |
| 624 | IPortObject mockIPort = createMock(IPortObject.class); |
| 625 | mockIPort.setState(state); |
| 626 | mockIPort.setPortState(OFPortState.OFPPS_STP_FORWARD.getValue()); |
| 627 | mockIPort.setDesc(name); |
| 628 | replay(mockIPort); |
| 629 | |
| 630 | //Expectation of mock Switch |
| 631 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
| 632 | mockISw.setState(state); |
| 633 | mockISw.addPort(mockIPort); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 634 | expect(mockISw.getPort(portNumber)).andReturn(null); |
| 635 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 636 | replay(mockISw); |
| 637 | |
| 638 | //Expectation of mock operation. |
| 639 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 640 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
| 641 | mockOpe.commit(); |
| 642 | expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 643 | // expect(mockOpe.searchPort(dpid, portNumber)).andReturn(null); |
Pankaj Berde | bbd3861 | 2013-06-22 05:59:12 -0700 | [diff] [blame] | 644 | expect(mockOpe.newPort(dpid, portNumber)).andReturn(mockIPort); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 645 | mockOpe.commit(); |
| 646 | expectLastCall().andThrow(new RuntimeException()); |
| 647 | mockOpe.rollback(); |
| 648 | mockOpe.close(); |
| 649 | replay(mockOpe); |
| 650 | |
| 651 | swSt.init(conf); |
| 652 | swSt.addSwitch(dpid); |
| 653 | swSt.addPort(dpid, portToAdd); |
| 654 | } |
| 655 | |
| 656 | /** |
| 657 | * Desc: |
| 658 | * Test method for deletePort method. |
| 659 | * Condition: |
| 660 | * port is existing. |
| 661 | * Expect: |
| 662 | * Should call removePort and commit. |
| 663 | */ |
| 664 | //@Ignore |
| 665 | @Test |
| 666 | public void testDeletePort() { |
| 667 | String dpid = "00:00:00:00:00:00:0a:01"; |
| 668 | short portNumber = 5; |
Pankaj Berde | ac54a4b | 2013-08-02 15:31:28 -0700 | [diff] [blame] | 669 | String portState = "INACTIVE"; |
| 670 | String swState = "ACTIVE"; |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 671 | String portId = "5"; |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 672 | String name = "port 5 at SEA switch"; |
| 673 | |
| 674 | OFPhysicalPort portToAdd = new OFPhysicalPort(); |
| 675 | portToAdd.setName(name); |
| 676 | portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue()); |
| 677 | portToAdd.setPortNumber(portNumber); |
| 678 | portToAdd.setState(OFPortState.OFPPS_STP_FORWARD.getValue()); |
| 679 | |
| 680 | //Expectation of mock Port |
| 681 | IPortObject mockIPort = createMock(IPortObject.class); |
Pankaj Berde | ac54a4b | 2013-08-02 15:31:28 -0700 | [diff] [blame] | 682 | mockIPort.setState(swState); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 683 | // mockIPort.setPortState(OFPortState.OFPPS_STP_FORWARD.getValue()); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 684 | mockIPort.setDesc(name); |
Pankaj Berde | ac54a4b | 2013-08-02 15:31:28 -0700 | [diff] [blame] | 685 | mockIPort.setState(portState); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 686 | expect(mockIPort.getPortId()).andReturn(portId); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 687 | replay(mockIPort); |
| 688 | |
| 689 | //Expectation of mock Switch |
| 690 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
Pankaj Berde | ac54a4b | 2013-08-02 15:31:28 -0700 | [diff] [blame] | 691 | mockISw.setState(swState); |
Pankaj Berde | ac54a4b | 2013-08-02 15:31:28 -0700 | [diff] [blame] | 692 | // mockISw.removePort(mockIPort); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 693 | expect(mockISw.getPort(portNumber)).andReturn(null); |
| 694 | mockISw.addPort(mockIPort); |
| 695 | expect(mockISw.getPort(portNumber)).andReturn(mockIPort); |
| 696 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 697 | replay(mockISw); |
| 698 | |
| 699 | //Expectation of mock operation. |
| 700 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 701 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
| 702 | mockOpe.commit(); |
| 703 | expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 704 | // expect(mockOpe.searchPort(dpid, portNumber)).andReturn(null); |
Pankaj Berde | bbd3861 | 2013-06-22 05:59:12 -0700 | [diff] [blame] | 705 | expect(mockOpe.newPort(dpid, portNumber)).andReturn(mockIPort); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 706 | mockOpe.commit(); |
| 707 | expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 708 | // expect(mockOpe.searchPort(dpid, portNumber)).andReturn(mockIPort); |
| 709 | mockOpe.removePort(mockIPort); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 710 | mockOpe.commit(); |
| 711 | mockOpe.close(); |
| 712 | replay(mockOpe); |
| 713 | |
| 714 | swSt.init(conf); |
| 715 | swSt.addSwitch(dpid); |
| 716 | swSt.addPort(dpid, portToAdd); |
| 717 | swSt.deletePort(dpid, portNumber); |
| 718 | } |
| 719 | |
| 720 | /** |
| 721 | * Desc: |
| 722 | * Test method for addPort method. |
| 723 | * Condition: |
| 724 | * commit throws the exception. |
| 725 | * Expect: |
| 726 | * Should call rollback. |
| 727 | */ |
| 728 | //@Ignore |
| 729 | @Test |
| 730 | public void testDeletePortException() { |
| 731 | String dpid = "00:00:00:00:00:00:0a:01"; |
| 732 | short portNumber = 5; |
Pankaj Berde | ac54a4b | 2013-08-02 15:31:28 -0700 | [diff] [blame] | 733 | String swState = "ACTIVE"; |
| 734 | String portState = "INACTIVE"; |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 735 | String portId = "5"; |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 736 | String name = "port 5 at SEA switch"; |
| 737 | |
| 738 | OFPhysicalPort portToAdd = new OFPhysicalPort(); |
| 739 | portToAdd.setName(name); |
| 740 | portToAdd.setCurrentFeatures(OFPhysicalPort.OFPortFeatures.OFPPF_100MB_FD.getValue()); |
| 741 | portToAdd.setPortNumber(portNumber); |
| 742 | portToAdd.setState(OFPortState.OFPPS_STP_FORWARD.getValue()); |
| 743 | |
| 744 | //Expectation of mock Port |
| 745 | IPortObject mockIPort = createMock(IPortObject.class); |
Pankaj Berde | ac54a4b | 2013-08-02 15:31:28 -0700 | [diff] [blame] | 746 | mockIPort.setState(swState); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 747 | mockIPort.setPortState(OFPortState.OFPPS_STP_FORWARD.getValue()); |
| 748 | mockIPort.setDesc(name); |
Pankaj Berde | ac54a4b | 2013-08-02 15:31:28 -0700 | [diff] [blame] | 749 | mockIPort.setState(portState); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 750 | expect(mockIPort.getPortId()).andReturn(portId); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 751 | replay(mockIPort); |
| 752 | |
| 753 | //Expectation of mock Switch |
| 754 | ISwitchObject mockISw = createMock(ISwitchObject.class); |
Pankaj Berde | ac54a4b | 2013-08-02 15:31:28 -0700 | [diff] [blame] | 755 | mockISw.setState(swState); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 756 | mockISw.addPort(mockIPort); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 757 | expect(mockISw.getPort(portNumber)).andReturn(null); |
| 758 | expect(mockISw.getPort(portNumber)).andReturn(mockIPort).anyTimes(); |
Pankaj Berde | ac54a4b | 2013-08-02 15:31:28 -0700 | [diff] [blame] | 759 | // mockISw.removePort(mockIPort); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 760 | |
| 761 | expect(mockISw.getDPID()).andReturn(dpid).anyTimes(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 762 | replay(mockISw); |
| 763 | |
| 764 | //Expectation of mock operation. |
| 765 | expect(mockOpe.searchSwitch(dpid)).andReturn(null); |
| 766 | expect(mockOpe.newSwitch(dpid)).andReturn(mockISw); |
| 767 | mockOpe.commit(); |
| 768 | expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 769 | // expect(mockOpe.searchPort(dpid, portNumber)).andReturn(null); |
Pankaj Berde | bbd3861 | 2013-06-22 05:59:12 -0700 | [diff] [blame] | 770 | expect(mockOpe.newPort(dpid, portNumber)).andReturn(mockIPort); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 771 | mockOpe.commit(); |
| 772 | expect(mockOpe.searchSwitch(dpid)).andReturn(mockISw); |
Naoki Shiota | 987a572 | 2013-10-23 11:59:36 -0700 | [diff] [blame] | 773 | // expect(mockOpe.searchPort(dpid, portNumber)).andReturn(mockIPort); |
| 774 | // mockOpe.commit(); // Cannot generate exception..need to revisit this test |
| 775 | mockOpe.removePort(mockIPort); |
| 776 | expectLastCall().andThrow(new RuntimeException()); |
| 777 | mockOpe.rollback(); |
Teru | ab4b01a | 2013-06-20 10:09:57 -0700 | [diff] [blame] | 778 | mockOpe.close(); |
| 779 | replay(mockOpe); |
| 780 | |
| 781 | swSt.init(conf); |
| 782 | swSt.addSwitch(dpid); |
| 783 | swSt.addPort(dpid, portToAdd); |
| 784 | swSt.deletePort(dpid, portNumber); |
| 785 | } |
| 786 | } |