/** * @return The Debug Properties */ public Properties getDebug() { final String strNull="null"; Properties p = new Properties(); p.put("MqttVersion", new Integer(getMqttVersion())); p.put("CleanSession", Boolean.valueOf(isCleanSession())); p.put("ConTimeout", new Integer(getConnectionTimeout())); p.put("KeepAliveInterval", new Integer(getKeepAliveInterval())); p.put("UserName", (getUserName() == null) ? strNull : getUserName()); p.put("WillDestination", (getWillDestination() == null) ? strNull : getWillDestination()); if (getSocketFactory()==null) { p.put("SocketFactory", strNull); } else { p.put("SocketFactory", getSocketFactory()); } if (getSSLProperties()==null) { p.put("SSLProperties", strNull); } else { p.put("SSLProperties", getSSLProperties()); } return p; }
private ContentValues getValues(Connection connection){ MqttConnectOptions conOpts = connection.getConnectionOptions(); MqttMessage lastWill = conOpts.getWillMessage(); ContentValues values = new ContentValues(); //put the column values object values.put(COLUMN_CLIENT_HANDLE, connection.handle()); values.put(COLUMN_HOST, connection.getHostName()); values.put(COLUMN_port, connection.getPort()); values.put(COLUMN_client_ID, connection.getId()); values.put(COLUMN_ssl, connection.isSSL()); values.put(COLUMN_KEEP_ALIVE, conOpts.getKeepAliveInterval()); values.put(COLUMN_TIME_OUT, conOpts.getConnectionTimeout()); values.put(COLUMN_USER_NAME, conOpts.getUserName()); values.put(COLUMN_TOPIC, conOpts.getWillDestination()); //uses "condition ? trueValue: falseValue" for in line converting of values char[] password = conOpts.getPassword(); values.put(COLUMN_CLEAN_SESSION, conOpts.isCleanSession() ? 1 : 0); //convert boolean to int and then put in values values.put(COLUMN_PASSWORD, password != null ? String.valueOf(password) : null); //convert char[] to String values.put(COLUMN_MESSAGE, lastWill != null ? new String(lastWill.getPayload()) : null); // convert byte[] to string values.put(COLUMN_QOS, lastWill != null ? lastWill.getQos() : 0); if (lastWill == null) { values.put(COLUMN_RETAINED, 0); } else { values.put(COLUMN_RETAINED, lastWill.isRetained() ? 1 : 0); //convert from boolean to int } return values; }
/** * Get a Last Will and Testament message's destination topic. * @return the value. may be null. */ public String getWillDestination() { return options.getWillDestination(); }
keepAlive = connection.getConnectionOptions().getKeepAliveInterval(); if(connection.getConnectionOptions().getWillDestination() == null){ lwtTopic = ""; } else { lwtTopic = connection.getConnectionOptions().getWillDestination();
assertSame(props, options.getSSLProperties()); assertEquals("user", options.getUserName()); assertEquals("foo", options.getWillDestination()); assertEquals("bar", new String(options.getWillMessage().getPayload())); assertEquals(2, options.getWillMessage().getQos());
assertSame(props, options.getSSLProperties()); assertEquals("user", options.getUserName()); assertEquals("foo", options.getWillDestination()); assertEquals("bar", new String(options.getWillMessage().getPayload())); assertEquals(2, options.getWillMessage().getQos());
conOptions.getPassword(), conOptions.getWillMessage(), conOptions.getWillDestination());
@Test public void testConnectWithLwt() throws Exception { MockMqttClient mockClient = new MockMqttClient(); AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMqttClient(mockClient); AWSIotMqttLastWillAndTestament lwt = new AWSIotMqttLastWillAndTestament("test/lwt", "bye", AWSIotMqttQos.QOS0); testClient.setMqttLastWillAndTestament(lwt); TestClientStatusCallback csb = new TestClientStatusCallback(); KeyStore testKeystore = AWSIotKeystoreHelper .getIotKeystore(CERT_ID, KEYSTORE_PATH, KEYSTORE_NAME, KEYSTORE_PASSWORD); testClient.connect(testKeystore, csb); mockClient.mockConnectSuccess(); assertEquals(1, mockClient.connectCalls); assertTrue(mockClient.mostRecentOptions.isCleanSession()); assertEquals(300, mockClient.mostRecentOptions.getKeepAliveInterval()); assertEquals("test/lwt", mockClient.mostRecentOptions.getWillDestination()); assertEquals("bye", new String(mockClient.mostRecentOptions.getWillMessage().getPayload())); assertEquals(AWSIotMqttQos.QOS0.asInt(), mockClient.mostRecentOptions.getWillMessage().getQos()); assertFalse(mockClient.mostRecentOptions.getWillMessage().isRetained()); assertEquals(2, csb.statuses.size()); assertEquals(AWSIotMqttClientStatusCallback.AWSIotMqttClientStatus.Connecting, csb.statuses.get(0)); assertEquals(AWSIotMqttClientStatusCallback.AWSIotMqttClientStatus.Connected, csb.statuses.get(1)); assertEquals(MqttManagerConnectionState.Connected, testClient.getConnectionState()); }
public Properties getDebug() { Properties p = new Properties(); p.put("CleanSession", new Boolean(isCleanSession())); p.put("ConTimeout", new Integer(getConnectionTimeout())); p.put("KeepAliveInterval", new Integer(getKeepAliveInterval())); p.put("UserName", (getUserName()==null)?"null":getUserName()); p.put("WillDestination", (getWillDestination()==null)?"null":getWillDestination()); if (getSocketFactory()==null) { p.put("SocketFactory", "null"); } else { p.put("SocketFactory", getSocketFactory()); } if (getSSLProperties()==null) { p.put("SSLProperties", "null"); } else { p.put("SSLProperties", getSSLProperties()); } return p; }
/** * @return The Debug Properties */ public Properties getDebug() { final String strNull="null"; Properties p = new Properties(); p.put("MqttVersion", new Integer(getMqttVersion())); p.put("CleanSession", Boolean.valueOf(isCleanSession())); p.put("ConTimeout", new Integer(getConnectionTimeout())); p.put("KeepAliveInterval", new Integer(getKeepAliveInterval())); p.put("UserName", (getUserName() == null) ? strNull : getUserName()); p.put("WillDestination", (getWillDestination() == null) ? strNull : getWillDestination()); if (getSocketFactory()==null) { p.put("SocketFactory", strNull); } else { p.put("SocketFactory", getSocketFactory()); } if (getSSLProperties()==null) { p.put("SSLProperties", strNull); } else { p.put("SSLProperties", getSSLProperties()); } return p; }
/** * @return The Debug Properties */ public Properties getDebug() { final String strNull="null"; Properties p = new Properties(); p.put("MqttVersion", new Integer(getMqttVersion())); p.put("CleanSession", Boolean.valueOf(isCleanSession())); p.put("ConTimeout", new Integer(getConnectionTimeout())); p.put("KeepAliveInterval", new Integer(getKeepAliveInterval())); p.put("UserName", (getUserName() == null) ? strNull : getUserName()); p.put("WillDestination", (getWillDestination() == null) ? strNull : getWillDestination()); if (getSocketFactory()==null) { p.put("SocketFactory", strNull); } else { p.put("SocketFactory", getSocketFactory()); } if (getSSLProperties()==null) { p.put("SSLProperties", strNull); } else { p.put("SSLProperties", getSSLProperties()); } return p; }
values.put(COLUMN_TIME_OUT, conOpts.getConnectionTimeout()); values.put(COLUMN_USER_NAME, conOpts.getUserName()); values.put(COLUMN_TOPIC, conOpts.getWillDestination());
assertEquals("test/lwt", mockClient.mostRecentOptions.getWillDestination()); assertEquals("bye", new String(mockClient.mostRecentOptions.getWillMessage().getPayload())); assertEquals(AWSIotMqttQos.QOS0.asInt(),
options.getKeepAliveInterval(), options.getServerURIs(), options.getWillDestination(), options.getWillMessage() );
options.getPassword(), options.getWillMessage(), options.getWillDestination());
conOptions.getPassword(), conOptions.getWillMessage(), conOptions.getWillDestination());
conOptions.getPassword(), conOptions.getWillMessage(), conOptions.getWillDestination());