Skip to content

Commit

Permalink
Add ability to ignore response
Browse files Browse the repository at this point in the history
  • Loading branch information
ar committed Mar 29, 2017
1 parent 97e0dea commit 88e820a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 24 deletions.
7 changes: 7 additions & 0 deletions doc/src/asciidoc/module_client_simulator.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ cfg/echo_r:
</isomsg>
---------------------------------

[TIP]
=====
If the response template file (i.e. `echo_r` in the previous example) is
not present, client simulator blindly sends the message to the server,
ignoring the response. A _response ignored_ note is added to the test log.
=====

In the previous example, we send a 1800 message with some fixed data,
and we expect to receive a 1810 message, with a 00 content in field 39.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void run () {
shutdownQ2();
}
private void runSuite (List suite, MUX mux, Interpreter bsh)
throws ISOException, EvalError
throws ISOException, IOException, EvalError
{
LogEvent evt = getLog().createLogEvent ("results");
LogEvent evt_error = null;
Expand All @@ -102,17 +102,25 @@ private void runSuite (List suite, MUX mux, Interpreter bsh)
}
tc.setExpandedRequest (applyRequestProps (m, bsh));
tc.start();
tc.setResponse (mux.request (m, tc.getTimeout()));
tc.end ();
assertResponse(tc, bsh, evt_error);
evt.addMessage (i + ": " + tc.toString());
if (evt_error.getPayLoad().size()!=0) {
evt_error.addMessage("filename", tc.getFilename());
evt.addMessage(NL + evt_error.toString(" "));
if (tc.getExpectedResponse() != null) {
tc.setResponse(mux.request(m, tc.getTimeout()));
tc.end();
assertResponse(tc, bsh, evt_error);
evt.addMessage(i + ": " + tc.toString());
if (evt_error.getPayLoad().size() != 0) {
evt_error.addMessage("filename", tc.getFilename());
evt.addMessage(NL + evt_error.toString(" "));
}
serverTime += tc.elapsed();
if (!tc.ok() && !tc.isContinueOnErrors())
break;
} else {
// response not expected - fire and forget
mux.send(m);
tc.end();
tc.setResultCode(TestCase.OK);
evt.addMessage(i + ": " + tc.toString() + " (response ignored)");
}
serverTime += tc.elapsed();
if (!tc.ok() && !tc.isContinueOnErrors())
break;
}
if (!tc.ok()) {
getLog().error (tc);
Expand All @@ -139,10 +147,10 @@ private void runSuite (List suite, MUX mux, Interpreter bsh)

Logger.log (evt);
}
private List initSuite (Element suite)
private List<TestCase> initSuite (Element suite)
throws IOException, ISOException
{
List l = new ArrayList();
List<TestCase> l = new ArrayList<>();
String prefix = suite.getChildTextTrim ("path");
Iterator iter = suite.getChildren ("test").iterator();
while (iter.hasNext ()) {
Expand Down Expand Up @@ -178,17 +186,17 @@ private ISOMsg getMessage (String filename)
throws IOException, ISOException
{
File f = new File (filename);
FileInputStream fis = new FileInputStream (f);
try {
byte[] b = new byte[fis.available()];
fis.read (b);
ISOMsg m = new ISOMsg ();
m.setPackager (packager);
m.unpack (b);
return m;
} finally {
fis.close();
}
ISOMsg m = null;
if (f.canRead()) {
try (FileInputStream fis = new FileInputStream (f)) {
byte[] b = new byte[fis.available()];
fis.read (b);
m = new ISOMsg ();
m.setPackager (packager);
m.unpack (b);
}
}
return m;
}
private boolean processResponse
(ISOMsg er, ISOMsg m, ISOMsg expected, Interpreter bsh, LogEvent evt)
Expand Down

0 comments on commit 88e820a

Please # to comment.