Search in sources :

Example 86 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class CollectMapForkJoinStrategyTestCase method collectMap.

@Test
@Description("This strategy waits for all routes to return and then collects results into a map where the key of each entry is the string representation of the index of the routing pair.")
public void collectMap() throws Throwable {
    Message route1Result = of(1);
    Message route2Result = of(2);
    Message route3Result = of(3);
    RoutingPair pair1 = createRoutingPair(route1Result);
    RoutingPair pair2 = createRoutingPair(route2Result);
    RoutingPair pair3 = createRoutingPair(route3Result);
    CoreEvent result = invokeStrategyBlocking(strategy, testEvent(), asList(pair1, pair2, pair3));
    assertThat(result.getMessage().getPayload().getValue(), instanceOf(Map.class));
    Map<String, Message> resultMap = (Map<String, Message>) result.getMessage().getPayload().getValue();
    assertThat(resultMap.entrySet(), hasSize(3));
    assertThat(resultMap.get("0"), is(route1Result));
    assertThat(resultMap.get("1"), is(route2Result));
    assertThat(resultMap.get("2"), is(route3Result));
}
Also used : Message(org.mule.runtime.api.message.Message) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) RoutingPair(org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair) Map(java.util.Map) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 87 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class JoinOnlyForkJoinStrategyTestCase method joinOnly.

@Test
@Description("This strategy waits for all routes to return and then returns the original event.")
public void joinOnly() throws Throwable {
    CoreEvent original = testEvent();
    Processor processor1 = createProcessorSpy(of(1));
    Processor processor2 = createProcessorSpy(of(2));
    Processor processor3 = createProcessorSpy(of(3));
    RoutingPair pair1 = createRoutingPair(processor1);
    RoutingPair pair2 = createRoutingPair(processor2);
    RoutingPair pair3 = createRoutingPair(processor3);
    CoreEvent result = invokeStrategyBlocking(strategy, original, asList(pair1, pair2, pair3));
    assertThat(result, is(original));
    verify(processor1, times(1)).process(any(CoreEvent.class));
    verify(processor2, times(1)).process(any(CoreEvent.class));
    verify(processor2, times(1)).process(any(CoreEvent.class));
}
Also used : Processor(org.mule.runtime.core.api.processor.Processor) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) RoutingPair(org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 88 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class WorkQueueProcessingStrategyTestCase method blockingRejectedExecution.

@Test
@Description("If IO pool is busy OVERLOAD error is thrown")
public void blockingRejectedExecution() throws Exception {
    Scheduler blockingSchedulerSpy = spy(blocking);
    Scheduler rejectingSchedulerSpy = spy(new RejectingScheduler(blockingSchedulerSpy));
    flow = flowBuilder.get().processors(blockingProcessor).processingStrategyFactory((context, prefix) -> new WorkQueueProcessingStrategy(() -> rejectingSchedulerSpy)).build();
    flow.initialise();
    flow.start();
    expectRejected();
    processFlow(testEvent());
}
Also used : WorkQueueProcessingStrategy(org.mule.runtime.core.internal.processor.strategy.WorkQueueProcessingStrategyFactory.WorkQueueProcessingStrategy) Scheduler(org.mule.runtime.api.scheduler.Scheduler) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 89 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class CompositeProcessorChainRouterTestCase method simpleChain.

@Test
@Description("Ensure that with simple chains both chains are executed consecutively with the result of the first chain being used for the second chain.")
public void simpleChain() throws Exception {
    Message chain1Out = of(1);
    Message chain2Out = of(2);
    AtomicReference<Message> chain1In = new AtomicReference<>();
    AtomicReference<Message> chain2In = new AtomicReference<>();
    MessageProcessorChain chain1 = newChain(empty(), event -> {
        chain1In.set(event.getMessage());
        return builder(event).message(chain1Out).build();
    });
    MessageProcessorChain chain2 = newChain(empty(), event -> {
        chain2In.set(event.getMessage());
        return builder(event).message(chain2Out).build();
    });
    chainRouter = createCompositeProcessorChainRouter(chain1, chain2);
    Message result = chainRouter.execute(testEvent()).get().getMessage();
    assertThat(chain1In.get(), equalTo(testEvent().getMessage()));
    assertThat(chain2In.get(), equalTo(chain1Out));
    assertThat(result, equalTo(chain2Out));
}
Also used : MessageProcessorChain(org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain) Message(org.mule.runtime.api.message.Message) AtomicReference(java.util.concurrent.atomic.AtomicReference) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 90 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class ApplicationDeploymentTestCase method deploysAppWithNotExportedPackageAndPlugin.

@Test
@Issue("MULE-13756")
@Description("Tests that code called form plugin's Processor cannot access internal resources/packages of the application")
public void deploysAppWithNotExportedPackageAndPlugin() throws Exception {
    ArtifactPluginFileBuilder loadsAppResourcePlugin = new ArtifactPluginFileBuilder("loadsAppResourcePlugin").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.foo").containingClass(loadsAppResourceCallbackClassFile, "org/foo/LoadsAppResourceCallback.class");
    ApplicationFileBuilder nonExposingAppFileBuilder = new ApplicationFileBuilder("non-exposing-app").configuredWith(EXPORTED_PACKAGES, "org.bar1").configuredWith(EXPORTED_RESOURCES, "test-resource.txt").definedBy("app-with-loads-app-resource-plugin-config.xml").containingClass(barUtils1ClassFile, "org/bar1/BarUtils.class").containingClass(barUtils2ClassFile, "org/bar2/BarUtils.class").containingResource("test-resource.txt", "test-resource.txt").containingResource("test-resource.txt", "test-resource-not-exported.txt").dependingOn(loadsAppResourcePlugin);
    addPackedAppFromBuilder(nonExposingAppFileBuilder);
    startDeployment();
    assertApplicationDeploymentSuccess(applicationDeploymentListener, nonExposingAppFileBuilder.getId());
    executeApplicationFlow("main");
}
Also used : ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) Issue(io.qameta.allure.Issue) Description(io.qameta.allure.Description) Test(org.junit.Test)

Aggregations

Description (io.qameta.allure.Description)117 Test (org.junit.Test)111 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)41 Matchers.containsString (org.hamcrest.Matchers.containsString)15 Message (org.mule.runtime.api.message.Message)13 TypedValue (org.mule.runtime.api.metadata.TypedValue)13 RoutingPair (org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair)12 MessageProcessorChain (org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain)12 OperationParameters (org.mule.runtime.extension.api.client.OperationParameters)12 Matchers.anyString (org.mockito.Matchers.anyString)8 List (java.util.List)7 MavenConfiguration (org.mule.maven.client.api.model.MavenConfiguration)7 Processor (org.mule.runtime.core.api.processor.Processor)7 RemoteRepository (org.mule.maven.client.api.model.RemoteRepository)6 Event (org.mule.runtime.api.event.Event)6 ReactiveProcessor (org.mule.runtime.core.api.processor.ReactiveProcessor)6 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)6 InternalProcessor (org.mule.runtime.core.privileged.processor.InternalProcessor)6 SmallTest (org.mule.tck.size.SmallTest)6 TestTransaction (org.mule.tck.testmodels.mule.TestTransaction)6