From c48f963d9aeacfac0dbbeda4dac3207cc262ee31 Mon Sep 17 00:00:00 2001 From: free will <2647778488@qq.com> Date: Thu, 25 Mar 2021 15:20:27 +0800 Subject: [PATCH] add test: InterestLifeTimeTest --- .../java/component/InterestLifeTimeTest.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/test/java/component/InterestLifeTimeTest.java diff --git a/src/test/java/component/InterestLifeTimeTest.java b/src/test/java/component/InterestLifeTimeTest.java new file mode 100644 index 0000000..e5e2f60 --- /dev/null +++ b/src/test/java/component/InterestLifeTimeTest.java @@ -0,0 +1,65 @@ +package component; + +import encoding.*; +import org.junit.Test; + +import java.util.Arrays; + +/* + * @Author: Wang Feng + * @Description: + * @Version: 1.0.0 + * @Date: 15:03 2021/3/25 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +public class InterestLifeTimeTest { + @Test + public void TestInterestLifeTime_GetInterestLifeTime(){ + InterestLifeTime interestLifeTime=new InterestLifeTime(); + System.out.println(interestLifeTime.getInterestLifeTime()); + System.out.println(interestLifeTime.isInitial()); + interestLifeTime.setInterestLifeTime(12365484613215634L); + System.out.println(interestLifeTime.getInterestLifeTime()); + System.out.println(interestLifeTime.isInitial()); + } + + @Test + public void TestInterestLifeTime_WireEncode() throws EncoderException, ComponentException, BlockException { + InterestLifeTime interestLifeTime=new InterestLifeTime(); + System.out.println(interestLifeTime.getInterestLifeTime()); + System.out.println(interestLifeTime.isInitial()); + interestLifeTime.setInterestLifeTime(12365484613215634L); + System.out.println(interestLifeTime.getInterestLifeTime()); + System.out.println(interestLifeTime.isInitial()); + Encoder encoder=new Encoder(); + encoder.encoderReset(new SizeT(Encoder.MaxPacketSize),new SizeT(0)); + interestLifeTime.wireEncode(encoder); + byte[] buffer=encoder.getBuffer(); + System.out.println("interest buf: "+Arrays.toString(buffer)); + Block block= Block.createBlockByBuffer(buffer,false); + System.out.println("interest block: "+block.getType()+", " + +block.getLength()+", "+Arrays.toString(block.getValue())); + } + + @Test + public void TestInterestLifeTime_WireDecode()throws EncoderException, ComponentException, BlockException{ + InterestLifeTime interestLifeTime=new InterestLifeTime(); + System.out.println(interestLifeTime.getInterestLifeTime()); + System.out.println(interestLifeTime.isInitial()); + interestLifeTime.setInterestLifeTime(12365484613215634L); + System.out.println(interestLifeTime.getInterestLifeTime()); + System.out.println(interestLifeTime.isInitial()); + Encoder encoder=new Encoder(); + encoder.encoderReset(new SizeT(Encoder.MaxPacketSize),new SizeT(0)); + interestLifeTime.wireEncode(encoder); + byte[] buffer=encoder.getBuffer(); + System.out.println("interest buf: "+Arrays.toString(buffer)); + Block block= Block.createBlockByBuffer(buffer,false); + System.out.println("interest block: "+block.getType()+", " + +block.getLength()+", "+Arrays.toString(block.getValue())); + InterestLifeTime interestLifeTime1=new InterestLifeTime(); + interestLifeTime1.wireDecode(block); + System.out.println("interest1 time: "+interestLifeTime1.getInterestLifeTime()); + System.out.println("interest1 ini: "+interestLifeTime1.isInitial()); + } +}