Commit c4df8f4c authored by garciay's avatar garciay
Browse files

Validate SREM/SSEM test suite

parent 5f578575
...@@ -20,19 +20,41 @@ public class LibItsMapemSpatem_asn1 extends LibIts_asn1 { ...@@ -20,19 +20,41 @@ public class LibItsMapemSpatem_asn1 extends LibIts_asn1 {
_encodingName = "MAPEM_SPATEM_ETSI"; _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 @Override
public Value decode(final TriMessage message, final Type decodingHypothesis) { public Value decode(final TriMessage message, final Type decodingHypothesis) {
_logger.entering("LibItsMapemSpatem_asn1", "decode", decodingHypothesis.getName()); _logger.entering("LibItsMapemSpatem_asn1", "decode", decodingHypothesis.getName());
Value result;
if (decodingHypothesis.getName().endsWith("MAPEM")) { if (decodingHypothesis.getName().endsWith("MAPEM")) {
Type type = getTypeForName("MAPEM_PDU_Descriptions.MAPEM"); Type type = getTypeForName("MAPEM_PDU_Descriptions.MAPEM");
return super.decode(message, type); _encodingName = "MAPEM_PDU_Descriptions";
} else if (decodingHypothesis.getName().endsWith("SPATEM")) { result = super.decode(message, type);
} else {
Type type = getTypeForName("SPATEM_PDU_Descriptions.SPATEM"); 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 } // End of class LibItsMapemSpatem_asn1
...@@ -24,15 +24,31 @@ public class LibItsSremSsem_asn1 extends LibIts_asn1 { ...@@ -24,15 +24,31 @@ public class LibItsSremSsem_asn1 extends LibIts_asn1 {
public Value decode(final TriMessage message, final Type decodingHypothesis) { public Value decode(final TriMessage message, final Type decodingHypothesis) {
_logger.entering("LibItsSremSsem_asn1", "decode", decodingHypothesis.getName()); _logger.entering("LibItsSremSsem_asn1", "decode", decodingHypothesis.getName());
if (decodingHypothesis.getName().endsWith("sremPacket")) { if (decodingHypothesis.getName().endsWith("SREM")) {
Type type = getTypeForName("SREM_PDU_Descriptions.MAPEM"); Type type = getTypeForName("SREM_PDU_Descriptions.SREM");
return super.decode(message, type); return super.decode(message, type);
} else if (decodingHypothesis.getName().endsWith("ssemPacket")) { } else {
Type type = getTypeForName("SSEM_PDU_Descriptions.SPATEM"); Type type = getTypeForName("SSEM_PDU_Descriptions.SSEM");
return super.decode(message, type); 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 } // End of class LibItsSremSsem_asn1
...@@ -59,16 +59,7 @@ public class LibIts_asn1 implements TciCDProvided { ...@@ -59,16 +59,7 @@ public class LibIts_asn1 implements TciCDProvided {
msg.setEncodedMessage(message.getEncodedMessage()); msg.setEncodedMessage(message.getEncodedMessage());
if (_logger.isLoggable(Level.ALL)) ByteHelper.dump("LibIts_asn1.decode: ", msg.getEncodedMessage()); if (_logger.isLoggable(Level.ALL)) ByteHelper.dump("LibIts_asn1.decode: ", msg.getEncodedMessage());
String type = null; String type = String.format("%s.%s", _encodingName, decodingHypothesis.getName());
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());
}
_logger.info("Type: " + type); _logger.info("Type: " + type);
Type asnOriginalType = getTypeForName(type); Type asnOriginalType = getTypeForName(type);
// Check which type class the decoding hypothesis is of // Check which type class the decoding hypothesis is of
...@@ -92,17 +83,17 @@ public class LibIts_asn1 implements TciCDProvided { ...@@ -92,17 +83,17 @@ public class LibIts_asn1 implements TciCDProvided {
internalASNEncodecValue = (RecordValue)asnOriginalType.newInstance(); internalASNEncodecValue = (RecordValue)asnOriginalType.newInstance();
String[] fields = ((RecordValue)internalASNEncodecValue).getFieldNames(); String[] fields = ((RecordValue)internalASNEncodecValue).getFieldNames();
RecordValue asn1Value = (RecordValue)template; RecordValue asn1Value = (RecordValue)template;
for(String field: fields) { for(String field: fields) {
_logger.info(String.format("Process field %s", field)); _logger.info(String.format("Process field %s", field));
Value fieldValue = asn1Value.getField(field); Value fieldValue = asn1Value.getField(field);
if(fieldValue.notPresent()) { if(fieldValue.notPresent()) {
_logger.info(String.format("Field %s was omitted", field)); _logger.info(String.format("Field %s was omitted", field));
((RecordValue)internalASNEncodecValue).setFieldOmitted(field); ((RecordValue)internalASNEncodecValue).setFieldOmitted(field);
} else { } else {
_logger.info(String.format("Field %s was added", field)); _logger.info(String.format("Field %s was added", field));
((RecordValue)internalASNEncodecValue).setField(field, fieldValue); ((RecordValue)internalASNEncodecValue).setField(field, fieldValue);
} }
} // End of 'for' statement } // End of 'for' statement
break; break;
case TciTypeClass.INTEGER: case TciTypeClass.INTEGER:
internalASNEncodecValue = (IntegerValueEx)asnOriginalType.newInstance(); internalASNEncodecValue = (IntegerValueEx)asnOriginalType.newInstance();
......
Supports Markdown
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