Search in sources :

Example 6 with Injector

use of org.apache.camel.spi.Injector in project camel by apache.

the class DefaultFactoryFinderTest method shouldCreateNewInstancesWithInjector.

@Test
public void shouldCreateNewInstancesWithInjector() throws ClassNotFoundException, IOException {
    final Injector injector = createMock(Injector.class);
    final TestImplA expected = new TestImplA();
    expect(injector.newInstance(TestImplA.class)).andReturn(expected);
    replay(injector);
    final List<TestType> instances = factoryFinder.newInstances("TestImplA", injector, TestType.class);
    verify(injector);
    assertEquals(1, instances.size());
    assertThat(instances, hasItem(expected));
    assertSame(expected, instances.get(0));
}
Also used : Injector(org.apache.camel.spi.Injector) Test(org.junit.Test)

Aggregations

Injector (org.apache.camel.spi.Injector)6 DefaultInjector (org.apache.camel.impl.DefaultInjector)3 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 TransformerFactory (javax.xml.transform.TransformerFactory)1 CamelContext (org.apache.camel.CamelContext)1 XsltBuilder (org.apache.camel.builder.xml.XsltBuilder)1 ClassResolver (org.apache.camel.spi.ClassResolver)1