Search in sources :

Example 31 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project xtext-core by eclipse.

the class AbstractParallelScenarioRunner method process.

@Override
protected void process(String data) throws Exception {
    IInjectorProvider delegate = getOrCreateInjectorProvider().getDelegate();
    ScenarioProcessor processor = delegate.getInjector().getInstance(getProcessorClass());
    String preProcessed = processor.preProcess(data);
    if (preProcessed == null) {
        throw new AssumptionViolatedException("Input is filtered by the pre processing step: " + data);
    }
    doProcess(preProcessed, processor);
}
Also used : ScenarioProcessor(org.eclipse.xtext.testing.smoketest.ScenarioProcessor) IInjectorProvider(org.eclipse.xtext.testing.IInjectorProvider) AssumptionViolatedException(org.junit.AssumptionViolatedException)

Example 32 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project jacoco by jacoco.

the class Pack200StreamsTest method unpack_should_throw_IOException_when_Pack200_not_available_in_JDK.

@Test
public void unpack_should_throw_IOException_when_Pack200_not_available_in_JDK() {
    try {
        Class.forName("java.util.jar.Pack200");
        throw new AssumptionViolatedException("this test requires JDK without Pack200");
    } catch (ClassNotFoundException ignore) {
    }
    try {
        Pack200Streams.unpack(new ByteArrayInputStream(new byte[0]));
        fail("expected exception");
    } catch (IOException e) {
        assertNull(e.getMessage());
        assertTrue(e.getCause() instanceof ClassNotFoundException);
    }
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) Test(org.junit.Test)

Example 33 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project jacoco by jacoco.

the class Pack200StreamsTest method pack_should_throw_IOException_when_can_not_write_to_OutputStream.

@Test
public void pack_should_throw_IOException_when_can_not_write_to_OutputStream() {
    try {
        Class.forName("java.util.jar.Pack200");
    } catch (ClassNotFoundException e) {
        throw new AssumptionViolatedException("this test requires JDK with Pack200");
    }
    final OutputStream outputStream = new BrokenOutputStream();
    try {
        Pack200Streams.pack(new byte[0], outputStream);
        fail("expected exception");
    } catch (IOException e) {
        assertTrue(e.getCause() instanceof IOException);
        assertEquals("fake broken output stream", e.getCause().getMessage());
    }
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) OutputStream(java.io.OutputStream) ZipOutputStream(java.util.zip.ZipOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FilterOutputStream(java.io.FilterOutputStream) JarOutputStream(java.util.jar.JarOutputStream) IOException(java.io.IOException) Test(org.junit.Test)

Example 34 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project iaf by ibissource.

the class XsltErrorTestBase method documentIncludedInSourceNotFoundXslt2.

@Test
public void documentIncludedInSourceNotFoundXslt2() throws Exception {
    // error not during configure(), but during doPipe()
    setStyleSheetName("/Xslt/importDocument/importNotFound2.xsl");
    setXslt2(true);
    pipe.configure();
    pipe.start();
    String input = TestFileUtils.getTestFile("/Xslt/importDocument/in.xml");
    String errorMessage = null;
    try {
        doPipe(pipe, input, session);
        fail("Expected to run into an exception");
    } catch (AssumptionViolatedException e) {
        assumeTrue("assumption violated:" + e.getMessage(), false);
    } catch (Exception e) {
        errorMessage = e.getMessage();
        assertThat(errorMessage, containsString(FILE_NOT_FOUND_EXCEPTION));
    }
    checkTestAppender(0, null);
    System.out.println("ErrorMessage: " + errorMessage);
    if (testForEmptyOutputStream) {
        System.out.println("ErrorStream(=stderr): " + errorOutputStream.toString());
        System.out.println("Clearing ErrorStream, as I am currently unable to catch it");
        errorOutputStream = new ErrorOutputStream();
    }
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Matchers.containsString(org.hamcrest.Matchers.containsString) PipeRunException(nl.nn.adapterframework.core.PipeRunException) TimeoutException(nl.nn.adapterframework.core.TimeoutException) PipeStartException(nl.nn.adapterframework.core.PipeStartException) AssumptionViolatedException(org.junit.AssumptionViolatedException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) SenderException(nl.nn.adapterframework.core.SenderException) Test(org.junit.Test)

Example 35 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project iaf by ibissource.

the class XsltErrorTestBase method documentIncludedInSourceNotFoundXslt1.

@Test
public void documentIncludedInSourceNotFoundXslt1() throws Exception {
    setStyleSheetName("/Xslt/importDocument/importNotFound1.xsl");
    setXslt2(false);
    setIndent(true);
    pipe.configure();
    pipe.start();
    String input = TestFileUtils.getTestFile("/Xslt/importDocument/in.xml");
    String errorMessage = null;
    try {
        doPipe(pipe, input, session);
    } catch (AssumptionViolatedException e) {
        assumeTrue("assumption violated:" + e.getMessage(), false);
    } catch (Exception e) {
        errorMessage = e.getMessage();
        // System.out.println("ErrorMessage: "+errorMessage);
        assertThat(errorMessage, containsString(FILE_NOT_FOUND_EXCEPTION));
    }
    assertThat(testAppender.toString(), containsString(FILE_NOT_FOUND_EXCEPTION));
    System.out.println("ErrorMessage: " + errorMessage);
    if (testForEmptyOutputStream) {
        System.out.println("ErrorStream(=stderr): " + errorOutputStream.toString());
        System.out.println("Clearing ErrorStream, as I am currently unable to catch it");
        errorOutputStream = new ErrorOutputStream();
    }
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Matchers.containsString(org.hamcrest.Matchers.containsString) PipeRunException(nl.nn.adapterframework.core.PipeRunException) TimeoutException(nl.nn.adapterframework.core.TimeoutException) PipeStartException(nl.nn.adapterframework.core.PipeStartException) AssumptionViolatedException(org.junit.AssumptionViolatedException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) SenderException(nl.nn.adapterframework.core.SenderException) Test(org.junit.Test)

Aggregations

AssumptionViolatedException (org.junit.AssumptionViolatedException)79 Test (org.junit.Test)26 IOException (java.io.IOException)16 Statement (org.junit.runners.model.Statement)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Method (java.lang.reflect.Method)6 Set (java.util.Set)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 File (java.io.File)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 ZipEntry (java.util.zip.ZipEntry)5 ZipOutputStream (java.util.zip.ZipOutputStream)5 InputStream (java.io.InputStream)4 HashSet (java.util.HashSet)4 ZipInputStream (java.util.zip.ZipInputStream)4 FilterInputStream (java.io.FilterInputStream)3 UnknownHostException (java.net.UnknownHostException)3 JarInputStream (java.util.jar.JarInputStream)3 Configuration (org.apache.flink.configuration.Configuration)3 IInjectorProvider (org.eclipse.xtext.junit4.IInjectorProvider)3