mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
component部分方法测试,出现首个byte为负数的情况
This commit is contained in:
1 parent
36c735bc3f
commit
3f1c1e12e8
7 files changed
+489
No files matched your search
@@ -0,0 +1,68 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
import org.junit.Test;
|
||||
import packet.Interest;
|
||||
import packet.PacketException;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/*
|
||||
* @Author: feng Zhao
|
||||
* @Description:
|
||||
* @Version: 1.0.0
|
||||
* @Date: 15:47 2021/3/25
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
|
||||
public class CongestionMarkTest {
|
||||
int MaxPacketSize = 8800;
|
||||
@Test
|
||||
public void TestCongestionMark_GetCongestionLevel() {
|
||||
CongestionMark congestionMark = new CongestionMark();
|
||||
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
||||
congestionMark.setCongestionLevel(1248355635356896986L);
|
||||
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
||||
System.out.println("interest:"+congestionMark.isInitial());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestCongestionMark_WireEncode() throws EncoderException, ComponentException, BlockException {
|
||||
CongestionMark congestionMark = new CongestionMark();
|
||||
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
||||
congestionMark.setCongestionLevel(1248355635356896986L);
|
||||
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
||||
System.out.println("interest:"+congestionMark.isInitial());
|
||||
|
||||
Encoder encoder = new Encoder();
|
||||
encoder.encoderReset(new SizeT(MaxPacketSize), new SizeT(0));
|
||||
congestionMark.wireEncode(encoder);
|
||||
byte[] buf = encoder.getBuffer();
|
||||
System.out.println("CongestionMark buf:"+ Arrays.toString(buf));
|
||||
Block block = Block.createBlockByBuffer(buf, false);
|
||||
System.out.println("CongestionMark block: "+block.getType()+","+block.getLength()+","+Arrays.toString(block.getValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestCongestionMark_WireDecode() throws EncoderException, ComponentException, BlockException, PacketException {
|
||||
CongestionMark congestionMark = new CongestionMark();
|
||||
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
||||
congestionMark.setCongestionLevel(1248355635356896986L);
|
||||
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
||||
System.out.println("interest:"+congestionMark.isInitial());
|
||||
|
||||
Encoder encoder = new Encoder();
|
||||
encoder.encoderReset(new SizeT(MaxPacketSize), new SizeT(0));
|
||||
congestionMark.wireEncode(encoder);
|
||||
byte[] buf = encoder.getBuffer();
|
||||
System.out.println("CongestionMark buf:"+ Arrays.toString(buf));
|
||||
Block block = Block.createBlockByBuffer(buf, false);
|
||||
System.out.println("CongestionMark block: "+block.getType()+","+block.getLength()+","+Arrays.toString(block.getValue()));
|
||||
InterestLifeTime interest1 = new InterestLifeTime();
|
||||
interest1.wireDecode(block);
|
||||
System.out.println("interest1:" + congestionMark.getCongestionLevel());
|
||||
System.out.println("interest1:" + congestionMark.isInitial());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user