Search in sources :

Example 56 with AssumptionViolatedException

use of org.junit.AssumptionViolatedException in project xtext-eclipse 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.junit4.smoketest.ScenarioProcessor) IInjectorProvider(org.eclipse.xtext.junit4.IInjectorProvider) AssumptionViolatedException(org.junit.AssumptionViolatedException)

Example 57 with AssumptionViolatedException

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

the class AbstractScenarioRunner method methodBlock.

@Override
protected Statement methodBlock(final FrameworkMethod method) {
    IInjectorProvider injectorProvider = getOrCreateInjectorProvider();
    final IRegistryConfigurator registryConfigurator = (IRegistryConfigurator) injectorProvider;
    registryConfigurator.setupRegistry();
    final Statement methodBlock = superMethodBlock(method);
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            try {
                try {
                    methodBlock.evaluate();
                    throw new AssumptionViolatedException("Method " + method.getName() + " did parse any input");
                } finally {
                    registryConfigurator.restoreRegistry();
                }
            } catch (TestDataCarrier testData) {
                process(testData.getData());
            }
        }
    };
}
Also used : IInjectorProvider(org.eclipse.xtext.junit4.IInjectorProvider) AssumptionViolatedException(org.junit.AssumptionViolatedException) Statement(org.junit.runners.model.Statement) IRegistryConfigurator(org.eclipse.xtext.junit4.IRegistryConfigurator)

Example 58 with AssumptionViolatedException

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

the class AbstractScenarioRunner method process.

protected void process(String data) throws Exception {
    IInjectorProvider delegate = getOrCreateInjectorProvider().getDelegate();
    if (delegate instanceof IRegistryConfigurator) {
        IRegistryConfigurator registryConfigurator = (IRegistryConfigurator) delegate;
        registryConfigurator.setupRegistry();
        try {
            ScenarioProcessor processor = delegate.getInjector().getInstance(processorClass);
            String preProcessed = processor.preProcess(data);
            if (preProcessed == null) {
                throw new AssumptionViolatedException("Input is filtered by the pre processing step: " + data);
            }
            doProcess(preProcessed, processor);
        } finally {
            registryConfigurator.restoreRegistry();
        }
    }
}
Also used : ScenarioProcessor(org.eclipse.xtext.junit4.smoketest.ScenarioProcessor) IInjectorProvider(org.eclipse.xtext.junit4.IInjectorProvider) AssumptionViolatedException(org.junit.AssumptionViolatedException) IRegistryConfigurator(org.eclipse.xtext.junit4.IRegistryConfigurator)

Example 59 with AssumptionViolatedException

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

the class StreamingPipeTestBase method doPipe.

@Override
protected PipeRunResult doPipe(P pipe, Message input, PipeLineSession session) throws PipeRunException {
    PipeRunResult prr = null;
    // TODO: CapProvider should not be provided as argument to provideOutputStream, because that is not used there.
    // Instead, it must be the next pipe in the pipeline. When it is called, the forward of that pipe
    // must be the result of the streaming operation.
    // CapProvider capProvider = writeOutputToStream?new CapProvider(null):null;
    // TODO: must replace with capProvider, to monitor proper pass through
    IPipe nextPipe = null;
    if (provideStreamForInput) {
        // Object result;
        try (MessageOutputStream target = pipe.provideOutputStream(session, nextPipe)) {
            assumeNotNull(target);
            if (input.isBinary()) {
                try (OutputStream stream = target.asStream()) {
                    stream.write(input.asByteArray());
                }
            } else {
                try (Writer writer = target.asWriter()) {
                    writer.write(input.asString());
                }
            }
            prr = target.getPipeRunResult();
        } catch (AssumptionViolatedException e) {
            throw e;
        } catch (Exception e) {
            throw new PipeRunException(pipe, "cannot convert input", e);
        }
    } else {
        // if (classic) {
        prr = pipe.doPipe(input, session);
    // } else {
    // prr = pipe.doPipe(input, session, nextPipe);
    // }
    }
    assertNotNull(prr);
    assertNotNull(prr.getPipeForward());
    // }
    return prr;
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) AssumptionViolatedException(org.junit.AssumptionViolatedException) OutputStream(java.io.OutputStream) PipeRunException(nl.nn.adapterframework.core.PipeRunException) IPipe(nl.nn.adapterframework.core.IPipe) Writer(java.io.Writer) PipeRunException(nl.nn.adapterframework.core.PipeRunException) AssumptionViolatedException(org.junit.AssumptionViolatedException)

Example 60 with AssumptionViolatedException

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

the class RobolectricTestRunner method getSandbox.

@Override
@Nonnull
protected AndroidSandbox getSandbox(FrameworkMethod method) {
    RobolectricFrameworkMethod roboMethod = (RobolectricFrameworkMethod) method;
    Sdk sdk = roboMethod.getSdk();
    InstrumentationConfiguration classLoaderConfig = createClassLoaderConfig(method);
    ResourcesMode resourcesMode = roboMethod.getResourcesMode();
    if (resourcesMode == ResourcesMode.LEGACY && sdk.getApiLevel() > Build.VERSION_CODES.P) {
        throw new AssumptionViolatedException("Robolectric doesn't support legacy mode after P");
    }
    LooperMode.Mode looperMode = roboMethod.configuration == null ? Mode.LEGACY : roboMethod.configuration.get(LooperMode.Mode.class);
    sdk.verifySupportedSdk(method.getDeclaringClass().getName());
    return sandboxManager.getAndroidSandbox(classLoaderConfig, sdk, resourcesMode, looperMode);
}
Also used : ResourcesMode(org.robolectric.internal.ResourcesMode) InstrumentationConfiguration(org.robolectric.internal.bytecode.InstrumentationConfiguration) AssumptionViolatedException(org.junit.AssumptionViolatedException) Mode(org.robolectric.annotation.LooperMode.Mode) SQLiteMode(org.robolectric.annotation.SQLiteMode) ResourcesMode(org.robolectric.internal.ResourcesMode) LooperMode(org.robolectric.annotation.LooperMode) Sdk(org.robolectric.pluginapi.Sdk) LooperMode(org.robolectric.annotation.LooperMode) Mode(org.robolectric.annotation.LooperMode.Mode) Nonnull(javax.annotation.Nonnull)

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