Examples of MQTT


Examples of org.fusesource.mqtt.client.MQTT

    protected MQTT createMQTTConnection() throws Exception {
        return createMQTTConnection(null, false);
    }

    protected MQTT createMQTTConnection(String clientId, boolean clean) throws Exception {
        MQTT mqtt = new MQTT();
        mqtt.setConnectAttemptsMax(1);
        mqtt.setReconnectAttemptsMax(0);
        mqtt.setTracer(createTracer());
        if (clientId != null) {
            mqtt.setClientId(clientId);
        }
        mqtt.setCleanSession(clean);
        mqtt.setHost("localhost", mqttConnector.getConnectUri().getPort());
        // shut off connect retry
        return mqtt;
    }
View Full Code Here

Examples of org.fusesource.mqtt.client.MQTT

    @Test(timeout=60 * 1000)
    public void testMQTT311Connection()throws Exception{
        addMQTTConnector();
        brokerService.start();
        MQTT mqtt = createMQTTConnection();
        mqtt.setClientId("foo");
        mqtt.setVersion("3.1.1");
        final BlockingConnection connection = mqtt.blockingConnection();
        connection.connect();
        connection.disconnect();
    }
View Full Code Here

Examples of org.fusesource.mqtt.client.MQTT

    @Test
    public void testPingKeepsInactivityMonitorAlive() throws Exception {
        addMQTTConnector();
        brokerService.start();
        MQTT mqtt = createMQTTConnection();
        mqtt.setKeepAlive((short)2);
        final BlockingConnection connection = mqtt.blockingConnection();
        connection.connect();

        assertTrue("KeepAlive didn't work properly", Wait.waitFor(new Wait.Condition() {

            @Override
View Full Code Here

Examples of org.fusesource.mqtt.client.MQTT

    @Test
    public void testTurnOffInactivityMonitor()throws Exception{
        addMQTTConnector("?transport.useInactivityMonitor=false");
        brokerService.start();
        MQTT mqtt = createMQTTConnection();
        mqtt.setKeepAlive((short)2);
        final BlockingConnection connection = mqtt.blockingConnection();
        connection.connect();

        assertTrue("KeepAlive didn't work properly", Wait.waitFor(new Wait.Condition() {

            @Override
View Full Code Here

Examples of org.fusesource.mqtt.client.MQTT

    @Test
    public void testDefaultKeepAliveWhenClientSpecifiesZero() throws Exception {
        // default keep alive in milliseconds
        addMQTTConnector("?transport.defaultKeepAlive=2000");
        brokerService.start();
        MQTT mqtt = createMQTTConnection();
        mqtt.setKeepAlive((short)0);
        final BlockingConnection connection = mqtt.blockingConnection();
        connection.connect();

        assertTrue("KeepAlive didn't work properly", Wait.waitFor(new Wait.Condition() {

            @Override
View Full Code Here

Examples of org.fusesource.mqtt.client.MQTT

    protected MQTTClientProvider getMQTTClientProvider() {
        return new FuseMQQTTClientProvider();
    }

    protected MQTT createMQTTConnection() throws Exception {
        MQTT mqtt = new MQTT();
        mqtt.setHost("localhost", mqttConnector.getConnectUri().getPort());
        // shut off connect retry
        mqtt.setConnectAttemptsMax(0);
        mqtt.setReconnectAttemptsMax(0);
        return mqtt;
    }
View Full Code Here

Examples of org.fusesource.mqtt.client.MQTT

    protected String getProtocolScheme() {
        return "mqtt+ssl";
    }

    protected MQTT createMQTTConnection() throws Exception {
        MQTT mqtt = new MQTT();
        mqtt.setHost("ssl://localhost:"+mqttConnector.getConnectUri().getPort());
        SSLContext ctx = SSLContext.getInstance("TLS");
        ctx.init(new KeyManager[0], new TrustManager[]{new DefaultTrustManager()}, new SecureRandom());
        mqtt.setSslContext(ctx);
        return mqtt;
    }
View Full Code Here

Examples of org.fusesource.mqtt.client.MQTT

    @Test
    public void testPingOnMQTTNIO() throws Exception {
        addMQTTConnector("?maxInactivityDuration=-1");
        brokerService.start();
        MQTT mqtt = createMQTTConnection();
        mqtt.setKeepAlive((short)2);
        final BlockingConnection connection = mqtt.blockingConnection();
        connection.connect();
        assertTrue("KeepAlive didn't work properly", Wait.waitFor(new Wait.Condition() {

            @Override
            public boolean isSatisified() throws Exception {
View Full Code Here

Examples of org.fusesource.mqtt.client.MQTT

public class MQTTProducerTest extends MQTTBaseTest {

    @Test
    public void testProduce() throws Exception {
        MQTT mqtt = new MQTT();
        final BlockingConnection subscribeConnection = mqtt.blockingConnection();
        subscribeConnection.connect();
        Topic topic = new Topic(TEST_TOPIC, QoS.AT_MOST_ONCE);
        Topic[] topics = {topic};
        subscribeConnection.subscribe(topics);
        final CountDownLatch latch = new CountDownLatch(numberOfMessages);
View Full Code Here

Examples of org.fusesource.mqtt.client.MQTT

public class MQTTConsumerTest extends MQTTBaseTest {

    @Test
    public void testConsume() throws Exception {
        MQTT mqtt = new MQTT();
        BlockingConnection publisherConnection = mqtt.blockingConnection();
        Topic topic = new Topic(TEST_TOPIC, QoS.AT_MOST_ONCE);
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMinimumMessageCount(numberOfMessages);

        publisherConnection.connect();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.