Search in sources :

Example 1 with HttpClientConnection

use of org.apache.cayenne.rop.HttpClientConnection 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));
}
Also used : Binder(org.apache.cayenne.di.Binder) HashMap(java.util.HashMap) Injector(org.apache.cayenne.di.Injector) HttpClientConnection(org.apache.cayenne.rop.HttpClientConnection) MockClientConnection(org.apache.cayenne.remote.MockClientConnection) ClientConnection(org.apache.cayenne.remote.ClientConnection) HttpClientConnection(org.apache.cayenne.rop.HttpClientConnection) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Binder (org.apache.cayenne.di.Binder)1 Injector (org.apache.cayenne.di.Injector)1 ClientConnection (org.apache.cayenne.remote.ClientConnection)1 MockClientConnection (org.apache.cayenne.remote.MockClientConnection)1 HttpClientConnection (org.apache.cayenne.rop.HttpClientConnection)1 Test (org.junit.Test)1