Search in sources :

Example 1 with InitialContext

use of javax.naming.InitialContext in project camel by apache.

the class GreaterCamelBeanTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    Properties properties = new Properties();
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
    InitialContext initialContext = new InitialContext(properties);
    return new JndiRegistry(initialContext);
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext)

Example 2 with InitialContext

use of javax.naming.InitialContext in project camel by apache.

the class GreaterCamelEjbTest method createEjbContext.

private static Context createEjbContext() throws NamingException {
    // here we need to define our context factory to use OpenEJB for our testing
    Properties properties = new Properties();
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
    return new InitialContext(properties);
}
Also used : Properties(java.util.Properties) InitialContext(javax.naming.InitialContext)

Example 3 with InitialContext

use of javax.naming.InitialContext in project camel by apache.

the class GreaterTest method setUp.

protected void setUp() throws Exception {
    Properties properties = new Properties();
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
    initialContext = new InitialContext(properties);
}
Also used : Properties(java.util.Properties) InitialContext(javax.naming.InitialContext)

Example 4 with InitialContext

use of javax.naming.InitialContext in project camel by apache.

the class JndiCamelSingletonInitialContextFactoryTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry jndi = new JndiRegistry(new InitialContext(env));
    jndi.bind("jdbc/myDataSource", FAKE);
    return jndi;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) InitialContext(javax.naming.InitialContext)

Example 5 with InitialContext

use of javax.naming.InitialContext in project camel by apache.

the class ComponentFoundInRegistryTest method testGuice.

@Test
public void testGuice() throws Exception {
    Hashtable<String, Object> env = new Hashtable<String, Object>();
    env.put(Context.PROVIDER_URL, GuiceInitialContextFactory.class.getName());
    env.put(Injectors.MODULE_CLASS_NAMES, MyModule.class.getName());
    InitialContext context = new InitialContext(env);
    Injector injector = (Injector) context.lookup(Injector.class.getName());
    assertNotNull("Found injector", injector);
    Object value = context.lookup("foo");
    assertNotNull("Should have found a value for foo!", value);
    CamelContext camelContext = injector.getInstance(CamelContext.class);
    Component component = camelContext.getComponent("foo");
    assertThat(component, is(MockComponent.class));
    Endpoint endpoint = camelContext.getEndpoint("foo:cheese");
    assertThat(endpoint, is(MockEndpoint.class));
}
Also used : CamelContext(org.apache.camel.CamelContext) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Hashtable(java.util.Hashtable) MockComponent(org.apache.camel.component.mock.MockComponent) InitialContext(javax.naming.InitialContext) Endpoint(org.apache.camel.Endpoint) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Injector(com.google.inject.Injector) MockComponent(org.apache.camel.component.mock.MockComponent) Component(org.apache.camel.Component) GuiceInitialContextFactory(org.apache.camel.guice.jndi.GuiceInitialContextFactory) Test(org.junit.Test)

Aggregations

InitialContext (javax.naming.InitialContext)1068 Test (org.junit.Test)325 EJBException (javax.ejb.EJBException)228 Properties (java.util.Properties)213 Context (javax.naming.Context)194 RemoteException (java.rmi.RemoteException)173 TestFailureException (org.apache.openejb.test.TestFailureException)172 NamingException (javax.naming.NamingException)168 AssertionFailedError (junit.framework.AssertionFailedError)168 JMSException (javax.jms.JMSException)167 RemoveException (javax.ejb.RemoveException)66 CreateException (javax.ejb.CreateException)57 DataSource (javax.sql.DataSource)55 Hashtable (java.util.Hashtable)54 Assembler (org.apache.openejb.assembler.classic.Assembler)47 EjbJar (org.apache.openejb.jee.EjbJar)41 NameNotFoundException (javax.naming.NameNotFoundException)40 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)38 Connection (java.sql.Connection)37 StatelessBean (org.apache.openejb.jee.StatelessBean)30