Example usage for org.springframework.integration.mqtt.core DefaultMqttPahoClientFactory getConnectionOptions

List of usage examples for org.springframework.integration.mqtt.core DefaultMqttPahoClientFactory getConnectionOptions

Introduction

In this page you can find the example usage for org.springframework.integration.mqtt.core DefaultMqttPahoClientFactory getConnectionOptions.

Prototype

@Override
    public MqttConnectOptions getConnectionOptions() 

Source Link

Usage

From source file:org.springframework.integration.mqtt.MqttAdapterTests.java

@Test
public void testPahoConnectOptions() {
    DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory();
    factory.setCleanSession(false);/*w w w .  j a v a2s  . c  om*/
    factory.setConnectionTimeout(23);
    factory.setKeepAliveInterval(45);
    factory.setPassword("pass");
    SocketFactory socketFactory = mock(SocketFactory.class);
    factory.setSocketFactory(socketFactory);
    Properties props = new Properties();
    factory.setSslProperties(props);
    factory.setUserName("user");
    Will will = new Will("foo", "bar".getBytes(), 2, true);
    factory.setWill(will);

    MqttConnectOptions options = factory.getConnectionOptions();

    assertEquals(23, options.getConnectionTimeout());
    assertEquals(45, options.getKeepAliveInterval());
    assertEquals("pass", new String(options.getPassword()));
    assertSame(socketFactory, options.getSocketFactory());
    assertSame(props, options.getSSLProperties());
    assertEquals("user", options.getUserName());
    assertEquals("foo", options.getWillDestination());
    assertEquals("bar", new String(options.getWillMessage().getPayload()));
    assertEquals(2, options.getWillMessage().getQos());

}