@@ -48,11 +48,8 @@ public final class JavaFxSchedulerTest {
4848 public ExpectedException exception = ExpectedException .none ();
4949
5050 private static void waitForEmptyEventQueue () throws Exception {
51- FXUtilities .runAndWait (new Runnable () {
52- @ Override
53- public void run () {
54- // nothing to do, we're just waiting here for the event queue to be emptied
55- }
51+ FXUtilities .runAndWait (() -> {
52+ // nothing to do, we're just waiting here for the event queue to be emptied
5653 });
5754 }
5855
@@ -77,15 +74,12 @@ public void testPeriodicScheduling() throws Exception {
7774 final CountDownLatch latch = new CountDownLatch (4 );
7875
7976 final Action0 innerAction = mock (Action0 .class );
80- final Action0 action = new Action0 () {
81- @ Override
82- public void call () {
83- try {
84- innerAction .call ();
85- assertTrue (Platform .isFxApplicationThread ());
86- } finally {
87- latch .countDown ();
88- }
77+ final Action0 action = () -> {
78+ try {
79+ innerAction .call ();
80+ assertTrue (Platform .isFxApplicationThread ());
81+ } finally {
82+ latch .countDown ();
8983 }
9084 };
9185
@@ -114,31 +108,22 @@ public void testNestedActions() throws Exception {
114108 final Action0 thirdStepStart = mock (Action0 .class );
115109 final Action0 thirdStepEnd = mock (Action0 .class );
116110
117- final Action0 firstAction = new Action0 () {
118- @ Override
119- public void call () {
120- assertTrue (Platform .isFxApplicationThread ());
121- firstStepStart .call ();
122- firstStepEnd .call ();
123- }
111+ final Action0 firstAction = () -> {
112+ assertTrue (Platform .isFxApplicationThread ());
113+ firstStepStart .call ();
114+ firstStepEnd .call ();
124115 };
125- final Action0 secondAction = new Action0 () {
126- @ Override
127- public void call () {
128- assertTrue (Platform .isFxApplicationThread ());
129- secondStepStart .call ();
130- inner .schedule (firstAction );
131- secondStepEnd .call ();
132- }
116+ final Action0 secondAction = () -> {
117+ assertTrue (Platform .isFxApplicationThread ());
118+ secondStepStart .call ();
119+ inner .schedule (firstAction );
120+ secondStepEnd .call ();
133121 };
134- final Action0 thirdAction = new Action0 () {
135- @ Override
136- public void call () {
137- assertTrue (Platform .isFxApplicationThread ());
138- thirdStepStart .call ();
139- inner .schedule (secondAction );
140- thirdStepEnd .call ();
141- }
122+ final Action0 thirdAction = () -> {
123+ assertTrue (Platform .isFxApplicationThread ());
124+ thirdStepStart .call ();
125+ inner .schedule (secondAction );
126+ thirdStepEnd .call ();
142127 };
143128
144129 InOrder inOrder = inOrder (firstStepStart , firstStepEnd , secondStepStart , secondStepEnd , thirdStepStart , thirdStepEnd );
@@ -190,21 +175,17 @@ public static void runAndWait( final Runnable run) throws InterruptedException,
190175 final ThrowableWrapper throwableWrapper = new ThrowableWrapper ();
191176 lock .lock ();
192177 try {
193- Platform .runLater (new Runnable () {
194-
195- @ Override
196- public void run () {
197- lock .lock ();
178+ Platform .runLater (() -> {
179+ lock .lock ();
180+ try {
181+ run .run ();
182+ } catch (Throwable e ) {
183+ throwableWrapper .t = e ;
184+ } finally {
198185 try {
199- run .run ();
200- } catch (Throwable e ) {
201- throwableWrapper .t = e ;
186+ condition .signal ();
202187 } finally {
203- try {
204- condition .signal ();
205- } finally {
206- lock .unlock ();
207- }
188+ lock .unlock ();
208189 }
209190 }
210191 });
0 commit comments