Fix checkstyle whitespace issues - WHITESPACE ONLY
Change-Id: Ic205c1afd639c6008d61d9de95cb764eeb6238ca
diff --git a/src/test/java/net/onrc/onos/core/datastore/topology/KVSwitchTest.java b/src/test/java/net/onrc/onos/core/datastore/topology/KVSwitchTest.java
index 58b30a3..ba25903 100644
--- a/src/test/java/net/onrc/onos/core/datastore/topology/KVSwitchTest.java
+++ b/src/test/java/net/onrc/onos/core/datastore/topology/KVSwitchTest.java
@@ -27,181 +27,182 @@
@Before
public void setUp() throws Exception {
- switchTable = DataStoreClient.getClient().getTable(KVSwitch.GLOBAL_SWITCH_TABLE_NAME);
- sw1 = new KVSwitch(dpid1);
+ switchTable = DataStoreClient.getClient().getTable(KVSwitch.GLOBAL_SWITCH_TABLE_NAME);
+ sw1 = new KVSwitch(dpid1);
}
@After
public void tearDown() throws Exception {
- DataStoreClient.getClient().dropTable(switchTable);
+ DataStoreClient.getClient().dropTable(switchTable);
}
public KVSwitch assertSwitchInDataStore(final Long dpid, final STATUS status) {
- try {
- final KVSwitch sw = new KVSwitch(dpid);
- sw.read();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
- assertEquals(dpid, sw.getDpid());
- assertEquals(status, sw.getStatus());
- return sw;
- } catch (ObjectDoesntExistException e) {
- fail("Switch was not written to datastore");
- }
- return null;
+ try {
+ final KVSwitch sw = new KVSwitch(dpid);
+ sw.read();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
+ assertEquals(dpid, sw.getDpid());
+ assertEquals(status, sw.getStatus());
+ return sw;
+ } catch (ObjectDoesntExistException e) {
+ fail("Switch was not written to datastore");
+ }
+ return null;
}
+
public void assertSwitchNotInDataStore(final Long dpid) {
- final KVSwitch sw = new KVSwitch(dpid);
- try {
- sw.read();
- fail("Switch was not supposed to be there in datastore");
- } catch (ObjectDoesntExistException e) {
- }
+ final KVSwitch sw = new KVSwitch(dpid);
+ try {
+ sw.read();
+ fail("Switch was not supposed to be there in datastore");
+ } catch (ObjectDoesntExistException e) {
+ }
}
@Test
public void testGetAllSwitches() throws ObjectExistsException {
- final int NUM_SWITCHES = 100;
- Map<Long,KVSwitch> expected = new HashMap<>();
- for (long dpid = 1 ; dpid <= NUM_SWITCHES ; ++dpid) {
- KVSwitch sw = new KVSwitch(dpid);
- sw.setStatus(STATUS.ACTIVE);
- sw.create();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
- expected.put(sw.getDpid(), sw);
- }
+ final int NUM_SWITCHES = 100;
+ Map<Long, KVSwitch> expected = new HashMap<>();
+ for (long dpid = 1; dpid <= NUM_SWITCHES; ++dpid) {
+ KVSwitch sw = new KVSwitch(dpid);
+ sw.setStatus(STATUS.ACTIVE);
+ sw.create();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
+ expected.put(sw.getDpid(), sw);
+ }
- Iterable<KVSwitch> switches = KVSwitch.getAllSwitches();
+ Iterable<KVSwitch> switches = KVSwitch.getAllSwitches();
- for (KVSwitch sw : switches) {
- KVSwitch expectedSw = expected.get(sw.getDpid());
- assertNotNull(expectedSw);
- assertEquals(expectedSw.getDpid(), sw.getDpid());
- assertEquals(expectedSw.getStatus(), sw.getStatus());
- assertEquals(expectedSw.getVersion(), sw.getVersion());
+ for (KVSwitch sw : switches) {
+ KVSwitch expectedSw = expected.get(sw.getDpid());
+ assertNotNull(expectedSw);
+ assertEquals(expectedSw.getDpid(), sw.getDpid());
+ assertEquals(expectedSw.getStatus(), sw.getStatus());
+ assertEquals(expectedSw.getVersion(), sw.getVersion());
- assertArrayEquals(expectedSw.getKey(), sw.getKey());
- }
+ assertArrayEquals(expectedSw.getKey(), sw.getKey());
+ }
}
@Test
public void testCreate() throws ObjectExistsException {
- sw1.setStatus(STATUS.ACTIVE);
- sw1.create();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
+ sw1.setStatus(STATUS.ACTIVE);
+ sw1.create();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
- assertEquals(dpid1, sw1.getDpid());
- assertEquals(STATUS.ACTIVE, sw1.getStatus());
+ assertEquals(dpid1, sw1.getDpid());
+ assertEquals(STATUS.ACTIVE, sw1.getStatus());
- assertSwitchInDataStore(dpid1, STATUS.ACTIVE);
+ assertSwitchInDataStore(dpid1, STATUS.ACTIVE);
}
@Test(expected = ObjectExistsException.class)
public void testCreateFailAlreadyExist() throws ObjectExistsException {
- // setup pre-existing Switch
- KVSwitch sw = new KVSwitch(dpid1);
- sw.forceCreate();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
- assertSwitchInDataStore(dpid1, STATUS.INACTIVE);
+ // setup pre-existing Switch
+ KVSwitch sw = new KVSwitch(dpid1);
+ sw.forceCreate();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
+ assertSwitchInDataStore(dpid1, STATUS.INACTIVE);
- sw1.setStatus(STATUS.ACTIVE);
- sw1.create();
- fail("Should have thrown an exception");
+ sw1.setStatus(STATUS.ACTIVE);
+ sw1.create();
+ fail("Should have thrown an exception");
}
@Test
public void testForceCreate() {
- // setup pre-existing Switch
- KVSwitch sw = new KVSwitch(dpid1);
- sw.forceCreate();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
- assertSwitchInDataStore(dpid1, STATUS.INACTIVE);
+ // setup pre-existing Switch
+ KVSwitch sw = new KVSwitch(dpid1);
+ sw.forceCreate();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
+ assertSwitchInDataStore(dpid1, STATUS.INACTIVE);
- sw1.setStatus(STATUS.ACTIVE);
- sw1.forceCreate();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
+ sw1.setStatus(STATUS.ACTIVE);
+ sw1.forceCreate();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
- assertEquals(dpid1, sw1.getDpid());
- assertEquals(STATUS.ACTIVE, sw1.getStatus());
- assertSwitchInDataStore(dpid1, STATUS.ACTIVE);
+ assertEquals(dpid1, sw1.getDpid());
+ assertEquals(STATUS.ACTIVE, sw1.getStatus());
+ assertSwitchInDataStore(dpid1, STATUS.ACTIVE);
}
@Test
public void testRead() throws ObjectDoesntExistException {
- // setup pre-existing Switch
- KVSwitch sw = new KVSwitch(dpid1);
- sw.setStatus(STATUS.ACTIVE);
- sw.forceCreate();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
- assertSwitchInDataStore(dpid1, STATUS.ACTIVE);
+ // setup pre-existing Switch
+ KVSwitch sw = new KVSwitch(dpid1);
+ sw.setStatus(STATUS.ACTIVE);
+ sw.forceCreate();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
+ assertSwitchInDataStore(dpid1, STATUS.ACTIVE);
- sw1.read();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
- assertEquals(sw.getVersion(), sw1.getVersion());
- assertEquals(dpid1, sw1.getDpid());
- assertEquals(STATUS.ACTIVE, sw1.getStatus());
+ sw1.read();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
+ assertEquals(sw.getVersion(), sw1.getVersion());
+ assertEquals(dpid1, sw1.getDpid());
+ assertEquals(STATUS.ACTIVE, sw1.getStatus());
}
@Test(expected = ObjectDoesntExistException.class)
public void testReadFailNoExist() throws ObjectDoesntExistException {
- sw1.read();
- fail("Should have thrown an exception");
+ sw1.read();
+ fail("Should have thrown an exception");
}
@Test
public void testUpdate() throws ObjectDoesntExistException, WrongVersionException {
- // setup pre-existing Switch
- KVSwitch sw = new KVSwitch(dpid1);
- sw.setStatus(STATUS.ACTIVE);
- sw.forceCreate();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
- assertSwitchInDataStore(dpid1, STATUS.ACTIVE);
+ // setup pre-existing Switch
+ KVSwitch sw = new KVSwitch(dpid1);
+ sw.setStatus(STATUS.ACTIVE);
+ sw.forceCreate();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
+ assertSwitchInDataStore(dpid1, STATUS.ACTIVE);
- sw1.read();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
+ sw1.read();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
- sw1.setStatus(STATUS.INACTIVE);
- sw1.update();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
- assertNotEquals(sw.getVersion(), sw1.getVersion());
- assertEquals(dpid1, sw1.getDpid());
- assertEquals(STATUS.INACTIVE, sw1.getStatus());
+ sw1.setStatus(STATUS.INACTIVE);
+ sw1.update();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
+ assertNotEquals(sw.getVersion(), sw1.getVersion());
+ assertEquals(dpid1, sw1.getDpid());
+ assertEquals(STATUS.INACTIVE, sw1.getStatus());
}
@Test
public void testDelete() throws ObjectDoesntExistException, WrongVersionException {
- // setup pre-existing Switch
- KVSwitch sw = new KVSwitch(dpid1);
- sw.setStatus(STATUS.ACTIVE);
- sw.forceCreate();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
- assertSwitchInDataStore(dpid1, STATUS.ACTIVE);
+ // setup pre-existing Switch
+ KVSwitch sw = new KVSwitch(dpid1);
+ sw.setStatus(STATUS.ACTIVE);
+ sw.forceCreate();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
+ assertSwitchInDataStore(dpid1, STATUS.ACTIVE);
- try {
- sw1.read();
- } catch (ObjectDoesntExistException e) {
- fail("Failed reading switch to delete");
- }
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
- sw1.delete();
- assertSwitchNotInDataStore(dpid1);
+ try {
+ sw1.read();
+ } catch (ObjectDoesntExistException e) {
+ fail("Failed reading switch to delete");
+ }
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
+ sw1.delete();
+ assertSwitchNotInDataStore(dpid1);
}
@Test
public void testForceDelete() {
- // setup pre-existing Switch
- KVSwitch sw = new KVSwitch(dpid1);
- sw.setStatus(STATUS.ACTIVE);
- sw.forceCreate();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
- assertSwitchInDataStore(dpid1, STATUS.ACTIVE);
+ // setup pre-existing Switch
+ KVSwitch sw = new KVSwitch(dpid1);
+ sw.setStatus(STATUS.ACTIVE);
+ sw.forceCreate();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw.getVersion());
+ assertSwitchInDataStore(dpid1, STATUS.ACTIVE);
- sw1.forceDelete();
- assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
+ sw1.forceDelete();
+ assertNotEquals(DataStoreClient.getClient().VERSION_NONEXISTENT(), sw1.getVersion());
}
}