@Test @Description("Regardless of back-pressure strategy this processing strategy blocks and processes all events") public void sourceBackPressureDrop() throws Exception { testBackPressure(DROP, equalTo(STREAM_ITERATIONS), equalTo(0), equalTo(STREAM_ITERATIONS)); }
@Override @Description("With the ProactorProcessingStrategy, when all processor are CPU_LIGHT then they are all exectured in a single " + " cpu light thread.") public void multipleCpuLight() throws Exception { super.multipleCpuLight(); assertThat(threads, hasSize(equalTo(1))); assertThat(threads.stream().filter(name -> name.startsWith(CPU_LIGHT)).count(), equalTo(1l)); assertThat(threads, not(hasItem(startsWith(IO)))); assertThat(threads, not(hasItem(startsWith(CPU_INTENSIVE)))); assertThat(threads, not(hasItem(startsWith(CUSTOM)))); }
@Test @Description("Regardless of back-pressure strategy this processing strategy blocks and processes all events") public void sourceBackPressureWait() throws Exception { if (mode.equals(SOURCE)) { testBackPressure(WAIT, equalTo(STREAM_ITERATIONS), equalTo(0), equalTo(STREAM_ITERATIONS)); } }
@Test @Description("If the processing type is IO_RW and the payload is not a stream processing occurs in CPU_LIGHT thread.") public void singleIOWRWString() throws Exception { super.singleIORW(() -> testEvent(), contains(CPU_LIGHT)); assertThat(threads, hasSize(equalTo(1))); assertThat(threads.stream().filter(name -> name.startsWith(CPU_LIGHT)).count(), equalTo(1l)); assertThat(threads, not(hasItem(startsWith(IO)))); assertThat(threads, not(hasItem(startsWith(CPU_INTENSIVE)))); assertThat(threads, not(hasItem(startsWith(CUSTOM)))); }
@Test @Description("Verifies that a simple literal expression is successful.") public void simple() { String expression = "\"wow\""; assertString(expression); }
@Test @Description("iterator has size") public void size() throws Exception { StreamingIterator<String> it = this.newIterator(); assertThat(it.getSize(), is(TOP)); }
@Override @Test @Description("When back-pressure strategy is 'DROP' the flow rejects requests in the same way way with 'FAIL. It is the source that handles FAIL and DROP differently.") public void sourceBackPressureDrop() throws Exception { testBackPressure(DROP, lessThan(STREAM_ITERATIONS), greaterThan(0), equalTo(STREAM_ITERATIONS)); }
@Test @Description("Verifies that an unmapped error is handled as ANY.") public void simpleRequest() throws Exception { verifySuccessExpression("noMapping", UNMATCHED_ERROR_MESSAGE); }
@Test @Description("Verifies that a mapped error via a custom matcher is handled through the proxy smart connector.") public void matchingMappedRequestProxy() throws Exception { verifySuccessExpression("complexMappingProxy", CONNECT_ERROR_MESSAGE); }
@Test @Description("Verifies that a mapped error via global error handler works.") public void globalMappingWithDefaultErrorHandlerTimeout() throws Exception { verifySuccessExpression("globalMappingWithDefaultErrorHandlerTimeout", TIMEOUT_ERROR_MESSAGE); }
@Override @Description("Regardless of processor type, when the ReactorProcessingStrategy is configured, the pipeline is executed " + "synchronously in a single cpu light thread.") public void singleBlocking() throws Exception { super.singleBlocking(); assertEverythingOnEventLoop(); }
@Override @Description("When the WorkQueueProcessingStrategy is configured any async processing will be returned to IO thread. " + "This helps avoid deadlocks when there are reduced number of threads used by async processor.") public void asyncCpuLightConcurrent() throws Exception { super.asyncCpuLightConcurrent(); assertThat(threads.size(), between(2, 4)); assertThat(threads.stream().filter(name -> name.startsWith(IO)).count(), between(2l, 4l)); assertThat(threads, not(hasItem(startsWith(CPU_LIGHT)))); assertThat(threads, not(hasItem(startsWith(CPU_INTENSIVE)))); assertThat(threads, not(hasItem(startsWith(CUSTOM)))); }
@Override @Description("When the ReactorProcessingStrategy is configured and a transaction is active processing fails with an error") public void asyncCpuLight() throws Exception { super.asyncCpuLight(); assertThat(threads, hasSize(between(1, 2))); assertThat(threads.stream().filter(name -> name.startsWith(CPU_LIGHT)).count(), between(1l, 2l)); assertThat(threads, not(hasItem(startsWith(IO)))); assertThat(threads, not(hasItem(startsWith(CPU_INTENSIVE)))); assertThat(threads, not(hasItem(startsWith(CUSTOM)))); }
@Test @Description("Verifies that parsing works with inner expressions in MVEL but only with regular ones in DW.") public void parseCompatibility() throws MuleException { assertThat(expressionManager.parse("this is #[payload]", testEvent(), TEST_CONNECTOR_LOCATION), is(format("this is %s", TEST_PAYLOAD))); assertThat(expressionManager.parse("#[dw:'this is ' ++ payload]", testEvent(), TEST_CONNECTOR_LOCATION), is(format("this is %s", TEST_PAYLOAD))); }
@Test @Description("Verifies that a map expression is successful.") public void map() { String expression = "{\'name\' : \'Sarah\', \'surname\' : \'Manning\'}"; Object result = expressionManager.evaluate(expression).getValue(); assertThat(result, is(instanceOf(Map.class))); assertThat((Map<String, String>) result, hasEntry("name", "Sarah")); assertThat((Map<String, String>) result, hasEntry("surname", "Manning")); }
@Test @Description("A closed iterator doesn't have next") public void closedIterator() throws Exception { StreamingIterator<String> it = this.newIterator(); it.close(); Assert.assertFalse(it.hasNext()); }
@Test @Description("Test that repeatable iterator in typed value is consumed into a list") public void consumeRepeatableIteratorTypedValue() throws Exception { CursorIteratorProvider payload = asCursorProvider(TEST_LIST); TypedValue consumed = consumeRepeatableValue(TypedValue.of(payload)); assertConsumedObjectStream(payload, consumed); }
@Test @Description("Verify that a single component location produces connector and source data.") public void componentDataFromSingleComponent() throws Exception { BaseEventContext context = this.context.get(); assertThat(context.getOriginatingLocation().getComponentIdentifier().getIdentifier().getNamespace(), is(CORE_PREFIX)); assertThat(context.getOriginatingLocation().getComponentIdentifier().getIdentifier().getName(), is("test")); }
@Test @Description("Verifies that the Event variable still works for MVEL but that it fails for DW.") public void eventCompatibilityVariables() throws MuleException { String expression = "_muleEvent"; Object mvelFlowResult = expressionLanguageAdapter.evaluate(melify(expression), testEvent(), emptyBindingContext).getValue(); assertThat(mvelFlowResult, is(instanceOf(CoreEvent.class))); expectedException.expect(RuntimeException.class); expressionLanguageAdapter.evaluate(expression, testEvent(), emptyBindingContext).getValue(); }
@Override @Description("When the ProactorProcessingStrategy is configured and a transaction is active processing fails with an error") public void tx() throws Exception { flow = flowBuilder.get().processors(cpuLightProcessor, cpuIntensiveProcessor, blockingProcessor).build(); flow.initialise(); flow.start(); TransactionCoordination.getInstance().bindTransaction(new TestTransaction(muleContext)); expectedException.expect(MessagingException.class); expectedException.expectCause(instanceOf(DefaultMuleException.class)); expectedException.expectCause(hasMessage(equalTo(TRANSACTIONAL_ERROR_MESSAGE))); processFlow(testEvent()); }