Package org.apache.cayenne.di

Examples of org.apache.cayenne.di.Injector


        Map<String, String> properties = new HashMap<String, String>();
        properties.put(Constants.ROP_SERVICE_URL_PROPERTY, "http://localhost/YuM");
        ClientModule module = new ClientModule(properties);

        Injector injector = DIBootstrap.createInjector(module);

        ClientConnection connection = injector.getInstance(ClientConnection.class);
        assertNotNull(connection);
        assertTrue(connection instanceof HessianConnection);

        assertSame("Connection must be a singleton", connection, injector
                .getInstance(ClientConnection.class));
    }
View Full Code Here


                // use a noop connection to prevent startup errors...
                binder.bind(ClientConnection.class).to(MockClientConnection.class);
            }
        };

        Injector injector = DIBootstrap.createInjector(module);

        ObjectContextFactory factory = injector.getInstance(ObjectContextFactory.class);
        assertNotNull(factory);
        assertSame("ObjectContextFactory must be a singleton", factory, injector
                .getInstance(ObjectContextFactory.class));
    }
View Full Code Here

                // use a noop connection to prevent startup errors...
                binder.bind(ClientConnection.class).to(MockClientConnection.class);
            }
        };

        Injector injector = DIBootstrap.createInjector(module);

        DataChannel channel = injector.getInstance(DataChannel.class);
        assertNotNull(channel);
        assertTrue(channel instanceof ClientChannel);
        assertSame("DataChannel must be a singleton", channel, injector
                .getInstance(DataChannel.class));

        ClientChannel clientChannel = (ClientChannel) channel;
        assertTrue(clientChannel.getConnection() instanceof MockClientConnection);
        assertTrue(clientChannel.getEventManager() instanceof DefaultEventManager);
View Full Code Here

                // use a noop connection to prevent startup errors...
                binder.bind(ClientConnection.class).to(MockClientConnection.class);
            }
        };

        Injector injector = DIBootstrap.createInjector(module);

        DataChannel channel = injector.getInstance(DataChannel.class);
        ClientChannel clientChannel = (ClientChannel) channel;
        assertTrue(clientChannel.isChannelEventsEnabled());
    }
View Full Code Here

                binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
                binder.bind(QueryCache.class).toInstance(mock(QueryCache.class));
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        // create and initialize provide instance to test
        DataDomainProvider provider = new DataDomainProvider();
        injector.injectMembers(provider);

        DataChannel channel = provider.get();
        assertNotNull(channel);

        assertTrue(channel instanceof DataDomain);
View Full Code Here

public class WebModuleTest extends TestCase {

    public void testBind_Scopes() {

        Injector injector = new DefaultInjector(new WebModule());
        RequestHandler handler = injector.getInstance(RequestHandler.class);
        assertTrue(handler instanceof SessionContextRequestHandler);

        RequestHandler handler1 = injector.getInstance(RequestHandler.class);
        assertNotSame("Incorrect singleton scope for request handler", handler, handler1);
    }
View Full Code Here

                binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
                binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        DefaultDbAdapterFactory factory = new DefaultDbAdapterFactory(detectors);
        injector.injectMembers(factory);

        DbAdapter createdAdapter = factory.createAdapter(
                new DataNodeDescriptor(),
                dataSource);
        assertTrue(createdAdapter instanceof AutoAdapter);
View Full Code Here

                binder.bind(BatchQueryBuilderFactory.class).toInstance(
                        mock(BatchQueryBuilderFactory.class));
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        DefaultDbAdapterFactory factory = new DefaultDbAdapterFactory(detectors);
        injector.injectMembers(factory);

        DbAdapter createdAdapter = factory.createAdapter(
                new DataNodeDescriptor(),
                new MockDataSource());
        assertNotNull(createdAdapter);
View Full Code Here

                binder.bind(BatchQueryBuilderFactory.class).toInstance(
                        mock(BatchQueryBuilderFactory.class));
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        DefaultDbAdapterFactory factory = new DefaultDbAdapterFactory(detectors);
        injector.injectMembers(factory);

        DbAdapter createdAdapter = factory.createAdapter(
                nodeDescriptor,
                new MockDataSource());
        assertNotNull(createdAdapter);
View Full Code Here

                        DefaultObjectMapRetainStrategy.class);
                binder.bind(ObjectStoreFactory.class).to(DefaultObjectStoreFactory.class);
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        DataContextFactory factory = new DataContextFactory();
        injector.injectMembers(factory);

        DataContext c3 = (DataContext) factory.createContext();
        assertNotNull(c3.getObjectStore().getDataRowCache());
        assertNull(domain.getSharedSnapshotCache());
        assertNotSame(
View Full Code Here

TOP

Related Classes of org.apache.cayenne.di.Injector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.