private BlockingQueue<byte[]> ofMsg;
private ChannelHandlerContext ctx;
private int eventNumber;
+ private boolean scenarioFinished = false;
/**
*
}
LOGGER.debug("Scenario finished");
synchronized (this) {
+ scenarioFinished = true;
this.notify();
}
}
public void addOfMsg(byte[] message) {
ofMsg.add(message);
}
+
+ /**
+ * @return true is scenario is finished
+ */
+ public boolean isScenarioFinished() {
+ return scenarioFinished;
+ }
}
* @param msgToSend message to be sent
*/
public SendEvent(byte[] msgToSend) {
- this.msgToSend = msgToSend;
+ this.msgToSend = new byte[msgToSend.length];
+ for (int i = 0; i < msgToSend.length; i++) {
+ this.msgToSend[i] = msgToSend[i];
+ }
}
@Override
synchronized (scenarioHandler) {
LOGGER.debug("WAITING FOR SCENARIO");
- scenarioHandler.wait();
+ while (! scenarioHandler.isScenarioFinished()) {
+ scenarioHandler.wait();
+ }
}
} catch (Exception ex) {
LOGGER.error(ex.getMessage(), ex);
synchronized (scenarioHandler) {
LOGGER.debug("WAITING FOR SCENARIO");
- scenarioHandler.wait();
+ while (! scenarioHandler.isScenarioFinished()) {
+ scenarioHandler.wait();
+ }
}
} catch (Exception ex) {
LOGGER.error(ex.getMessage(), ex);
* @param headerExpected header (first 8 bytes) of expected message
*/
public WaitForMessageEvent(byte[] headerExpected) {
- this.headerExpected = headerExpected;
+ this.headerExpected = new byte[headerExpected.length];
+ for (int i = 0; i < headerExpected.length; i++) {
+ this.headerExpected[i] = headerExpected[i];
+ }
}
@Override
* @param headerReceived header (first 8 bytes) of expected message
*/
public void setHeaderReceived(byte[] headerReceived) {
- this.headerReceived = headerReceived;
+ this.headerReceived = new byte[headerReceived.length];
+ for (int i = 0; i < headerReceived.length; i++) {
+ this.headerReceived[i] = headerReceived[i];
+ }
}
-
-
}