File tree 1 file changed +12
-7
lines changed
balking/src/test/java/com/iluwatar/balking 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 22
22
*/
23
23
package com .iluwatar .balking ;
24
24
25
- import org .junit .jupiter .api .Disabled ;
26
- import org .junit .jupiter .api .Test ;
25
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
27
26
28
27
import java .util .concurrent .ExecutorService ;
29
28
import java .util .concurrent .Executors ;
30
29
import java .util .concurrent .TimeUnit ;
31
30
32
- import static org .junit .jupiter .api .Assertions . assertEquals ;
31
+ import org .junit .jupiter .api .Test ;
33
32
34
33
/**
35
34
* Tests for {@link WashingMachine}
36
35
*/
37
36
public class WashingMachineTest {
38
37
39
- private volatile WashingMachineState machineStateGlobal ;
38
+ private WashingMachineState machineStateGlobal ;
40
39
41
- @ Disabled
42
40
@ Test
43
41
public void wash () throws Exception {
44
42
WashingMachine washingMachine = new WashingMachine ();
45
43
ExecutorService executorService = Executors .newFixedThreadPool (2 );
46
- executorService .execute (washingMachine ::wash );
47
44
executorService .execute (() -> {
48
45
washingMachine .wash ();
49
- machineStateGlobal = washingMachine .getWashingMachineState ();
46
+ if (machineStateGlobal ==null ) {
47
+ machineStateGlobal = washingMachine .getWashingMachineState ();
48
+ }
49
+ });
50
+ executorService .execute (() -> {
51
+ washingMachine .wash ();
52
+ if (machineStateGlobal ==null ) {
53
+ machineStateGlobal = washingMachine .getWashingMachineState ();
54
+ }
50
55
});
51
56
executorService .shutdown ();
52
57
try {
You can’t perform that action at this time.
0 commit comments