Search in sources :

Example 1 with Banana

use of org.mule.tck.testmodels.fruit.Banana in project mule by mulesoft.

the class ClassUtilsTestCase method testInstanciateClass.

@Test
public void testInstanciateClass() throws Exception {
    Object object = ClassUtils.instantiateClass("org.mule.tck.testmodels.fruit.Orange");
    assertNotNull(object);
    assertTrue(object instanceof Orange);
    object = ClassUtils.instantiateClass("org.mule.tck.testmodels.fruit.FruitBowl", new Apple(), new Banana());
    assertNotNull(object);
    assertTrue(object instanceof FruitBowl);
    FruitBowl bowl = (FruitBowl) object;
    assertTrue(bowl.hasApple());
    assertTrue(bowl.hasBanana());
    try {
        ClassUtils.instantiateClass("java.lang.Bing");
        fail("Class does not exist, ClassNotFoundException should have been thrown");
    } catch (ClassNotFoundException e) {
    // expected
    }
}
Also used : Apple(org.mule.tck.testmodels.fruit.Apple) FruitBowl(org.mule.tck.testmodels.fruit.FruitBowl) Orange(org.mule.tck.testmodels.fruit.Orange) Banana(org.mule.tck.testmodels.fruit.Banana) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 2 with Banana

use of org.mule.tck.testmodels.fruit.Banana in project mule by mulesoft.

the class CachedConnectionHandlerTestCase method getConnection.

@Test
public void getConnection() throws Exception {
    Banana connection = managedConnection.getConnection();
    verify(connectionProvider).connect();
    assertThat(connection, is(sameInstance(connection)));
}
Also used : Banana(org.mule.tck.testmodels.fruit.Banana) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 3 with Banana

use of org.mule.tck.testmodels.fruit.Banana in project mule by mulesoft.

the class CachedConnectionManagementStrategyTestCase method getConnection.

@Test
public void getConnection() throws Exception {
    ConnectionHandler<Banana> connectionHandler = connectionStrategy.getConnectionHandler();
    // verify lazy behavior
    verify(connectionProvider, never()).connect();
    Banana connection = connectionHandler.getConnection();
    verify(connectionProvider).connect();
    assertThat(connection, is(sameInstance(this.connection)));
}
Also used : Banana(org.mule.tck.testmodels.fruit.Banana) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 4 with Banana

use of org.mule.tck.testmodels.fruit.Banana in project mule by mulesoft.

the class ImmutableMapCollectorTestCase method collect.

@Test
public void collect() {
    final List<Fruit> fruits = Arrays.asList(new Apple(), new Banana(), new Kiwi());
    Map<String, Fruit> map = fruits.stream().collect(collector);
    assertThat(map.size(), is(3));
    fruits.forEach(fruit -> {
        Fruit value = map.get(fruit.getClass().getName());
        assertThat(value, sameInstance(fruit));
    });
}
Also used : Apple(org.mule.tck.testmodels.fruit.Apple) Kiwi(org.mule.tck.testmodels.fruit.Kiwi) Fruit(org.mule.tck.testmodels.fruit.Fruit) Banana(org.mule.tck.testmodels.fruit.Banana) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 5 with Banana

use of org.mule.tck.testmodels.fruit.Banana in project mule by mulesoft.

the class AbstractSplitterTestCase method simpleSplitter.

@Test
public void simpleSplitter() throws Exception {
    TestSplitter splitter = new TestSplitter(false);
    MultipleEventSensingMessageProcessor listener = new MultipleEventSensingMessageProcessor();
    splitter.setListener(listener);
    splitter.setMuleContext(muleContext);
    Apple apple = new Apple();
    Banana banana = new Banana();
    Orange orange = new Orange();
    FruitBowl fruitBowl = new FruitBowl();
    fruitBowl.addFruit(apple);
    fruitBowl.addFruit(banana);
    fruitBowl.addFruit(orange);
    final CoreEvent inEvent = eventBuilder(muleContext).message(of(fruitBowl)).build();
    CoreEvent resultEvent = splitter.process(inEvent);
    assertThat(listener.events, hasSize(3));
    assertThat(listener.events.get(0).getMessage().getPayload().getValue(), instanceOf(Fruit.class));
    assertThat(listener.events.get(1).getMessage().getPayload().getValue(), instanceOf(Fruit.class));
    assertThat(listener.events.get(2).getMessage().getPayload().getValue(), instanceOf(Fruit.class));
    assertThat(resultEvent.getMessage().getPayload().getValue(), instanceOf(List.class));
    assertThat(((List<InternalMessage>) resultEvent.getMessage().getPayload().getValue()), hasSize(3));
    assertThat(((List<InternalMessage>) resultEvent.getMessage().getPayload().getValue()).get(0).getPayload().getValue(), instanceOf(Fruit.class));
    assertThat(((List<InternalMessage>) resultEvent.getMessage().getPayload().getValue()).get(1).getPayload().getValue(), instanceOf(Fruit.class));
    assertThat(((List<InternalMessage>) resultEvent.getMessage().getPayload().getValue()).get(2).getPayload().getValue(), instanceOf(Fruit.class));
}
Also used : Apple(org.mule.tck.testmodels.fruit.Apple) FruitBowl(org.mule.tck.testmodels.fruit.FruitBowl) InternalMessage(org.mule.runtime.core.internal.message.InternalMessage) Fruit(org.mule.tck.testmodels.fruit.Fruit) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) ArrayList(java.util.ArrayList) List(java.util.List) Orange(org.mule.tck.testmodels.fruit.Orange) Banana(org.mule.tck.testmodels.fruit.Banana) Test(org.junit.Test)

Aggregations

Banana (org.mule.tck.testmodels.fruit.Banana)17 Test (org.junit.Test)13 Apple (org.mule.tck.testmodels.fruit.Apple)7 SmallTest (org.mule.tck.size.SmallTest)6 Orange (org.mule.tck.testmodels.fruit.Orange)5 FruitBowl (org.mule.tck.testmodels.fruit.FruitBowl)4 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)3 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)2 Fruit (org.mule.tck.testmodels.fruit.Fruit)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Before (org.junit.Before)1 ConnectionProvider (org.mule.runtime.api.connection.ConnectionProvider)1 Message (org.mule.runtime.api.message.Message)1 Latch (org.mule.runtime.api.util.concurrent.Latch)1 SimpleConfigurationBuilder (org.mule.runtime.core.api.config.builders.SimpleConfigurationBuilder)1 Transformer (org.mule.runtime.core.api.transformer.Transformer)1 TransformerException (org.mule.runtime.core.api.transformer.TransformerException)1 MuleContextWithRegistries (org.mule.runtime.core.internal.context.MuleContextWithRegistries)1