use of org.eclipse.scout.rt.platform.exception.PlatformException in project scout.rt by eclipse.
the class JobExceptionTranslationTest method testWithExplicitExceptionTranslator.
@Test
public void testWithExplicitExceptionTranslator() {
final Exception error = new Exception("expected JUnit test exception");
IFuture<Void> future = Jobs.schedule(new IRunnable() {
@Override
public void run() throws Exception {
throw error;
}
}, Jobs.newInput());
try {
future.awaitDoneAndGet(DefaultExceptionTranslator.class);
fail("Exception expected");
} catch (Exception e) {
assertSame(error, e);
}
try {
future.awaitDoneAndGet(DefaultRuntimeExceptionTranslator.class);
fail("PlatformException expected");
} catch (PlatformException e) {
assertSame(error, e.getCause());
}
}
use of org.eclipse.scout.rt.platform.exception.PlatformException in project scout.rt by eclipse.
the class JobScheduleTest method testExceptionExceptionWithRunnable.
@Test
public void testExceptionExceptionWithRunnable() {
final Exception exception = new Exception("expected JUnit test exception");
IFuture<Void> future = Jobs.getJobManager().schedule(new IRunnable() {
@Override
public void run() throws Exception {
throw exception;
}
}, Jobs.newInput().withRunContext(RunContexts.copyCurrent()).withExceptionHandling(null, false));
try {
future.awaitDoneAndGet();
fail("PlatformException expected");
} catch (PlatformException e) {
assertSame(exception, e.getCause());
assertTrue(future.isDone());
}
}
use of org.eclipse.scout.rt.platform.exception.PlatformException in project scout.rt by eclipse.
the class JobScheduleTest method testExceptionExceptionWithCallable.
@Test
public void testExceptionExceptionWithCallable() {
final Exception exception = new Exception("expected JUnit test exception");
IFuture<Void> future = Jobs.getJobManager().schedule(new IRunnable() {
@Override
public void run() throws Exception {
throw exception;
}
}, Jobs.newInput().withRunContext(RunContexts.copyCurrent()).withExceptionHandling(null, false));
try {
future.awaitDoneAndGet();
fail("PlatformException expected");
} catch (PlatformException e) {
assertSame(exception, e.getCause());
assertTrue(future.isDone());
}
}
use of org.eclipse.scout.rt.platform.exception.PlatformException in project scout.rt by eclipse.
the class JobAsyncExceptionTest method testExceptionInChainInterceptor.
@Test
public void testExceptionInChainInterceptor() throws Exception {
registerTestBeans(new P_InterceptorThrowingExceptionProducer());
P_JobManager jobManager = new P_JobManager();
IFuture<Void> future = jobManager.schedule(new IRunnable() {
@Override
public void run() throws Exception {
// NOP
}
}, Jobs.newInput().withRunContext(RunContexts.copyCurrent()));
future.awaitDone();
Assert.assertTrue(jobManager.e1 instanceof PlatformException);
Assert.assertTrue(jobManager.e2 instanceof PlatformException);
Assert.assertNull(jobManager.e3);
}
use of org.eclipse.scout.rt.platform.exception.PlatformException in project scout.rt by eclipse.
the class PlatformAwaitStartedTest method testAwaitPlatformStarted.
@Test
public void testAwaitPlatformStarted() {
final FixturePlatformWithStartListener platform = new FixturePlatformWithStartListener();
new PlatformStarter(platform).start();
try {
platform.m_asyncFinished.await(1, TimeUnit.MINUTES);
} catch (InterruptedException e) {
throw new PlatformException("interrupted waiting for asyncFinished", e);
}
Assert.assertArrayEquals(new Object[] { "asyncStart", "listenerFinished", "asyncFinished" }, platform.m_events.toArray());
}
Aggregations