mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
add test: InterestLifeTimeTest
This commit is contained in:
1 parent
d6fa359bfe
commit
c48f963d9a
1 file changed
+65
@@ -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());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user