Search in sources :

Example 1 with AbstractDatabusCombinedConsumer

use of com.linkedin.databus.client.consumer.AbstractDatabusCombinedConsumer in project databus by linkedin.

the class TestDatabusV2RegistrationImpl method testErrorRegistration.

@Test
public void testErrorRegistration() throws Exception {
    DatabusHttpClientImpl client = null;
    try {
        DatabusHttpClientImpl.Config clientConfig = new DatabusHttpClientImpl.Config();
        clientConfig.getContainer().getJmx().setRmiEnabled(false);
        clientConfig.getContainer().setHttpPort(12003);
        client = new DatabusHttpClientImpl(clientConfig);
        registerRelay(1, "relay1", new InetSocketAddress("localhost", 8888), "S1,S2", client);
        registerRelay(2, "relay2", new InetSocketAddress("localhost", 7777), "S1,S3", client);
        registerRelay(3, "relay1.1", new InetSocketAddress("localhost", 8887), "S1,S2", client);
        registerRelay(4, "relay3", new InetSocketAddress("localhost", 6666), "S3,S4,S5", client);
        TestConsumer listener1 = new TestConsumer();
        DatabusRegistration reg = client.register(listener1, "S6", "S2");
        assertEquals("Registered State", RegistrationState.REGISTERED, reg.getState());
        assertEquals("Component Name", "Status_TestConsumer_6fdc9d8d", reg.getStatus().getComponentName());
        assertEquals("Component Status", Status.INITIALIZING, reg.getStatus().getStatus());
        // Start
        boolean started = false;
        boolean gotException = false;
        try {
            started = reg.start();
        } catch (DatabusClientException ex) {
            gotException = true;
        }
        assertEquals("gotException", true, gotException);
        assertEquals("Registered State", RegistrationState.REGISTERED, reg.getState());
        assertEquals("Component Status", Status.INITIALIZING, reg.getStatus().getStatus());
        gotException = false;
        try {
            reg = client.register((AbstractDatabusCombinedConsumer) null, "S6", "S2");
        } catch (DatabusClientException ex) {
            gotException = true;
        }
        assertEquals("gotException", true, gotException);
        gotException = false;
        try {
            reg = client.register(listener1, null);
        } catch (DatabusClientException ex) {
            gotException = true;
        }
        assertEquals("gotException", true, gotException);
        if (reg != null)
            reg.deregister();
    } finally {
        if (null != client)
            client.shutdown();
    }
}
Also used : DatabusRegistration(com.linkedin.databus.client.pub.DatabusRegistration) InetSocketAddress(java.net.InetSocketAddress) DatabusHttpClientImpl(com.linkedin.databus.client.DatabusHttpClientImpl) AbstractDatabusCombinedConsumer(com.linkedin.databus.client.consumer.AbstractDatabusCombinedConsumer) DatabusClientException(com.linkedin.databus.client.pub.DatabusClientException) Test(org.testng.annotations.Test)

Aggregations

DatabusHttpClientImpl (com.linkedin.databus.client.DatabusHttpClientImpl)1 AbstractDatabusCombinedConsumer (com.linkedin.databus.client.consumer.AbstractDatabusCombinedConsumer)1 DatabusClientException (com.linkedin.databus.client.pub.DatabusClientException)1 DatabusRegistration (com.linkedin.databus.client.pub.DatabusRegistration)1 InetSocketAddress (java.net.InetSocketAddress)1 Test (org.testng.annotations.Test)1