Backport ci test changes from master

- Relates to #343
- Relates to #376
This commit is contained in:
Janne Valkealahti
2017-06-10 14:33:55 +01:00
parent bbca0ea504
commit bec44751d9
2 changed files with 19 additions and 2 deletions

View File

@@ -121,7 +121,7 @@ public class EventDeferTests extends AbstractStateMachineTests {
@Test
public void testDeferWithSubsThreadExecutor() throws Exception {
context.register(Config1.class, ExecutorConfig.class);
context.register(Config1.class, ExecutorConfig2.class);
context.refresh();
@SuppressWarnings("unchecked")
StateMachine<String, String> machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, StateMachine.class);
@@ -155,7 +155,7 @@ public class EventDeferTests extends AbstractStateMachineTests {
@Test
public void testDeferWithSubs2ThreadExecutor() throws Exception {
context.register(Config1.class, ExecutorConfig.class);
context.register(Config1.class, ExecutorConfig2.class);
context.refresh();
@SuppressWarnings("unchecked")
StateMachine<String, String> machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, StateMachine.class);
@@ -555,6 +555,19 @@ public class EventDeferTests extends AbstractStateMachineTests {
}
@Configuration
static class ExecutorConfig2 {
@Bean(name=StateMachineSystemConstants.TASK_EXECUTOR_BEAN_NAME)
public TaskExecutor taskExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(1);
taskExecutor.setMaxPoolSize(4);
return taskExecutor;
}
}
static class TestListener extends StateMachineListenerAdapter<String, String> {
volatile CountDownLatch stateChangedLatch = new CountDownLatch(1);

View File

@@ -64,6 +64,7 @@ public class StateMachineMonitorTests extends AbstractStateMachineTests {
// there's also initial transition, thus 2 instead 1
assertThat(monitor.transitions.size(), is(2));
assertThat(saction.latch.await(2, TimeUnit.SECONDS), is(true));
assertThat(monitor.latch.await(2, TimeUnit.SECONDS), is(true));
assertThat(monitor.actions.size(), is(4));
assertThat(monitor.actions.keySet(), containsInAnyOrder(taction, enaction, exaction, saction));
monitor.reset();
@@ -181,6 +182,7 @@ public class StateMachineMonitorTests extends AbstractStateMachineTests {
Map<Transition<String, String>, Transitions> transitions = new HashMap<>();
Map<Action<String, String>, Actions> actions = new HashMap<>();
CountDownLatch latch = new CountDownLatch(4);
@Override
public void transition(StateMachine<String, String> stateMachine, Transition<String, String> transition, long duration) {
@@ -191,11 +193,13 @@ public class StateMachineMonitorTests extends AbstractStateMachineTests {
public void action(StateMachine<String, String> stateMachine, Action<String, String> action,
long duration) {
actions.put(action, new Actions(action, duration));
latch.countDown();
}
void reset() {
transitions.clear();
actions.clear();
latch = new CountDownLatch(4);
}
@SuppressWarnings("unused")