use of org.awaitility.core.ConditionTimeoutException in project JavaFXLibrary by eficode.
the class HelperFunctions method waitUntilExists.
public static Node waitUntilExists(String target, int timeout, String timeUnit) {
robotLog("TRACE", "Waiting until target \"" + target.toString() + "\" becomes existent, timeout=" + Integer.toString(timeout) + ", timeUnit=" + timeUnit);
try {
Awaitility.setDefaultTimeout(timeout, getTimeUnit(timeUnit));
AtomicReference<Node> node = new AtomicReference<>();
Awaitility.await().until(() -> {
node.set(robot.lookup(target).query());
return node.get() != null;
});
robotLog("TRACE", "Node located: \"" + node.get().toString() + "\"");
return node.get();
} catch (ConditionTimeoutException e) {
throw new JavaFXLibraryNonFatalException("Given element \"" + target.toString() + "\" was not found within given timeout of " + Integer.toString(timeout) + " " + timeUnit);
}
}
use of org.awaitility.core.ConditionTimeoutException in project pinpoint by naver.
the class PipelineFactoryTest method testBind.
@Test
public void testBind() throws Exception {
PinpointServerAcceptor serverAcceptor = null;
Socket socket = null;
try {
serverAcceptor = new PinpointServerAcceptor(ChannelFilter.BYPASS, new TestPipelineFactory());
final DiscardServerHandler discardServerHandler = new DiscardServerHandler();
serverAcceptor.setMessageHandler(discardServerHandler);
serverAcceptor.bind("127.0.0.1", bindPort);
socket = new Socket("127.0.0.1", bindPort);
socket.getOutputStream().write((START_KEY + "Test").getBytes());
socket.getOutputStream().flush();
assertMessageReceivedCount(1, discardServerHandler);
socket.getOutputStream().write(('@' + "Test").getBytes());
socket.getOutputStream().flush();
try {
assertMessageReceivedCount(2, discardServerHandler);
Assert.fail();
} catch (ConditionTimeoutException e) {
// ignore
}
} finally {
IOUtils.closeQuietly(socket);
PinpointRPCTestUtils.close(serverAcceptor);
}
}
use of org.awaitility.core.ConditionTimeoutException in project pinpoint by naver.
the class AwaitIOUtils method read.
public static byte[] read(final InputStream inputStream, long waitUnitTime, long maxWaitTime) throws IOException {
try {
waitForIoReady(inputStream, waitUnitTime, maxWaitTime);
} catch (ConditionTimeoutException e) {
throw new IOException("no available data", e);
}
int availableSize = inputStream.available();
byte[] payload = new byte[availableSize];
inputStream.read(payload);
return payload;
}
use of org.awaitility.core.ConditionTimeoutException in project AntennaPod by AntennaPod.
the class EspressoTestUtils method tryKillPlaybackService.
public static void tryKillPlaybackService() {
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
context.stopService(new Intent(context, PlaybackService.class));
try {
// Android has no reliable way to stop a service instantly.
// Calling stopSelf marks allows the system to destroy the service but the actual call
// to onDestroy takes until the next GC of the system, which we can not influence.
// Try to wait for the service at least a bit.
Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> !PlaybackService.isRunning);
} catch (ConditionTimeoutException e) {
e.printStackTrace();
}
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
}
use of org.awaitility.core.ConditionTimeoutException in project AntennaPod by AntennaPod.
the class AutoDownloadTest method downloadsEnqueuedToAfterCurrent_CurrentAdvancedToNextOnPlaybackComplete.
/**
* A cross-functional test, ensuring playback's behavior works with Auto Download in boundary condition.
*
* Scenario:
* - For setting enqueue location AFTER_CURRENTLY_PLAYING
* - when playback of an episode is complete and the app advances to the next episode (continuous playback on)
* - when automatic download kicks in,
* - ensure the next episode is the current playing one, needed for AFTER_CURRENTLY_PLAYING enqueue location.
*/
@Test
public void downloadsEnqueuedToAfterCurrent_CurrentAdvancedToNextOnPlaybackComplete() throws Exception {
// continuous playback
UserPreferences.setFollowQueue(true);
// Setup: feeds and queue
// downloads 3 of them, leave some in new state (auto-downloadable)
stubFeedsServer.addLocalFeedData(false);
List<FeedItem> queue = DBReader.getQueue();
assertTrue(queue.size() > 1);
FeedItem item0 = queue.get(0);
FeedItem item1 = queue.get(1);
// Actual test
// Play the first one in the queue
playEpisode(item0);
try {
// when playback is complete, advances to the next one, and auto download kicks in,
// ensure that currently playing has been advanced to the next one by this point.
Awaitility.await("advanced to the next episode").atMost(6000, // the test mp3 media is 3-second long. twice should be enough
MILLISECONDS).until(() -> item1.getMedia().getId() == stubDownloadAlgorithm.getCurrentlyPlayingAtDownload());
} catch (ConditionTimeoutException cte) {
long actual = stubDownloadAlgorithm.getCurrentlyPlayingAtDownload();
fail("when auto download is triggered, the next episode should be playing: (" + item1.getId() + ", " + item1.getTitle() + ") . " + "Actual playing: (" + actual + ")");
}
}
Aggregations