use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class TransformerChainingTestCase method testIgnoreBadInputBreaksChainWithTransformationOrderInvalidValid.
@Test
public void testIgnoreBadInputBreaksChainWithTransformationOrderInvalidValid() throws Exception {
AbstractTransformer invalidTransformer = (AbstractTransformer) this.getInvalidTransformer();
assertNotNull(invalidTransformer);
invalidTransformer.setIgnoreBadInput(false);
AbstractTransformer validTransformer = (AbstractTransformer) this.getIncreaseByOneTransformer();
assertNotNull(validTransformer);
Message message = of(new Integer(0));
Transformer messageTransformer = new TransformerChain(invalidTransformer, validTransformer);
try {
transformationService.applyTransformers(message, eventBuilder(muleContext).message(of(0)).build(), messageTransformer);
fail("Transformer chain is expected to fail because of invalid transformer within chain.");
} catch (MuleException tfe) {
// ignore
}
}
use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class AbstractProcessingStrategyTestCase method testBackPressure.
protected void testBackPressure(BackPressureStrategy backPressureStrategy, Matcher<Integer> processedAssertion, Matcher<Integer> rejectedAssertion, Matcher<Integer> totalAssertion) throws MuleException {
if (mode.equals(SOURCE)) {
triggerableMessageSource = new TriggerableMessageSource(backPressureStrategy);
flow = flowBuilder.get().source(triggerableMessageSource).processors(asList(cpuLightProcessor, new ThreadTrackingProcessor() {
@Override
public CoreEvent process(CoreEvent event) throws MuleException {
try {
sleep(3);
} catch (InterruptedException e) {
currentThread().interrupt();
throw new RuntimeException(e);
}
return super.process(event);
}
@Override
public ProcessingType getProcessingType() {
return BLOCKING;
}
})).maxConcurrency(2).build();
flow.initialise();
flow.start();
AtomicInteger rejected = new AtomicInteger();
AtomicInteger processed = new AtomicInteger();
for (int i = 0; i < STREAM_ITERATIONS; i++) {
cachedThreadPool.submit(() -> Flux.just(newEvent()).cast(CoreEvent.class).transform(triggerableMessageSource.getListener()).doOnNext(event -> processed.getAndIncrement()).doOnError(e -> rejected.getAndIncrement()).subscribe());
}
new PollingProber(DEFAULT_TIMEOUT * 10, DEFAULT_POLLING_INTERVAL).check(new JUnitLambdaProbe(() -> {
LOGGER.info("DONE " + processed.get() + " , REJECTED " + rejected.get() + ", ");
assertThat(rejected.get() + processed.get(), totalAssertion);
assertThat(processed.get(), processedAssertion);
assertThat(rejected.get(), rejectedAssertion);
return true;
}));
}
}
use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class AbstractProcessingStrategyTestCase method concurrentStream.
@Test
public void concurrentStream() throws Exception {
flow = flowBuilder.get().processors(cpuLightProcessor).build();
flow.initialise();
flow.start();
CountDownLatch latch = new CountDownLatch(STREAM_ITERATIONS);
for (int i = 0; i < CONCURRENT_TEST_CONCURRENCY; i++) {
asyncExecutor.submit(() -> {
for (int j = 0; j < STREAM_ITERATIONS / CONCURRENT_TEST_CONCURRENCY; j++) {
try {
dispatchFlow(newEvent(), t -> latch.countDown(), response -> bubble(new AssertionError("Unexpected error")));
} catch (MuleException e) {
throw new RuntimeException(e);
}
}
});
}
assertThat(latch.await(RECEIVE_TIMEOUT, MILLISECONDS), is(true));
}
Aggregations