mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
refresh test: ttl,etc...
This commit is contained in:
1 parent
dc060c2fc2
commit
fafde2b015
14 files changed
+307
-347
No files matched your search
@@ -6,6 +6,8 @@ import org.junit.Test;
|
||||
import packet.Interest;
|
||||
import packet.PacketException;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/*
|
||||
@@ -22,11 +24,11 @@ public class CanBePrefixTest {
|
||||
@Test
|
||||
public void TestCanBePrefix_GetCanBePrefix() {
|
||||
CanBePrefix can = new CanBePrefix();
|
||||
// System.out.println(can.getCanBePrefix());
|
||||
System.out.println(can.getCanBePrefix());
|
||||
assertFalse(can.getCanBePrefix());
|
||||
can.setCanBePrefix(true);
|
||||
// System.out.println(can.getCanBePrefix());
|
||||
// System.out.println(can.isInitial());
|
||||
System.out.println(can.getCanBePrefix());
|
||||
System.out.println(can.isInitial());
|
||||
assertEquals(can.getCanBePrefix(),can.isInitial());
|
||||
}
|
||||
|
||||
@@ -41,9 +43,9 @@ public class CanBePrefixTest {
|
||||
encoder.encoderReset(new SizeT(MaxPacketSize), new SizeT(0));
|
||||
can.wireEncode(encoder);
|
||||
byte[] buf = encoder.getBuffer();
|
||||
System.out.println(buf);
|
||||
System.out.println(Arrays.toString(buf));
|
||||
Block block = Block.createBlockByBuffer(buf, false);
|
||||
System.out.println(block);
|
||||
System.out.println(" block: "+block.getType()+","+block.getLength()+","+Arrays.toString(block.getValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,9 +59,9 @@ public class CanBePrefixTest {
|
||||
encoder.encoderReset(new SizeT(MaxPacketSize), new SizeT(0));
|
||||
can.wireEncode(encoder);
|
||||
byte[] buf = encoder.getBuffer();
|
||||
System.out.println("interest buf:"+buf);
|
||||
System.out.println(Arrays.toString(buf));
|
||||
Block block = Block.createBlockByBuffer(buf, false);
|
||||
System.out.println("interest block:"+block);
|
||||
System.out.println(" block: "+block.getType()+","+block.getLength()+","+Arrays.toString(block.getValue()));
|
||||
|
||||
InterestLifeTime interest1 = new InterestLifeTime();
|
||||
interest1.wireDecode(block);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class CongestionMarkTest {
|
||||
public void TestCongestionMark_GetCongestionLevel() {
|
||||
CongestionMark congestionMark = new CongestionMark();
|
||||
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
||||
congestionMark.setCongestionLevel(1248355635356896986L);
|
||||
congestionMark.setCongestionLevel(Long.MAX_VALUE);
|
||||
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
||||
System.out.println("interest:"+congestionMark.isInitial());
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class CongestionMarkTest {
|
||||
public void TestCongestionMark_WireEncode() throws EncoderException, ComponentException, BlockException {
|
||||
CongestionMark congestionMark = new CongestionMark();
|
||||
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
||||
congestionMark.setCongestionLevel(1248355635356896986L);
|
||||
congestionMark.setCongestionLevel(Long.MAX_VALUE);
|
||||
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
||||
System.out.println("interest:"+congestionMark.isInitial());
|
||||
|
||||
@@ -49,7 +49,7 @@ public class CongestionMarkTest {
|
||||
public void TestCongestionMark_WireDecode() throws EncoderException, ComponentException, BlockException, PacketException {
|
||||
CongestionMark congestionMark = new CongestionMark();
|
||||
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
||||
congestionMark.setCongestionLevel(1248355635356896986L);
|
||||
congestionMark.setCongestionLevel(Long.MAX_VALUE);
|
||||
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
||||
System.out.println("interest:"+congestionMark.isInitial());
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class FreshnessPeriodTest {
|
||||
public void getFreshnessPeriod() {
|
||||
FreshnessPeriod fresh = new FreshnessPeriod();
|
||||
System.out.println("interest:"+fresh.getFreshnessPeriod());
|
||||
fresh.setFreshnessPeriod(1234848876468746468L);
|
||||
fresh.setFreshnessPeriod(Long.MAX_VALUE);
|
||||
System.out.println("interest:"+fresh.getFreshnessPeriod());
|
||||
System.out.println("interest:"+fresh.isInitial());
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class FreshnessPeriodTest {
|
||||
public void TestFreshnessPeriod_WireEncode() throws EncoderException, ComponentException, BlockException {
|
||||
FreshnessPeriod fresh = new FreshnessPeriod();
|
||||
System.out.println("interest:"+fresh.getFreshnessPeriod());
|
||||
fresh.setFreshnessPeriod(1234848876468746468L);
|
||||
fresh.setFreshnessPeriod(Long.MAX_VALUE);
|
||||
System.out.println("interest:"+fresh.getFreshnessPeriod());
|
||||
System.out.println("interest:"+fresh.isInitial());
|
||||
|
||||
@@ -47,7 +47,7 @@ public class FreshnessPeriodTest {
|
||||
public void TestFreshnessPeriod_WireDecode() throws EncoderException, ComponentException, BlockException {
|
||||
FreshnessPeriod fresh = new FreshnessPeriod();
|
||||
System.out.println("interest:"+fresh.getFreshnessPeriod());
|
||||
fresh.setFreshnessPeriod(1234848876468746468L);
|
||||
fresh.setFreshnessPeriod(Long.MAX_VALUE);
|
||||
System.out.println("interest:"+fresh.getFreshnessPeriod());
|
||||
System.out.println("interest:"+fresh.isInitial());
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ public class HopLimitTest {
|
||||
public void TestHopLimit_GetHopLimit() {
|
||||
HopLimit hop = new HopLimit();
|
||||
System.out.println("interest;"+hop.getHopLimit());
|
||||
hop.setHopLimit(1234848876468746468L);
|
||||
assertEquals(hop.getHopLimit(),1234848876468746468L);
|
||||
hop.setHopLimit(Long.MAX_VALUE);
|
||||
assertEquals(hop.getHopLimit(),Long.MAX_VALUE);
|
||||
assertTrue(hop.isInitial());
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ public class HopLimitTest {
|
||||
public void TestHopLimit_WireEncode() throws ComponentException, EncoderException, BlockException {
|
||||
HopLimit hop = new HopLimit();
|
||||
System.out.println("interest;"+hop.getHopLimit());
|
||||
hop.setHopLimit(1234848876468746468L);
|
||||
assertEquals(hop.getHopLimit(),1234848876468746468L);
|
||||
hop.setHopLimit(Long.MAX_VALUE);
|
||||
assertEquals(hop.getHopLimit(),Long.MAX_VALUE);
|
||||
assertTrue(hop.isInitial());
|
||||
|
||||
Encoder encoder = new Encoder();
|
||||
@@ -47,8 +47,8 @@ public class HopLimitTest {
|
||||
public void TestHopLimit_WireDecode() throws EncoderException, ComponentException, BlockException {
|
||||
HopLimit hop = new HopLimit();
|
||||
System.out.println("interest;"+hop.getHopLimit());
|
||||
hop.setHopLimit(1234848876468746468L);
|
||||
assertEquals(hop.getHopLimit(),1234848876468746468L);
|
||||
hop.setHopLimit(Long.MAX_VALUE);
|
||||
assertEquals(hop.getHopLimit(),Long.MAX_VALUE);
|
||||
assertTrue(hop.isInitial());
|
||||
|
||||
Encoder encoder = new Encoder();
|
||||
|
||||
@@ -65,17 +65,17 @@ public class MustBeRefreshTest {
|
||||
must.setMustBeRefresh(true);
|
||||
must.wireEncode(encoder);
|
||||
byte[] buf = encoder.getBuffer();
|
||||
System.out.println("buf"+buf);
|
||||
System.out.println("buf"+Arrays.toString(buf));
|
||||
|
||||
must.setMustBeRefresh(false);
|
||||
must.wireEncode(encoder);
|
||||
buf = encoder.getBuffer();
|
||||
System.out.println("buf"+buf);
|
||||
System.out.println("buf"+Arrays.toString(buf));
|
||||
|
||||
Block block = Block.createBlockByBuffer(buf, false);
|
||||
MustBeRefresh must1 = new MustBeRefresh();
|
||||
must1.wireDecode(block);
|
||||
System.out.println("must1:"+must1.getMustBeRefresh()+must1.isInitial());
|
||||
System.out.println("must1:"+must1.getMustBeRefresh()+" "+must1.isInitial());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,18 +26,19 @@ public class NonceTest {
|
||||
// nonce.setNonce(18446744073709551615L);
|
||||
nonce.setNonce(0);
|
||||
System.out.println("nonce:"+nonce.getNonce());
|
||||
System.out.println(nonce.isInitial());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestNonce_RefreshNonce() {
|
||||
Nonce nonce = new Nonce();
|
||||
nonce.setNonce(1844674407370955161L);
|
||||
nonce.setNonce(Long.MAX_VALUE);
|
||||
nonce.setNonce(0);
|
||||
System.out.println("nonce:"+nonce.getNonce());
|
||||
nonce.refreshNonce();;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
nonce.refreshNonce();;
|
||||
System.out.println("nonce"+nonce.getNonce());
|
||||
System.out.println("nonce: "+nonce.getNonce());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,13 @@ public class TTLTest {
|
||||
Encoder encoder = new Encoder();
|
||||
encoder.encoderReset(new SizeT(MaxPacketSize), new SizeT(0));
|
||||
TTL ttl = new TTL();
|
||||
ttl.setTtl(15346343413545L);
|
||||
ttl.setTtl(Long.MAX_VALUE);
|
||||
ttl.wireEncode(encoder);
|
||||
byte[] buf = encoder.getBuffer();
|
||||
Block block = Block.createBlockByBuffer(buf, false);
|
||||
TTL newttl = new TTL();
|
||||
newttl.buildTTLByBlock(block);
|
||||
assertEquals(newttl.ttl(),15346343413545L);
|
||||
assertEquals(newttl.ttl(),Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -38,7 +38,7 @@ public class TTLTest {
|
||||
Encoder encoder = new Encoder();
|
||||
encoder.encoderReset(new SizeT(MaxPacketSize), new SizeT(0));
|
||||
TTL ttl = new TTL();
|
||||
ttl.setTtl(15346343413545L);
|
||||
ttl.setTtl(Long.MAX_VALUE);
|
||||
ttl.wireEncode(encoder);
|
||||
byte[] buf = encoder.getBuffer();
|
||||
Block block = Block.createBlockByBuffer(buf, false);
|
||||
@@ -51,13 +51,13 @@ public class TTLTest {
|
||||
Encoder encoder = new Encoder();
|
||||
encoder.encoderReset(new SizeT(MaxPacketSize), new SizeT(0));
|
||||
TTL ttl = new TTL();
|
||||
ttl.setTtl(15346343413545L);
|
||||
ttl.setTtl(Long.MAX_VALUE);
|
||||
ttl.wireEncode(encoder);
|
||||
byte[] buf = encoder.getBuffer();
|
||||
System.out.println("TTL buf:"+ Arrays.toString(buf));
|
||||
Block block = Block.createBlockByBuffer(buf, false);
|
||||
TTL newttl1 = new TTL();
|
||||
newttl1.wireDecode(block);
|
||||
assertEquals(newttl1.ttl(),15346343413545L);
|
||||
assertEquals(newttl1.ttl(),Long.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user