Update management protocol to be compatible with NFD 0.6.2
Change-Id: I85975151d969901b842c83c649ccd86059488274
diff --git a/src/test/java/com/intel/jndn/management/NfdcIT.java b/src/test/java/com/intel/jndn/management/NfdcIT.java
index 350c79a..f1deef1 100644
--- a/src/test/java/com/intel/jndn/management/NfdcIT.java
+++ b/src/test/java/com/intel/jndn/management/NfdcIT.java
@@ -13,7 +13,6 @@
*/
package com.intel.jndn.management;
-import com.intel.jndn.management.enums.LocalControlHeader;
import com.intel.jndn.management.enums.Strategies;
import com.intel.jndn.management.types.RibEntry;
import com.intel.jndn.management.types.StrategyChoice;
@@ -62,7 +61,7 @@
@Before
public void setUp() throws SecurityException {
face = new Face("localhost");
- mockFace = new MockFace();
+ mockFace = new MockFace(new MockFace.Options().setEnablePacketLogging(false).setEnableRegistrationReply(false));
noKeyChainFace = new Face("localhost"); // don't set command signing info
KeyChain keyChain = MockKeyChain.configure(new Name("/tmp/identity"));
face.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());
@@ -226,7 +225,7 @@
@Test
public void testFailOfSetStrategyWithoutKeychain() throws Exception {
- exception.expect(IllegalArgumentException.class);
+ exception.expect(NullPointerException.class);
Nfdc.setStrategy(noKeyChainFace, new Name("/test"), Strategies.BEST_ROUTE);
}
@@ -256,19 +255,6 @@
Nfdc.setStrategy(mockFace, new Name("/"), Strategies.BROADCAST);
}
- /**
- * LocalControlHeader works only with NFD < 0.3.4, broken otherwise.
- */
- @Test(expected = ManagementException.class)
- public void testLocalControlHeader() throws Exception {
- Nfdc.enableLocalControlHeader(face, LocalControlHeader.INCOMING_FACE_ID);
- Thread.sleep(1000); // strategy takes a while to register
-
- // TODO: add asserts
-
- Nfdc.disableLocalControlHeader(face, LocalControlHeader.INCOMING_FACE_ID);
- }
-
@Test
public void testGetChannelStatus() throws Exception {
assertFalse(Nfdc.getChannelStatusList(face).isEmpty());
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 a960e15..0b09dee 100644
--- a/src/test/java/com/intel/jndn/management/types/FaceStatusTest.java
+++ b/src/test/java/com/intel/jndn/management/types/FaceStatusTest.java
@@ -24,6 +24,7 @@
import java.nio.ByteBuffer;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* Test encode/decode of FaceStatus.
@@ -36,40 +37,98 @@
@Before
public void setUp() throws Exception {
testFaceStatusWire = TestHelper.bufferFromIntArray(new int[] {
- 0x80, 0x5e, 0x69, 0x01, 0x64, 0x72, 0x15, 0x74, 0x63, 0x70,
+ 0x80, 0x6a, 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,
0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32,
0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32, 0x3a, 0x35, 0x35, 0x35,
0x35, 0x35, 0x6d, 0x02, 0x27, 0x10, 0x84, 0x01, 0x01, 0x85,
- 0x01, 0x01, 0x86, 0x01, 0x01, 0x90, 0x01, 0x0a, 0x91, 0x01,
- 0xc8, 0x97, 0x01, 0x01, 0x92, 0x02, 0x0b, 0xb8, 0x93, 0x01,
- 0x04, 0x98, 0x01, 0x02, 0x94, 0x04, 0x4f, 0x41, 0xe7, 0x7b,
- 0x95, 0x04, 0x3b, 0x8d, 0x37, 0x30,
+ 0x01, 0x01, 0x86, 0x01, 0x01, 0x87, 0x01, 0x05, 0x88, 0x01,
+ 0x07, 0x89, 0x01, 0x09, 0x90, 0x01, 0x0a, 0x91, 0x01, 0xc8,
+ 0x97, 0x01, 0x01, 0x92, 0x02, 0x0b, 0xb8, 0x93, 0x01, 0x04,
+ 0x98, 0x01, 0x02, 0x94, 0x04, 0x4f, 0x41, 0xe7, 0x7b, 0x95,
+ 0x04, 0x3b, 0x8d, 0x37, 0x30, 0x6c, 0x01, 0x07,
});
}
@Test
- public void testEncode() throws Exception {
+ public void testSettersGetters() throws Exception {
FaceStatus status = new FaceStatus();
- status.setFaceId(100)
+ status
+ .setFaceId(100)
.setRemoteUri("tcp4://192.0.2.1:6363")
.setLocalUri("tcp4://192.0.2.2:55555")
.setFaceScope(FaceScope.LOCAL)
.setFacePersistency(FacePersistency.ON_DEMAND)
.setLinkType(LinkType.MULTI_ACCESS)
.setExpirationPeriod(10000)
+ .setBaseCongestionMarkingInterval(5)
+ .setDefaultCongestionThreshold(7)
+ .setMtu(9)
.setNInInterests(10)
- .setNInDatas(200)
+ .setNInData(200)
.setNInNacks(1)
.setNOutInterests(3000)
- .setNOutDatas(4)
+ .setNOutData(4)
.setNOutNacks(2)
.setNInBytes(1329719163)
- .setNOutBytes(999110448);
+ .setNOutBytes(999110448)
+ .setFlags(0x7);
+
+ assertEquals(100, status.getFaceId());
+ assertEquals("tcp4://192.0.2.1:6363", status.getRemoteUri());
+ assertEquals("tcp4://192.0.2.2:55555", status.getLocalUri());
+ assertEquals(FaceScope.LOCAL, status.getFaceScope());
+ assertEquals(FacePersistency.ON_DEMAND, status.getFacePersistency());
+ assertEquals(LinkType.MULTI_ACCESS, status.getLinkType());
+ assertEquals(10000, status.getExpirationPeriod());
+ assertEquals(10, status.getNInInterests());
+ assertEquals(200, status.getNInData());
+ assertEquals(1, status.getNInNacks());
+ assertEquals(3000, status.getNOutInterests());
+ assertEquals(4, status.getNOutData());
+ assertEquals(2, status.getNOutNacks());
+ assertEquals(1329719163, status.getNInBytes());
+ assertEquals(999110448, status.getNOutBytes());
+
+ assertEquals(9, status.getMtu());
+ assertEquals(0x7, status.getFlags());
+ assertEquals(5, status.getBaseCongestionMarkingInterval());
+ assertEquals(7, status.getDefaultCongestionThreshold());
+ assertTrue(status.hasMtu());
+ assertTrue(status.hasBaseCongestionMarkingInterval());
+ assertTrue(status.hasDefaultCongestionThreshold());
+ }
+
+ @Test
+ public void testEncode() throws Exception {
+ FaceStatus status = new FaceStatus();
+ status
+ .setFaceId(100)
+ .setRemoteUri("tcp4://192.0.2.1:6363")
+ .setLocalUri("tcp4://192.0.2.2:55555")
+ .setFaceScope(FaceScope.LOCAL)
+ .setFacePersistency(FacePersistency.ON_DEMAND)
+ .setLinkType(LinkType.MULTI_ACCESS)
+ .setExpirationPeriod(10000)
+ .setBaseCongestionMarkingInterval(5)
+ .setDefaultCongestionThreshold(7)
+ .setMtu(9)
+ .setNInInterests(10)
+ .setNInData(200)
+ .setNInNacks(1)
+ .setNOutInterests(3000)
+ .setNOutData(4)
+ .setNOutNacks(2)
+ .setNInBytes(1329719163)
+ .setNOutBytes(999110448)
+ .setFlags(0x7);
// encode
Blob encoded = status.wireEncode();
+// for (final byte b : encoded.getImmutableArray()) {
+// System.err.format("0x%02x, ", b);
+// }
assertEquals(testFaceStatusWire, encoded.buf());
}
@@ -85,46 +144,64 @@
assertEquals(LinkType.MULTI_ACCESS, status.getLinkType());
assertEquals(10000, status.getExpirationPeriod());
assertEquals(10, status.getNInInterests());
- assertEquals(200, status.getNInDatas());
+ assertEquals(200, status.getNInData());
assertEquals(1, status.getNInNacks());
assertEquals(3000, status.getNOutInterests());
- assertEquals(4, status.getNOutDatas());
+ assertEquals(4, status.getNOutData());
assertEquals(2, status.getNOutNacks());
assertEquals(1329719163, status.getNInBytes());
assertEquals(999110448, status.getNOutBytes());
+
+ assertEquals(9, status.getMtu());
+ assertEquals(0x7, status.getFlags());
+ assertEquals(5, status.getBaseCongestionMarkingInterval());
+ assertEquals(7, status.getDefaultCongestionThreshold());
+ assertTrue(status.hasMtu());
+ assertTrue(status.hasBaseCongestionMarkingInterval());
+ assertTrue(status.hasDefaultCongestionThreshold());
}
@Test
public void testToString() throws Exception {
FaceStatus status = new FaceStatus(testFaceStatusWire);
- assertEquals("FaceStatus(FaceID: 100,\n" +
- "RemoteUri: tcp4://192.0.2.1:6363,\n" +
- "LocalUri: tcp4://192.0.2.2:55555,\n" +
- "ExpirationPeriod: 10000 milliseconds,\n" +
- "FaceScope: LOCAL,\n" +
- "FacePersistency: ON_DEMAND,\n" +
- "LinkType: MULTI_ACCESS,\n" +
- "Counters: { Interests: {in: 10, out: 3000},\n" +
- " Data: {in: 200, out: 4},\n" +
- " Nack: {in: 1, out: 2},\n" +
- " bytes: {in: 1329719163, out: 999110448} }\n" +
- ")",
+ assertEquals(
+ "Face(FaceId: 100,\n" +
+ " RemoteUri: tcp4://192.0.2.1:6363,\n" +
+ " LocalUri: tcp4://192.0.2.2:55555,\n" +
+ " ExpirationPeriod: 10000 milliseconds,\n" +
+ " FaceScope: local,\n" +
+ " FacePersistency: on-demand,\n" +
+ " LinkType: multi-access,\n" +
+ " BaseCongestionMarkingInterval: 5 nanoseconds,\n" +
+ " DefaultCongestionThreshold: 7 bytes,\n" +
+ " Mtu: 9 bytes,\n" +
+ " Flags: 0x7,\n" +
+ " Counters: {Interests: {in: 10, out: 3000},\n" +
+ " Data: {in: 200, out: 4},\n" +
+ " Nacks: {in: 1, out: 2},\n" +
+ " bytes: {in: 1329719163, out: 999110448}}\n" +
+ " )",
status.toString());
status.setExpirationPeriod(0);
- assertEquals("FaceStatus(FaceID: 100,\n" +
- "RemoteUri: tcp4://192.0.2.1:6363,\n" +
- "LocalUri: tcp4://192.0.2.2:55555,\n" +
- "ExpirationPeriod: infinite,\n" +
- "FaceScope: LOCAL,\n" +
- "FacePersistency: ON_DEMAND,\n" +
- "LinkType: MULTI_ACCESS,\n" +
- "Counters: { Interests: {in: 10, out: 3000},\n" +
- " Data: {in: 200, out: 4},\n" +
- " Nack: {in: 1, out: 2},\n" +
- " bytes: {in: 1329719163, out: 999110448} }\n" +
- ")",
+ assertEquals(
+ "Face(FaceId: 100,\n" +
+ " RemoteUri: tcp4://192.0.2.1:6363,\n" +
+ " LocalUri: tcp4://192.0.2.2:55555,\n" +
+ " ExpirationPeriod: infinite,\n" +
+ " FaceScope: local,\n" +
+ " FacePersistency: on-demand,\n" +
+ " LinkType: multi-access,\n" +
+ " BaseCongestionMarkingInterval: 5 nanoseconds,\n" +
+ " DefaultCongestionThreshold: 7 bytes,\n" +
+ " Mtu: 9 bytes,\n" +
+ " Flags: 0x7,\n" +
+ " Counters: {Interests: {in: 10, out: 3000},\n" +
+ " Data: {in: 200, out: 4},\n" +
+ " Nacks: {in: 1, out: 2},\n" +
+ " bytes: {in: 1329719163, out: 999110448}}\n" +
+ " )",
status.toString());
}
}
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 fc2484d..cc2eafe 100644
--- a/src/test/java/com/intel/jndn/management/types/ForwarderStatusTest.java
+++ b/src/test/java/com/intel/jndn/management/types/ForwarderStatusTest.java
@@ -56,10 +56,10 @@
status.setNMeasurementsEntries(1771725298);
status.setNCsEntries(1264968688);
status.setNInInterests(612811615);
- status.setNInDatas(1843576050);
+ status.setNInData(1843576050);
status.setNInNacks(1234);
status.setNOutInterests(952144445);
- status.setNOutDatas(138198826);
+ status.setNOutData(138198826);
status.setNOutNacks(4321);
ByteBuffer wire = status.wireEncode().buf();
@@ -79,10 +79,10 @@
assertEquals(1771725298, status.getNMeasurementsEntries());
assertEquals(1264968688, status.getNCsEntries());
assertEquals(612811615, status.getNInInterests());
- assertEquals(1843576050, status.getNInDatas());
+ assertEquals(1843576050, status.getNInData());
assertEquals(1234, status.getNInNacks());
assertEquals(952144445, status.getNOutInterests());
- assertEquals(138198826, status.getNOutDatas());
+ assertEquals(138198826, status.getNOutData());
assertEquals(4321, status.getNOutNacks());
}
}