Commit c4df8f4c authored by garciay's avatar garciay

Validate SREM/SSEM test suite

parent 5f578575
......@@ -20,19 +20,41 @@ public class LibItsMapemSpatem_asn1 extends LibIts_asn1 {
_encodingName = "MAPEM_SPATEM_ETSI";
}
@Override
public TriMessage encode(final Value template) {
_logger.entering("LibItsMapemSpatem_asn1", "encode", template.getType().getName());
TriMessage result;
String type = String.format("%s.%s", _encodingName, template.getType().getName());
if (template.getType().getName().endsWith("SREM")) {
_encodingName = "MAPEM_PDU_Descriptions";
result = super.encode(template);
} else {
_encodingName = "SPATEM_PDU_Descriptions";
result = super.encode(template);
}
_encodingName = "MAPEM_SPATEM_ETSI";
return result;
}
@Override
public Value decode(final TriMessage message, final Type decodingHypothesis) {
_logger.entering("LibItsMapemSpatem_asn1", "decode", decodingHypothesis.getName());
Value result;
if (decodingHypothesis.getName().endsWith("MAPEM")) {
Type type = getTypeForName("MAPEM_PDU_Descriptions.MAPEM");
return super.decode(message, type);
} else if (decodingHypothesis.getName().endsWith("SPATEM")) {
_encodingName = "MAPEM_PDU_Descriptions";
result = super.decode(message, type);
} else {
Type type = getTypeForName("SPATEM_PDU_Descriptions.SPATEM");
return super.decode(message, type);
_encodingName = "SPATEM_PDU_Descriptions";
result = super.decode(message, type);
}
_encodingName = "MAPEM_SPATEM_ETSI";
return super.decode(message, decodingHypothesis);
return result;
}
} // End of class LibItsMapemSpatem_asn1
......@@ -24,15 +24,31 @@ public class LibItsSremSsem_asn1 extends LibIts_asn1 {
public Value decode(final TriMessage message, final Type decodingHypothesis) {
_logger.entering("LibItsSremSsem_asn1", "decode", decodingHypothesis.getName());
if (decodingHypothesis.getName().endsWith("sremPacket")) {
Type type = getTypeForName("SREM_PDU_Descriptions.MAPEM");
if (decodingHypothesis.getName().endsWith("SREM")) {
Type type = getTypeForName("SREM_PDU_Descriptions.SREM");
return super.decode(message, type);
} else if (decodingHypothesis.getName().endsWith("ssemPacket")) {
Type type = getTypeForName("SSEM_PDU_Descriptions.SPATEM");
} else {
Type type = getTypeForName("SSEM_PDU_Descriptions.SSEM");
return super.decode(message, type);
}
}
@Override
public TriMessage encode(final Value template) {
_logger.entering("LibItsSremSsem_asn1", "encode", template.getType().getName());
TriMessage result;
String type = String.format("%s.%s", _encodingName, template.getType().getName());
if (template.getType().getName().endsWith("SREM")) {
_encodingName = "SREM_PDU_Descriptions";
result = super.encode(template);
} else {
_encodingName = "SREM_PDU_Descriptions";
result = super.encode(template);
}
_encodingName = "SREM_SSEM_ETSI";
return super.decode(message, decodingHypothesis);
return result;
}
} // End of class LibItsSremSsem_asn1
......@@ -59,16 +59,7 @@ public class LibIts_asn1 implements TciCDProvided {
msg.setEncodedMessage(message.getEncodedMessage());
if (_logger.isLoggable(Level.ALL)) ByteHelper.dump("LibIts_asn1.decode: ", msg.getEncodedMessage());
String type = null;
if (_encodingName.equals("MAPEM_SPATEM_ETSI")) {
if (decodingHypothesis.getName().endsWith("MAPEM")) {
type = String.format("%s.%s", "MAPEM_PDU_Descriptions", decodingHypothesis.getName());
} else {
type = String.format("%s.%s", "SPATEM_PDU_Descriptions", decodingHypothesis.getName());
}
} else {
type = String.format("%s.%s", _encodingName, decodingHypothesis.getName());
}
String type = String.format("%s.%s", _encodingName, decodingHypothesis.getName());
_logger.info("Type: " + type);
Type asnOriginalType = getTypeForName(type);
// Check which type class the decoding hypothesis is of
......@@ -92,17 +83,17 @@ public class LibIts_asn1 implements TciCDProvided {
internalASNEncodecValue = (RecordValue)asnOriginalType.newInstance();
String[] fields = ((RecordValue)internalASNEncodecValue).getFieldNames();
RecordValue asn1Value = (RecordValue)template;
for(String field: fields) {
_logger.info(String.format("Process field %s", field));
Value fieldValue = asn1Value.getField(field);
if(fieldValue.notPresent()) {
_logger.info(String.format("Field %s was omitted", field));
((RecordValue)internalASNEncodecValue).setFieldOmitted(field);
} else {
_logger.info(String.format("Field %s was added", field));
((RecordValue)internalASNEncodecValue).setField(field, fieldValue);
}
} // End of 'for' statement
for(String field: fields) {
_logger.info(String.format("Process field %s", field));
Value fieldValue = asn1Value.getField(field);
if(fieldValue.notPresent()) {
_logger.info(String.format("Field %s was omitted", field));
((RecordValue)internalASNEncodecValue).setFieldOmitted(field);
} else {
_logger.info(String.format("Field %s was added", field));
((RecordValue)internalASNEncodecValue).setField(field, fieldValue);
}
} // End of 'for' statement
break;
case TciTypeClass.INTEGER:
internalASNEncodecValue = (IntegerValueEx)asnOriginalType.newInstance();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment