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()); } }