ServerIntegrationSSLTest: System properties saved

ServerLowlevelMessagesIntegrationTests: timeouts raised

osgi: log4j.properties added
MoquetteOsgiTest: test imporved

storage packages will checked too
The state must be active
osgi: README added for development
log4j: fixed
broker/pom.xml: dependencie added osgi config added
osgi_test/pom: dependencies added

MoquetteOsgiTest: test fixed
This commit is contained in:
Andreas Mager
2017-08-23 21:47:09 +02:00
parent dbd1310eb3
commit 4d59a54ad0
9 changed files with 175 additions and 20 deletions
@@ -40,6 +40,7 @@ import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -113,11 +114,21 @@ public class ServerIntegrationSSLClientAuthTest {
IMqttClient m_client;
MessageCollector m_callback;
static String backup;
@BeforeClass
public static void beforeTests() {
String tmpDir = System.getProperty("java.io.tmpdir");
s_dataStore = new MqttDefaultFilePersistence(tmpDir);
backup = System.getProperty("moquette.path");
}
@AfterClass
public static void afterTests() {
if (backup == null)
System.clearProperty("moquette.path");
else
System.setProperty("moquette.path", backup);
}
protected void startServer() throws IOException {
@@ -41,6 +41,7 @@ import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -60,10 +61,21 @@ public class ServerIntegrationSSLTest {
IMqttClient m_client;
MessageCollector m_callback;
static String backup;
@BeforeClass
public static void beforeTests() {
String tmpDir = System.getProperty("java.io.tmpdir");
s_dataStore = new MqttDefaultFilePersistence(tmpDir);
backup = System.getProperty("moquette.path");
}
@AfterClass
public static void afterTests() {
if (backup == null)
System.clearProperty("moquette.path");
else
System.setProperty("moquette.path", backup);
}
protected void startServer() throws IOException {
@@ -27,8 +27,11 @@ import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.awaitility.Awaitility;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import static io.netty.handler.codec.mqtt.MqttConnectReturnCode.*;
import static org.junit.Assert.*;
@@ -81,10 +84,10 @@ public class ServerLowlevelMessagesIntegrationTests {
*/
m_client.sendMessage(connectMessage);
// wait 2 times the keepAlive
Thread.sleep(keepAlive * 2 * 1000);
assertTrue(m_client.isConnectionLost());
// wait 3 times the keepAlive
Awaitility.await()
.atMost(3 * keepAlive, TimeUnit.SECONDS)
.until(m_client::isConnectionLost);
}
private static MqttConnectMessage createConnectMessage(String clientID, int keepAlive) {
@@ -109,14 +112,18 @@ public class ServerLowlevelMessagesIntegrationTests {
m_client.clientId("FAKECLNT").connect(willTestamentTopic, willTestamentMsg);
long connectTime = System.currentTimeMillis();
// but after the 2 KEEP ALIVE timeout expires it gets fired,
// NB it's 1,5 * KEEP_ALIVE so 3 secs and some millis to propagate the message
org.eclipse.paho.client.mqttv3.MqttMessage msg = m_messageCollector.waitMessage(5);
assertNotNull("the will message should be fired after keep alive!", msg);
// the will message hasn't to be received before the elapsing of Keep Alive timeout
assertTrue(System.currentTimeMillis() - connectTime > 3000);
Awaitility.await()
.atMost(7, TimeUnit.SECONDS)
.untilAsserted(() -> {
// but after the 2 KEEP ALIVE timeout expires it gets fired,
// NB it's 1,5 * KEEP_ALIVE so 3 secs and some millis to propagate the message
org.eclipse.paho.client.mqttv3.MqttMessage msg = m_messageCollector.getMessageImmediate();
assertNotNull("the will message should be fired after keep alive!", msg);
// the will message hasn't to be received before the elapsing of Keep Alive timeout
assertTrue(System.currentTimeMillis() - connectTime > 3000);
assertEquals(willTestamentMsg, new String(msg.getPayload(), StandardCharsets.UTF_8));
});
assertEquals(willTestamentMsg, new String(msg.getPayload()));
m_willSubscriber.disconnect();
}