Search in sources :

Example 1 with Orange

use of org.mule.tck.testmodels.fruit.Orange 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 Orange

use of org.mule.tck.testmodels.fruit.Orange 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)

Example 3 with Orange

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

the class BeanUtilsTestCase method testBeanPropertiesWithoutFail.

@Test
public void testBeanPropertiesWithoutFail() throws Exception {
    Orange o = new Orange();
    BeanUtils.populateWithoutFail(o, map, true);
    assertNotNull(o);
    assertEquals("Juicy!", o.getBrand());
    assertEquals(new Double(2.32), o.getRadius());
    assertEquals(new Integer(22), o.getSegments());
}
Also used : Orange(org.mule.tck.testmodels.fruit.Orange) Test(org.junit.Test)

Example 4 with Orange

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

the class TestContextFactory method populateTestData.

protected void populateTestData(Context context) throws NamingException {
    context.bind("fruit/apple", new Apple());
    context.bind("fruit/banana", new Banana());
    context.bind("fruit/orange", new Orange(new Integer(8), new Double(10), "Florida Sunny"));
}
Also used : Apple(org.mule.tck.testmodels.fruit.Apple) Orange(org.mule.tck.testmodels.fruit.Orange) Banana(org.mule.tck.testmodels.fruit.Banana)

Example 5 with Orange

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

the class BeanUtilsTestCase method testBeanPropertiesWithFail.

@Test
public void testBeanPropertiesWithFail() throws Exception {
    try {
        BeanUtils.populate(new Orange(), map);
        fail("Trombones is not a valid property");
    } catch (IllegalArgumentException e) {
        // expected
        assertTrue(e.getMessage().indexOf("trombone") > -1);
    }
}
Also used : Orange(org.mule.tck.testmodels.fruit.Orange) Test(org.junit.Test)

Aggregations

Orange (org.mule.tck.testmodels.fruit.Orange)9 Test (org.junit.Test)8 Apple (org.mule.tck.testmodels.fruit.Apple)6 Banana (org.mule.tck.testmodels.fruit.Banana)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 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 InternalMessage (org.mule.runtime.core.internal.message.InternalMessage)1 SmallTest (org.mule.tck.size.SmallTest)1 Fruit (org.mule.tck.testmodels.fruit.Fruit)1 OrangeInterface (org.mule.tck.testmodels.fruit.OrangeInterface)1