@@ -171,7 +171,7 @@ project('spring-statemachine-core') {
|
||||
description = "Spring State Machine Core"
|
||||
|
||||
configurations {
|
||||
testArtifacts.extendsFrom testRuntime
|
||||
testArtifacts
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -302,6 +302,7 @@ project('spring-statemachine-data-common') {
|
||||
compile "com.fasterxml.jackson.core:jackson-databind"
|
||||
testCompile project(":spring-statemachine-test")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile "io.projectreactor:reactor-test"
|
||||
testCompile "org.springframework.boot:spring-boot-starter-test"
|
||||
testRuntime "org.springframework.boot:spring-boot-starter-web"
|
||||
}
|
||||
@@ -360,6 +361,7 @@ project('spring-statemachine-uml') {
|
||||
compile "org.eclipse.emf:org.eclipse.emf.ecore"
|
||||
compile "org.eclipse.emf:org.eclipse.emf.common"
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile "io.projectreactor:reactor-test"
|
||||
testCompile "org.springframework:spring-test"
|
||||
testCompile "org.hamcrest:hamcrest-core"
|
||||
testCompile "org.hamcrest:hamcrest-library"
|
||||
@@ -399,6 +401,7 @@ configure(recipeProjects()) {
|
||||
dependencies {
|
||||
compile project(":spring-statemachine-recipes-common")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile "io.projectreactor:reactor-test"
|
||||
testCompile "org.springframework:spring-test"
|
||||
testCompile "org.hamcrest:hamcrest-core"
|
||||
testCompile "org.hamcrest:hamcrest-library"
|
||||
@@ -411,6 +414,7 @@ project('spring-statemachine-recipes-common') {
|
||||
compile "org.springframework:spring-context"
|
||||
compile project(":spring-statemachine-core")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile "io.projectreactor:reactor-test"
|
||||
testCompile "org.springframework:spring-test"
|
||||
testCompile "org.hamcrest:hamcrest-core"
|
||||
testCompile "org.hamcrest:hamcrest-library"
|
||||
@@ -521,6 +525,7 @@ project('spring-statemachine-samples-common') {
|
||||
compile project(":spring-statemachine-core")
|
||||
compile "org.springframework.shell:spring-shell"
|
||||
compile "org.springframework.boot:spring-boot-starter"
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ project('spring-statemachine-data-jpa') {
|
||||
testCompile project(":spring-statemachine-test")
|
||||
testCompile project(path:":spring-statemachine-data-common", configuration:"testArtifacts")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile "io.projectreactor:reactor-test"
|
||||
optional "org.eclipse.persistence:javax.persistence"
|
||||
testCompile "org.hsqldb:hsqldb"
|
||||
testCompile "org.springframework.boot:spring-boot-starter-test"
|
||||
@@ -25,6 +26,7 @@ project('spring-statemachine-data-redis') {
|
||||
optional "org.eclipse.persistence:javax.persistence"
|
||||
testCompile project(path:":spring-statemachine-data-common", configuration:"testArtifacts")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile "io.projectreactor:reactor-test"
|
||||
testCompile "org.springframework.boot:spring-boot-starter-test"
|
||||
testRuntime "org.apache.commons:commons-pool2"
|
||||
testRuntime "redis.clients:jedis"
|
||||
@@ -42,6 +44,7 @@ project('spring-statemachine-data-mongodb') {
|
||||
optional "org.eclipse.persistence:javax.persistence"
|
||||
testCompile project(path:":spring-statemachine-data-common", configuration:"testArtifacts")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile "io.projectreactor:reactor-test"
|
||||
testCompile "org.springframework.boot:spring-boot-starter-test"
|
||||
testRuntime "org.springframework.boot:spring-boot-starter-data-mongodb"
|
||||
testRuntime "org.springframework.boot:spring-boot-starter-web"
|
||||
|
||||
@@ -4,6 +4,8 @@ project('spring-statemachine-samples-turnstile') {
|
||||
description = 'Spring State Machine Turnstile Sample'
|
||||
dependencies {
|
||||
compile project(":spring-statemachine-samples-common")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +14,7 @@ project('spring-statemachine-samples-turnstilereactive') {
|
||||
dependencies {
|
||||
compile project(":spring-statemachine-samples-common")
|
||||
compile 'org.springframework.boot:spring-boot-starter-webflux'
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
testCompile 'org.springframework.boot:spring-boot-starter-test'
|
||||
}
|
||||
@@ -20,6 +23,8 @@ project('spring-statemachine-samples-turnstilereactive') {
|
||||
project('spring-statemachine-samples-showcase') {
|
||||
description = 'Spring State Machine Showcase Sample'
|
||||
dependencies {
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
compile project(":spring-statemachine-samples-common")
|
||||
}
|
||||
}
|
||||
@@ -28,6 +33,8 @@ project('spring-statemachine-samples-cdplayer') {
|
||||
description = 'Spring State Machine CD Player Sample'
|
||||
dependencies {
|
||||
compile project(":spring-statemachine-samples-common")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +42,8 @@ project('spring-statemachine-samples-tasks') {
|
||||
description = 'Spring State Machine Parallel Regions Sample'
|
||||
dependencies {
|
||||
compile project(":spring-statemachine-samples-common")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +51,8 @@ project('spring-statemachine-samples-washer') {
|
||||
description = 'Spring State Machine History State Sample'
|
||||
dependencies {
|
||||
compile project(":spring-statemachine-samples-common")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +61,8 @@ project('spring-statemachine-samples-zookeeper') {
|
||||
dependencies {
|
||||
compile project(":spring-statemachine-samples-common")
|
||||
compile project(":spring-statemachine-zookeeper")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +73,8 @@ project('spring-statemachine-samples-persist') {
|
||||
compile project(":spring-statemachine-recipes-common")
|
||||
compile ("org.hsqldb:hsqldb")
|
||||
compile ("org.springframework:spring-jdbc")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +89,8 @@ project('spring-statemachine-samples-web') {
|
||||
compile("org.springframework:spring-websocket")
|
||||
compile("org.springframework.security:spring-security-messaging")
|
||||
compile("org.springframework.session:spring-session-core")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +99,8 @@ project('spring-statemachine-samples-scope') {
|
||||
dependencies {
|
||||
compile("org.springframework.boot:spring-boot-starter-web")
|
||||
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +112,8 @@ project('spring-statemachine-samples-security') {
|
||||
compile("org.springframework.boot:spring-boot-starter-security")
|
||||
compile("org.springframework.security:spring-security-config")
|
||||
compile("org.springframework.security:spring-security-web")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +125,8 @@ project('spring-statemachine-samples-eventservice') {
|
||||
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
|
||||
compile("org.apache.commons:commons-pool2")
|
||||
runtime("redis.clients:jedis")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +136,8 @@ project('spring-statemachine-samples-deploy') {
|
||||
compile project(":spring-statemachine-uml")
|
||||
compile("org.springframework.boot:spring-boot-starter-web")
|
||||
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +147,8 @@ project('spring-statemachine-samples-ordershipping') {
|
||||
compile project(":spring-statemachine-uml")
|
||||
compile("org.springframework.boot:spring-boot-starter-web")
|
||||
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +162,8 @@ project('spring-statemachine-samples-datajpa') {
|
||||
compile("org.springframework.boot:spring-boot-starter-data-jpa")
|
||||
compile("org.springframework.boot:spring-boot-devtools")
|
||||
compile("com.h2database:h2")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +177,8 @@ project('spring-statemachine-samples-datajpamultipersist') {
|
||||
compile("org.springframework.boot:spring-boot-starter-data-jpa")
|
||||
compile("org.springframework.boot:spring-boot-devtools")
|
||||
compile("com.h2database:h2")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,6 +196,8 @@ project('spring-statemachine-samples-datapersist') {
|
||||
compile("org.springframework.boot:spring-boot-starter-data-mongodb")
|
||||
compile("org.springframework.boot:spring-boot-devtools")
|
||||
compile("com.h2database:h2")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,6 +210,8 @@ project('spring-statemachine-samples-monitoring') {
|
||||
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
|
||||
testCompile("com.jayway.jsonpath:json-path")
|
||||
testCompile("com.jayway.jsonpath:json-path-assert")
|
||||
testCompile project(path:":spring-statemachine-core", configuration:"testArtifacts")
|
||||
testCompile 'io.projectreactor:reactor-test'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,8 @@ import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.statemachine.TestUtils.doStartAndAssert;
|
||||
import static org.springframework.statemachine.TestUtils.doStopAndAssert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -276,13 +278,13 @@ public class CdPlayerTests {
|
||||
player = context.getBean(CdPlayer.class);
|
||||
library = context.getBean(Library.class);
|
||||
listener = context.getBean(TestListener.class);
|
||||
machine.start();
|
||||
doStartAndAssert(machine);
|
||||
assertThat(listener.stateMachineStartedLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
}
|
||||
|
||||
@After
|
||||
public void clean() {
|
||||
machine.stop();
|
||||
doStopAndAssert(machine);
|
||||
context.close();
|
||||
context = null;
|
||||
machine = null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,6 +19,7 @@ import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.statemachine.TestUtils.doStartAndAssert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -62,7 +63,7 @@ public class PersistTests {
|
||||
public void testInitialState() throws Exception {
|
||||
TestListener listener = new TestListener();
|
||||
machine.addStateListener(listener);
|
||||
machine.start();
|
||||
doStartAndAssert(machine);
|
||||
assertThat(listener.stateChangedLatch.await(3, TimeUnit.SECONDS), is(true));
|
||||
assertThat(listener.stateEnteredLatch.await(3, TimeUnit.SECONDS), is(true));
|
||||
assertThat(machine.getState().getIds(), contains("PLACED"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,9 @@ package demo.showcase;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.statemachine.TestUtils.doSendEventAndConsumeAll;
|
||||
import static org.springframework.statemachine.TestUtils.doStartAndAssert;
|
||||
import static org.springframework.statemachine.TestUtils.doStopAndAssert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -66,7 +69,8 @@ public class ShowcaseTests {
|
||||
public void testA() throws Exception {
|
||||
testInitialState();
|
||||
listener.reset(1, 2, 2);
|
||||
machine.sendEvent(Events.A);
|
||||
doSendEventAndConsumeAll(machine, Events.A);
|
||||
// machine.sendEvent(Events.A);
|
||||
// variable foo is 0, guard denies transition
|
||||
assertThat(listener.stateChangedLatch.await(1, TimeUnit.SECONDS), is(false));
|
||||
assertThat(listener.stateEnteredLatch.await(1, TimeUnit.SECONDS), is(false));
|
||||
@@ -78,7 +82,7 @@ public class ShowcaseTests {
|
||||
public void testB() throws Exception {
|
||||
testInitialState();
|
||||
listener.reset(1, 2, 2);
|
||||
machine.sendEvent(Events.B);
|
||||
doSendEventAndConsumeAll(machine, Events.B);
|
||||
assertThat(listener.stateChangedLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
assertThat(listener.stateEnteredLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
assertThat(listener.stateExitedLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
@@ -91,13 +95,13 @@ public class ShowcaseTests {
|
||||
public void testCHCA() throws Exception {
|
||||
testInitialState();
|
||||
listener.reset(3, 0, 0);
|
||||
machine.sendEvent(Events.C);
|
||||
machine.sendEvent(Events.H);
|
||||
machine.sendEvent(Events.C);
|
||||
doSendEventAndConsumeAll(machine, Events.C);
|
||||
doSendEventAndConsumeAll(machine, Events.H);
|
||||
doSendEventAndConsumeAll(machine, Events.C);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
|
||||
listener.reset(1, 2, 2, 1);
|
||||
machine.sendEvent(Events.A);
|
||||
doSendEventAndConsumeAll(machine, Events.A);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
listener.stateEnteredLatch.await(1, TimeUnit.SECONDS);
|
||||
listener.stateExitedLatch.await(1, TimeUnit.SECONDS);
|
||||
@@ -116,7 +120,7 @@ public class ShowcaseTests {
|
||||
public void testC() throws Exception {
|
||||
testInitialState();
|
||||
listener.reset(1, 3, 0);
|
||||
machine.sendEvent(Events.C);
|
||||
doSendEventAndConsumeAll(machine, Events.C);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
listener.stateEnteredLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.S0, States.S2, States.S21, States.S211));
|
||||
@@ -130,11 +134,11 @@ public class ShowcaseTests {
|
||||
public void testCC() throws Exception {
|
||||
testInitialState();
|
||||
listener.reset(1, 3, 0);
|
||||
machine.sendEvent(Events.C);
|
||||
doSendEventAndConsumeAll(machine, Events.C);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.S0, States.S2, States.S21, States.S211));
|
||||
listener.reset(1, 2, 0);
|
||||
machine.sendEvent(Events.C);
|
||||
doSendEventAndConsumeAll(machine, Events.C);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
listener.stateEnteredLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.S0, States.S1, States.S11));
|
||||
@@ -147,7 +151,7 @@ public class ShowcaseTests {
|
||||
public void testD() throws Exception {
|
||||
testInitialState();
|
||||
listener.reset(3, 3, 0);
|
||||
machine.sendEvent(Events.D);
|
||||
doSendEventAndConsumeAll(machine, Events.D);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
listener.stateEnteredLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.S0, States.S1, States.S11));
|
||||
@@ -162,10 +166,10 @@ public class ShowcaseTests {
|
||||
public void testCD() throws Exception {
|
||||
testInitialState();
|
||||
listener.reset(1, 3, 0);
|
||||
machine.sendEvent(Events.C);
|
||||
doSendEventAndConsumeAll(machine, Events.C);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
listener.reset(1, 2, 0);
|
||||
machine.sendEvent(Events.D);
|
||||
doSendEventAndConsumeAll(machine, Events.D);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
listener.stateEnteredLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.S0, States.S2, States.S21, States.S211));
|
||||
@@ -178,7 +182,7 @@ public class ShowcaseTests {
|
||||
public void testI() throws Exception {
|
||||
testInitialState();
|
||||
listener.reset(1, 1, 1);
|
||||
machine.sendEvent(Events.I);
|
||||
doSendEventAndConsumeAll(machine, Events.I);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
listener.stateEnteredLatch.await(1, TimeUnit.SECONDS);
|
||||
listener.stateExitedLatch.await(1, TimeUnit.SECONDS);
|
||||
@@ -193,7 +197,7 @@ public class ShowcaseTests {
|
||||
public void testII() throws Exception {
|
||||
testInitialState();
|
||||
listener.reset(1, 1, 1);
|
||||
machine.sendEvent(Events.I);
|
||||
doSendEventAndConsumeAll(machine, Events.I);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(listener.stateChangedLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
assertThat(listener.stateEnteredLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
@@ -203,7 +207,7 @@ public class ShowcaseTests {
|
||||
assertThat(machine.getState().getIds(), contains(States.S0, States.S1, States.S12));
|
||||
|
||||
listener.reset(1, 3, 2);
|
||||
machine.sendEvent(Events.I);
|
||||
doSendEventAndConsumeAll(machine, Events.I);
|
||||
assertThat(listener.stateChangedLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
assertThat(listener.stateEnteredLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
assertThat(listener.stateExitedLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
@@ -216,7 +220,7 @@ public class ShowcaseTests {
|
||||
public void testH() throws Exception {
|
||||
testInitialState();
|
||||
listener.reset(0, 0, 0, 1);
|
||||
machine.sendEvent(Events.H);
|
||||
doSendEventAndConsumeAll(machine, Events.H);
|
||||
listener.transitionLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(listener.transitionCount, is(1));
|
||||
assertThat(listener.transitions.get(0).getSource().getId(), is(States.S1));
|
||||
@@ -225,9 +229,9 @@ public class ShowcaseTests {
|
||||
@Test
|
||||
public void testCH() throws Exception {
|
||||
testInitialState();
|
||||
machine.sendEvent(Events.C);
|
||||
doSendEventAndConsumeAll(machine, Events.C);
|
||||
listener.reset(0, 0, 0, 1);
|
||||
machine.sendEvent(Events.H);
|
||||
doSendEventAndConsumeAll(machine, Events.H);
|
||||
listener.transitionLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(listener.transitionCount, is(1));
|
||||
assertThat(listener.transitions.get(0).getSource().getId(), is(States.S0));
|
||||
@@ -236,10 +240,11 @@ public class ShowcaseTests {
|
||||
@Test
|
||||
public void testACH() throws Exception {
|
||||
testInitialState();
|
||||
machine.sendEvent(Events.A);
|
||||
machine.sendEvent(Events.C);
|
||||
doSendEventAndConsumeAll(machine, Events.A);
|
||||
doSendEventAndConsumeAll(machine, Events.C);
|
||||
listener.reset(0, 0, 0, 1);
|
||||
machine.sendEvent(Events.H);
|
||||
doSendEventAndConsumeAll(machine, Events.H);
|
||||
doSendEventAndConsumeAll(machine, Events.A);
|
||||
listener.transitionLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(listener.transitionCount, is(1));
|
||||
assertThat(listener.transitions.get(0).getSource().getId(), is(States.S0));
|
||||
@@ -249,7 +254,7 @@ public class ShowcaseTests {
|
||||
public void testE() throws Exception {
|
||||
testInitialState();
|
||||
listener.reset(1, 4, 3, 0);
|
||||
machine.sendEvent(Events.E);
|
||||
doSendEventAndConsumeAll(machine, Events.E);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(listener.stateChangedLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
assertThat(listener.stateEnteredLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
@@ -263,7 +268,7 @@ public class ShowcaseTests {
|
||||
public void testF() throws Exception {
|
||||
testInitialState();
|
||||
listener.reset(1, 3, 2, 0);
|
||||
machine.sendEvent(Events.F);
|
||||
doSendEventAndConsumeAll(machine, Events.F);
|
||||
assertThat(listener.stateChangedLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
assertThat(listener.stateEnteredLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
assertThat(listener.stateExitedLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
@@ -276,7 +281,7 @@ public class ShowcaseTests {
|
||||
public void testG() throws Exception {
|
||||
testInitialState();
|
||||
listener.reset(1, 3, 2, 0);
|
||||
machine.sendEvent(Events.G);
|
||||
doSendEventAndConsumeAll(machine, Events.G);
|
||||
assertThat(listener.stateChangedLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
assertThat(listener.stateEnteredLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
assertThat(listener.stateExitedLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
@@ -358,12 +363,12 @@ public class ShowcaseTests {
|
||||
context.refresh();
|
||||
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
|
||||
listener = context.getBean(TestListener.class);
|
||||
machine.start();
|
||||
doStartAndAssert(machine);
|
||||
}
|
||||
|
||||
@After
|
||||
public void clean() {
|
||||
machine.stop();
|
||||
doStopAndAssert(machine);
|
||||
context.close();
|
||||
context = null;
|
||||
machine = null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2018 the original author or authors.
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,8 @@ package demo.tasks;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.statemachine.TestUtils.doStartAndAssert;
|
||||
import static org.springframework.statemachine.TestUtils.doStopAndAssert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -144,7 +146,7 @@ public class TasksTests {
|
||||
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
|
||||
tasks = context.getBean(Tasks.class);
|
||||
listener = context.getBean(TestListener.class);
|
||||
machine.start();
|
||||
doStartAndAssert(machine);
|
||||
assertThat(listener.stateChangedLatch.await(1, TimeUnit.SECONDS), is(true));
|
||||
assertThat(listener.stateChangedCount, is(1));
|
||||
assertThat(machine.getState().getIds(), contains(States.READY));
|
||||
@@ -152,7 +154,7 @@ public class TasksTests {
|
||||
|
||||
@After
|
||||
public void clean() {
|
||||
machine.stop();
|
||||
doStopAndAssert(machine);
|
||||
context.close();
|
||||
context = null;
|
||||
machine = null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,8 @@ package demo.turnstile;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.statemachine.TestUtils.doStartAndAssert;
|
||||
import static org.springframework.statemachine.TestUtils.doStopAndAssert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -59,7 +61,7 @@ public class TurnstileTests {
|
||||
|
||||
@Test
|
||||
public void testInitialState() throws Exception {
|
||||
machine.start();
|
||||
doStartAndAssert(machine);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
listener.stateEnteredLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.LOCKED));
|
||||
@@ -146,7 +148,7 @@ public class TurnstileTests {
|
||||
|
||||
@After
|
||||
public void clean() {
|
||||
machine.stop();
|
||||
doStopAndAssert(machine);
|
||||
context.close();
|
||||
context = null;
|
||||
machine = null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,9 @@ package demo.washer;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.statemachine.TestUtils.doSendEventAndConsumeAll;
|
||||
import static org.springframework.statemachine.TestUtils.doStartAndAssert;
|
||||
import static org.springframework.statemachine.TestUtils.doStopAndAssert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -64,7 +67,7 @@ public class WasherTests {
|
||||
@Test
|
||||
public void testRinse() throws Exception {
|
||||
listener.reset(1, 0, 0);
|
||||
machine.sendEvent(Events.RINSE);
|
||||
doSendEventAndConsumeAll(machine, Events.RINSE);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.RUNNING, States.RINSING));
|
||||
}
|
||||
@@ -72,11 +75,11 @@ public class WasherTests {
|
||||
@Test
|
||||
public void testRinseCutPower() throws Exception {
|
||||
listener.reset(1, 0, 0);
|
||||
machine.sendEvent(Events.RINSE);
|
||||
doSendEventAndConsumeAll(machine, Events.RINSE);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
|
||||
listener.reset(1, 0, 0);
|
||||
machine.sendEvent(Events.CUTPOWER);
|
||||
doSendEventAndConsumeAll(machine, Events.CUTPOWER);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.POWEROFF));
|
||||
}
|
||||
@@ -84,15 +87,15 @@ public class WasherTests {
|
||||
@Test
|
||||
public void testRinseCutRestorePower() throws Exception {
|
||||
listener.reset(1, 0, 0);
|
||||
machine.sendEvent(Events.RINSE);
|
||||
doSendEventAndConsumeAll(machine, Events.RINSE);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
|
||||
listener.reset(1, 0, 0);
|
||||
machine.sendEvent(Events.CUTPOWER);
|
||||
doSendEventAndConsumeAll(machine, Events.CUTPOWER);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
|
||||
listener.reset(1, 0, 0);
|
||||
machine.sendEvent(Events.RESTOREPOWER);
|
||||
doSendEventAndConsumeAll(machine, Events.RESTOREPOWER);
|
||||
listener.stateChangedLatch.await(1, TimeUnit.SECONDS);
|
||||
assertThat(machine.getState().getIds(), contains(States.RUNNING, States.RINSING));
|
||||
}
|
||||
@@ -170,12 +173,12 @@ public class WasherTests {
|
||||
context.refresh();
|
||||
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
|
||||
listener = context.getBean(TestListener.class);
|
||||
machine.start();
|
||||
doStartAndAssert(machine);
|
||||
}
|
||||
|
||||
@After
|
||||
public void clean() {
|
||||
machine.stop();
|
||||
doStopAndAssert(machine);
|
||||
context.close();
|
||||
context = null;
|
||||
machine = null;
|
||||
|
||||
Reference in New Issue
Block a user