Add Checkstyle to enforce codestyle rules
Rules are based on Sun style with a few minor modifications
Change-Id: If9e772105053c67550e4f206024fea26b65e611b
diff --git a/src/test/java/com/intel/jndn/management/NdnPingClientIT.java b/src/test/java/com/intel/jndn/management/NdnPingClientIT.java
index b561b6e..e0f9562 100644
--- a/src/test/java/com/intel/jndn/management/NdnPingClientIT.java
+++ b/src/test/java/com/intel/jndn/management/NdnPingClientIT.java
@@ -13,29 +13,17 @@
*/
package com.intel.jndn.management;
-import com.intel.jndn.management.enums.Strategies;
-import com.intel.jndn.management.types.RibEntry;
-import com.intel.jndn.management.types.StrategyChoice;
-import com.intel.jndn.mock.MockKeyChain;
import net.named_data.jndn.Face;
-import net.named_data.jndn.KeyLocator;
-import net.named_data.jndn.Name;
-import net.named_data.jndn.encoding.EncodingException;
-import net.named_data.jndn.security.KeyChain;
import net.named_data.jndn.security.SecurityException;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
-import java.util.List;
-import java.util.Random;
-import java.util.logging.Logger;
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
/**
- * Testing basic pining using real NFD instance (NFD must be run locally while executing the test)
+ * Testing basic pining using real NFD instance (NFD must be run locally while executing the test).
*
* @author Andrew Brown <andrew.brown@intel.com>
*/
diff --git a/src/test/java/com/intel/jndn/management/NfdcIT.java b/src/test/java/com/intel/jndn/management/NfdcIT.java
index 8a8a0c3..da341a2 100644
--- a/src/test/java/com/intel/jndn/management/NfdcIT.java
+++ b/src/test/java/com/intel/jndn/management/NfdcIT.java
@@ -13,11 +13,6 @@
*/
package com.intel.jndn.management;
-import java.io.IOException;
-import java.util.List;
-import java.util.Random;
-import java.util.logging.Logger;
-
import com.intel.jndn.management.enums.LocalControlHeader;
import com.intel.jndn.management.enums.Strategies;
import com.intel.jndn.management.types.RibEntry;
@@ -31,13 +26,19 @@
import net.named_data.jndn.security.SecurityException;
import org.junit.Before;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.*;
+import java.io.IOException;
+import java.util.List;
+import java.util.Random;
+import java.util.logging.Logger;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
/**
- * Testing Nfdc with real NFD instance (NFD must be run locally while executing the test)
+ * Testing Nfdc with real NFD instance (NFD must be run locally while executing the test).
*
* @author Andrew Brown <andrew.brown@intel.com>
*/
@@ -112,7 +113,7 @@
}
/**
- * LocalControlHeader would work only with NFD < 0.3.4, broken otherwise
+ * LocalControlHeader works only with NFD < 0.3.4, broken otherwise.
*/
@Test(expected = ManagementException.class)
public void testLocalControlHeader() throws Exception {
diff --git a/src/test/java/com/intel/jndn/management/TestHelper.java b/src/test/java/com/intel/jndn/management/TestHelper.java
index 09ea326..492d272 100644
--- a/src/test/java/com/intel/jndn/management/TestHelper.java
+++ b/src/test/java/com/intel/jndn/management/TestHelper.java
@@ -16,21 +16,22 @@
import java.nio.ByteBuffer;
/**
- * Helper methods for unit tests
+ * Helper methods for unit tests.
*/
-public class TestHelper {
+public final class TestHelper {
/**
- * Prevent instances of TestHelper
+ * Prevent instances of TestHelper.
*/
private TestHelper() {
}
/**
- * Construct ByteBuffer from int[]
+ * Construct ByteBuffer from int[].
+ *
+ * @param array array to convert
*/
public static ByteBuffer
- bufferFromIntArray(int[] array)
- {
+ bufferFromIntArray(final int[] array) {
ByteBuffer result = ByteBuffer.allocate(array.length);
for (int value : array) {
result.put((byte) (value & 0xFF));
diff --git a/src/test/java/com/intel/jndn/management/types/FaceStatusTest.java b/src/test/java/com/intel/jndn/management/types/FaceStatusTest.java
index b6b959b..6816ebd 100644
--- a/src/test/java/com/intel/jndn/management/types/FaceStatusTest.java
+++ b/src/test/java/com/intel/jndn/management/types/FaceStatusTest.java
@@ -17,26 +17,25 @@
import com.intel.jndn.management.enums.FacePersistency;
import com.intel.jndn.management.enums.FaceScope;
import com.intel.jndn.management.enums.LinkType;
-
-import java.nio.ByteBuffer;
import net.named_data.jndn.util.Blob;
-import static org.junit.Assert.*;
-
import org.junit.Before;
import org.junit.Test;
+import java.nio.ByteBuffer;
+
+import static org.junit.Assert.assertEquals;
+
/**
- * Test whether the decoding for the face management service is working
- * correctly
+ * Test encode/decode of FaceStatus.
*
* @author Andrew Brown <andrew.brown@intel.com>
*/
public class FaceStatusTest {
- ByteBuffer TestFaceStatus;
+ private ByteBuffer testFaceStatusWire;
@Before
public void setUp() throws Exception {
- TestFaceStatus = TestHelper.bufferFromIntArray(new int[] {
+ testFaceStatusWire = TestHelper.bufferFromIntArray(new int[] {
0x80, 0x5e, 0x69, 0x01, 0x64, 0x72, 0x15, 0x74, 0x63, 0x70,
0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e,
0x32, 0x2e, 0x31, 0x3a, 0x36, 0x33, 0x36, 0x33, 0x81, 0x16,
@@ -50,9 +49,6 @@
});
}
- /**
- * Test encoding
- */
@Test
public void testEncode() throws Exception {
FaceStatus status = new FaceStatus();
@@ -74,15 +70,12 @@
// encode
Blob encoded = status.wireEncode();
- assertEquals(TestFaceStatus, encoded.buf());
+ assertEquals(testFaceStatusWire, encoded.buf());
}
- /**
- * Test decoding
- */
@Test
public void testDecode() throws Exception {
- FaceStatus status = new FaceStatus(TestFaceStatus);
+ FaceStatus status = new FaceStatus(testFaceStatusWire);
assertEquals(100, status.getFaceId());
assertEquals("tcp4://192.0.2.1:6363", status.getRemoteUri());
diff --git a/src/test/java/com/intel/jndn/management/types/FibEntryTest.java b/src/test/java/com/intel/jndn/management/types/FibEntryTest.java
index d8c19f4..a1080a0 100644
--- a/src/test/java/com/intel/jndn/management/types/FibEntryTest.java
+++ b/src/test/java/com/intel/jndn/management/types/FibEntryTest.java
@@ -14,39 +14,39 @@
package com.intel.jndn.management.types;
import com.intel.jndn.management.TestHelper;
+import net.named_data.jndn.Name;
+import net.named_data.jndn.encoding.EncodingException;
+import org.junit.Before;
+import org.junit.Test;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
-import net.named_data.jndn.Name;
-import net.named_data.jndn.encoding.EncodingException;
+
import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-
/**
- * Test encode/decode of FibEntry and NextHopRecord
+ * Test encode/decode of FibEntry and NextHopRecord.
*
* @author Andrew Brown <andrew.brown@intel.com>
*/
public class FibEntryTest {
- ByteBuffer TestNextHopRecord;
- ByteBuffer TestFibEntryNoNextHops;
- ByteBuffer TestFibEntry;
+ private ByteBuffer testNextHopRecordWire;
+ private ByteBuffer testFibEntryNoNextHopsWire;
+ private ByteBuffer testFibEntryWire;
@Before
public void setUp() {
- TestNextHopRecord = TestHelper.bufferFromIntArray(new int[] {
+ testNextHopRecordWire = TestHelper.bufferFromIntArray(new int[] {
0x81, 0x06, 0x69, 0x01, 0x0a, 0x6a, 0x01, 0xc8
});
- TestFibEntryNoNextHops = TestHelper.bufferFromIntArray(new int[] {
+ testFibEntryNoNextHopsWire = TestHelper.bufferFromIntArray(new int[] {
0x80, 0x15, 0x07, 0x13, 0x08, 0x04, 0x74, 0x68, 0x69, 0x73,
0x08, 0x02, 0x69, 0x73, 0x08, 0x01, 0x61, 0x08, 0x04, 0x74,
0x65, 0x73, 0x74
});
- TestFibEntry = TestHelper.bufferFromIntArray(new int[] {
+ testFibEntryWire = TestHelper.bufferFromIntArray(new int[] {
0x80, 0x38, 0x07, 0x13, 0x08, 0x04, 0x74, 0x68, 0x69, 0x73, 0x08, 0x02, 0x69, 0x73, 0x08, 0x01,
0x61, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x81, 0x06, 0x69, 0x01, 0x0a, 0x6a, 0x01, 0xc8, 0x81,
0x07, 0x69, 0x01, 0x14, 0x6a, 0x02, 0x01, 0x2c, 0x81, 0x07, 0x69, 0x01, 0x1e, 0x6a, 0x02, 0x01,
@@ -55,51 +55,47 @@
}
@Test
- public void testNextHopRecordEncode()
- {
+ public void testNextHopRecordEncode() {
NextHopRecord record = new NextHopRecord();
record.setFaceId(10);
record.setCost(200);
ByteBuffer wire = record.wireEncode().buf();
- assertEquals(TestNextHopRecord, wire);
+ assertEquals(testNextHopRecordWire, wire);
}
@Test
public void testNextHopRecordDecode() throws EncodingException {
- NextHopRecord record = new NextHopRecord(TestNextHopRecord);
+ NextHopRecord record = new NextHopRecord(testNextHopRecordWire);
assertEquals(10, record.getFaceId());
assertEquals(200, record.getCost());
}
@Test
- public void testFibEntryNoNextHopEncode()
- {
+ public void testFibEntryNoNextHopEncode() {
FibEntry entry = new FibEntry();
entry.setPrefix(new Name("/this/is/a/test"));
ByteBuffer wire = entry.wireEncode().buf();
- assertEquals(TestFibEntryNoNextHops, wire);
+ assertEquals(testFibEntryNoNextHopsWire, wire);
}
@Test
public void testFibEntryNoNextHopsDecode() throws EncodingException {
- FibEntry entry = new FibEntry(TestFibEntryNoNextHops);
+ FibEntry entry = new FibEntry(testFibEntryNoNextHopsWire);
assertEquals("/this/is/a/test", entry.getPrefix().toString());
assertEquals(0, entry.getNextHopRecords().size());
}
@Test
- public void testFibEntryEncode()
- {
+ public void testFibEntryEncode() {
FibEntry entry = new FibEntry();
entry.setPrefix(new Name("/this/is/a/test"));
List<NextHopRecord> records = new ArrayList<>();
- for (int i = 1; i < 4; i++)
- {
+ for (int i = 1; i < 4; i++) {
NextHopRecord record = new NextHopRecord();
record.setFaceId(i * 10);
record.setCost((i * 100) + 100);
@@ -115,12 +111,12 @@
entry.addNextHopRecord(oneMore);
ByteBuffer wire = entry.wireEncode().buf();
- assertEquals(TestFibEntry, wire);
+ assertEquals(testFibEntryWire, wire);
}
@Test
public void testFibEntryDecode() throws EncodingException {
- FibEntry entry = new FibEntry(TestFibEntry);
+ FibEntry entry = new FibEntry(testFibEntryWire);
List<NextHopRecord> records = entry.getNextHopRecords();
diff --git a/src/test/java/com/intel/jndn/management/types/ForwarderStatusTest.java b/src/test/java/com/intel/jndn/management/types/ForwarderStatusTest.java
index 5ff5157..fc2484d 100644
--- a/src/test/java/com/intel/jndn/management/types/ForwarderStatusTest.java
+++ b/src/test/java/com/intel/jndn/management/types/ForwarderStatusTest.java
@@ -27,11 +27,11 @@
* @author Andrew Brown <andrew.brown@intel.com>
*/
public class ForwarderStatusTest {
- ByteBuffer TestForwarderStatus;
+ private ByteBuffer testForwarderStatusWire;
@Before
public void setUp() throws Exception {
- TestForwarderStatus = TestHelper.bufferFromIntArray(new int[] {
+ testForwarderStatusWire = TestHelper.bufferFromIntArray(new int[] {
0x80, 0x11, 0x30, 0x2e, 0x32, 0x2e, 0x30, 0x2d, 0x36, 0x35,
0x2d, 0x67, 0x37, 0x35, 0x61, 0x62, 0x36, 0x62, 0x37, 0x81, 0x08, 0x00,
0x00, 0x00, 0x57, 0x5b, 0x42, 0xa6, 0x2d, 0x82, 0x08, 0x00, 0x00, 0x00,
@@ -63,12 +63,12 @@
status.setNOutNacks(4321);
ByteBuffer wire = status.wireEncode().buf();
- assertEquals(TestForwarderStatus, wire);
+ assertEquals(testForwarderStatusWire, wire);
}
@Test
public void testDecode() throws EncodingException {
- ForwarderStatus status = new ForwarderStatus(TestForwarderStatus);
+ ForwarderStatus status = new ForwarderStatus(testForwarderStatusWire);
assertEquals("0.2.0-65-g75ab6b7", status.getNfdVersion());
assertEquals(375193249325L, status.getStartTimestamp());
diff --git a/src/test/java/com/intel/jndn/management/types/RibEntryTest.java b/src/test/java/com/intel/jndn/management/types/RibEntryTest.java
index 82b4d22..bb980ca 100644
--- a/src/test/java/com/intel/jndn/management/types/RibEntryTest.java
+++ b/src/test/java/com/intel/jndn/management/types/RibEntryTest.java
@@ -13,68 +13,69 @@
*/
package com.intel.jndn.management.types;
-import java.nio.ByteBuffer;
-
import com.intel.jndn.management.TestHelper;
import com.intel.jndn.management.enums.RouteFlags;
+import net.named_data.jndn.Name;
+import org.junit.Before;
+import org.junit.Test;
+import java.nio.ByteBuffer;
import java.util.List;
import java.util.ListIterator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import net.named_data.jndn.Name;
-import org.junit.Before;
-import org.junit.Test;
-
+/**
+ * Test RibEntry and Route encoding/decoding.
+ */
public class RibEntryTest {
- ByteBuffer RouteData;
- ByteBuffer RouteInfiniteExpirationPeriod;
- ByteBuffer RibEntryData;
- ByteBuffer RibEntryInfiniteExpirationPeriod;
- ByteBuffer RibEntryForRootData;
+ private ByteBuffer testRouteDataWire;
+ private ByteBuffer testRouteInfiniteExpirationPeriodWire;
+ private ByteBuffer testRibEntryDataWire;
+ private ByteBuffer testRibEntryInfiniteExpirationPeriodWire;
+ private ByteBuffer testRibEntryForRootDataWire;
@Before
public void setUp() throws Exception {
- RouteData = TestHelper.bufferFromIntArray(new int[] {
- 0x81, 0x10, 0x69, 0x01, 0x01, 0x6f, 0x01, 0x80, 0x6a, 0x01, 0x64, 0x6c, 0x01, 0x02,
- 0x6d, 0x02, 0x27, 0x10
- });
- RouteInfiniteExpirationPeriod = TestHelper.bufferFromIntArray(new int[] {
- 0x81, 0x0C, 0x69, 0x01, 0x01, 0x6f, 0x01, 0x80, 0x6a, 0x01, 0x64, 0x6c, 0x01, 0x02
- });
- RibEntryData = TestHelper.bufferFromIntArray(new int[] {
- // Header + Name (ndn:/hello/world)
- 0x80, 0x34, 0x07, 0x0e, 0x08, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f,
- 0x08, 0x05, 0x77, 0x6f, 0x72, 0x6c, 0x64,
- // Route
- 0x81, 0x10, 0x69, 0x01, 0x01, 0x6f, 0x01, 0x80, 0x6a, 0x01, 0x64, 0x6c, 0x01, 0x02,
- 0x6d, 0x02, 0x27, 0x10,
- // Route
- 0x81, 0x10, 0x69, 0x01, 0x02, 0x6f, 0x01, 0x00, 0x6a, 0x01, 0x20, 0x6c, 0x01, 0x01,
- 0x6d, 0x02, 0x13, 0x88
- });
- RibEntryInfiniteExpirationPeriod = TestHelper.bufferFromIntArray(new int[] {
- // Header + Name (ndn:/hello/world)
- 0x80, 0x30, 0x07, 0x0e, 0x08, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f,
- 0x08, 0x05, 0x77, 0x6f, 0x72, 0x6c, 0x64,
- // Route
- 0x81, 0x10, 0x69, 0x01, 0x01, 0x6f, 0x01, 0x80, 0x6a, 0x01, 0x64, 0x6c, 0x01, 0x02,
- 0x6d, 0x02, 0x27, 0x10,
- // Route with no ExpirationPeriod
- 0x81, 0x0C, 0x69, 0x01, 0x02, 0x6f, 0x01, 0x00, 0x6a, 0x01, 0x20, 0x6c, 0x01, 0x01,
- });
- RibEntryForRootData = TestHelper.bufferFromIntArray(new int[] {
- // Header + Name (ndn:/)
- 0x80, 0x26, 0x07, 0x00,
- // Route
- 0x81, 0x10, 0x69, 0x01, 0x01, 0x6f, 0x01, 0x80, 0x6a, 0x01, 0x64, 0x6c, 0x01, 0x02,
- 0x6d, 0x02, 0x27, 0x10,
- // Route
- 0x81, 0x10, 0x69, 0x01, 0x02, 0x6f, 0x01, 0x00, 0x6a, 0x01, 0x20, 0x6c, 0x01, 0x01,
- 0x6d, 0x02, 0x13, 0x88
- });
+ testRouteDataWire = TestHelper.bufferFromIntArray(new int[]{
+ 0x81, 0x10, 0x69, 0x01, 0x01, 0x6f, 0x01, 0x80, 0x6a, 0x01, 0x64, 0x6c, 0x01, 0x02,
+ 0x6d, 0x02, 0x27, 0x10
+ });
+ testRouteInfiniteExpirationPeriodWire = TestHelper.bufferFromIntArray(new int[]{
+ 0x81, 0x0C, 0x69, 0x01, 0x01, 0x6f, 0x01, 0x80, 0x6a, 0x01, 0x64, 0x6c, 0x01, 0x02
+ });
+ testRibEntryDataWire = TestHelper.bufferFromIntArray(new int[]{
+ // Header + Name (ndn:/hello/world)
+ 0x80, 0x34, 0x07, 0x0e, 0x08, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f,
+ 0x08, 0x05, 0x77, 0x6f, 0x72, 0x6c, 0x64,
+ // Route
+ 0x81, 0x10, 0x69, 0x01, 0x01, 0x6f, 0x01, 0x80, 0x6a, 0x01, 0x64, 0x6c, 0x01, 0x02,
+ 0x6d, 0x02, 0x27, 0x10,
+ // Route
+ 0x81, 0x10, 0x69, 0x01, 0x02, 0x6f, 0x01, 0x00, 0x6a, 0x01, 0x20, 0x6c, 0x01, 0x01,
+ 0x6d, 0x02, 0x13, 0x88
+ });
+ testRibEntryInfiniteExpirationPeriodWire = TestHelper.bufferFromIntArray(new int[]{
+ // Header + Name (ndn:/hello/world)
+ 0x80, 0x30, 0x07, 0x0e, 0x08, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f,
+ 0x08, 0x05, 0x77, 0x6f, 0x72, 0x6c, 0x64,
+ // Route
+ 0x81, 0x10, 0x69, 0x01, 0x01, 0x6f, 0x01, 0x80, 0x6a, 0x01, 0x64, 0x6c, 0x01, 0x02,
+ 0x6d, 0x02, 0x27, 0x10,
+ // Route with no ExpirationPeriod
+ 0x81, 0x0C, 0x69, 0x01, 0x02, 0x6f, 0x01, 0x00, 0x6a, 0x01, 0x20, 0x6c, 0x01, 0x01,
+ });
+ testRibEntryForRootDataWire = TestHelper.bufferFromIntArray(new int[]{
+ // Header + Name (ndn:/)
+ 0x80, 0x26, 0x07, 0x00,
+ // Route
+ 0x81, 0x10, 0x69, 0x01, 0x01, 0x6f, 0x01, 0x80, 0x6a, 0x01, 0x64, 0x6c, 0x01, 0x02,
+ 0x6d, 0x02, 0x27, 0x10,
+ // Route
+ 0x81, 0x10, 0x69, 0x01, 0x02, 0x6f, 0x01, 0x00, 0x6a, 0x01, 0x20, 0x6c, 0x01, 0x01,
+ 0x6d, 0x02, 0x13, 0x88
+ });
}
@Test
@@ -86,12 +87,12 @@
route.setFlags(RouteFlags.CAPTURE.toInteger());
route.setExpirationPeriod(10000);
- assertEquals(RouteData, route.wireEncode().buf());
+ assertEquals(testRouteDataWire, route.wireEncode().buf());
}
@Test
public void testRouteDecode() throws Exception {
- Route route = new Route(RouteData);
+ Route route = new Route(testRouteDataWire);
assertEquals(route.getFaceId(), 1);
assertEquals(route.getOrigin(), 128);
@@ -110,12 +111,12 @@
route.setFlags(RouteFlags.CAPTURE.toInteger());
route.setExpirationPeriod(Route.INFINITE_EXPIRATION_PERIOD);
- assertEquals(RouteInfiniteExpirationPeriod, route.wireEncode().buf());
+ assertEquals(testRouteInfiniteExpirationPeriodWire, route.wireEncode().buf());
}
@Test
public void testRouteInfiniteExpirationPeriodDecode() throws Exception {
- Route route = new Route(RouteInfiniteExpirationPeriod);
+ Route route = new Route(testRouteInfiniteExpirationPeriodWire);
assertEquals(route.getFaceId(), 1);
assertEquals(route.getOrigin(), 128);
@@ -135,19 +136,19 @@
route.setExpirationPeriod(10000);
assertEquals(route.toString(), "Route(FaceId: 1, Origin: 128, Cost: 100, " +
- "Flags: 2, ExpirationPeriod: 10000 milliseconds)");
+ "Flags: 2, ExpirationPeriod: 10000 milliseconds)");
}
@Test
public void testRibEntryEncode() throws Exception {
RibEntry entry = newRibEntry("/hello/world", 2, false);
- assertEquals(RibEntryData, entry.wireEncode().buf());
+ assertEquals(testRibEntryDataWire, entry.wireEncode().buf());
}
@Test
public void testRibEntryDecode() throws Exception {
- RibEntry entry = new RibEntry(RibEntryData);
+ RibEntry entry = new RibEntry(testRibEntryDataWire);
assertRibEntry(entry, "/hello/world", 2, false);
}
@@ -156,12 +157,12 @@
public void testRibEntryForRootEncode() throws Exception {
RibEntry entry = newRibEntry("/", 2, false);
- assertEquals(RibEntryForRootData, entry.wireEncode().buf());
+ assertEquals(testRibEntryForRootDataWire, entry.wireEncode().buf());
}
@Test
public void testRibEntryForRootDecode() throws Exception {
- RibEntry entry = new RibEntry(RibEntryForRootData);
+ RibEntry entry = new RibEntry(testRibEntryForRootDataWire);
assertRibEntry(entry, "/", 2, false);
}
@@ -169,14 +170,14 @@
@Test
public void testRibEntryInfiniteExpirationPeriodEncode() throws Exception {
RibEntry entry = newRibEntry("/hello/world", 2, true);
- assertEquals(RibEntryInfiniteExpirationPeriod, entry.wireEncode().buf());
+ assertEquals(testRibEntryInfiniteExpirationPeriodWire, entry.wireEncode().buf());
}
@Test
public void testRibEntryInfiniteExpirationPeriodDecode() throws Exception {
RibEntry entry = new RibEntry();
- entry.wireDecode(RibEntryInfiniteExpirationPeriod);
+ entry.wireDecode(testRibEntryInfiniteExpirationPeriodWire);
assertRibEntry(entry, "/hello/world", 2, true);
}
@@ -195,11 +196,11 @@
RibEntry entry = newRibEntry("/hello/world", 2, true);
assertEquals("RibEntry{\n" +
- " Name: /hello/world\n" +
- " Route(FaceId: 1, Origin: 128, Cost: 100, Flags: 2, ExpirationPeriod: 10000 milliseconds)\n" +
- " Route(FaceId: 2, Origin: 0, Cost: 32, Flags: 1, ExpirationPeriod: Infinity)\n" +
- "}",
- entry.toString());
+ " Name: /hello/world\n" +
+ " Route(FaceId: 1, Origin: 128, Cost: 100, Flags: 2, ExpirationPeriod: 10000 milliseconds)\n" +
+ " Route(FaceId: 2, Origin: 0, Cost: 32, Flags: 1, ExpirationPeriod: Infinity)\n" +
+ "}",
+ entry.toString());
}
@Test
@@ -211,17 +212,17 @@
b.setRoutes(a.getRoutes());
assertEquals("RibEntry{\n" +
- " Name: /another/prefix\n" +
- " Route(FaceId: 1, Origin: 128, Cost: 100, Flags: 2, ExpirationPeriod: 10000 milliseconds)\n" +
- " Route(FaceId: 2, Origin: 0, Cost: 32, Flags: 1, ExpirationPeriod: Infinity)\n" +
- "}",
- b.toString());
+ " Name: /another/prefix\n" +
+ " Route(FaceId: 1, Origin: 128, Cost: 100, Flags: 2, ExpirationPeriod: 10000 milliseconds)\n" +
+ " Route(FaceId: 2, Origin: 0, Cost: 32, Flags: 1, ExpirationPeriod: Infinity)\n" +
+ "}",
+ b.toString());
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
- private RibEntry newRibEntry(String name, int nRoutes, boolean isInfiniteSecond) {
+ private RibEntry newRibEntry(final String name, final int nRoutes, final boolean isInfiniteSecond) {
RibEntry entry = new RibEntry();
entry.setName(new Name(name));
@@ -241,8 +242,7 @@
route2.setFlags(RouteFlags.CHILD_INHERIT.toInteger());
if (isInfiniteSecond) {
route2.setExpirationPeriod(Route.INFINITE_EXPIRATION_PERIOD);
- }
- else {
+ } else {
route2.setExpirationPeriod(5000);
}
entry.addRoute(route2);
@@ -251,7 +251,8 @@
return entry;
}
- private void assertRibEntry(RibEntry entry, String name, int nRoutes, boolean isInfiniteSecond) throws Exception {
+ private void assertRibEntry(final RibEntry entry, final String name, final int nRoutes,
+ final boolean isInfiniteSecond) throws Exception {
assertEquals(entry.getName().toUri(), name);
assertEquals(entry.getRoutes().size(), nRoutes);
@@ -278,8 +279,7 @@
if (isInfiniteSecond) {
assertEquals(item.getExpirationPeriod(), Route.INFINITE_EXPIRATION_PERIOD);
assertEquals(item.hasInfiniteExpirationPeriod(), true);
- }
- else {
+ } else {
assertEquals(item.getExpirationPeriod(), 5000);
assertEquals(item.hasInfiniteExpirationPeriod(), false);
}
diff --git a/src/test/java/com/intel/jndn/management/types/StrategyChoiceTest.java b/src/test/java/com/intel/jndn/management/types/StrategyChoiceTest.java
index 077d91c..1940b41 100644
--- a/src/test/java/com/intel/jndn/management/types/StrategyChoiceTest.java
+++ b/src/test/java/com/intel/jndn/management/types/StrategyChoiceTest.java
@@ -24,16 +24,16 @@
import static org.junit.Assert.assertEquals;
/**
- * Test StrategyChoice encoding/decoding
+ * Test StrategyChoice encoding/decoding.
*
* @author Andrew Brown <andrew.brown@intel.com>
*/
public class StrategyChoiceTest {
- ByteBuffer TestStrategyChoice;
+ private ByteBuffer testStrategyChoiceWire;
@Before
public void setUp() throws Exception {
- TestStrategyChoice = TestHelper.bufferFromIntArray(new int[] {
+ testStrategyChoiceWire = TestHelper.bufferFromIntArray(new int[]{
0x80, 0x39, 0x07, 0x0e, 0x08, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x08, 0x05, 0x77,
0x6f, 0x72, 0x6c, 0x64, 0x6b, 0x27, 0x07, 0x25, 0x08, 0x04, 0x73, 0x6f, 0x6d, 0x65,
0x08, 0x03, 0x6e, 0x6f, 0x6e, 0x08, 0x08, 0x65, 0x78, 0x69, 0x73, 0x74, 0x69, 0x6e,
@@ -47,16 +47,15 @@
StrategyChoice strategyChoice = new StrategyChoice();
strategyChoice
.setName(new Name("/hello/world"))
- .setStrategy(new Name("/some/non/existing/strategy/name"))
- ;
+ .setStrategy(new Name("/some/non/existing/strategy/name"));
ByteBuffer wire = strategyChoice.wireEncode().buf();
- assertEquals(TestStrategyChoice, wire);
+ assertEquals(testStrategyChoiceWire, wire);
}
@Test
public void testDecode() throws EncodingException {
- StrategyChoice strategyChoice = new StrategyChoice(TestStrategyChoice);
+ StrategyChoice strategyChoice = new StrategyChoice(testStrategyChoiceWire);
assertEquals("/hello/world", strategyChoice.getName().toUri());
assertEquals("/some/non/existing/strategy/name", strategyChoice.getStrategy().toUri());
}