Loading tools/TTworkbenchSupport/TTworkbenchAdapter/XmlDiffExternalFunction/com/testingtech/tri/extfct/XmlDiffExtFctPlugin.java +30 −0 Original line number Diff line number Diff line package com.testingtech.tri.extfct; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.text.MessageFormat; import org.etsi.mts.ttcn.part9.xmldiff.XmlDiff; import org.etsi.ttcn.tci.BooleanValue; import org.etsi.ttcn.tci.RecordOfValue; Loading @@ -7,6 +12,9 @@ import org.etsi.ttcn.tci.UniversalCharstringValue; import com.testingtech.ttcn.annotation.ExternalFunction; import com.testingtech.ttcn.tri.AnnotationsExternalFunctionPlugin; import com.testingtech.util.FileUtil; import de.tu_berlin.cs.uebb.muttcn.runtime.TestCaseError; @ExternalFunction.Definitions(XmlDiffExtFctPlugin.class) public class XmlDiffExtFctPlugin extends AnnotationsExternalFunctionPlugin { Loading Loading @@ -42,4 +50,26 @@ public class XmlDiffExtFctPlugin extends AnnotationsExternalFunctionPlugin { return newBooleanValue(res); } //external function readFile(universal charstring p_referenceXmlFile) return universal charstring; @ExternalFunction(name = "readFile") public UniversalCharstringValue readFile(UniversalCharstringValue p_referenceXmlFile) { FileInputStream in = null; try { File file = new File(p_referenceXmlFile.getString()); in = new FileInputStream(file); ByteArrayOutputStream out = new ByteArrayOutputStream(4096); FileUtil.copy(in, out); return newUniversalCharstringValue(out.toString("UTF-8")); } catch (Throwable e) { throw new TestCaseError(new RuntimeException(MessageFormat.format("error while reading UTF-8 encoded file: {0} {1}", p_referenceXmlFile.getString(), e.toString()), e)); } finally { try { in.close(); } catch (Throwable e) { // ignore exception } } } } tools/TestMacroProcessor/macros/TC.ttcn_macro +1 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ } external function matchFile(Raw p_textToMatch, XsdFile p_referenceXmlFile, XsdFileList p_xsdFileList, out universal charstring p_matchError) return boolean; // external function matchFile(Raw p_textToMatch, charstring p_filePath, out charstring p_matchError) return boolean; testcase TC_${module}() runs on C system C { var Raw v_rcv; Loading @@ -23,7 +22,7 @@ if (matchFile(v_rcv, "${module}.xml", ${xsdFileList}, v_matchError)) { alt { [] p.receive(m_msg) { setverdict(pass); setverdict(pass, "Decoded value matches encoded template and reference XML"); } [] p.receive { setverdict(fail, "XML decoding failure"); Loading tools/TestMacroProcessor/macros/TC_Decode.ttcn_macro 0 → 100644 +38 −0 Original line number Diff line number Diff line type universal charstring Raw; type port P message { inout all; } type component C { port P p; } external function readFile(universal charstring p_referenceXmlFile) return universal charstring; testcase TC_${module}() runs on C system C { var Raw v_rcv; map(self:p, system:p); v_rcv := readFile("${module}.xml"); p.send(v_rcv); alt { [] p.check(receive(Raw:?) -> value v_rcv) { log("XML message ", v_rcv); alt { [] p.receive(m_msg) { setverdict(pass, "Decoded value matches template"); } [] p.receive { setverdict(fail, "XML decoding failure"); } } } [] p.receive { setverdict(fail, "Raw decoding failure"); } } } control { execute(TC_${module}(), 5.0); } tools/TestMacroProcessor/macros/TC_NoXMLMatch.ttcn_macro 0 → 100644 +35 −0 Original line number Diff line number Diff line type universal charstring Raw; type port P message { inout all; } type component C { port P p; } testcase TC_${module}() runs on C system C { var Raw v_rcv; map(self:p, system:p); p.send(m_msg); alt { [] p.check(receive(Raw:?) -> value v_rcv) { log("XML message ", v_rcv); alt { [] p.receive(m_msg) { setverdict(pass, "Decoded value matches encoded template"); } [] p.receive { setverdict(fail, "XML decoding failure"); } } } [] p.receive { setverdict(fail, "Raw decoding failure"); } } } control { execute(TC_${module}(), 5.0); } Loading
tools/TTworkbenchSupport/TTworkbenchAdapter/XmlDiffExternalFunction/com/testingtech/tri/extfct/XmlDiffExtFctPlugin.java +30 −0 Original line number Diff line number Diff line package com.testingtech.tri.extfct; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.text.MessageFormat; import org.etsi.mts.ttcn.part9.xmldiff.XmlDiff; import org.etsi.ttcn.tci.BooleanValue; import org.etsi.ttcn.tci.RecordOfValue; Loading @@ -7,6 +12,9 @@ import org.etsi.ttcn.tci.UniversalCharstringValue; import com.testingtech.ttcn.annotation.ExternalFunction; import com.testingtech.ttcn.tri.AnnotationsExternalFunctionPlugin; import com.testingtech.util.FileUtil; import de.tu_berlin.cs.uebb.muttcn.runtime.TestCaseError; @ExternalFunction.Definitions(XmlDiffExtFctPlugin.class) public class XmlDiffExtFctPlugin extends AnnotationsExternalFunctionPlugin { Loading Loading @@ -42,4 +50,26 @@ public class XmlDiffExtFctPlugin extends AnnotationsExternalFunctionPlugin { return newBooleanValue(res); } //external function readFile(universal charstring p_referenceXmlFile) return universal charstring; @ExternalFunction(name = "readFile") public UniversalCharstringValue readFile(UniversalCharstringValue p_referenceXmlFile) { FileInputStream in = null; try { File file = new File(p_referenceXmlFile.getString()); in = new FileInputStream(file); ByteArrayOutputStream out = new ByteArrayOutputStream(4096); FileUtil.copy(in, out); return newUniversalCharstringValue(out.toString("UTF-8")); } catch (Throwable e) { throw new TestCaseError(new RuntimeException(MessageFormat.format("error while reading UTF-8 encoded file: {0} {1}", p_referenceXmlFile.getString(), e.toString()), e)); } finally { try { in.close(); } catch (Throwable e) { // ignore exception } } } }
tools/TestMacroProcessor/macros/TC.ttcn_macro +1 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ } external function matchFile(Raw p_textToMatch, XsdFile p_referenceXmlFile, XsdFileList p_xsdFileList, out universal charstring p_matchError) return boolean; // external function matchFile(Raw p_textToMatch, charstring p_filePath, out charstring p_matchError) return boolean; testcase TC_${module}() runs on C system C { var Raw v_rcv; Loading @@ -23,7 +22,7 @@ if (matchFile(v_rcv, "${module}.xml", ${xsdFileList}, v_matchError)) { alt { [] p.receive(m_msg) { setverdict(pass); setverdict(pass, "Decoded value matches encoded template and reference XML"); } [] p.receive { setverdict(fail, "XML decoding failure"); Loading
tools/TestMacroProcessor/macros/TC_Decode.ttcn_macro 0 → 100644 +38 −0 Original line number Diff line number Diff line type universal charstring Raw; type port P message { inout all; } type component C { port P p; } external function readFile(universal charstring p_referenceXmlFile) return universal charstring; testcase TC_${module}() runs on C system C { var Raw v_rcv; map(self:p, system:p); v_rcv := readFile("${module}.xml"); p.send(v_rcv); alt { [] p.check(receive(Raw:?) -> value v_rcv) { log("XML message ", v_rcv); alt { [] p.receive(m_msg) { setverdict(pass, "Decoded value matches template"); } [] p.receive { setverdict(fail, "XML decoding failure"); } } } [] p.receive { setverdict(fail, "Raw decoding failure"); } } } control { execute(TC_${module}(), 5.0); }
tools/TestMacroProcessor/macros/TC_NoXMLMatch.ttcn_macro 0 → 100644 +35 −0 Original line number Diff line number Diff line type universal charstring Raw; type port P message { inout all; } type component C { port P p; } testcase TC_${module}() runs on C system C { var Raw v_rcv; map(self:p, system:p); p.send(m_msg); alt { [] p.check(receive(Raw:?) -> value v_rcv) { log("XML message ", v_rcv); alt { [] p.receive(m_msg) { setverdict(pass, "Decoded value matches encoded template"); } [] p.receive { setverdict(fail, "XML decoding failure"); } } } [] p.receive { setverdict(fail, "Raw decoding failure"); } } } control { execute(TC_${module}(), 5.0); }