@@ -0,0 +1,2726 @@
+%0Apackage eu.mosaic_cloud.tools.callbacks.core.tests;%0A%0A%0Aimport eu.mosaic_cloud.tools.callbacks.core.CallbackCompletion;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0A%0Apublic final class CallbackCompletionTest%0A%7B%0A%09@Test%0A%09public final void testFailure ()%0A%09%7B%0A%09%09final Throwable exception = new Throwable ();%0A%09%09final CallbackCompletion%3CVoid%3E completion = CallbackCompletion.createFailure (exception);%0A%09%09Assert.assertTrue (completion.isCompleted ());%0A%09%09Assert.assertSame (exception, completion.getException ());%0A%09%09try %7B%0A%09%09%09completion.getOutcome ();%0A%09%09%09Assert.fail ();%0A%09%09%7D catch (final IllegalStateException exception1) %7B%0A%09%09%09// NOTE: expected behavior%0A%09%09%7D%0A%09%09Assert.assertTrue (this.awaitFailure (completion));%0A%09%7D%0A%09%0A%09@Test%0A%09public final void testOutcome ()%0A%09%7B%0A%09%09final CallbackCompletion%3CVoid%3E completion = CallbackCompletion.createOutcome ();%0A%09%09Assert.assertTrue (completion.isCompleted ());%0A%09%09Assert.assertNull (completion.getException ());%0A%09%09Assert.assertNull (completion.getOutcome ());%0A%09%09Assert.assertTrue (this.awaitSuccess (completion));%0A%09%7D%0A%09%0A%09protected final boolean awaitBooleanOutcome (final CallbackCompletion%3CBoolean%3E completion)%0A%09%7B%0A%09%09CallbackCompletionTest.await (completion, this.defaultPoolTimeout);%0A%09%09return this.getBooleanOutcome (completion);%0A%09%7D%0A%09%0A%09protected final %3C_Outcome_ extends Object%3E _Outcome_ awaitOutcome (final CallbackCompletion%3C_Outcome_%3E completion)%0A%09%7B%0A%09%09CallbackCompletionTest.await (completion, this.defaultPoolTimeout);%0A%09%09return this.getOutcome (completion);%0A%09%7D%0A%09%0A%09protected final boolean awaitSuccess (final CallbackCompletion%3C?%3E completion)%0A%09%7B%0A%09%09CallbackCompletionTest.await (completion, this.defaultPoolTimeout);%0A%09%09Assert.assertTrue (completion.isCompleted ());%0A%09%09Assert.assertEquals (null, completion.getException ());%0A%09%09return true;%0A%09%7D%0A%0A%09protected final boolean awaitFailure (final CallbackCompletion%3C?%3E completion)%0A%09%7B%0A%09%09CallbackCompletionTest.await (completion, this.defaultPoolTimeout);%0A%09%09Assert.assertTrue (completion.isCompleted ());%0A%09%09Assert.assertNotNull (completion.getException ());%0A%09%09return true;%0A%09%7D%0A%09%0A%09protected final boolean getBooleanOutcome (final CallbackCompletion%3CBoolean%3E completion)%0A%09%7B%0A%09%09final Boolean value = this.getOutcome (completion);%0A%09%09Assert.assertNotNull (value);%0A%09%09return value.booleanValue ();%0A%09%7D%0A%09%0A%09protected final %3C_Outcome_ extends Object%3E _Outcome_ getOutcome (final CallbackCompletion%3C_Outcome_%3E completion)%0A%09%7B%0A%09%09Assert.assertTrue (completion.isCompleted ());%0A%09%09Assert.assertEquals (null, completion.getException ());%0A%09%09return completion.getOutcome ();%0A%09%7D%0A%09%0A%09public final long defaultPoolTimeout = 1000;%0A%09%0A%09protected static final void await (final CallbackCompletion%3C?%3E completion, final long timeout)%0A%09%7B%0A%09%09Assert.assertTrue (completion.await (timeout));%0A%09%7D%0A%7D%0A

Add callback completion tests