Fixed #30 bad remove of mapdb file in integration test (ServerRestartIntegrationTest)
This commit is contained in:
@@ -24,7 +24,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME;
|
import static org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME;
|
||||||
@@ -185,12 +184,10 @@ public class ServerIntegrationFuseTest {
|
|||||||
m_subscriber.connect();
|
m_subscriber.connect();
|
||||||
Topic[] topics = new Topic[]{new Topic("/topic", QoS.AT_LEAST_ONCE)};
|
Topic[] topics = new Topic[]{new Topic("/topic", QoS.AT_LEAST_ONCE)};
|
||||||
m_subscriber.subscribe(topics);
|
m_subscriber.subscribe(topics);
|
||||||
System.out.println("***Subscriber listen to /topic and disonnect");
|
|
||||||
m_subscriber.disconnect();
|
m_subscriber.disconnect();
|
||||||
|
|
||||||
//force the publisher to send
|
//force the publisher to send
|
||||||
m_publisher.publish("/topic", "Hello world MQTT!!-1".getBytes(), QoS.AT_LEAST_ONCE, false);
|
m_publisher.publish("/topic", "Hello world MQTT!!-1".getBytes(), QoS.AT_LEAST_ONCE, false);
|
||||||
System.out.println("***Publisher published to /topic :: Hello world MQTT!!-1");
|
|
||||||
|
|
||||||
//reconnect and expect to receive the hello 2 message
|
//reconnect and expect to receive the hello 2 message
|
||||||
m_subscriber = m_mqtt.blockingConnection();
|
m_subscriber = m_mqtt.blockingConnection();
|
||||||
@@ -201,7 +198,6 @@ public class ServerIntegrationFuseTest {
|
|||||||
assertNotNull(msg);
|
assertNotNull(msg);
|
||||||
msg.ack();
|
msg.ack();
|
||||||
assertEquals("Hello world MQTT!!-1", new String(msg.getPayload()));
|
assertEquals("Hello world MQTT!!-1", new String(msg.getPayload()));
|
||||||
System.out.println(String.format("***Subscriber received message <%s> from /topic", new String(msg.getPayload())));
|
|
||||||
// m_subscriber.disconnect();
|
// m_subscriber.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +218,6 @@ public class ServerIntegrationFuseTest {
|
|||||||
Topic[] topics = new Topic[]{new Topic("topic", QoS.EXACTLY_ONCE)};
|
Topic[] topics = new Topic[]{new Topic("topic", QoS.EXACTLY_ONCE)};
|
||||||
m_subscriber.subscribe(topics);
|
m_subscriber.subscribe(topics);
|
||||||
m_subscriber.disconnect();
|
m_subscriber.disconnect();
|
||||||
System.out.println("***Subscriber listen to topic and disconnects");
|
|
||||||
|
|
||||||
MQTT mqtt = new MQTT();
|
MQTT mqtt = new MQTT();
|
||||||
mqtt.setHost("localhost", 1883);
|
mqtt.setHost("localhost", 1883);
|
||||||
@@ -232,7 +227,6 @@ public class ServerIntegrationFuseTest {
|
|||||||
m_publisher.publish("topic", "Hello1".getBytes(), QoS.EXACTLY_ONCE, true);
|
m_publisher.publish("topic", "Hello1".getBytes(), QoS.EXACTLY_ONCE, true);
|
||||||
m_publisher.publish("topic", "Hello2".getBytes(), QoS.EXACTLY_ONCE, true);
|
m_publisher.publish("topic", "Hello2".getBytes(), QoS.EXACTLY_ONCE, true);
|
||||||
m_publisher.disconnect();
|
m_publisher.disconnect();
|
||||||
System.out.println("***Publisher published 2 messges to topic and disconnects");
|
|
||||||
|
|
||||||
//subscriber reconnects
|
//subscriber reconnects
|
||||||
m_mqtt = new MQTT();
|
m_mqtt = new MQTT();
|
||||||
@@ -240,7 +234,6 @@ public class ServerIntegrationFuseTest {
|
|||||||
m_mqtt.setClientId("Subscriber");
|
m_mqtt.setClientId("Subscriber");
|
||||||
m_mqtt.setCleanSession(false);
|
m_mqtt.setCleanSession(false);
|
||||||
m_subscriber = m_mqtt.blockingConnection();
|
m_subscriber = m_mqtt.blockingConnection();
|
||||||
System.out.println("***Subscriber reconnects");
|
|
||||||
m_subscriber.connect();
|
m_subscriber.connect();
|
||||||
//subscriber should receive the 2 messages missed
|
//subscriber should receive the 2 messages missed
|
||||||
Message msg = m_subscriber.receive(1, TimeUnit.SECONDS);
|
Message msg = m_subscriber.receive(1, TimeUnit.SECONDS);
|
||||||
|
|||||||
@@ -89,12 +89,15 @@ public class ServerIntegrationSSLTest {
|
|||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
if (m_client.isConnected()) {
|
if (m_client != null && m_client.isConnected()) {
|
||||||
m_client.disconnect();
|
m_client.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_server.stopServer();
|
if (m_server != null) {
|
||||||
File dbFile = new File(m_server.getProperties().getProperty(org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME));
|
m_server.stopServer();
|
||||||
|
}
|
||||||
|
String dbPath = IntegrationUtils.localMapDBPath();
|
||||||
|
File dbFile = new File(dbPath);
|
||||||
if (dbFile.exists()) {
|
if (dbFile.exists()) {
|
||||||
dbFile.delete();
|
dbFile.delete();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package org.eclipse.moquette.server;
|
|||||||
import org.fusesource.mqtt.client.*;
|
import org.fusesource.mqtt.client.*;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -94,7 +95,7 @@ public class ServerRestartIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//restart the server
|
//restart the server
|
||||||
m_server.startServer();
|
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||||
|
|
||||||
//reconnect the Subscriber subscribing to the same /topic but different QoS
|
//reconnect the Subscriber subscribing to the same /topic but different QoS
|
||||||
m_subscriber = m_mqtt.blockingConnection();
|
m_subscriber = m_mqtt.blockingConnection();
|
||||||
@@ -129,7 +130,7 @@ public class ServerRestartIntegrationTest {
|
|||||||
m_server.stopServer();
|
m_server.stopServer();
|
||||||
|
|
||||||
//restart the server
|
//restart the server
|
||||||
m_server.startServer();
|
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||||
|
|
||||||
MQTT mqtt = new MQTT();
|
MQTT mqtt = new MQTT();
|
||||||
mqtt.setHost("localhost", 1883);
|
mqtt.setHost("localhost", 1883);
|
||||||
|
|||||||
Reference in New Issue
Block a user