Package org.fusesource.mqtt.client

Examples of org.fusesource.mqtt.client.BlockingConnection.disconnect()


            String payload = "Test Message: " + i;
            connection.publish("foo", payload.getBytes(), QoS.AT_MOST_ONCE, false);
            Message message = connection.receive();
            assertEquals(payload, new String(message.getPayload()));
        }
        connection.disconnect();
    }

    @Test
    public void testSendAndReceiveAtLeastOnce() throws Exception {
        addMQTTConnector(brokerService);
View Full Code Here


            connection.publish("foo", payload.getBytes(), QoS.AT_LEAST_ONCE, false);
            Message message = connection.receive();
            message.ack();
            assertEquals(payload, new String(message.getPayload()));
        }
        connection.disconnect();
    }

    @Test
    public void testSendAndReceiveExactlyOnce() throws Exception {
        addMQTTConnector(brokerService);
View Full Code Here

            pubConnection.publish("foo", payload.getBytes(), QoS.EXACTLY_ONCE, false);
            Message message = subConnection.receive();
            message.ack();
            assertEquals(payload, new String(message.getPayload()));
        }
        subConnection.disconnect();
        pubConnection.disconnect();
    }

    @Test
    public void testSendAndReceiveLargeMessages() throws Exception {
View Full Code Here

            pubConnection.publish("foo", payload, QoS.AT_LEAST_ONCE, false);
            Message message = subConnection.receive();
            message.ack();
            assertArrayEquals(payload, message.getPayload());
        }
        subConnection.disconnect();
        pubConnection.disconnect();
    }


    @Test
View Full Code Here

            assertEquals(payload, new String(bs.data, bs.offset, bs.length));
        }


        activeMQConnection.close();
        connection.disconnect();
    }

    protected void addMQTTConnector(BrokerService brokerService) throws Exception {
        brokerService.addConnector("mqtt://localhost:1883");
    }
View Full Code Here

        final BlockingConnection mqtt = createMQTTConnection().blockingConnection();
        mqtt.connect();
        byte[] payload = bytes("Hello World");
        mqtt.publish("FOO", payload, QoS.AT_LEAST_ONCE, false);
        mqtt.disconnect();

        Message msg = consumer.receive(1000 * 5);
        assertNotNull(msg);
        assertTrue(msg instanceof BytesMessage);

View Full Code Here

            public boolean isSatisified() throws Exception {
                return connection.isConnected();
            }
        }));

        connection.disconnect();
    }

    @Test
    public void testAnonymousUserConnect() throws Exception {
        addMQTTConnector();
View Full Code Here

        final BlockingConnection connection = mqtt.blockingConnection();
        connection.connect();

        System.out.println("Connected!");

        connection.disconnect();

    }

    private void configureAuthentication(BrokerService brokerService) throws Exception {
        LinkedList<AuthenticationUser> users = new LinkedList<AuthenticationUser>();
View Full Code Here

            public boolean isSatisified() throws Exception {
                return connection.isConnected();
            }
        }));

        connection.disconnect();
    }

    @Test(timeout=300000)
    public void testTurnOffInactivityMonitor()throws Exception{
        addMQTTConnector("transport.useInactivityMonitor=false");
View Full Code Here

            public boolean isSatisified() throws Exception {
                return connection.isConnected();
            }
        }));

        connection.disconnect();
    }

    @Test(timeout = 300000)
    public void testJmsMapping() throws Exception {
        addMQTTConnector();
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.