add test: IdentifierFieldTest

This commit is contained in:
free will committed 2021-03-29 20:28:04 +08:00
1 parent 4e8193e275
commit dc060c2fc2
9 files changed
+392 -360

No files matched your search

@@ -0,0 +1,40 @@
package component;
import encoding.*;
import org.junit.Test;
/*
* @Author: Wang Feng
* @Description:
* @Version: 1.0.0
* @Date: 17:23 2021/3/29
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
*/
public class IdentifierFieldTest {
@Test
public void TestIdentifierField_WireEncode() throws ComponentException, EncoderException, BlockException {
IdentifierWrapper wrapper=new IdentifierWrapper().
createCommonIdentifierByString("/min/pku/sz");
IdentifierWrapper wrapper1=new IdentifierWrapper(new VlInt(105),"/install/mnfd");
IdentifierWrapper wrapper2=new IdentifierWrapper(new VlInt(106),"/1");
IdentifierField field=new IdentifierField();
field.addIdentifier(wrapper);
field.addIdentifier(wrapper1);
field.addIdentifier(wrapper2);
for (int i = 0; i < field.getIdentifiers().length(); i++) {
System.out.println(field.getIdentifiers().getElement(i).toUri());
}
Encoder encoder=new Encoder();
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize),new SizeT(0));
field.wireEncode(encoder);
byte[] buf=encoder.getBuffer();
Block block=new Block(buf,false);
IdentifierField field1=new IdentifierField();
System.out.println(field1.wireDecode(block));
for (int i = 0; i < field1.getIdentifiers().length(); i++) {
System.out.println(field1.getIdentifiers().getElement(i).toUri());
}
}
}
@@ -162,9 +162,9 @@ public class IdentifierWrapperTest {
@Test
public void TestCreateIdentifierWrapperByTypeAndIdentifier() throws ComponentException {
Identifier identifier=new Identifier("/min/pku/王");
for (int i = 100; i < 200; i++) {
for (int i = 199; i >0; i--) {
IdentifierWrapper got=new IdentifierWrapper(new VlInt(i),identifier);
System.out.println(got.toUri());
System.out.println(i+":"+got.toUri());
}
}
}