当前位置: 首页>>代码示例>>Java>>正文


Java MQTT.setVersion方法代码示例

本文整理汇总了Java中org.fusesource.mqtt.client.MQTT.setVersion方法的典型用法代码示例。如果您正苦于以下问题:Java MQTT.setVersion方法的具体用法?Java MQTT.setVersion怎么用?Java MQTT.setVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.fusesource.mqtt.client.MQTT的用法示例。


在下文中一共展示了MQTT.setVersion方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testConnection

import org.fusesource.mqtt.client.MQTT; //导入方法依赖的package包/类
@Test(timeout = 30000)
public void testConnection() throws Exception {
   for (String version : Arrays.asList("3.1", "3.1.1")) {

      BlockingConnection connection = null;
      try {
         MQTT mqtt = createMQTTConnection("test-" + version, true);
         mqtt.setUserName(fullUser);
         mqtt.setPassword(fullPass);
         mqtt.setConnectAttemptsMax(1);
         mqtt.setVersion(version);
         connection = mqtt.blockingConnection();
         connection.connect();
         BlockingConnection finalConnection = connection;
         assertTrue("Should be connected", Wait.waitFor(() -> finalConnection.isConnected(), 5000, 100));
      } finally {
         if (connection != null && connection.isConnected()) connection.disconnect();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:21,代码来源:MQTTSecurityTest.java

示例2: testConnectionWithNullPassword

import org.fusesource.mqtt.client.MQTT; //导入方法依赖的package包/类
@Test(timeout = 30000, expected = EOFException.class)
public void testConnectionWithNullPassword() throws Exception {
   for (String version : Arrays.asList("3.1", "3.1.1")) {

      BlockingConnection connection = null;
      try {
         MQTT mqtt = createMQTTConnection("test-" + version, true);
         mqtt.setUserName(fullUser);
         mqtt.setPassword((String) null);
         mqtt.setConnectAttemptsMax(1);
         mqtt.setVersion(version);
         connection = mqtt.blockingConnection();
         connection.connect();
         fail("Connect should fail");
      } finally {
         if (connection != null && connection.isConnected()) connection.disconnect();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:20,代码来源:MQTTSecurityTest.java

示例3: testConnectWithLargePassword

import org.fusesource.mqtt.client.MQTT; //导入方法依赖的package包/类
@Test
public void testConnectWithLargePassword() throws Exception {
   for (String version : Arrays.asList("3.1", "3.1.1")) {
      String longString = new String(new char[65535]);

      BlockingConnection connection = null;
      try {
         MQTT mqtt = createMQTTConnection("test-" + version, true);
         mqtt.setUserName(longString);
         mqtt.setPassword(longString);
         mqtt.setConnectAttemptsMax(1);
         mqtt.setVersion(version);
         connection = mqtt.blockingConnection();
         connection.connect();
         BlockingConnection finalConnection = connection;
         assertTrue("Should be connected", Wait.waitFor(() -> finalConnection.isConnected(), 5000, 100));
      } finally {
         if (connection != null && connection.isConnected()) connection.disconnect();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:MQTTTest.java

示例4: createMQTTTcpConnection

import org.fusesource.mqtt.client.MQTT; //导入方法依赖的package包/类
private MQTT createMQTTTcpConnection(String clientId, boolean clean) throws Exception {
   MQTT mqtt = new MQTT();
   mqtt.setConnectAttemptsMax(1);
   mqtt.setReconnectAttemptsMax(0);
   mqtt.setTracer(createTracer());
   mqtt.setVersion("3.1.1");
   if (clientId != null) {
      mqtt.setClientId(clientId);
   }
   mqtt.setCleanSession(clean);
   mqtt.setHost("localhost", port);
   return mqtt;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:14,代码来源:MQTTTestSupport.java

示例5: testMQTT311Connection

import org.fusesource.mqtt.client.MQTT; //导入方法依赖的package包/类
@Test(timeout = 60 * 1000)
public void testMQTT311Connection() throws Exception {
   MQTT mqtt = createMQTTConnection();
   mqtt.setClientId("foo");
   mqtt.setVersion("3.1.1");
   final BlockingConnection connection = mqtt.blockingConnection();
   connection.connect();
   connection.disconnect();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:10,代码来源:MQTTTest.java

示例6: createMQTTConnection

import org.fusesource.mqtt.client.MQTT; //导入方法依赖的package包/类
protected MQTT createMQTTConnection() throws Exception {
   MQTT client = createMQTTConnection(null, false);
   client.setVersion("3.1.1");
   return client;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:6,代码来源:MQTTTestSupport.java


注:本文中的org.fusesource.mqtt.client.MQTT.setVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。