add test: IdentifierTest

This commit is contained in:
free will committed 2021-03-29 16:04:31 +08:00
1 parent 186d7a48f7
commit e0f36a740e
3 files changed
+96 -28

No files matched your search

@@ -0,0 +1,62 @@
package component;
import org.junit.Test;
import util.ByteHelper;
import util.StringHelper;
/*
* @Author: Wang Feng
* @Description:
* @Version: 1.0.0
* @Date: 15:27 2021/3/29
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
*/
public class IdentifierTest {
@Test
public void TestCreateIdentifierByString() throws ComponentException {
String str="/min/pkusz/王锋";
Identifier got=new Identifier(str);
System.out.println(got.size());
String encode=got.toUri();
System.out.println(encode);
System.out.println(StringHelper.unescape(encode));
}
@Test
public void TestIdentifier_Get() throws ComponentException {
String str="/min/王锋";
Identifier got=new Identifier(str);
for (int i = 0; i < got.size(); i++) {
System.out.println(got.get(i).toUri());
}
}
@Test
public void TestIdentifier_GetPrefix() throws ComponentException {
String str="/min/pku/王锋";
Identifier got=new Identifier(str);
for (int i = 0; i < got.size(); i++) {
System.out.println("prefix: "+got.getPrefix(i+1).toUri());
}
}
@Test
public void TestIdentifier_GetSubIdentifier() throws ComponentException {
String str="/min/pku/王锋";
Identifier got=new Identifier(str);
for (int i = 0; i < got.size(); i++) {
System.out.println("prefix: "+got.getSubIdentifier(0,i+1).toUri());
}
System.out.println("prefix: "+got.getSubIdentifier(1,2).toUri());
}
@Test
public void TestIdentifier_Append() throws ComponentException {
String str="/min/pku/王锋";
Identifier got=new Identifier(str);
IdentifierComponent addcomponent=new IdentifierComponent("1");
got.append(addcomponent);
System.out.println(got.toUri());
System.out.println(got.getPrefix(4).toUri());
}
}