use of org.mule.tck.testmodels.fruit.FruitBowl in project mule by mulesoft.
the class ClassUtilsTestCase method testGetParameterTypes.
@Test
public void testGetParameterTypes() throws Exception {
FruitBowl bowl = new FruitBowl();
Class[] classes = ClassUtils.getParameterTypes(bowl, "apple");
assertNotNull(classes);
assertEquals(1, classes.length);
assertEquals(Apple.class, classes[0]);
classes = ClassUtils.getParameterTypes(bowl, "invalid");
assertNotNull(classes);
assertEquals(0, classes.length);
}
use of org.mule.tck.testmodels.fruit.FruitBowl 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
}
}
use of org.mule.tck.testmodels.fruit.FruitBowl 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));
}
use of org.mule.tck.testmodels.fruit.FruitBowl in project mule by mulesoft.
the class AbstractSplitterTestCase method allFilteredSplitter.
@Test
public void allFilteredSplitter() throws Exception {
TestSplitter splitter = new TestSplitter(true);
splitter.setListener(event -> {
throw new MessagingException(createStaticMessage("Expected"), event, splitter);
});
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(resultEvent.getMessage().getPayload().getValue(), nullValue());
}
use of org.mule.tck.testmodels.fruit.FruitBowl in project mule by mulesoft.
the class AbstractSplitterTestCase method failingNotFilteredSplitter.
@Test
public void failingNotFilteredSplitter() throws Exception {
TestSplitter splitter = new TestSplitter(false);
splitter.setListener(event -> {
throw new MessagingException(createStaticMessage("Expected"), event, splitter);
});
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();
expected.expect(MessagingException.class);
expected.expectMessage("Expected");
splitter.process(inEvent);
}
Aggregations