Search in sources :

Example 1 with PlatformException

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());
    }
}
Also used : PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) ExecutionException(java.util.concurrent.ExecutionException) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) Test(org.junit.Test)

Example 2 with PlatformException

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());
    }
}
Also used : PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) AssertionException(org.eclipse.scout.rt.platform.util.Assertions.AssertionException) Test(org.junit.Test)

Example 3 with PlatformException

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());
    }
}
Also used : PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) AssertionException(org.eclipse.scout.rt.platform.util.Assertions.AssertionException) Test(org.junit.Test)

Example 4 with PlatformException

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);
}
Also used : PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) CallableChainHandledException(org.eclipse.scout.rt.platform.job.internal.CallableChainHandledException) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) Test(org.junit.Test)

Example 5 with PlatformException

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());
}
Also used : PlatformStarter(org.eclipse.scout.rt.platform.internal.PlatformStarter) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) Test(org.junit.Test)

Aggregations

PlatformException (org.eclipse.scout.rt.platform.exception.PlatformException)35 Test (org.junit.Test)13 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)9 IOException (java.io.IOException)8 FileInputStream (java.io.FileInputStream)4 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)4 VetoException (org.eclipse.scout.rt.platform.exception.VetoException)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InputStream (java.io.InputStream)3 URL (java.net.URL)3 ArrayList (java.util.ArrayList)3 TestLookupCall (org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall)3 AssertionException (org.eclipse.scout.rt.platform.util.Assertions.AssertionException)3 ILookupCall (org.eclipse.scout.rt.shared.services.lookup.ILookupCall)3 File (java.io.File)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 List (java.util.List)2 ExecutionException (java.util.concurrent.ExecutionException)2 BeanMetaData (org.eclipse.scout.rt.platform.BeanMetaData)2