Files
min-dev-java/src/test/java/component/HopLimitTest.java
T
2021-03-31 10:44:47 +08:00

68 lines
2.5 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package component;
import encoding.*;
import org.junit.Test;
import java.util.Arrays;
import static org.junit.Assert.*;
/*
* @Author: feng Zhao
* @Description:
* @Version: 1.0.0
* @Date: 16:09 2021/3/25
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
*/
public class HopLimitTest {
int MaxPacketSize = 8800;
@Test
public void TestHopLimit_GetHopLimit() {
HopLimit hop = new HopLimit();
System.out.println("interest;"+hop.getHopLimit());
hop.setHopLimit(Long.MAX_VALUE);
assertEquals(hop.getHopLimit(),Long.MAX_VALUE);
assertTrue(hop.isInitial());
}
@Test
public void TestHopLimit_WireEncode() throws ComponentException, EncoderException, BlockException {
HopLimit hop = new HopLimit();
System.out.println("interest;"+hop.getHopLimit());
hop.setHopLimit(Long.MAX_VALUE);
assertEquals(hop.getHopLimit(),Long.MAX_VALUE);
assertTrue(hop.isInitial());
Encoder encoder = new Encoder();
encoder.encoderReset(new SizeT(MaxPacketSize), new SizeT(0));
hop.wireEncode(encoder);
byte[] buf = encoder.getBuffer();
System.out.println("HopLimit buf:"+ Arrays.toString(buf));
Block block = Block.createBlockByBuffer(buf, false);
System.out.println("HopLimit block: "+block.getType()+","+block.getLength()+","+Arrays.toString(block.getValue()));
}
@Test
public void TestHopLimit_WireDecode() throws EncoderException, ComponentException, BlockException {
HopLimit hop = new HopLimit();
System.out.println("interest;"+hop.getHopLimit());
hop.setHopLimit(Long.MAX_VALUE);
assertEquals(hop.getHopLimit(),Long.MAX_VALUE);
assertTrue(hop.isInitial());
Encoder encoder = new Encoder();
encoder.encoderReset(new SizeT(MaxPacketSize), new SizeT(0));
hop.wireEncode(encoder);
byte[] buf = encoder.getBuffer();
System.out.println("HopLimit buf:"+ Arrays.toString(buf));
Block block = Block.createBlockByBuffer(buf, false);
System.out.println("HopLimit block: "+block.getType()+","+block.getLength()+","+Arrays.toString(block.getValue()));
InterestLifeTime interest1 = new InterestLifeTime();
interest1.wireDecode(block);
System.out.println("interest1: "+hop.getHopLimit());
System.out.println("interest1: "+hop.isInitial());
}
}