Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ConcurrentModificationException in test #92

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ public void mqttChannelTriggered() throws MqttException {
}

@Test
public void preconditionExecution() throws IOException {
public void preconditionExecution() throws IOException, InterruptedException {
sendCommand(TestRules.ITEM_PRECONDITION_STRING, "will not match");
sendCommand(TestRules.ITEM_PRECONDITIONED_SWITCH, JRuleSwitchItem.ON);
verifyRuleWasNotExecuted(TestRules.NAME_PRECONDITION_EXECUTION);

sendCommand(TestRules.ITEM_PRECONDITION_STRING, "that matches");
Thread.sleep(500);
sendCommand(TestRules.ITEM_PRECONDITIONED_SWITCH, JRuleSwitchItem.ON);
verifyRuleWasExecuted(TestRules.NAME_PRECONDITION_EXECUTION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Base64;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

Expand Down Expand Up @@ -72,7 +73,7 @@
*/
public abstract class JRuleITBase {
private static final Network network = Network.newNetwork();
protected static final List<String> logLines = new ArrayList<>();
protected static final List<String> logLines = new CopyOnWriteArrayList<>();
private static final Logger log = LoggerFactory.getLogger(ITJRule.class);
private static final String version;

Expand Down Expand Up @@ -168,6 +169,8 @@ void initTest() throws IOException, InterruptedException, MqttException {
sendCommand(TestRules.ITEM_RECEIVING_COMMAND_SWITCH, JRuleSwitchItem.OFF);
sendCommand(TestRules.ITEM_PRECONDITION_STRING, JRuleSwitchItem.OFF);
sendCommand(TestRules.ITEM_MQTT_ACTION_TRIGGER, JRuleSwitchItem.OFF);
sendCommand(TestRules.ITEM_PRECONDITIONED_SWITCH, JRuleSwitchItem.OFF);
sendCommand(TestRules.ITEM_PRECONDITION_STRING, "");

receivedMqttMessages.clear();
mqttClient = getMqttClient();
Expand Down