use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class ClientRuntimeBuilderTest method testDataChannel_NoChannelEvents.
@Test
public void testDataChannel_NoChannelEvents() {
Map<String, String> properties1 = new HashMap<>();
properties1.put(ClientConstants.ROP_CHANNEL_EVENTS_PROPERTY, "true");
ClientModule module = new ClientModule() {
@Override
public void configure(Binder binder) {
super.configure(binder);
// use a noop connection to prevent startup errors...
binder.bind(ClientConnection.class).to(MockClientConnection.class);
ServerModule.contributeProperties(binder).putAll(properties1);
}
};
Injector injector = DIBootstrap.createInjector(module);
DataChannel channel = injector.getInstance(DataChannel.class);
ClientChannel clientChannel = (ClientChannel) channel;
assertTrue(clientChannel.isChannelEventsEnabled());
}
use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class ClientRuntimeBuilderTest method testClientConnection.
@Test
public void testClientConnection() {
Map<String, String> properties1 = new HashMap<>();
properties1.put(ClientConstants.ROP_SERVICE_URL_PROPERTY, "http://localhost/YuM");
ClientModule module = new ClientModule() {
@Override
public void configure(Binder binder) {
super.configure(binder);
ServerModule.contributeProperties(binder).putAll(properties1);
}
};
Injector injector = DIBootstrap.createInjector(module);
ClientConnection connection = injector.getInstance(ClientConnection.class);
assertNotNull(connection);
assertTrue(connection instanceof HttpClientConnection);
assertSame("Connection must be a singleton", connection, injector.getInstance(ClientConnection.class));
}
use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class CommitLogModuleBuilderTest method testListener_Class.
@Test
public void testListener_Class() {
Module m = CommitLogModule.extend().addListener(L.class).module();
Injector i = DIBootstrap.createInjector(m);
List<CommitLogListener> listeners = i.getInstance(Key.getListOf(CommitLogListener.class));
assertEquals(1, listeners.size());
assertTrue(listeners.get(0) instanceof L);
}
use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class CommitLogModuleBuilderTest method testListener_Object.
@Test
public void testListener_Object() {
L listener = new L();
Module m = CommitLogModule.extend().addListener(listener).module();
Injector i = DIBootstrap.createInjector(m);
List<CommitLogListener> listeners = i.getInstance(Key.getListOf(CommitLogListener.class));
assertEquals(1, listeners.size());
assertTrue(listeners.contains(listener));
}
use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class CryptoModuleBuilderTest method testBuild_KeySource.
@Test
public void testBuild_KeySource() {
URL ksUrl = JceksKeySourceTest.class.getResource(JceksKeySourceTest.KS1_JCEKS);
Module m = new CryptoModuleExtender().keyStore(ksUrl, JceksKeySourceTest.TEST_KEY_PASS, "k1").valueTransformer(DefaultValueTransformerFactory.class).module();
Injector injector = DIBootstrap.createInjector(new CryptoModule(), m);
KeySource ks = injector.getInstance(KeySource.class);
Key k1 = ks.getKey("k1");
assertNotNull(k1);
assertEquals("DES", k1.getAlgorithm());
String dkName = ks.getDefaultKeyAlias();
assertEquals("k1", dkName);
}
Aggregations