add: ControlBaseTest

This commit is contained in:
ChessNineeee
2021-05-14 13:27:08 +08:00
parent fd783fa807
commit dee974b0df
2 changed files with 43 additions and 0 deletions
@@ -162,6 +162,11 @@ public class ControlParameters implements IEncodingAble {
Block newBlock = elementContainer.getBlock(i);
int type = newBlock.getType().getVlIntValue2Int();
switch (type) {
case TLV.TlvManagementLogicFaceId:
if (!this.controlParameterLogicFaceId.wireDecode(newBlock)) {
return false;
}
break;
case TLV.TlvManagementPrefix:
if (!this.controlParameterPrefix.wireDecode(newBlock)) {
return false;
+38
View File
@@ -0,0 +1,38 @@
package mgmt;
import component.*;
import org.junit.Test;
import org.slf4j.LoggerFactory;
import packet.Interest;
public class CommandBaseTest {
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(CommandBaseTest.class);
@Test
public void testCreateAndParseCommand(){
try{
ControlParameters parameters = new ControlParameters();
Identifier prefix = new Identifier("/pku/sz");
ControlParameterPrefix controlParameterPrefix = new ControlParameterPrefix(prefix);
parameters.controlParameterPrefix = controlParameterPrefix;
parameters.controlParameterLogicFaceId.setLogicFaceId(1);
parameters.controlParameterCost.setCost(1);
parameters.controlParameterCapacity.setCapacity(1);
parameters.controlParameterCount.setCount(1);
parameters.controlParameterExpireTime.setExpireTime(1);
parameters.controlParameterUri.setUri("/pku/sz");
parameters.controlParameterLocalUri.setLocalUri("/local");
parameters.controlParameterLogicFacePersistency.setPersistency(1);
parameters.controlParameterUriScheme.setUriScheme(1);
parameters.controlParameterMtu.setMtu(1);
Interest interest = CommandBase.createCommandIdentifierInterest(parameters, "/cp1/test");
ControlParameters cp = CommandBase.parseControlParameters(interest);
System.out.println(cp);
}catch (Exception ex){
logger.debug(ex.getMessage());
}
}
}