Search in sources :

Example 1 with MqttStatusReceiver

use of io.joynr.messaging.mqtt.statusmetrics.MqttStatusReceiver in project joynr by bmwcarit.

the class MqttPahoClientTest method testClientNotifiesStatusReceiverAboutShutdownDisconnect.

@Test
public void testClientNotifiesStatusReceiverAboutShutdownDisconnect() throws Exception {
    final MqttStatusReceiver mqttStatusReceiver = mock(MqttStatusReceiver.class);
    final JoynrMqttClient mqttClient = createMqttClientWithoutSubscription(false, mqttStatusReceiver);
    verify(mqttStatusReceiver).notifyConnectionStatusChanged(MqttStatusReceiver.ConnectionStatus.CONNECTED);
    mqttClient.shutdown();
    verify(mqttStatusReceiver).notifyConnectionStatusChanged(MqttStatusReceiver.ConnectionStatus.NOT_CONNECTED);
}
Also used : JoynrMqttClient(io.joynr.messaging.mqtt.JoynrMqttClient) MqttStatusReceiver(io.joynr.messaging.mqtt.statusmetrics.MqttStatusReceiver) Test(org.junit.Test)

Example 2 with MqttStatusReceiver

use of io.joynr.messaging.mqtt.statusmetrics.MqttStatusReceiver in project joynr by bmwcarit.

the class MqttPahoClientTest method testClientNotifiesStatusReceiverAboutBrokerDisconnect.

// This test was disabled, because it runs perfectly on a local machine but not in the CI.
// Further investigations are required to stabilize this test.
@Test
@Ignore
public void testClientNotifiesStatusReceiverAboutBrokerDisconnect() throws Exception {
    final MqttStatusReceiver mqttStatusReceiver = mock(MqttStatusReceiver.class);
    @SuppressWarnings("unused") final JoynrMqttClient mqttClient = createMqttClientWithoutSubscription(false, mqttStatusReceiver);
    verify(mqttStatusReceiver).notifyConnectionStatusChanged(MqttStatusReceiver.ConnectionStatus.CONNECTED);
    stopBroker();
    Thread.sleep(1000);
    verify(mqttStatusReceiver).notifyConnectionStatusChanged(MqttStatusReceiver.ConnectionStatus.NOT_CONNECTED);
    startBroker();
    Thread.sleep(2000);
    verify(mqttStatusReceiver, times(2)).notifyConnectionStatusChanged(MqttStatusReceiver.ConnectionStatus.CONNECTED);
}
Also used : JoynrMqttClient(io.joynr.messaging.mqtt.JoynrMqttClient) MqttStatusReceiver(io.joynr.messaging.mqtt.statusmetrics.MqttStatusReceiver) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with MqttStatusReceiver

use of io.joynr.messaging.mqtt.statusmetrics.MqttStatusReceiver in project joynr by bmwcarit.

the class JeeIntegrationBeanTest method testJoynrStatusMetricsObjectIsUsedAsJoynrStatusReceiver.

@Test
public void testJoynrStatusMetricsObjectIsUsedAsJoynrStatusReceiver() {
    Injector joynrInjector = joynrIntegrationBean.getJoynrInjector();
    MqttStatusReceiver mqttStatusReceiver = joynrInjector.getInstance(MqttStatusReceiver.class);
    StatusReceiver statusReceiver = joynrInjector.getInstance(StatusReceiver.class);
    assertNotNull(joynrStatusMetrics);
    // We cannot compare these objects directly using the == operator. The reason is that the joynrStatusMetrics object is
    // wrapped by a java proxy. Therefore the objects are different. However, the toString() method is called on the
    // underlying object.
    assertEquals(mqttStatusReceiver.toString(), joynrStatusMetrics.toString());
    assertEquals(statusReceiver.toString(), joynrStatusMetrics.toString());
}
Also used : Injector(com.google.inject.Injector) MqttStatusReceiver(io.joynr.messaging.mqtt.statusmetrics.MqttStatusReceiver) StatusReceiver(io.joynr.statusmetrics.StatusReceiver) MqttStatusReceiver(io.joynr.messaging.mqtt.statusmetrics.MqttStatusReceiver) Test(org.junit.Test)

Aggregations

MqttStatusReceiver (io.joynr.messaging.mqtt.statusmetrics.MqttStatusReceiver)3 Test (org.junit.Test)3 JoynrMqttClient (io.joynr.messaging.mqtt.JoynrMqttClient)2 Injector (com.google.inject.Injector)1 StatusReceiver (io.joynr.statusmetrics.StatusReceiver)1 Ignore (org.junit.Ignore)1