Fix checkstyle whitespace issues - WHITESPACE ONLY
Change-Id: Ic205c1afd639c6008d61d9de95cb764eeb6238ca
diff --git a/src/test/java/net/floodlightcontroller/util/MACAddressTest.java b/src/test/java/net/floodlightcontroller/util/MACAddressTest.java
index 2e8a793..6b81135 100644
--- a/src/test/java/net/floodlightcontroller/util/MACAddressTest.java
+++ b/src/test/java/net/floodlightcontroller/util/MACAddressTest.java
@@ -21,33 +21,33 @@
assertEquals(address,
MACAddress.valueOf(new byte[]{(byte) 0xFF, (byte) 0xFE, (byte) 0xFD, 0x10, 0x20, 0x30}));
assertEquals("ff:fe:fd:10:20:30", address.toString());
-
+
address = MACAddress.valueOf("00:11:22:aa:bb:cc");
assertEquals(address,
- MACAddress.valueOf(new byte[]{0x00, 0x11, 0x22, (byte)0xaa, (byte)0xbb, (byte)0xcc}));
+ MACAddress.valueOf(new byte[]{0x00, 0x11, 0x22, (byte) 0xaa, (byte) 0xbb, (byte) 0xcc}));
}
- @Test(expected=NumberFormatException.class)
+ @Test(expected = NumberFormatException.class)
public void testIllegalFormat() {
MACAddress.valueOf("0T:00:01:02:03:04");
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testLongStringFields() {
MACAddress.valueOf("00:01:02:03:04:05:06");
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testShortStringFields() {
MACAddress.valueOf("00:01:02:03:04");
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testLongByteFields() {
MACAddress.valueOf(new byte[]{0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06});
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testShortByteField() {
MACAddress.valueOf(new byte[]{0x01, 0x01, 0x02, 0x03, 0x04});
}
@@ -62,16 +62,16 @@
assertEquals(
1103823438081L,
- MACAddress.valueOf(new byte[] { (byte) 0x01, (byte) 0x01,
- (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01 }).toLong());
+ MACAddress.valueOf(new byte[]{(byte) 0x01, (byte) 0x01,
+ (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01}).toLong());
assertEquals(
141289400074368L,
- MACAddress.valueOf(new byte[] { (byte) 0x80, (byte) 0x80,
- (byte) 0x80, (byte) 0x80, (byte) 0x80, (byte) 0x80 }).toLong());
+ MACAddress.valueOf(new byte[]{(byte) 0x80, (byte) 0x80,
+ (byte) 0x80, (byte) 0x80, (byte) 0x80, (byte) 0x80}).toLong());
}
-
+
@Test
public void testIsBroadcast() {
assertTrue(MACAddress.valueOf("FF:FF:FF:FF:FF:FF").isBroadcast());
diff --git a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java
index e3ded96..574dc23 100644
--- a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java
+++ b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java
@@ -28,54 +28,54 @@
/**
* A mock implementation of IFOSwitch we use for {@link OFMessageDamper}
- *
+ * <p/>
* We need to mock equals() and hashCode() but alas, EasyMock doesn't support
* this. Sigh. And of course this happens to be the interface with the most
- * methods.
- * @author gregor
+ * methods.
*
+ * @author gregor
*/
public class OFMessageDamperMockSwitch implements IOFSwitch {
OFMessage writtenMessage;
FloodlightContext writtenContext;
-
+
public OFMessageDamperMockSwitch() {
reset();
}
-
+
/* reset this mock. I.e., clear the stored message previously written */
public void reset() {
writtenMessage = null;
writtenContext = null;
}
-
+
/* assert that a message was written to this switch and that the
* written message and context matches the expected values
* @param expected
* @param expectedContext
*/
- public void assertMessageWasWritten(OFMessage expected,
+ public void assertMessageWasWritten(OFMessage expected,
FloodlightContext expectedContext) {
assertNotNull("No OFMessage was written", writtenMessage);
assertEquals(expected, writtenMessage);
assertEquals(expectedContext, writtenContext);
}
-
+
/*
* assert that no message was written
*/
public void assertNoMessageWritten() {
- assertNull("OFMessage was written but didn't expect one",
- writtenMessage);
- assertNull("There was a context but didn't expect one",
- writtenContext);
+ assertNull("OFMessage was written but didn't expect one",
+ writtenMessage);
+ assertNull("There was a context but didn't expect one",
+ writtenContext);
}
/*
* use hashCode() and equals() from Object
*/
-
-
+
+
//-------------------------------------------------------
// IOFSwitch: mocked methods
@Override
@@ -85,222 +85,222 @@
writtenContext = bc;
writtenMessage = m;
}
-
+
//-------------------------------------------------------
// IOFSwitch: not-implemented methods
@Override
- public void write(List<OFMessage> msglist, FloodlightContext bc)
+ public void write(List<OFMessage> msglist, FloodlightContext bc)
throws IOException {
assertTrue("Unexpected method call", false);
}
-
+
@Override
public void disconnectOutputStream() {
assertTrue("Unexpected method call", false);
}
-
+
@Override
public Channel getChannel() {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public void setFeaturesReply(OFFeaturesReply featuresReply) {
assertTrue("Unexpected method call", false);
}
-
+
@Override
public void setSwitchProperties(OFDescriptionStatistics description) {
assertTrue("Unexpected method call", false);
// TODO Auto-generated method stub
}
-
+
@Override
public Collection<OFPhysicalPort> getEnabledPorts() {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public Collection<Short> getEnabledPortNumbers() {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public OFPhysicalPort getPort(short portNumber) {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public OFPhysicalPort getPort(String portName) {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public void setPort(OFPhysicalPort port) {
assertTrue("Unexpected method call", false);
}
-
+
@Override
public void deletePort(short portNumber) {
assertTrue("Unexpected method call", false);
}
-
+
@Override
public void deletePort(String portName) {
assertTrue("Unexpected method call", false);
}
-
+
@Override
public Collection<OFPhysicalPort> getPorts() {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public boolean portEnabled(short portName) {
assertTrue("Unexpected method call", false);
return false;
}
-
+
@Override
public boolean portEnabled(String portName) {
assertTrue("Unexpected method call", false);
return false;
}
-
+
@Override
public boolean portEnabled(OFPhysicalPort port) {
assertTrue("Unexpected method call", false);
return false;
}
-
+
@Override
public long getId() {
assertTrue("Unexpected method call", false);
return 0;
}
-
+
@Override
public String getStringId() {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public Map<Object, Object> getAttributes() {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public Date getConnectedSince() {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public int getNextTransactionId() {
assertTrue("Unexpected method call", false);
return 0;
}
-
+
@Override
public Future<List<OFStatistics>>
- getStatistics(OFStatisticsRequest request) throws IOException {
+ getStatistics(OFStatisticsRequest request) throws IOException {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public boolean isConnected() {
assertTrue("Unexpected method call", false);
return false;
}
-
+
@Override
public void setConnected(boolean connected) {
assertTrue("Unexpected method call", false);
}
-
+
@Override
public Role getRole() {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public boolean isActive() {
assertTrue("Unexpected method call", false);
return false;
}
-
+
@Override
public void deliverStatisticsReply(OFMessage reply) {
assertTrue("Unexpected method call", false);
}
-
+
@Override
public void cancelStatisticsReply(int transactionId) {
assertTrue("Unexpected method call", false);
}
-
+
@Override
public void cancelAllStatisticsReplies() {
assertTrue("Unexpected method call", false);
}
-
+
@Override
public boolean hasAttribute(String name) {
assertTrue("Unexpected method call", false);
return false;
}
-
+
@Override
public Object getAttribute(String name) {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public void setAttribute(String name, Object value) {
assertTrue("Unexpected method call", false);
}
-
+
@Override
public Object removeAttribute(String name) {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public void clearAllFlowMods() {
assertTrue("Unexpected method call", false);
}
-
+
@Override
public boolean updateBroadcastCache(Long entry, Short port) {
assertTrue("Unexpected method call", false);
return false;
}
-
+
@Override
public Map<Short, Long> getPortBroadcastHits() {
assertTrue("Unexpected method call", false);
return null;
}
-
+
@Override
public void sendStatsQuery(OFStatisticsRequest request, int xid,
IOFMessageListener caller)
- throws IOException {
+ throws IOException {
assertTrue("Unexpected method call", false);
}
-
+
@Override
public void flush() {
assertTrue("Unexpected method call", false);
diff --git a/src/test/java/net/floodlightcontroller/util/OFMessageDamperTest.java b/src/test/java/net/floodlightcontroller/util/OFMessageDamperTest.java
index 1f39761..02cc535 100644
--- a/src/test/java/net/floodlightcontroller/util/OFMessageDamperTest.java
+++ b/src/test/java/net/floodlightcontroller/util/OFMessageDamperTest.java
@@ -20,50 +20,49 @@
OFMessageFactory factory;
OFMessageDamper damper;
FloodlightContext cntx;
-
+
OFMessageDamperMockSwitch sw1;
OFMessageDamperMockSwitch sw2;
-
+
OFEchoRequest echoRequst1;
OFEchoRequest echoRequst1Clone;
OFEchoRequest echoRequst2;
OFHello hello1;
OFHello hello2;
-
-
-
+
+
@Before
public void setUp() throws IOException {
factory = new BasicFactory();
cntx = new FloodlightContext();
-
+
sw1 = new OFMessageDamperMockSwitch();
sw2 = new OFMessageDamperMockSwitch();
-
- echoRequst1 = (OFEchoRequest)factory.getMessage(OFType.ECHO_REQUEST);
- echoRequst1.setPayload(new byte[] { 1 });
+
+ echoRequst1 = (OFEchoRequest) factory.getMessage(OFType.ECHO_REQUEST);
+ echoRequst1.setPayload(new byte[]{1});
echoRequst1Clone = (OFEchoRequest)
factory.getMessage(OFType.ECHO_REQUEST);
- echoRequst1Clone.setPayload(new byte[] { 1 });
- echoRequst2 = (OFEchoRequest)factory.getMessage(OFType.ECHO_REQUEST);
- echoRequst2.setPayload(new byte[] { 2 });
-
- hello1 = (OFHello)factory.getMessage(OFType.HELLO);
+ echoRequst1Clone.setPayload(new byte[]{1});
+ echoRequst2 = (OFEchoRequest) factory.getMessage(OFType.ECHO_REQUEST);
+ echoRequst2.setPayload(new byte[]{2});
+
+ hello1 = (OFHello) factory.getMessage(OFType.HELLO);
hello1.setXid(1);
- hello2 = (OFHello)factory.getMessage(OFType.HELLO);
+ hello2 = (OFHello) factory.getMessage(OFType.HELLO);
hello2.setXid(2);
-
+
}
-
- protected void doWrite(boolean expectWrite,
- OFMessageDamperMockSwitch sw,
+
+ protected void doWrite(boolean expectWrite,
+ OFMessageDamperMockSwitch sw,
OFMessage msg,
FloodlightContext cntx) throws IOException {
-
+
boolean result;
sw.reset();
result = damper.write(sw, msg, cntx);
-
+
if (expectWrite) {
assertEquals(true, result);
sw.assertMessageWasWritten(msg, cntx);
@@ -72,79 +71,77 @@
sw.assertNoMessageWritten();
}
}
-
-
+
+
@Test
public void testOneMessageType() throws IOException, InterruptedException {
int timeout = 50;
- int sleepTime = 60;
- damper = new OFMessageDamper(100,
- EnumSet.of(OFType.ECHO_REQUEST),
- timeout);
-
-
-
+ int sleepTime = 60;
+ damper = new OFMessageDamper(100,
+ EnumSet.of(OFType.ECHO_REQUEST),
+ timeout);
+
+
// echo requests should be dampened
doWrite(true, sw1, echoRequst1, cntx);
doWrite(false, sw1, echoRequst1, cntx);
doWrite(false, sw1, echoRequst1Clone, cntx);
doWrite(true, sw1, echoRequst2, cntx);
doWrite(false, sw1, echoRequst2, cntx);
-
+
// we don't dampen hellos. All should succeed
doWrite(true, sw1, hello1, cntx);
doWrite(true, sw1, hello1, cntx);
doWrite(true, sw1, hello1, cntx);
-
+
// echo request should also be dampened on sw2
doWrite(true, sw2, echoRequst1, cntx);
doWrite(false, sw2, echoRequst1, cntx);
doWrite(true, sw2, echoRequst2, cntx);
-
-
+
+
Thread.sleep(sleepTime);
doWrite(true, sw1, echoRequst1, cntx);
doWrite(true, sw2, echoRequst1, cntx);
-
+
}
-
+
@Test
public void testTwoMessageTypes() throws IOException, InterruptedException {
int timeout = 50;
- int sleepTime = 60;
- damper = new OFMessageDamper(100,
- EnumSet.of(OFType.ECHO_REQUEST,
- OFType.HELLO),
- timeout);
-
-
-
+ int sleepTime = 60;
+ damper = new OFMessageDamper(100,
+ EnumSet.of(OFType.ECHO_REQUEST,
+ OFType.HELLO),
+ timeout);
+
+
// echo requests should be dampened
doWrite(true, sw1, echoRequst1, cntx);
doWrite(false, sw1, echoRequst1, cntx);
doWrite(false, sw1, echoRequst1Clone, cntx);
doWrite(true, sw1, echoRequst2, cntx);
doWrite(false, sw1, echoRequst2, cntx);
-
+
// hello should be dampened as well
doWrite(true, sw1, hello1, cntx);
doWrite(false, sw1, hello1, cntx);
doWrite(false, sw1, hello1, cntx);
-
+
doWrite(true, sw1, hello2, cntx);
doWrite(false, sw1, hello2, cntx);
doWrite(false, sw1, hello2, cntx);
-
+
// echo request should also be dampened on sw2
doWrite(true, sw2, echoRequst1, cntx);
doWrite(false, sw2, echoRequst1, cntx);
doWrite(true, sw2, echoRequst2, cntx);
-
+
Thread.sleep(sleepTime);
doWrite(true, sw1, echoRequst1, cntx);
doWrite(true, sw2, echoRequst1, cntx);
doWrite(true, sw1, hello1, cntx);
doWrite(true, sw1, hello2, cntx);
}
-
+
}
diff --git a/src/test/java/net/floodlightcontroller/util/TimedCacheTest.java b/src/test/java/net/floodlightcontroller/util/TimedCacheTest.java
index 7f06c0d..331e0e6 100644
--- a/src/test/java/net/floodlightcontroller/util/TimedCacheTest.java
+++ b/src/test/java/net/floodlightcontroller/util/TimedCacheTest.java
@@ -8,7 +8,7 @@
public class TimedCacheTest {
public static class CacheEntry {
public int key;
-
+
public CacheEntry(int key) {
this.key = key;
}
@@ -35,56 +35,55 @@
return true;
}
}
-
+
protected TimedCache<CacheEntry> cache;
-
+
@Before
public void setUp() {
//
}
-
-
+
+
@Test
public void testCaching() throws InterruptedException {
int timeout = 50;
int timeToSleep = 60;
cache = new TimedCache<TimedCacheTest.CacheEntry>(100, timeout);
-
+
CacheEntry e1a = new CacheEntry(1);
CacheEntry e1b = new CacheEntry(1);
CacheEntry e1c = new CacheEntry(1);
CacheEntry e2 = new CacheEntry(2);
-
+
assertEquals(false, cache.update(e1a));
assertEquals(true, cache.update(e1a));
assertEquals(true, cache.update(e1b));
assertEquals(true, cache.update(e1c));
assertEquals(false, cache.update(e2));
assertEquals(true, cache.update(e2));
-
+
Thread.sleep(timeToSleep);
assertEquals(false, cache.update(e1a));
assertEquals(false, cache.update(e2));
}
-
+
@Test
public void testCapacity() throws InterruptedException {
int timeout = 5000;
cache = new TimedCache<TimedCacheTest.CacheEntry>(2, timeout);
-
+
// Testing the capacity is tricky since the capacity can be
// exceeded for short amounts of time, so we try to flood the cache
// to make sure the first entry is expired
CacheEntry e1 = new CacheEntry(1);
- for (int i=0; i < 100; i++) {
+ for (int i = 0; i < 100; i++) {
CacheEntry e = new CacheEntry(i);
cache.update(e);
}
-
+
// entry 1 should have been expired due to capacity limits
assertEquals(false, cache.update(e1));
}
-
-
-
+
+
}