Package org.apache.cayenne.di

Examples of org.apache.cayenne.di.Injector


public class DataContextSerializationTest extends CayenneCase {

    @Override
    protected void setUp() throws Exception {
        Injector injector = mock(Injector.class);
        when(injector.getInstance(DataChannel.class)).thenReturn(getDomain());
        CayenneRuntime.bindThreadInjector(injector);
        deleteTestData();
    }
View Full Code Here


    protected boolean attachToRuntimeIfNeeded() {
        if (channel != null) {
            return false;
        }

        Injector injector = CayenneRuntime.getThreadInjector();
        if (injector == null) {
            throw new CayenneRuntimeException("Can't attach to Cayenne runtime. "
                    + "Null injector returned from CayenneRuntime.getThreadInjector()");
        }
View Full Code Here

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

        Injector injector = DIBootstrap.createInjector(testModule);

        DelegatingDataSourceFactory factoryLoader = new DelegatingDataSourceFactory();
        injector.injectMembers(factoryLoader);

        DataSourceFactory factory = factoryLoader.getDataSourceFactory(nodeDescriptor);
        assertNotNull(factory);
        assertTrue(factory instanceof XMLPoolingDataSourceFactory);
    }
View Full Code Here

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

        Injector injector = DIBootstrap.createInjector(testModule);

        DelegatingDataSourceFactory factoryLoader = new DelegatingDataSourceFactory();
        injector.injectMembers(factoryLoader);

        DataSourceFactory factory = factoryLoader.getDataSourceFactory(nodeDescriptor);
        assertNotNull(factory);
        assertTrue(factory instanceof MockDataSourceFactory1);
        assertSame(
View Full Code Here

                binder.bind(RuntimeProperties.class).toInstance(properties);
                binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
            }
        };

        Injector injector = DIBootstrap.createInjector(testModule);

        DelegatingDataSourceFactory factoryLoader = new DelegatingDataSourceFactory();
        injector.injectMembers(factoryLoader);

        DataSourceFactory factory = factoryLoader.getDataSourceFactory(nodeDescriptor);
        assertNotNull(factory);
        assertTrue(factory instanceof PropertyDataSourceFactory);
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

                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

public class DbImportModuleTest extends TestCase {

    public void testModuleContents() {

        Log log = mock(Log.class);
        Injector i = DIBootstrap.createInjector(new ToolsModule(log), new DbImportModule());
        assertTrue(i.getInstance(DbImportAction.class) instanceof DbImportAction);
    }
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.