Skip to content

Commit 1d6fec9

Browse files
committed
switch tests from deprecated API
1 parent e0129b3 commit 1d6fec9

File tree

2 files changed

+36
-55
lines changed

2 files changed

+36
-55
lines changed

src/test/java/rx/javafx/sources/JavaFxObservableTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void testRxObservableListAdds() {
6161
new JFXPanel();
6262

6363
ObservableList<String> sourceList = FXCollections.observableArrayList();
64-
Observable<String> emissions = JavaFxObservable.fromObservableListAdds(sourceList);
64+
Observable<String> emissions = JavaFxObservable.additionsOf(sourceList);
6565

6666
CountDownLatch gate = new CountDownLatch(1);
6767

@@ -91,7 +91,7 @@ public void testRxObservableListRemoves() {
9191
new JFXPanel();
9292

9393
ObservableList<String> sourceList = FXCollections.observableArrayList();
94-
Observable<String> emissions = JavaFxObservable.fromObservableListRemovals(sourceList);
94+
Observable<String> emissions = JavaFxObservable.removalsOf(sourceList);
9595

9696
CountDownLatch gate = new CountDownLatch(1);
9797

@@ -121,7 +121,7 @@ public void testRxObservableListChanges() {
121121
new JFXPanel();
122122

123123
ObservableList<String> sourceList = FXCollections.observableArrayList();
124-
Observable<ListChange<String>> emissions = JavaFxObservable.fromObservableListChanges(sourceList);
124+
Observable<ListChange<String>> emissions = JavaFxObservable.changesOf(sourceList);
125125

126126
CountDownLatch gate = new CountDownLatch(1);
127127

@@ -165,7 +165,7 @@ public void testRxObservableListDistinctChangeMappings() {
165165
new JFXPanel();
166166

167167
ObservableList<String> sourceList = FXCollections.observableArrayList();
168-
Observable<ListChange<Integer>> emissions = JavaFxObservable.fromObservableListDistinctMappings(sourceList, String::length);
168+
Observable<ListChange<Integer>> emissions = JavaFxObservable.distinctMappingsOf(sourceList, String::length);
169169

170170
CountDownLatch gate = new CountDownLatch(1);
171171

@@ -211,7 +211,7 @@ public void testRxObservableListDistinctChanges() {
211211
new JFXPanel();
212212

213213
ObservableList<String> sourceList = FXCollections.observableArrayList();
214-
Observable<ListChange<String>> emissions = JavaFxObservable.fromObservableListDistinctChanges(sourceList);
214+
Observable<ListChange<String>> emissions = JavaFxObservable.distinctChangesOf(sourceList);
215215

216216
CountDownLatch gate = new CountDownLatch(1);
217217

src/test/java/rx/schedulers/JavaFxSchedulerTest.java

Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)