Enforce checkstyle for unit test codes
- First time contributer is likely to start with unit-test code,
so it is probably better to enforce the ONOS code style for
unit test codes also.
Change-Id: Id665e55b0f0bee7232dfb18ce6a7f9ea8cc3b164
diff --git a/.checkstyle b/.checkstyle
index 40e6b6c..de2d242 100644
--- a/.checkstyle
+++ b/.checkstyle
@@ -6,6 +6,6 @@
</local-check-config>
<fileset name="all" enabled="true" check-config-name="ONOS" local="true">
<file-match-pattern match-pattern="." include-pattern="true"/>
- <file-match-pattern match-pattern="src/test/.*" include-pattern="false"/>
+ <file-match-pattern match-pattern="src/test/.*" include-pattern="true"/>
</fileset>
</fileset-config>
diff --git a/conf/checkstyle/sun_checks.xml b/conf/checkstyle/sun_checks.xml
index f334784..4993209 100644
--- a/conf/checkstyle/sun_checks.xml
+++ b/conf/checkstyle/sun_checks.xml
@@ -135,7 +135,9 @@
<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
- <module name="AvoidStarImport"/>
+ <module name="AvoidStarImport">
+ <property name="allowStaticMemberImports" value="true"/>
+ </module>
<module name="IllegalImport"/>
<!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
diff --git a/pom.xml b/pom.xml
index 9a32fb3..80dbf31 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,6 +59,7 @@
<propertiesLocation>${basedir}/conf/checkstyle/checkstyle_maven.properties</propertiesLocation>
<failsOnError>false</failsOnError>
<logViolationsToConsole>true</logViolationsToConsole>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<executions>
<execution>
@@ -428,6 +429,7 @@
(under build and reporting)
-->
<propertiesLocation>${basedir}/conf/checkstyle/checkstyle_maven.properties</propertiesLocation>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<reportSets>
<reportSet>
diff --git a/src/test/java/net/onrc/onos/api/rest/ClientResourceStatusMatcher.java b/src/test/java/net/onrc/onos/api/rest/ClientResourceStatusMatcher.java
index c7d03df..3a08f4b 100644
--- a/src/test/java/net/onrc/onos/api/rest/ClientResourceStatusMatcher.java
+++ b/src/test/java/net/onrc/onos/api/rest/ClientResourceStatusMatcher.java
@@ -11,7 +11,7 @@
* Hamcrest Matcher to determine if a Restlet ClientResource object's status
* matches a given status.
*/
-public class ClientResourceStatusMatcher extends TypeSafeMatcher<ClientResource> {
+public final class ClientResourceStatusMatcher extends TypeSafeMatcher<ClientResource> {
private Status status;
/**
diff --git a/src/test/java/net/onrc/onos/api/rest/TestRestIntent.java b/src/test/java/net/onrc/onos/api/rest/TestRestIntent.java
index c47c56a..630000e 100644
--- a/src/test/java/net/onrc/onos/api/rest/TestRestIntent.java
+++ b/src/test/java/net/onrc/onos/api/rest/TestRestIntent.java
@@ -97,7 +97,7 @@
* Utility function to locate an intent in a JSON collection
* that has the given id.
* The JSON collection of intents looks like:
- * <code>
+ * {@code
* MAP =
* [0] =
* MAP =
@@ -112,7 +112,7 @@
* id = "3"
* ...
* ...
- * </code>
+ * }
*
* @param intents collection map to search
* @param id id of the intent to look for
@@ -120,7 +120,7 @@
*/
Map<String, String> findIntentWithId(final Collection<Map<String, String>> intents,
final String id) {
- for (final Map<String, String>intentMap : intents) {
+ for (final Map<String, String> intentMap : intents) {
if (id.equals(intentMap.get("id"))) {
return intentMap;
}
@@ -139,7 +139,7 @@
*/
@SuppressWarnings("unchecked")
Collection<Map<String, String>> getIntentsCollection(final ClientResource client) {
- return (Collection<Map<String, String>>)client.get(Collection.class);
+ return client.get(Collection.class);
}
/**
@@ -152,6 +152,6 @@
*/
@SuppressWarnings("unchecked")
Map<String, String> getIntent(final ClientResource client) {
- return (Map<String, String>)client.get(Map.class);
+ return client.get(Map.class);
}
}
diff --git a/src/test/java/net/onrc/onos/api/rest/TestRestIntentHighDelete.java b/src/test/java/net/onrc/onos/api/rest/TestRestIntentHighDelete.java
index 162957e..fbfe471 100644
--- a/src/test/java/net/onrc/onos/api/rest/TestRestIntentHighDelete.java
+++ b/src/test/java/net/onrc/onos/api/rest/TestRestIntentHighDelete.java
@@ -29,6 +29,7 @@
@PrepareForTest(PathCalcRuntimeModule.class)
public class TestRestIntentHighDelete extends TestRestIntent {
private static final Long LOCAL_PORT = 0xFFFEL;
+ private static final String BAD_SWITCH_INTENT_NAME = "No Such Switch Intent";
/**
@@ -56,7 +57,6 @@
* Make a set of Intents that can be used as test data.
*/
private void makeDefaultIntents() {
- final String BAD_SWITCH_INTENT_NAME = "No Such Switch Intent";
// create shortest path intents
final IntentOperationList opList = new IntentOperationList();
diff --git a/src/test/java/net/onrc/onos/api/rest/TestRestTopology.java b/src/test/java/net/onrc/onos/api/rest/TestRestTopology.java
index e87d232..3ef89eb 100644
--- a/src/test/java/net/onrc/onos/api/rest/TestRestTopology.java
+++ b/src/test/java/net/onrc/onos/api/rest/TestRestTopology.java
@@ -4,7 +4,6 @@
import net.floodlightcontroller.core.module.FloodlightModuleException;
import net.onrc.onos.core.intent.runtime.IntentTestMocks;
import net.onrc.onos.core.intent.runtime.PathCalcRuntimeModule;
-import net.onrc.onos.core.intent.runtime.web.IntentWebRoutable;
import net.onrc.onos.core.topology.ITopologyService;
import net.onrc.onos.core.topology.web.TopologyWebRoutable;
import org.json.JSONArray;
diff --git a/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java b/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java
index f0ebc7a..a38a90b 100644
--- a/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java
+++ b/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java
@@ -259,7 +259,8 @@
packetService.registerPacketListener(arpManager);
EasyMock.expectLastCall();
EasyMock.expect(topologyService.getTopology()).andReturn(topology);
- EasyMock.expect(datagridService.addListener((String) EasyMock.anyObject(), EasyMock.isA(IEventChannelListener.class),
+ EasyMock.expect(datagridService.addListener(EasyMock.<String>anyObject(),
+ EasyMock.isA(IEventChannelListener.class),
(Class) EasyMock.anyObject(), (Class) EasyMock.anyObject())).andReturn(eg).anyTimes();
List<ArpCacheNotification> list = new ArrayList<ArpCacheNotification>();
EasyMock.expect(eg.getAllEntries()).andReturn(list);
@@ -280,8 +281,10 @@
Map<String, String> config = new HashMap<String, String>();
EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
- EasyMock.replay(context, floodligthProviderService, configInfoService, restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology, eg, el, dev1, inPort1, sw1);
+ EasyMock.replay(context, floodligthProviderService, configInfoService,
+ restApiService, datagridService, flowPusherService,
+ topologyService, onosDeviceService, packetService, topology, eg,
+ el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
assertEquals(defaultStrAgingMsec, String.valueOf(arpManager.getArpEntryTimeout()));
@@ -297,8 +300,10 @@
config.put("cleanupmsec", strCleanupMsec);
EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
- EasyMock.replay(context, floodligthProviderService, configInfoService, restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology, eg, el, dev1, inPort1, sw1);
+ EasyMock.replay(context, floodligthProviderService, configInfoService,
+ restApiService, datagridService, flowPusherService,
+ topologyService, onosDeviceService, packetService, topology,
+ eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
assertEquals(defaultStrAgingMsec, String.valueOf(arpManager.getArpEntryTimeout()));
@@ -313,8 +318,10 @@
configMap.put("cleanupmsec", strCleanupMsec);
EasyMock.expect(context.getConfigParams(arpManager)).andReturn(configMap);
- EasyMock.replay(context, floodligthProviderService, configInfoService, restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology, eg, el, dev1, inPort1, sw1);
+ EasyMock.replay(context, floodligthProviderService, configInfoService,
+ restApiService, datagridService, flowPusherService,
+ topologyService, onosDeviceService, packetService, topology,
+ eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
assertEquals(strAgingMsec, String.valueOf(arpManager.getArpEntryTimeout()));
@@ -326,8 +333,10 @@
Map<String, String> config = new HashMap<String, String>();
EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
- EasyMock.replay(context, floodligthProviderService, configInfoService, restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology, eg, el, dev1, inPort1, sw1);
+ EasyMock.replay(context, floodligthProviderService, configInfoService,
+ restApiService, datagridService, flowPusherService,
+ topologyService, onosDeviceService, packetService, topology,
+ eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
MACAddress mac = arpManager.getMacAddress(cachedIp1);
@@ -339,8 +348,10 @@
Map<String, String> config = new HashMap<String, String>();
EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
- EasyMock.replay(context, floodligthProviderService, configInfoService, restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology, eg, el, dev1, inPort1, sw1);
+ EasyMock.replay(context, floodligthProviderService, configInfoService,
+ restApiService, datagridService, flowPusherService,
+ topologyService, onosDeviceService, packetService, topology,
+ eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
List<String> list = arpManager.getMappings();
@@ -354,8 +365,10 @@
Map<String, String> config = new HashMap<String, String>();
EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
- EasyMock.replay(context, floodligthProviderService, configInfoService, restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology, eg, el, dev1, inPort1, sw1);
+ EasyMock.replay(context, floodligthProviderService, configInfoService,
+ restApiService, datagridService, flowPusherService,
+ topologyService, onosDeviceService, packetService, topology,
+ eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
arpManager.receive(sw1, inPort1, ethRarpRequest);
@@ -368,8 +381,10 @@
prepareExpectForLearnArp();
- EasyMock.replay(context, floodligthProviderService, configInfoService, restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology, eg, el, dev1, inPort1, sw1);
+ EasyMock.replay(context, floodligthProviderService, configInfoService,
+ restApiService, datagridService, flowPusherService,
+ topologyService, onosDeviceService, packetService, topology,
+ eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
arpManager.receive(sw1, inPort1, ethArpOtherOp);
@@ -388,8 +403,10 @@
EasyMock.expectLastCall();
EasyMock.expect(context.getServiceImpl(IDatagridService.class)).andReturn(datagridService);
- EasyMock.replay(context, floodligthProviderService, configInfoService, restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology, eg, el, dev1, inPort1, sw1);
+ EasyMock.replay(context, floodligthProviderService, configInfoService,
+ restApiService, datagridService, flowPusherService,
+ topologyService, onosDeviceService, packetService, topology,
+ eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
arpManager.receive(sw1, inPort1, ethArpReply);
@@ -405,8 +422,10 @@
EasyMock.expect(configInfoService.fromExternalNetwork(EasyMock.anyLong(), EasyMock.anyShort())).andReturn(true);
EasyMock.expect(configInfoService.isInterfaceAddress(dstIp)).andReturn(false);
- EasyMock.replay(context, floodligthProviderService, configInfoService, restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology, eg, el, dev1, inPort1, sw1);
+ EasyMock.replay(context, floodligthProviderService, configInfoService,
+ restApiService, datagridService, flowPusherService,
+ topologyService, onosDeviceService, packetService, topology,
+ eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
arpManager.receive(sw1, inPort1, ethArpRequest);
@@ -422,7 +441,8 @@
prepareExpectForLearnArp();
- EasyMock.expect(configInfoService.fromExternalNetwork(EasyMock.anyLong(), EasyMock.anyShort())).andReturn(false);
+ EasyMock.expect(configInfoService.fromExternalNetwork(
+ EasyMock.anyLong(), EasyMock.anyShort())).andReturn(false);
topology.acquireReadLock();
EasyMock.expectLastCall();
EasyMock.expect(topology.getDeviceByMac(dstMac)).andReturn(dev1);
diff --git a/src/test/java/net/onrc/onos/apps/sdnip/PrefixTest.java b/src/test/java/net/onrc/onos/apps/sdnip/PrefixTest.java
index a000564..cee6898 100644
--- a/src/test/java/net/onrc/onos/apps/sdnip/PrefixTest.java
+++ b/src/test/java/net/onrc/onos/apps/sdnip/PrefixTest.java
@@ -65,11 +65,12 @@
assertEquals(p1.hashCode(), p3.hashCode());
}
+ private static final int MAX_PREFIX_LENGTH = 32;
+
@Test
public void testPrefixReturnsSame() {
//Create a prefix of all 1s for each prefix length.
//Check that Prefix doesn't mangle it
- final int MAX_PREFIX_LENGTH = 32;
for (int prefixLength = 1; prefixLength <= MAX_PREFIX_LENGTH; prefixLength++) {
byte[] address = new byte[MAX_PREFIX_LENGTH / Byte.SIZE];
diff --git a/src/test/java/net/onrc/onos/core/datastore/hazelcast/HZTableTest.java b/src/test/java/net/onrc/onos/core/datastore/hazelcast/HZTableTest.java
index 3be5061..3f43e38 100644
--- a/src/test/java/net/onrc/onos/core/datastore/hazelcast/HZTableTest.java
+++ b/src/test/java/net/onrc/onos/core/datastore/hazelcast/HZTableTest.java
@@ -192,7 +192,8 @@
}
@Test(expected = ObjectDoesntExistException.class)
- public void testUpdateByteArrayByteArrayLongFailNoOldValue() throws ObjectDoesntExistException, WrongVersionException {
+ public void testUpdateByteArrayByteArrayLongFailNoOldValue()
+ throws ObjectDoesntExistException, WrongVersionException {
final byte[] key = name.getMethodName().getBytes(StandardCharsets.UTF_8);
final byte[] value = "SomeValue".getBytes(StandardCharsets.UTF_8);
@@ -204,7 +205,8 @@
}
@Test(expected = WrongVersionException.class)
- public void testUpdateByteArrayByteArrayLongFailWrongVersion() throws ObjectDoesntExistException, WrongVersionException {
+ public void testUpdateByteArrayByteArrayLongFailWrongVersion()
+ throws ObjectDoesntExistException, WrongVersionException {
final byte[] key = name.getMethodName().getBytes(StandardCharsets.UTF_8);
final byte[] oldValue = "OldValue".getBytes(StandardCharsets.UTF_8);
final byte[] value = "SomeValue".getBytes(StandardCharsets.UTF_8);
@@ -250,7 +252,8 @@
}
@Test
- public void testUpdateByteArrayByteArraySuccessIgnoreVersion() throws ObjectDoesntExistException, WrongVersionException {
+ public void testUpdateByteArrayByteArraySuccessIgnoreVersion()
+ throws ObjectDoesntExistException, WrongVersionException {
final byte[] key = name.getMethodName().getBytes(StandardCharsets.UTF_8);
final byte[] oldValue = "OldValue".getBytes(StandardCharsets.UTF_8);
final byte[] value = "SomeValue".getBytes(StandardCharsets.UTF_8);
@@ -341,9 +344,9 @@
@Test
public void testGetAllEntries() {
- final int DATASETSIZE = 100;
+ final int dataSetSize = 100;
final Map<byte[], VersionedValue> testdata = new TreeMap<>(ByteArrayComparator.BYTEARRAY_COMPARATOR);
- for (int i = 0; i < DATASETSIZE; ++i) {
+ for (int i = 0; i < dataSetSize; ++i) {
final byte[] key = (name.getMethodName() + i).getBytes(StandardCharsets.UTF_8);
final byte[] value = ("Value" + i).getBytes(StandardCharsets.UTF_8);
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 fac33f5..bbef22e 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
@@ -32,7 +32,7 @@
System.setProperty("net.onrc.onos.core.datastore.hazelcast.client.attemptLimit", "0");
}
- private static final String namespace = UUID.randomUUID().toString();
+ private static final String NAMESPACE = UUID.randomUUID().toString();
IKVTable switchTable;
static final Long DPID1 = 0x1L;
@@ -40,8 +40,8 @@
@Before
public void setUp() throws Exception {
- switchTable = DataStoreClient.getClient().getTable(namespace + KVSwitch.SWITCH_TABLE_SUFFIX);
- sw1 = new KVSwitch(DPID1, namespace);
+ switchTable = DataStoreClient.getClient().getTable(NAMESPACE + KVSwitch.SWITCH_TABLE_SUFFIX);
+ sw1 = new KVSwitch(DPID1, NAMESPACE);
}
@After
@@ -51,7 +51,7 @@
public KVSwitch assertSwitchInDataStore(final Long dpid, final STATUS status) {
try {
- final KVSwitch sw = new KVSwitch(dpid, namespace);
+ final KVSwitch sw = new KVSwitch(dpid, NAMESPACE);
sw.read();
assertNotEquals(DataStoreClient.getClient().getVersionNonexistant(), sw.getVersion());
assertEquals(dpid, sw.getDpid());
@@ -64,7 +64,7 @@
}
public void assertSwitchNotInDataStore(final Long dpid) {
- final KVSwitch sw = new KVSwitch(dpid, namespace);
+ final KVSwitch sw = new KVSwitch(dpid, NAMESPACE);
try {
sw.read();
fail("Switch was not supposed to be there in datastore");
@@ -75,17 +75,17 @@
@Test
public void testGetAllSwitches() throws ObjectExistsException {
- final int NUM_SWITCHES = 100;
+ final int numSwitches = 100;
Map<Long, KVSwitch> expected = new HashMap<>();
- for (long dpid = 1; dpid <= NUM_SWITCHES; ++dpid) {
- KVSwitch sw = new KVSwitch(dpid, namespace);
+ for (long dpid = 1; dpid <= numSwitches; ++dpid) {
+ KVSwitch sw = new KVSwitch(dpid, NAMESPACE);
sw.setStatus(STATUS.ACTIVE);
sw.create();
assertNotEquals(DataStoreClient.getClient().getVersionNonexistant(), sw.getVersion());
expected.put(sw.getDpid(), sw);
}
- Iterable<KVSwitch> switches = KVSwitch.getAllSwitches(namespace);
+ Iterable<KVSwitch> switches = KVSwitch.getAllSwitches(NAMESPACE);
for (KVSwitch sw : switches) {
KVSwitch expectedSw = expected.get(sw.getDpid());
@@ -113,7 +113,7 @@
@Test(expected = ObjectExistsException.class)
public void testCreateFailAlreadyExist() throws ObjectExistsException {
// setup pre-existing Switch
- KVSwitch sw = new KVSwitch(DPID1, namespace);
+ KVSwitch sw = new KVSwitch(DPID1, NAMESPACE);
sw.forceCreate();
assertNotEquals(DataStoreClient.getClient().getVersionNonexistant(), sw.getVersion());
assertSwitchInDataStore(DPID1, STATUS.INACTIVE);
@@ -126,7 +126,7 @@
@Test
public void testForceCreate() {
// setup pre-existing Switch
- KVSwitch sw = new KVSwitch(DPID1, namespace);
+ KVSwitch sw = new KVSwitch(DPID1, NAMESPACE);
sw.forceCreate();
assertNotEquals(DataStoreClient.getClient().getVersionNonexistant(), sw.getVersion());
assertSwitchInDataStore(DPID1, STATUS.INACTIVE);
@@ -144,7 +144,7 @@
@Test
public void testRead() throws ObjectDoesntExistException {
// setup pre-existing Switch
- KVSwitch sw = new KVSwitch(DPID1, namespace);
+ KVSwitch sw = new KVSwitch(DPID1, NAMESPACE);
sw.setStatus(STATUS.ACTIVE);
sw.forceCreate();
assertNotEquals(DataStoreClient.getClient().getVersionNonexistant(), sw.getVersion());
@@ -167,7 +167,7 @@
@Test
public void testUpdate() throws ObjectDoesntExistException, WrongVersionException {
// setup pre-existing Switch
- KVSwitch sw = new KVSwitch(DPID1, namespace);
+ KVSwitch sw = new KVSwitch(DPID1, NAMESPACE);
sw.setStatus(STATUS.ACTIVE);
sw.forceCreate();
assertNotEquals(DataStoreClient.getClient().getVersionNonexistant(), sw.getVersion());
@@ -188,7 +188,7 @@
@Test
public void testDelete() throws ObjectDoesntExistException, WrongVersionException {
// setup pre-existing Switch
- KVSwitch sw = new KVSwitch(DPID1, namespace);
+ KVSwitch sw = new KVSwitch(DPID1, NAMESPACE);
sw.setStatus(STATUS.ACTIVE);
sw.forceCreate();
assertNotEquals(DataStoreClient.getClient().getVersionNonexistant(), sw.getVersion());
@@ -208,7 +208,7 @@
@Test
public void testForceDelete() {
// setup pre-existing Switch
- KVSwitch sw = new KVSwitch(DPID1, namespace);
+ KVSwitch sw = new KVSwitch(DPID1, NAMESPACE);
sw.setStatus(STATUS.ACTIVE);
sw.forceCreate();
assertNotEquals(DataStoreClient.getClient().getVersionNonexistant(), sw.getVersion());
diff --git a/src/test/java/net/onrc/onos/core/datastore/topology/KVTopologyTest.java b/src/test/java/net/onrc/onos/core/datastore/topology/KVTopologyTest.java
index ff37995..60390d8 100644
--- a/src/test/java/net/onrc/onos/core/datastore/topology/KVTopologyTest.java
+++ b/src/test/java/net/onrc/onos/core/datastore/topology/KVTopologyTest.java
@@ -58,21 +58,21 @@
private static final Long DPID1 = 0x1L;
- private static final String namespace = UUID.randomUUID().toString();
+ private static final String NAMESPACE = UUID.randomUUID().toString();
@Before
@After
public void wipeTopology() throws Exception {
- IKVTable switchTable = DataStoreClient.getClient().getTable(namespace + KVSwitch.SWITCH_TABLE_SUFFIX);
+ IKVTable switchTable = DataStoreClient.getClient().getTable(NAMESPACE + KVSwitch.SWITCH_TABLE_SUFFIX);
DataStoreClient.getClient().dropTable(switchTable);
- IKVTable portTable = DataStoreClient.getClient().getTable(namespace + KVPort.PORT_TABLE_SUFFIX);
+ IKVTable portTable = DataStoreClient.getClient().getTable(NAMESPACE + KVPort.PORT_TABLE_SUFFIX);
DataStoreClient.getClient().dropTable(portTable);
- IKVTable linkTable = DataStoreClient.getClient().getTable(namespace + KVLink.LINK_TABLE_SUFFIX);
+ IKVTable linkTable = DataStoreClient.getClient().getTable(NAMESPACE + KVLink.LINK_TABLE_SUFFIX);
DataStoreClient.getClient().dropTable(linkTable);
- IKVTable deviceTable = DataStoreClient.getClient().getTable(namespace + KVDevice.DEVICE_TABLE_SUFFIX);
+ IKVTable deviceTable = DataStoreClient.getClient().getTable(NAMESPACE + KVDevice.DEVICE_TABLE_SUFFIX);
DataStoreClient.getClient().dropTable(deviceTable);
}
@@ -80,7 +80,7 @@
public void basicSwitchTest() {
// create switch 0x1
try {
- KVSwitch sw = new KVSwitch(DPID1, namespace);
+ KVSwitch sw = new KVSwitch(DPID1, NAMESPACE);
sw.setStatus(KVSwitch.STATUS.ACTIVE);
sw.create();
assertNotEquals(VERSION_NONEXISTENT, sw.getVersion());
@@ -92,7 +92,7 @@
}
// read switch 0x1
- KVSwitch swRead = new KVSwitch(DPID1, namespace);
+ KVSwitch swRead = new KVSwitch(DPID1, NAMESPACE);
try {
swRead.read();
assertNotEquals(VERSION_NONEXISTENT, swRead.getVersion());
@@ -116,7 +116,7 @@
}
// read 0x1 again and delete
- KVSwitch swRead2 = new KVSwitch(DPID1, namespace);
+ KVSwitch swRead2 = new KVSwitch(DPID1, NAMESPACE);
try {
swRead2.read();
assertNotEquals(VERSION_NONEXISTENT, swRead2.getVersion());
@@ -136,7 +136,7 @@
}
// make sure 0x1 is deleted
- KVObject swRead3 = new KVSwitch(DPID1, namespace);
+ KVObject swRead3 = new KVSwitch(DPID1, NAMESPACE);
try {
swRead3.read();
fail(swRead3 + " was supposed to be deleted, but read succeed");
@@ -158,7 +158,7 @@
// d1 - s1p1 - s1 - s1p2 - s2p1 - s2 - s2p2
- KVSwitch sw1 = new KVSwitch(DPID1, namespace);
+ KVSwitch sw1 = new KVSwitch(DPID1, NAMESPACE);
sw1.setStatus(KVSwitch.STATUS.ACTIVE);
try {
sw1.create();
@@ -170,9 +170,9 @@
fail("Switch creation failed " + e);
}
- KVPort sw1p1 = new KVPort(DPID1, SW1_PORTNO1, namespace);
+ KVPort sw1p1 = new KVPort(DPID1, SW1_PORTNO1, NAMESPACE);
sw1p1.setStatus(KVPort.STATUS.ACTIVE);
- KVPort sw1p2 = new KVPort(DPID1, SW1_PORTNO2, namespace);
+ KVPort sw1p2 = new KVPort(DPID1, SW1_PORTNO2, NAMESPACE);
sw1p2.setStatus(KVPort.STATUS.ACTIVE);
try {
sw1p1.create();
@@ -201,7 +201,7 @@
fail("Switch update failed " + e);
}
- KVDevice d1 = new KVDevice(DEVICE1_MAC_SW1P1, namespace);
+ KVDevice d1 = new KVDevice(DEVICE1_MAC_SW1P1, NAMESPACE);
d1.addPortId(sw1p1.getId());
try {
@@ -225,14 +225,14 @@
fail("Device creation failed " + e);
}
- KVSwitch sw2 = new KVSwitch(DPID2, namespace);
+ KVSwitch sw2 = new KVSwitch(DPID2, NAMESPACE);
sw2.setStatus(KVSwitch.STATUS.ACTIVE);
- KVPort sw2p1 = new KVPort(DPID2, SW2_PORTNO1, namespace);
+ KVPort sw2p1 = new KVPort(DPID2, SW2_PORTNO1, NAMESPACE);
sw2p1.setStatus(KVPort.STATUS.ACTIVE);
- KVPort sw2p2 = new KVPort(DPID2, SW2_PORTNO2, namespace);
+ KVPort sw2p2 = new KVPort(DPID2, SW2_PORTNO2, NAMESPACE);
sw2p2.setStatus(KVPort.STATUS.ACTIVE);
- KVDevice d2 = new KVDevice(DEVICE2_MAC_SW2P2, namespace);
+ KVDevice d2 = new KVDevice(DEVICE2_MAC_SW2P2, NAMESPACE);
d2.addPortId(sw2p2.getId());
IKVClient client = DataStoreClient.getClient();
@@ -266,7 +266,7 @@
assertArrayEquals(sw2p2.getId(), d2.getAllPortIds().iterator().next());
}
- KVLink l1 = new KVLink(DPID1, SW1_PORTNO2, DPID2, SW2_PORTNO1, namespace);
+ KVLink l1 = new KVLink(DPID1, SW1_PORTNO2, DPID2, SW2_PORTNO1, NAMESPACE);
l1.setStatus(KVLink.STATUS.ACTIVE);
try {
@@ -302,7 +302,7 @@
private static void topologyWalk() {
- Iterable<KVSwitch> swIt = KVSwitch.getAllSwitches(namespace);
+ Iterable<KVSwitch> swIt = KVSwitch.getAllSwitches(NAMESPACE);
List<Long> switchesExpected = new ArrayList<>(Arrays.asList(DPID1, DPID2));
System.out.println("Enumerating Switches start");
@@ -316,7 +316,7 @@
}
System.out.println("Enumerating Switches end");
- KVSwitch sw1 = new KVSwitch(DPID1, namespace);
+ KVSwitch sw1 = new KVSwitch(DPID1, NAMESPACE);
try {
sw1.read();
assertNotEquals(VERSION_NONEXISTENT, sw1.getVersion());
@@ -327,7 +327,7 @@
fail("Reading switch failed " + e);
}
- KVSwitch sw2 = new KVSwitch(DPID2, namespace);
+ KVSwitch sw2 = new KVSwitch(DPID2, NAMESPACE);
if (KVObject.multiRead(Arrays.asList(sw2))) {
fail("Failed to read switch " + sw2);
} else {
@@ -344,7 +344,7 @@
put(DPID2, new ArrayList<>(Arrays.asList(SW2_PORTNO1, SW2_PORTNO2)));
} };
- for (KVPort port : KVPort.getAllPorts(namespace)) {
+ for (KVPort port : KVPort.getAllPorts(NAMESPACE)) {
System.out.println(port + " @ " + port.getVersion());
assertNotEquals(VERSION_NONEXISTENT, port.getVersion());
assertEquals(KVPort.STATUS.ACTIVE, port.getStatus());
@@ -363,7 +363,7 @@
put(DEVICE2_MAC_SW2P2, KVPort.getPortID(DPID2, SW2_PORTNO2));
} };
- for (KVDevice device : KVDevice.getAllDevices(namespace)) {
+ for (KVDevice device : KVDevice.getAllDevices(NAMESPACE)) {
System.out.println(device + " @ " + device.getVersion());
assertNotEquals(VERSION_NONEXISTENT, device.getVersion());
@@ -372,7 +372,7 @@
expectedDevice.remove(device.getMac());
}
- for (KVLink link : KVLink.getAllLinks(namespace)) {
+ for (KVLink link : KVLink.getAllLinks(NAMESPACE)) {
System.out.println(link + " @ " + link.getVersion());
assertNotEquals(VERSION_NONEXISTENT, link.getVersion());
@@ -388,7 +388,7 @@
private static void topologyDelete() {
- for (KVSwitch sw : KVSwitch.getAllSwitches(namespace)) {
+ for (KVSwitch sw : KVSwitch.getAllSwitches(NAMESPACE)) {
try {
sw.read();
sw.delete();
@@ -399,7 +399,7 @@
}
}
- for (KVPort p : KVPort.getAllPorts(namespace)) {
+ for (KVPort p : KVPort.getAllPorts(NAMESPACE)) {
try {
p.read();
p.delete();
@@ -410,12 +410,12 @@
}
}
- for (KVDevice d : KVDevice.getAllDevices(namespace)) {
+ for (KVDevice d : KVDevice.getAllDevices(NAMESPACE)) {
d.forceDelete();
assertNotEquals(VERSION_NONEXISTENT, d.getVersion());
}
- for (KVLink l : KVLink.getAllLinks(namespace)) {
+ for (KVLink l : KVLink.getAllLinks(NAMESPACE)) {
try {
l.read();
l.delete();
diff --git a/src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceManagerTest.java b/src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceManagerTest.java
index 256eb37..2eb83d4 100644
--- a/src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceManagerTest.java
+++ b/src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceManagerTest.java
@@ -85,7 +85,7 @@
expect(datagridService.createChannel("onos.device", Long.class, OnosDevice.class))
.andReturn(eventChannel).once();
- expect(topology.getOutgoingLink((long)1,(long)100)).andReturn(null).anyTimes();
+ expect(topology.getOutgoingLink(1L, 100L)).andReturn(null).anyTimes();
expect(datagridService.addListener(
eq("onos.device"),
anyObject(IEventChannelListener.class),
@@ -97,8 +97,8 @@
replay(networkGraphService);
replay(controllerRegistryService);
- modContext.addService(IDatagridService.class,datagridService);
- modContext.addService(ITopologyService.class,networkGraphService);
+ modContext.addService(IDatagridService.class, datagridService);
+ modContext.addService(ITopologyService.class, networkGraphService);
modContext.addService(IFloodlightProviderService.class, floodLightProvider);
modContext.getServiceImpl(IFloodlightProviderService.class);
sw1Dpid = 1L;
@@ -224,11 +224,11 @@
}
/**
- * Test set operation on lastSeenTimstamp field in OnosDevice
+ * Test set operation on lastSeenTimstamp field in OnosDevice.
*/
@Test
public void testSetLastSeenTimestamp() {
- Ethernet eth = (Ethernet)pkt1;
+ Ethernet eth = (Ethernet) pkt1;
OnosDevice srcDevice = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
floodLightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(OnosDeviceManager.class));
@@ -241,7 +241,7 @@
*/
@Test
public void testGetSourceDeviceFromPacket() {
- byte[] address = new byte[] {0x00,0x44,0x33,0x22,0x11,0x01};
+ byte[] address = new byte[] {0x00, 0x44, 0x33, 0x22, 0x11, 0x01};
MACAddress srcMac = new MACAddress(address);
OnosDevice dev1 = new OnosDevice(srcMac,
null,
@@ -252,24 +252,24 @@
/*
* test DHCP packet case
*/
- Ethernet eth = (Ethernet)pkt3;
+ Ethernet eth = (Ethernet) pkt3;
OnosDevice dev2 = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
assertEquals(dev1, dev2);
/*
* test ARP packet case
*/
- eth = (Ethernet)pkt4;
+ eth = (Ethernet) pkt4;
dev2 = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
assertEquals(dev1, dev2);
}
/**
- * This test will invoke addOnosDevice to add a new device through Packet pkt1
+ * This test will invoke addOnosDevice to add a new device through Packet pkt1.
*/
@Test
public void testProcessPacketInAddNewDevice() {
- Ethernet eth = (Ethernet)pkt1;
+ Ethernet eth = (Ethernet) pkt1;
Long longmac = eth.getSourceMAC().toLong();
OnosDevice srcDevice = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
@@ -281,7 +281,7 @@
EasyMock.expectLastCall();
replay(floodLightProvider, eventChannel);
- Command cmd = odm.processPacketIn(sw1, pktIn, (Ethernet)pkt1);
+ Command cmd = odm.processPacketIn(sw1, pktIn, (Ethernet) pkt1);
assertEquals(Command.CONTINUE, cmd);
verify(eventChannel);
@@ -289,11 +289,11 @@
/**
* This test will test return Command.STOP path in processPacketIn method
- * by injecting a broadcast packet
+ * by injecting a broadcast packet.
*/
@Test
public void testProcessPacketInStop() {
- Command cmd = odm.processPacketIn(sw1, pktIn, (Ethernet)pkt0);
+ Command cmd = odm.processPacketIn(sw1, pktIn, (Ethernet) pkt0);
assertEquals(Command.STOP, cmd);
}
@@ -302,37 +302,37 @@
*/
@Test
public void testProcessPacketInSamePacket() {
- Ethernet eth = (Ethernet)pkt2;
+ Ethernet eth = (Ethernet) pkt2;
OnosDevice srcDevice = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
odm.entryAdded(srcDevice);
srcDevice.setLastSeenTimestamp(lastSeenTimestamp);
- Command cmd = odm.processPacketIn(sw1, pktIn, (Ethernet)pkt2);
+ Command cmd = odm.processPacketIn(sw1, pktIn, (Ethernet) pkt2);
assertEquals(Command.CONTINUE, cmd);
assertTrue(lastSeenTimestamp.before(srcDevice.getLastSeenTimestamp()));
}
/**
- * This tests the packet with the same MAC but the second one without IP address
+ * This tests the packet with the same MAC but the second one without IP address.
*/
@Test
public void testProcessPacketInNoIpAddress() {
- Ethernet eth = (Ethernet)pkt3;
+ Ethernet eth = (Ethernet) pkt3;
OnosDevice srcDevice = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
odm.entryAdded(srcDevice);
srcDevice.setLastSeenTimestamp(lastSeenTimestamp);
- Command cmd = odm.processPacketIn(sw1, pktIn, (Ethernet)pkt2);
+ Command cmd = odm.processPacketIn(sw1, pktIn, (Ethernet) pkt2);
assertEquals(Command.CONTINUE, cmd);
assertTrue(lastSeenTimestamp.before(srcDevice.getLastSeenTimestamp()));
}
/**
- * Test add a device from the information from packet
+ * Test add a device from the information from packet.
*/
@Test
public void testAddOnosDevice() {
- Ethernet eth = (Ethernet)pkt1;
+ Ethernet eth = (Ethernet) pkt1;
Long longmac = eth.getSourceMAC().toLong();
OnosDevice srcDevice = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
@@ -350,11 +350,11 @@
}
/**
- * Test delete a device
+ * Test delete a device.
*/
@Test
public void testDeleteOnosDevice() {
- Ethernet eth = (Ethernet)pkt1;
+ Ethernet eth = (Ethernet) pkt1;
Long longmac = eth.getSourceMAC().toLong();
OnosDevice srcDevice = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
@@ -372,11 +372,11 @@
}
/**
- * Test delete a device by using its source mac address
+ * Test delete a device by using its source mac address.
*/
@Test
public void testDeleteOnosDeviceByMac() {
- Ethernet eth = (Ethernet)pkt1;
+ Ethernet eth = (Ethernet) pkt1;
MACAddress mac = eth.getSourceMAC();
Long longmac = mac.toLong();
OnosDevice srcDevice = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
diff --git a/src/test/java/net/onrc/onos/core/flowprogrammer/FlowPusherTest.java b/src/test/java/net/onrc/onos/core/flowprogrammer/FlowPusherTest.java
index 7ffe8e9..81938f7 100644
--- a/src/test/java/net/onrc/onos/core/flowprogrammer/FlowPusherTest.java
+++ b/src/test/java/net/onrc/onos/core/flowprogrammer/FlowPusherTest.java
@@ -18,7 +18,6 @@
import net.onrc.onos.core.util.Port;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
-import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.openflow.protocol.OFBarrierRequest;
@@ -102,7 +101,7 @@
@Test
public void testMassiveAddMessage() {
// Some number larger than FlowPusher.MAX_MESSAGE_SEND
- final int NUM_MSG = FlowPusher.MAX_MESSAGE_SEND * 2;
+ final int numMsg = FlowPusher.MAX_MESSAGE_SEND * 2;
beginInitMock();
@@ -114,7 +113,7 @@
List<OFMessage> messages = new ArrayList<OFMessage>();
- for (int i = 0; i < NUM_MSG; ++i) {
+ for (int i = 0; i < numMsg; ++i) {
OFMessage msg = EasyMock.createMock(OFMessage.class);
EasyMock.expect(msg.getXid()).andReturn(i).anyTimes();
EasyMock.expect(msg.getLength()).andReturn((short) 100).anyTimes();
@@ -158,13 +157,13 @@
*/
@Test
public void testMultiSwitchAddMessage() {
- final int NUM_SWITCH = 10;
- final int NUM_MSG = 100; // messages per thread
+ final int numSwitch = 10;
+ final int numMsg = 100; // messages per thread
beginInitMock();
Map<IOFSwitch, List<OFMessage>> swMap = new HashMap<IOFSwitch, List<OFMessage>>();
- for (int i = 0; i < NUM_SWITCH; ++i) {
+ for (int i = 0; i < numSwitch; ++i) {
IOFSwitch sw = EasyMock.createMock(IOFSwitch.class);
EasyMock.expect(sw.getId()).andReturn((long) i).anyTimes();
sw.flush();
@@ -173,7 +172,7 @@
List<OFMessage> messages = new ArrayList<OFMessage>();
- for (int j = 0; j < NUM_MSG; ++j) {
+ for (int j = 0; j < numMsg; ++j) {
OFMessage msg = EasyMock.createMock(OFMessage.class);
EasyMock.expect(msg.getXid()).andReturn(j).anyTimes();
EasyMock.expect(msg.getLength()).andReturn((short) 100).anyTimes();
@@ -224,13 +223,13 @@
*/
@Test
public void testMultiThreadedAddMessage() {
- final int NUM_THREAD = 10;
- final int NUM_MSG = 100; // messages per thread
+ final int numThreads = 10;
+ final int numMsg = 100; // messages per thread
beginInitMock();
Map<IOFSwitch, List<OFMessage>> swMap = new HashMap<IOFSwitch, List<OFMessage>>();
- for (int i = 0; i < NUM_THREAD; ++i) {
+ for (int i = 0; i < numThreads; ++i) {
IOFSwitch sw = EasyMock.createMock(IOFSwitch.class);
EasyMock.expect(sw.getId()).andReturn((long) i).anyTimes();
sw.flush();
@@ -239,7 +238,7 @@
List<OFMessage> messages = new ArrayList<OFMessage>();
- for (int j = 0; j < NUM_MSG; ++j) {
+ for (int j = 0; j < numMsg; ++j) {
OFMessage msg = EasyMock.createMock(OFMessage.class);
EasyMock.expect(msg.getXid()).andReturn(j).anyTimes();
EasyMock.expect(msg.getLength()).andReturn((short) 100).anyTimes();
@@ -257,7 +256,7 @@
}
endInitMock();
- initPusher(NUM_THREAD);
+ initPusher(numThreads);
for (IOFSwitch sw : swMap.keySet()) {
for (OFMessage msg : swMap.get(sw)) {
@@ -292,14 +291,14 @@
*/
@Test
public void testRateLimitedAddMessage() {
- final long LIMIT_RATE = 100; // [bytes/ms]
- final int NUM_MSG = 1000;
+ final long limitRate = 100; // [bytes/ms]
+ final int numMsg = 1000;
// Accuracy of FlowPusher's rate calculation can't be measured by unit test
// because switch doesn't return BARRIER_REPLY.
// In unit test we use approximate way to measure rate. This value is
// acceptable margin of measured rate.
- final double ACCEPTABLE_RATE = LIMIT_RATE * 1.2;
+ final double acceptableRate = limitRate * 1.2;
beginInitMock();
@@ -312,7 +311,7 @@
List<OFMessage> messages = new ArrayList<OFMessage>();
- for (int i = 0; i < NUM_MSG; ++i) {
+ for (int i = 0; i < numMsg; ++i) {
OFMessage msg = EasyMock.createMock(OFMessage.class);
EasyMock.expect(msg.getXid()).andReturn(1).anyTimes();
EasyMock.expect(msg.getLength()).andReturn((short) 100).anyTimes();
@@ -348,7 +347,7 @@
initPusher(1);
pusher.createQueue(sw);
- pusher.setRate(sw, LIMIT_RATE);
+ pusher.setRate(sw, limitRate);
long beginTime = System.currentTimeMillis();
for (OFMessage msg : messages) {
@@ -366,8 +365,8 @@
fail("Failed to sleep");
}
- double measuredRate = NUM_MSG * 100 / (barrierTime - beginTime);
- assertTrue(measuredRate < ACCEPTABLE_RATE);
+ double measuredRate = numMsg * 100 / (barrierTime - beginTime);
+ assertTrue(measuredRate < acceptableRate);
for (OFMessage msg : messages) {
EasyMock.verify(msg);
diff --git a/src/test/java/net/onrc/onos/core/flowprogrammer/FlowSynchronizerTest.java b/src/test/java/net/onrc/onos/core/flowprogrammer/FlowSynchronizerTest.java
index efbffb6..4be8f97 100644
--- a/src/test/java/net/onrc/onos/core/flowprogrammer/FlowSynchronizerTest.java
+++ b/src/test/java/net/onrc/onos/core/flowprogrammer/FlowSynchronizerTest.java
@@ -257,55 +257,55 @@
*/
private void initMockGraph(long[] idList) {
/*
- * TODO: The old FlowDatabaseOperation class is gone, so the method
- * below needs to be rewritten.
- */
- /*
- List<IFlowEntry> flowEntryList = new ArrayList<IFlowEntry>();
+ * TODO: The old FlowDatabaseOperation class is gone, so the method
+ * below needs to be rewritten.
+ */
+ /*
+ List<IFlowEntry> flowEntryList = new ArrayList<IFlowEntry>();
- for (long id : idList) {
- IFlowEntry entry = EasyMock.createMock(IFlowEntry.class);
- EasyMock.expect(entry.getFlowEntryId()).andReturn(String.valueOf(id)).anyTimes();
- EasyMock.replay(entry);
- flowEntryList.add(entry);
+ for (long id : idList) {
+ IFlowEntry entry = EasyMock.createMock(IFlowEntry.class);
+ EasyMock.expect(entry.getFlowEntryId()).andReturn(String.valueOf(id)).anyTimes();
+ EasyMock.replay(entry);
+ flowEntryList.add(entry);
+ }
+
+ ISwitchObject swObj = EasyMock.createMock(ISwitchObject.class);
+ EasyMock.expect(swObj.getFlowEntries()).andReturn(flowEntryList).once();
+ EasyMock.replay(swObj);
+
+ DBOperation mockOp = PowerMock.createMock(DBOperation.class);
+ EasyMock.expect(mockOp.searchSwitch(EasyMock.anyObject(String.class))).andReturn(swObj).once();
+
+ PowerMock.mockStatic(FlowDatabaseOperation.class);
+ for (IFlowEntry entry : flowEntryList) {
+ EasyMock.expect(FlowDatabaseOperation.extractFlowEntry(EasyMock.eq(entry)))
+ .andAnswer(new IAnswer<FlowEntry>() {
+ @Override
+ public FlowEntry answer() throws Throwable {
+ IFlowEntry iflow = (IFlowEntry)EasyMock.getCurrentArguments()[0];
+ long flowEntryId = Long.valueOf(iflow.getFlowEntryId());
+
+ FlowEntry flow = EasyMock.createMock(FlowEntry.class);
+ EasyMock.expect(flow.flowEntryId()).andReturn(new FlowEntryId(flowEntryId)).anyTimes();
+ EasyMock.replay(flow);
+ return flow;
}
- ISwitchObject swObj = EasyMock.createMock(ISwitchObject.class);
- EasyMock.expect(swObj.getFlowEntries()).andReturn(flowEntryList).once();
- EasyMock.replay(swObj);
+ }).anyTimes();
+ EasyMock.expect(mockOp.searchFlowEntry(EasyMock.eq(new FlowEntryId(entry.getFlowEntryId()))))
+ .andReturn(entry);
+ }
+ PowerMock.replay(FlowDatabaseOperation.class);
+ EasyMock.replay(mockOp);
- DBOperation mockOp = PowerMock.createMock(DBOperation.class);
- EasyMock.expect(mockOp.searchSwitch(EasyMock.anyObject(String.class))).andReturn(swObj).once();
-
- PowerMock.mockStatic(FlowDatabaseOperation.class);
- for (IFlowEntry entry : flowEntryList) {
- EasyMock.expect(FlowDatabaseOperation.extractFlowEntry(EasyMock.eq(entry)))
- .andAnswer(new IAnswer<FlowEntry>() {
- @Override
- public FlowEntry answer() throws Throwable {
- IFlowEntry iflow = (IFlowEntry)EasyMock.getCurrentArguments()[0];
- long flowEntryId = Long.valueOf(iflow.getFlowEntryId());
-
- FlowEntry flow = EasyMock.createMock(FlowEntry.class);
- EasyMock.expect(flow.flowEntryId()).andReturn(new FlowEntryId(flowEntryId)).anyTimes();
- EasyMock.replay(flow);
- return flow;
- }
-
- }).anyTimes();
- EasyMock.expect(mockOp.searchFlowEntry(EasyMock.eq(new FlowEntryId(entry.getFlowEntryId()))))
- .andReturn(entry);
- }
- PowerMock.replay(FlowDatabaseOperation.class);
- EasyMock.replay(mockOp);
-
- try {
- PowerMock.expectNew(DBOperation.class).andReturn(mockOp);
- } catch (Exception e) {
- fail("Failed to create DBOperation");
- }
- PowerMock.replay(DBOperation.class);
- */
+ try {
+ PowerMock.expectNew(DBOperation.class).andReturn(mockOp);
+ } catch (Exception e) {
+ fail("Failed to create DBOperation");
+ }
+ PowerMock.replay(DBOperation.class);
+ */
}
/**
diff --git a/src/test/java/net/onrc/onos/core/intent/runtime/IntentTestMocks.java b/src/test/java/net/onrc/onos/core/intent/runtime/IntentTestMocks.java
index 3d3cdcb..1a2e1c5 100644
--- a/src/test/java/net/onrc/onos/core/intent/runtime/IntentTestMocks.java
+++ b/src/test/java/net/onrc/onos/core/intent/runtime/IntentTestMocks.java
@@ -66,7 +66,7 @@
moduleContext = createMock(FloodlightModuleContext.class);
final IEventChannel<Long, IntentOperationList> intentOperationChannel =
createMock(IEventChannel.class);
- final IEventChannel<Long, IntentStateList>intentStateChannel =
+ final IEventChannel<Long, IntentStateList> intentStateChannel =
createMock(IEventChannel.class);
persistIntent = PowerMock.createMock(PersistIntent.class);
restApi = createMock(IRestApiService.class);
diff --git a/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java b/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
index f341628..262042f 100644
--- a/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
+++ b/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
@@ -170,6 +170,8 @@
mocks.tearDownIntentMocks();
}
+ private static final String BAD_SWITCH_INTENT_NAME = "No Such Switch Intent";
+
/**
* Test the result of executing a path calculation on an
* Intent Operation List which contains a path that references a
@@ -182,7 +184,6 @@
*/
@Test
public void testInvalidSwitchName() {
- final String BAD_SWITCH_INTENT_NAME = "No Such Switch Intent";
// create shortest path intents
final IntentOperationList opList = new IntentOperationList();
@@ -327,6 +328,7 @@
hasIntentWithIdAndState("3", IntentState.INST_REQ));
}
+ // CHECKSTYLE:OFF method too long
/**
* Test the result of executing a path calculation on an
* Intent Operation List and then forcing a reroute.
@@ -450,7 +452,6 @@
assertThat(processedPathIntents,
hasIntentWithIdAndState("3___0", IntentState.INST_ACK));
-
// Remove one of the links and check results
final List<SwitchEvent> emptySwitchEvents = new LinkedList<>();
final List<PortEvent> emptyPortEvents = new LinkedList<>();
@@ -465,15 +466,10 @@
LinkEvent linkEvent2 = new LinkEvent(2L, 21L, 1L, 12L);
removedLinkEvents.add(linkEvent1);
removedLinkEvents.add(linkEvent2);
- runtime.topologyEvents(
- emptySwitchEvents,
- emptySwitchEvents,
- emptyPortEvents,
- emptyPortEvents,
- addedLinkEvents,
- removedLinkEvents,
- emptyDeviceEvents,
- emptyDeviceEvents);
+ runtime.topologyEvents(emptySwitchEvents, emptySwitchEvents,
+ emptyPortEvents, emptyPortEvents,
+ addedLinkEvents, removedLinkEvents,
+ emptyDeviceEvents, emptyDeviceEvents);
// Check the high level intents.
final IntentMap highLevelIntentsAfterReroute = runtime.getHighLevelIntents();
@@ -818,4 +814,6 @@
assertThat(reroutedPathIntents,
hasIntentWithIdAndState("3___0", IntentState.INST_ACK));
}
+ // CHECKSTYLE:ON method too long
+
}
diff --git a/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java b/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java
index bd42884..cdae6d8 100644
--- a/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java
+++ b/src/test/java/net/onrc/onos/core/intent/runtime/UseCaseTest.java
@@ -167,11 +167,16 @@
public void createConstrainedShortestPaths() throws FloodlightModuleException {
// create constrained shortest path intents
IntentOperationList opList = new IntentOperationList();
- opList.add(Operator.ADD, new ConstrainedShortestPathIntent("1", 1L, 12L, LOCAL_PORT, 2L, 21L, LOCAL_PORT, 400.0));
- opList.add(Operator.ADD, new ConstrainedShortestPathIntent("2", 1L, 14L, LOCAL_PORT, 4L, 41L, LOCAL_PORT, 400.0));
- opList.add(Operator.ADD, new ConstrainedShortestPathIntent("3", 2L, 24L, LOCAL_PORT, 4L, 42L, LOCAL_PORT, 400.0));
- opList.add(Operator.ADD, new ConstrainedShortestPathIntent("4", 2L, 23L, LOCAL_PORT, 3L, 32L, LOCAL_PORT, 400.0));
- opList.add(Operator.ADD, new ConstrainedShortestPathIntent("5", 3L, 34L, LOCAL_PORT, 4L, 43L, LOCAL_PORT, 400.0));
+ opList.add(Operator.ADD, new ConstrainedShortestPathIntent("1", 1L, 12L,
+ LOCAL_PORT, 2L, 21L, LOCAL_PORT, 400.0));
+ opList.add(Operator.ADD, new ConstrainedShortestPathIntent("2", 1L, 14L,
+ LOCAL_PORT, 4L, 41L, LOCAL_PORT, 400.0));
+ opList.add(Operator.ADD, new ConstrainedShortestPathIntent("3", 2L, 24L,
+ LOCAL_PORT, 4L, 42L, LOCAL_PORT, 400.0));
+ opList.add(Operator.ADD, new ConstrainedShortestPathIntent("4", 2L, 23L,
+ LOCAL_PORT, 3L, 32L, LOCAL_PORT, 400.0));
+ opList.add(Operator.ADD, new ConstrainedShortestPathIntent("5", 3L, 34L,
+ LOCAL_PORT, 4L, 43L, LOCAL_PORT, 400.0));
// compile high-level intent operations into low-level intent operations (calculate paths)
PathCalcRuntimeModule runtime1 = new PathCalcRuntimeModule();
@@ -192,11 +197,16 @@
public void createMixedShortestPaths() throws FloodlightModuleException {
// create constrained & best effort shortest path intents
IntentOperationList opList = new IntentOperationList();
- opList.add(Operator.ADD, new ConstrainedShortestPathIntent("1", 1L, 12L, LOCAL_PORT, 2L, 21L, LOCAL_PORT, 400.0));
- opList.add(Operator.ADD, new ConstrainedShortestPathIntent("2", 1L, 14L, LOCAL_PORT, 4L, 41L, LOCAL_PORT, 400.0));
- opList.add(Operator.ADD, new ShortestPathIntent("3", 2L, 24L, LOCAL_PORT, 4L, 42L, LOCAL_PORT));
- opList.add(Operator.ADD, new ShortestPathIntent("4", 2L, 23L, LOCAL_PORT, 3L, 32L, LOCAL_PORT));
- opList.add(Operator.ADD, new ConstrainedShortestPathIntent("5", 3L, 34L, LOCAL_PORT, 4L, 43L, LOCAL_PORT, 400.0));
+ opList.add(Operator.ADD, new ConstrainedShortestPathIntent("1", 1L, 12L,
+ LOCAL_PORT, 2L, 21L, LOCAL_PORT, 400.0));
+ opList.add(Operator.ADD, new ConstrainedShortestPathIntent("2", 1L, 14L,
+ LOCAL_PORT, 4L, 41L, LOCAL_PORT, 400.0));
+ opList.add(Operator.ADD, new ShortestPathIntent("3", 2L, 24L, LOCAL_PORT, 4L,
+ 42L, LOCAL_PORT));
+ opList.add(Operator.ADD, new ShortestPathIntent("4", 2L, 23L, LOCAL_PORT, 3L,
+ 32L, LOCAL_PORT));
+ opList.add(Operator.ADD, new ConstrainedShortestPathIntent("5", 3L, 34L,
+ LOCAL_PORT, 4L, 43L, LOCAL_PORT, 400.0));
// compile high-level intent operations into low-level intent operations (calculate paths)
PathCalcRuntimeModule runtime1 = new PathCalcRuntimeModule();
diff --git a/src/test/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManagerTest.java b/src/test/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManagerTest.java
index c343631..33a1cd6 100644
--- a/src/test/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManagerTest.java
+++ b/src/test/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManagerTest.java
@@ -387,28 +387,28 @@
/**
* This test case verifies that LinkDiscoveryManager.sendDiscoveryMessage()
- * performs "write" operation on the specified IOFSwitch object
- * with a LLDP packet
- *
+ * performs "write" operation on the specified IOFSwitch object
+ * with a LLDP packet.
+ *
* @throws IOException
*/
@Test
- public void testSendDiscoveryMessage() throws IOException{
+ public void testSendDiscoveryMessage() throws IOException {
LinkDiscoveryManager topology = getTopology();
// Mock up our expected behavior
IOFSwitch swTest = createMockSwitch(3L);
getMockFloodlightProvider().getSwitches().put(3L, swTest);
-
+
short portNum = 1;
OFPhysicalPort ofpPort = new OFPhysicalPort();
ofpPort.setPortNumber(portNum);
-
- /* sendDiscoverMessage() should perform the following actions on
+
+ /* sendDiscoverMessage() should perform the following actions on
* IOFSwitch object
- * - getPort() with argument as "1"
- * - write() with OFPacketOut
- * - flush()
+ * - getPort() with argument as "1"
+ * - write() with OFPacketOut
+ * - flush()
*/
expect(swTest.getPort(portNum)).andReturn(ofpPort).atLeastOnce();
swTest.write(EasyMock.anyObject(OFMessage.class), EasyMock.anyObject(FloodlightContext.class));
@@ -416,9 +416,9 @@
swTest.flush();
EasyMock.expectLastCall().once();
replay(swTest);
-
+
topology.sendDiscoveryMessage(3L, portNum, true, false);
-
+
verify(swTest);
}
}
diff --git a/src/test/java/net/onrc/onos/core/packet/LLDPTest.java b/src/test/java/net/onrc/onos/core/packet/LLDPTest.java
index 928ee72..acab149 100644
--- a/src/test/java/net/onrc/onos/core/packet/LLDPTest.java
+++ b/src/test/java/net/onrc/onos/core/packet/LLDPTest.java
@@ -31,10 +31,17 @@
* @author David Erickson (daviderickson@cs.stanford.edu)
*/
public class LLDPTest {
- protected byte[] pkt = {0x01, 0x23, 0x20, 0x00, 0x00, 0x01, 0x00, 0x12, (byte) 0xe2, 0x78, 0x67, 0x78, (byte) 0x88, (byte) 0xcc, 0x02, 0x07,
- 0x04, 0x00, 0x12, (byte) 0xe2, 0x78, 0x67, 0x64, 0x04, 0x03, 0x02, 0x00, 0x06, 0x06, 0x02, 0x00, 0x78,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ protected byte[] pkt = {0x01, 0x23, 0x20, 0x00, 0x00, 0x01,
+ 0x00, 0x12, (byte) 0xe2, 0x78, 0x67, 0x78,
+ (byte) 0x88, (byte) 0xcc, 0x02, 0x07,
+ 0x04, 0x00, 0x12, (byte) 0xe2, 0x78, 0x67, 0x64,
+ 0x04, 0x03,
+ 0x02, 0x00, 0x06,
+ 0x06, 0x02,
+ 0x00, 0x78,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
protected IPacket getPacket() {
return new Ethernet()
@@ -44,9 +51,15 @@
.setEtherType(Ethernet.TYPE_LLDP)
.setPayload(
new LLDP()
- .setChassisId(new LLDPTLV().setType((byte) 1).setLength((short) 7).setValue(new byte[]{0x04, 0x00, 0x12, (byte) 0xe2, 0x78, 0x67, 0x64}))
- .setPortId(new LLDPTLV().setType((byte) 2).setLength((short) 3).setValue(new byte[]{0x02, 0x00, 0x06}))
- .setTtl(new LLDPTLV().setType((byte) 3).setLength((short) 2).setValue(new byte[]{0x00, 0x78}))
+ .setChassisId(new LLDPTLV().setType((byte) 1)
+ .setLength((short) 7)
+ .setValue(new byte[]{0x04, 0x00, 0x12, (byte) 0xe2, 0x78, 0x67, 0x64}))
+ .setPortId(new LLDPTLV().setType((byte) 2)
+ .setLength((short) 3)
+ .setValue(new byte[]{0x02, 0x00, 0x06}))
+ .setTtl(new LLDPTLV().setType((byte) 3)
+ .setLength((short) 2)
+ .setValue(new byte[]{0x00, 0x78}))
);
}
diff --git a/src/test/java/net/onrc/onos/core/registry/StandaloneRegistryTest.java b/src/test/java/net/onrc/onos/core/registry/StandaloneRegistryTest.java
index 89e26b6..bb62657 100644
--- a/src/test/java/net/onrc/onos/core/registry/StandaloneRegistryTest.java
+++ b/src/test/java/net/onrc/onos/core/registry/StandaloneRegistryTest.java
@@ -242,7 +242,8 @@
}
/**
- * Test if {@link StandaloneRegistry#requestControl(long, ControlChangeCallback)} can correctly take control for switch so that callback is called.
+ * Test if {@link StandaloneRegistry#requestControl(long, ControlChangeCallback)}
+ * can correctly take control for switch so that callback is called.
*
* @throws RegistryException
* @throws InterruptedException
@@ -272,7 +273,8 @@
}
/**
- * Test if {@link StandaloneRegistry#releaseControl(long)} can correctly release the control so that callback is called.
+ * Test if {@link StandaloneRegistry#releaseControl(long)}
+ * can correctly release the control so that callback is called.
*
* @throws InterruptedException
* @throws RegistryException
@@ -473,16 +475,16 @@
@Test
public void testAllocateUniqueIdBlock() {
// Number of blocks to be verified that any of them has unique block
- final int NUM_BLOCKS = 100;
- ArrayList<IdBlock> blocks = new ArrayList<IdBlock>(NUM_BLOCKS);
+ final int numBlocks = 100;
+ ArrayList<IdBlock> blocks = new ArrayList<IdBlock>(numBlocks);
- for (int i = 0; i < NUM_BLOCKS; ++i) {
+ for (int i = 0; i < numBlocks; ++i) {
blocks.add(registry.allocateUniqueIdBlock());
}
- for (int i = 0; i < NUM_BLOCKS; ++i) {
+ for (int i = 0; i < numBlocks; ++i) {
IdBlock block1 = blocks.get(i);
- for (int j = i + 1; j < NUM_BLOCKS; ++j) {
+ for (int j = i + 1; j < numBlocks; ++j) {
IdBlock block2 = blocks.get(j);
IdBlock lower, higher;
diff --git a/src/test/java/net/onrc/onos/core/registry/ZookeeperRegistryTest.java b/src/test/java/net/onrc/onos/core/registry/ZookeeperRegistryTest.java
index 0f9d61e..f73616e 100644
--- a/src/test/java/net/onrc/onos/core/registry/ZookeeperRegistryTest.java
+++ b/src/test/java/net/onrc/onos/core/registry/ZookeeperRegistryTest.java
@@ -60,7 +60,8 @@
protected static final String CONTROLLER_ID = "controller2013";
/**
- * Initialize {@link ZookeeperRegistry} Object and inject initial value with {@link ZookeeperRegistry#init(FloodlightModuleContext)} method.
+ * Initialize {@link ZookeeperRegistry} Object and inject initial value with
+ * {@link ZookeeperRegistry#init(FloodlightModuleContext)} method.
* This setup code also tests {@link ZookeeperRegistry#init(FloodlightModuleContext)} method itself.
*/
@Override
@@ -99,7 +100,9 @@
/**
* Test if {@link ZookeeperRegistry#registerController(String)} method can go through without exception.
- * (Exceptions are usually out of test target, but {@link ZookeeperRegistry#registerController(String)} throws an exception in case of invalid registration.)
+ * (Exceptions are usually out of test target,
+ * but {@link ZookeeperRegistry#registerController(String)}
+ * throws an exception in case of invalid registration.)
*/
@Test
public void testRegisterController() {
@@ -137,7 +140,8 @@
/**
* Test if {@link ZookeeperRegistry#getAllControllers()} returns all controllers.
- * Controllers to be returned are injected while setup. See {@link ZookeeperRegistryTest#createCuratorFrameworkMock()}
+ * Controllers to be returned are injected while setup.
+ * See {@link ZookeeperRegistryTest#createCuratorFrameworkMock()}
* to what controllers are injected using mock {@link ServiceCache}.
*
* @throws Exception
@@ -158,8 +162,9 @@
}
/**
- * Test if {@link ZookeeperRegistry#requestControl(long, net.onrc.onos.core.registry.IControllerRegistryService.ControlChangeCallback)}
- * correctly take control of specific switch. Because {@link ZookeeperRegistry#requestControl(long, net.onrc.onos.core.registry.IControllerRegistryService.ControlChangeCallback)}
+ * Test if {@link ZookeeperRegistry#requestControl(long, IControllerRegistryService.ControlChangeCallback)}
+ * correctly take control of specific switch.
+ * Because {@link ZookeeperRegistry#requestControl(long, IControllerRegistryService.ControlChangeCallback)}
* doesn't return values, inject mock {@link LeaderLatch} object and verify latch is correctly set up.
*
* @throws Exception
@@ -175,7 +180,9 @@
EasyMock.replay(latch);
PowerMock.expectNew(LeaderLatch.class,
- EasyMock.anyObject(CuratorFramework.class), EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))
+ EasyMock.anyObject(CuratorFramework.class),
+ EasyMock.anyObject(String.class),
+ EasyMock.anyObject(String.class))
.andReturn(latch).once();
PowerMock.replay(LeaderLatch.class);
@@ -217,7 +224,9 @@
EasyMock.replay(latch);
PowerMock.expectNew(LeaderLatch.class,
- EasyMock.anyObject(CuratorFramework.class), EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))
+ EasyMock.anyObject(CuratorFramework.class),
+ EasyMock.anyObject(String.class),
+ EasyMock.anyObject(String.class))
.andReturn(latch).once();
PowerMock.replay(LeaderLatch.class);
@@ -234,7 +243,8 @@
}
/**
- * Test if {@link ZookeeperRegistry#hasControl(long)} returns correct status whether controller has control of specific switch.
+ * Test if {@link ZookeeperRegistry#hasControl(long)} returns
+ * correct status whether controller has control of specific switch.
*
* @throws Exception
*/
@@ -254,7 +264,9 @@
EasyMock.replay(latch);
PowerMock.expectNew(LeaderLatch.class,
- EasyMock.anyObject(CuratorFramework.class), EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))
+ EasyMock.anyObject(CuratorFramework.class),
+ EasyMock.anyObject(String.class),
+ EasyMock.anyObject(String.class))
.andReturn(latch);
PowerMock.replay(LeaderLatch.class);
@@ -281,8 +293,10 @@
}
/**
- * Test if {@link ZookeeperRegistry#getControllerForSwitch(long)} correctly returns controller ID of specific switch.
- * Relation between controllers and switches are defined by {@link ZookeeperRegistryTest#setPathChildrenCache()} function.
+ * Test if {@link ZookeeperRegistry#getControllerForSwitch(long)}
+ * correctly returns controller ID of specific switch.
+ * Relation between controllers and switches are defined by
+ * {@link ZookeeperRegistryTest#setPathChildrenCache()} function.
*
* @throws Throwable
*/
@@ -353,18 +367,18 @@
@Test
public void testAllocateUniqueIdBlock() {
// Number of blocks to be verified that any of them has unique block
- final int NUM_BLOCKS = 100;
- ArrayList<IdBlock> blocks = new ArrayList<IdBlock>(NUM_BLOCKS);
+ final int numBlocks = 100;
+ ArrayList<IdBlock> blocks = new ArrayList<IdBlock>(numBlocks);
- for (int i = 0; i < NUM_BLOCKS; ++i) {
+ for (int i = 0; i < numBlocks; ++i) {
IdBlock block = registry.allocateUniqueIdBlock();
assertNotNull(block);
blocks.add(block);
}
- for (int i = 0; i < NUM_BLOCKS; ++i) {
+ for (int i = 0; i < numBlocks; ++i) {
IdBlock block1 = blocks.get(i);
- for (int j = i + 1; j < NUM_BLOCKS; ++j) {
+ for (int j = i + 1; j < numBlocks; ++j) {
IdBlock block2 = blocks.get(j);
IdBlock lower, higher;
@@ -428,7 +442,9 @@
EasyMock.replay(daLong);
PowerMock.expectNew(DistributedAtomicLong.class,
new Class<?>[]{CuratorFramework.class, String.class, RetryPolicy.class},
- EasyMock.anyObject(CuratorFramework.class), EasyMock.anyObject(String.class), EasyMock.anyObject(RetryPolicy.class)).
+ EasyMock.anyObject(CuratorFramework.class),
+ EasyMock.anyObject(String.class),
+ EasyMock.anyObject(RetryPolicy.class)).
andReturn(daLong).anyTimes();
PowerMock.replay(DistributedAtomicLong.class);
@@ -445,10 +461,14 @@
EasyMock.replay(listenerContainer);
// Mock PathChildrenCache
- PathChildrenCache pathChildrenCacheMain = createPathChildrenCacheMock(CONTROLLER_ID, new String[]{"/switches"}, listenerContainer);
- PathChildrenCache pathChildrenCache1 = createPathChildrenCacheMock("controller1", new String[]{HexString.toHexString(1000L)}, listenerContainer);
- PathChildrenCache pathChildrenCache2 = createPathChildrenCacheMock("controller2", new String[]{
- HexString.toHexString(1001L), HexString.toHexString(1002L)}, listenerContainer);
+ PathChildrenCache pathChildrenCacheMain = createPathChildrenCacheMock(
+ CONTROLLER_ID, new String[] {"/switches"}, listenerContainer);
+ PathChildrenCache pathChildrenCache1 = createPathChildrenCacheMock("controller1",
+ new String[] {HexString.toHexString(1000L)}, listenerContainer);
+ PathChildrenCache pathChildrenCache2 = createPathChildrenCacheMock("controller2",
+ new String[] {
+ HexString.toHexString(1001L), HexString.toHexString(1002L)},
+ listenerContainer);
// Mock PathChildrenCache constructor
PowerMock.expectNew(PathChildrenCache.class,
@@ -474,7 +494,8 @@
// Mock ServiceCacheBuilder
ServiceCacheBuilder<ControllerService> serviceCacheBuilder = EasyMock.createMock(ServiceCacheBuilder.class);
- EasyMock.expect(serviceCacheBuilder.name(EasyMock.anyObject(String.class))).andReturn(serviceCacheBuilder).once();
+ EasyMock.expect(serviceCacheBuilder.name(EasyMock.anyObject(String.class)))
+ .andReturn(serviceCacheBuilder).once();
EasyMock.expect(serviceCacheBuilder.build()).andReturn(serviceCache).once();
EasyMock.replay(serviceCacheBuilder);
@@ -536,8 +557,11 @@
* @return Mock PathChildrenCache object
* @throws Exception
*/
- private PathChildrenCache createPathChildrenCacheMock(final String controllerId, final String[] paths,
- ListenerContainer<PathChildrenCacheListener> listener) throws Exception {
+ private PathChildrenCache createPathChildrenCacheMock(
+ final String controllerId,
+ final String[] paths,
+ ListenerContainer<PathChildrenCacheListener> listener)
+ throws Exception {
PathChildrenCache pathChildrenCache = EasyMock.createMock(PathChildrenCache.class);
EasyMock.expect(pathChildrenCache.getListenable()).andReturn(listener).anyTimes();
@@ -582,12 +606,18 @@
* @throws Exception
*/
private void setPathChildrenCache() throws Exception {
- pathChildrenCacheListener.childEvent(client,
- createChildrenCacheEventMock("controller1", HexString.toHexString(1000L), PathChildrenCacheEvent.Type.CHILD_ADDED));
- pathChildrenCacheListener.childEvent(client,
- createChildrenCacheEventMock("controller2", HexString.toHexString(1001L), PathChildrenCacheEvent.Type.CHILD_ADDED));
- pathChildrenCacheListener.childEvent(client,
- createChildrenCacheEventMock("controller2", HexString.toHexString(1002L), PathChildrenCacheEvent.Type.CHILD_ADDED));
+ pathChildrenCacheListener.childEvent(
+ client,
+ createChildrenCacheEventMock("controller1", HexString.toHexString(1000L),
+ PathChildrenCacheEvent.Type.CHILD_ADDED));
+ pathChildrenCacheListener.childEvent(
+ client,
+ createChildrenCacheEventMock("controller2", HexString.toHexString(1001L),
+ PathChildrenCacheEvent.Type.CHILD_ADDED));
+ pathChildrenCacheListener.childEvent(
+ client,
+ createChildrenCacheEventMock("controller2", HexString.toHexString(1002L),
+ PathChildrenCacheEvent.Type.CHILD_ADDED));
}
/**
diff --git a/src/test/java/net/onrc/onos/core/util/FlowEntryActionTest.java b/src/test/java/net/onrc/onos/core/util/FlowEntryActionTest.java
index f031f6d..c93f132 100644
--- a/src/test/java/net/onrc/onos/core/util/FlowEntryActionTest.java
+++ b/src/test/java/net/onrc/onos/core/util/FlowEntryActionTest.java
@@ -105,7 +105,8 @@
act.setActionSetVlanPriority(actVlan);
assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_VLAN_PCP, act.actionType());
- assertEquals("vlan priority should be the same", actVlan.vlanPriority(), act.actionSetVlanPriority().vlanPriority());
+ assertEquals("vlan priority should be the same", actVlan.vlanPriority(),
+ act.actionSetVlanPriority().vlanPriority());
FlowEntryAction actCopy = new FlowEntryAction(act);
FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
diff --git a/src/test/java/net/onrc/onos/core/util/FlowEntryMatchTest.java b/src/test/java/net/onrc/onos/core/util/FlowEntryMatchTest.java
index 39a0f91..1528433 100644
--- a/src/test/java/net/onrc/onos/core/util/FlowEntryMatchTest.java
+++ b/src/test/java/net/onrc/onos/core/util/FlowEntryMatchTest.java
@@ -307,7 +307,14 @@
FlowEntryMatch def = new FlowEntryMatch();
assertEquals("match default", def.toString(), "[]");
- assertEquals("match set", match.toString(), "[inPort=1 srcMac=01:02:03:04:05:06 dstMac=06:05:04:03:02:01 ethernetFrameType=2 vlanId=3 vlanPriority=4 srcIPv4Net=127.0.0.1/32 dstIPv4Net=127.0.0.2/32 ipProto=5 ipToS=6 srcTcpUdpPort=7 dstTcpUdpPort=8]");
+ assertEquals(
+ "match set",
+ match.toString(),
+ "[inPort=1 srcMac=01:02:03:04:05:06 dstMac=06:05:04:03:02:01"
+ + " ethernetFrameType=2 vlanId=3 vlanPriority=4"
+ + " srcIPv4Net=127.0.0.1/32"
+ + " dstIPv4Net=127.0.0.2/32 ipProto=5 ipToS=6"
+ + " srcTcpUdpPort=7 dstTcpUdpPort=8]");
}
}
diff --git a/src/test/java/net/onrc/onos/core/util/FlowEntryTest.java b/src/test/java/net/onrc/onos/core/util/FlowEntryTest.java
index ca94206..4be4bdb 100644
--- a/src/test/java/net/onrc/onos/core/util/FlowEntryTest.java
+++ b/src/test/java/net/onrc/onos/core/util/FlowEntryTest.java
@@ -260,8 +260,41 @@
@Test
public void testToString() {
FlowEntry def = new FlowEntry();
- assertEquals("toString", def.toString(), "[ idleTimeout=0 hardTimeout=0 priority=32768 flowEntryActions=[] flowEntryUserState=FE_USER_UNKNOWN flowEntrySwitchState=FE_SWITCH_UNKNOWN]");
- assertEquals("toString", entry.toString(), "[flowEntryId=0x5678 flowId=0x1234 idleTimeout=5 hardTimeout=10 priority=15 flowEntryMatch=[inPort=1 srcMac=01:02:03:04:05:06 dstMac=06:05:04:03:02:01 ethernetFrameType=2 vlanId=3 vlanPriority=4 srcIPv4Net=127.0.0.1/32 dstIPv4Net=127.0.0.2/32 ipProto=5 ipToS=6 srcTcpUdpPort=7 dstTcpUdpPort=8] flowEntryActions=[[type=ACTION_OUTPUT action=[port=9 maxLen=0]];[type=ACTION_OUTPUT action=[port=-3 maxLen=0]];[type=ACTION_SET_VLAN_VID action=[vlanId=3]];[type=ACTION_SET_VLAN_PCP action=[vlanPriority=4]];[type=ACTION_STRIP_VLAN action=[stripVlan=true]];[type=ACTION_SET_DL_SRC action=[addr=01:02:03:04:05:06]];[type=ACTION_SET_DL_DST action=[addr=06:05:04:03:02:01]];[type=ACTION_SET_NW_SRC action=[addr=127.0.0.3]];[type=ACTION_SET_NW_DST action=[addr=127.0.0.4]];[type=ACTION_SET_NW_TOS action=[ipToS=6]];[type=ACTION_SET_TP_SRC action=[port=7]];[type=ACTION_SET_TP_DST action=[port=8]];[type=ACTION_ENQUEUE action=[port=10 queueId=11]];] dpid=00:00:00:00:00:00:ca:fe inPort=1 outPort=9 flowEntryUserState=FE_USER_ADD flowEntrySwitchState=FE_SWITCH_UPDATED flowEntryErrorState=[type=12 code=13]]");
+ assertEquals("toString",
+ "[ idleTimeout=0 hardTimeout=0 priority=32768"
+ + " flowEntryActions=[] flowEntryUserState=FE_USER_UNKNOWN"
+ + " flowEntrySwitchState=FE_SWITCH_UNKNOWN]",
+ def.toString());
+
+ assertEquals("toString",
+ "[flowEntryId=0x5678 flowId=0x1234 idleTimeout=5 hardTimeout=10"
+ + " priority=15"
+ + " flowEntryMatch="
+ + "[inPort=1 srcMac=01:02:03:04:05:06 dstMac=06:05:04:03:02:01"
+ + " ethernetFrameType=2 vlanId=3 vlanPriority=4"
+ + " srcIPv4Net=127.0.0.1/32 dstIPv4Net=127.0.0.2/32"
+ + " ipProto=5 ipToS=6 srcTcpUdpPort=7 dstTcpUdpPort=8"
+ + "]"
+ + " flowEntryActions=["
+ + "[type=ACTION_OUTPUT action=[port=9 maxLen=0]];"
+ // PORT_CONTROLLER((short) 0xfffd) = 65533 (-3)
+ + "[type=ACTION_OUTPUT action=[port=-3 maxLen=0]];"
+ + "[type=ACTION_SET_VLAN_VID action=[vlanId=3]];"
+ + "[type=ACTION_SET_VLAN_PCP action=[vlanPriority=4]];"
+ + "[type=ACTION_STRIP_VLAN action=[stripVlan=true]];"
+ + "[type=ACTION_SET_DL_SRC action=[addr=01:02:03:04:05:06]];"
+ + "[type=ACTION_SET_DL_DST action=[addr=06:05:04:03:02:01]];"
+ + "[type=ACTION_SET_NW_SRC action=[addr=127.0.0.3]];"
+ + "[type=ACTION_SET_NW_DST action=[addr=127.0.0.4]];"
+ + "[type=ACTION_SET_NW_TOS action=[ipToS=6]];"
+ + "[type=ACTION_SET_TP_SRC action=[port=7]];"
+ + "[type=ACTION_SET_TP_DST action=[port=8]];"
+ + "[type=ACTION_ENQUEUE action=[port=10 queueId=11]];]"
+ + " dpid=00:00:00:00:00:00:ca:fe inPort=1 outPort=9"
+ + " flowEntryUserState=FE_USER_ADD"
+ + " flowEntrySwitchState=FE_SWITCH_UPDATED"
+ + " flowEntryErrorState=[type=12 code=13]]",
+ entry.toString());
}
}