diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationFuseTest.java b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationFuseTest.java index 31bc7902..be76cf71 100644 --- a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationFuseTest.java +++ b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationFuseTest.java @@ -17,14 +17,18 @@ package org.eclipse.moquette.server; import java.io.File; import java.io.IOException; +import java.util.Properties; import java.util.concurrent.TimeUnit; + import org.fusesource.mqtt.client.BlockingConnection; import org.fusesource.mqtt.client.MQTT; import org.fusesource.mqtt.client.Message; import org.fusesource.mqtt.client.QoS; import org.fusesource.mqtt.client.Topic; import org.junit.After; + import static org.junit.Assert.*; + import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; @@ -41,10 +45,15 @@ public class ServerIntegrationFuseTest { MQTT m_mqtt; BlockingConnection m_subscriber; BlockingConnection m_publisher; + Properties properties; + private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; + private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; protected void startServer() throws IOException { + properties = new Properties(); + properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); m_server = new Server(); - m_server.startServer(); + m_server.startServer(properties); } @Before @@ -69,7 +78,7 @@ public class ServerIntegrationFuseTest { } m_server.stopServer(); - File dbFile = new File(Server.STORAGE_FILE_PATH); + File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); if (dbFile.exists()) { dbFile.delete(); } diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationPahoTest.java b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationPahoTest.java index 11977692..3a8d33d8 100644 --- a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationPahoTest.java +++ b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationPahoTest.java @@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; +import java.util.Properties; import static org.junit.Assert.*; @@ -37,6 +38,9 @@ public class ServerIntegrationPahoTest { Server m_server; IMqttClient m_client; TestCallback m_callback; + Properties properties; + private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; + private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; @BeforeClass public static void beforeTests() { @@ -46,14 +50,16 @@ public class ServerIntegrationPahoTest { } protected void startServer() throws IOException { + properties = new Properties(); + properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); m_server = new Server(); - m_server.startServer(); + m_server.startServer(properties); } @Before public void setUp() throws Exception { - File dbFile = new File(Server.STORAGE_FILE_PATH); - assertFalse(String.format("The DB storagefile %s already exists", Server.STORAGE_FILE_PATH), dbFile.exists()); + File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); + assertFalse(String.format("The DB storagefile %s already exists", properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)), dbFile.exists()); startServer(); @@ -69,7 +75,7 @@ public class ServerIntegrationPahoTest { } m_server.stopServer(); - File dbFile = new File(Server.STORAGE_FILE_PATH); + File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); if (dbFile.exists()) { dbFile.delete(); } diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationQoSValidationTest.java b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationQoSValidationTest.java index f2c2310c..1fd28950 100644 --- a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationQoSValidationTest.java +++ b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationQoSValidationTest.java @@ -18,13 +18,17 @@ package org.eclipse.moquette.server; import java.io.File; import java.io.IOException; +import java.util.Properties; + import org.eclipse.paho.client.mqttv3.IMqttClient; import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttClientPersistence; import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence; import org.junit.After; + import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; import org.junit.BeforeClass; @@ -46,6 +50,10 @@ public class ServerIntegrationQoSValidationTest { IMqttClient m_subscriber; IMqttClient m_publisher; TestCallback m_callback; + + Properties properties; + private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; + private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; @BeforeClass public static void beforeTests() { @@ -55,8 +63,10 @@ public class ServerIntegrationQoSValidationTest { } protected void startServer() throws IOException { + properties = new Properties(); + properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); m_server = new Server(); - m_server.startServer(); + m_server.startServer(properties); } @Before @@ -85,7 +95,7 @@ public class ServerIntegrationQoSValidationTest { } m_server.stopServer(); - File dbFile = new File(Server.STORAGE_FILE_PATH); + File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); if (dbFile.exists()) { dbFile.delete(); } diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationSSLTest.java b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationSSLTest.java index 1e9175fe..87ab2b82 100644 --- a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationSSLTest.java +++ b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationSSLTest.java @@ -24,18 +24,23 @@ import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; +import java.util.Properties; + import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; + import org.eclipse.paho.client.mqttv3.IMqttClient; import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttClientPersistence; import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence; import org.junit.After; + import static org.junit.Assert.assertFalse; + import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -55,6 +60,10 @@ public class ServerIntegrationSSLTest { IMqttClient m_client; TestCallback m_callback; + + Properties properties; + private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; + private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; @BeforeClass public static void beforeTests() { @@ -65,14 +74,16 @@ public class ServerIntegrationSSLTest { protected void startServer() throws IOException { String file = getClass().getResource("/").getPath(); System.setProperty("moquette.path", file); + properties = new Properties(); + properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); m_server = new Server(); - m_server.startServer(); + m_server.startServer(properties); } @Before public void setUp() throws Exception { - File dbFile = new File(Server.STORAGE_FILE_PATH); - assertFalse(String.format("The DB storagefile %s already exists", Server.STORAGE_FILE_PATH), dbFile.exists()); + File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); + assertFalse(String.format("The DB storagefile %s already exists", properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)), dbFile.exists()); startServer(); @@ -90,7 +101,7 @@ public class ServerIntegrationSSLTest { } m_server.stopServer(); - File dbFile = new File(Server.STORAGE_FILE_PATH); + File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); if (dbFile.exists()) { dbFile.delete(); } diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationWebSocketTest.java b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationWebSocketTest.java index bc4b626a..c509296c 100644 --- a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationWebSocketTest.java +++ b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationWebSocketTest.java @@ -18,12 +18,16 @@ package org.eclipse.moquette.server; import java.io.File; import java.io.IOException; import java.net.URI; +import java.util.Properties; import java.util.concurrent.TimeUnit; + import org.eclipse.jetty.websocket.client.WebSocketClient; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.moquette.commons.Constants; import org.junit.After; + import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; @@ -40,10 +44,16 @@ public class ServerIntegrationWebSocketTest { Server m_server; WebSocketClient client; + + Properties properties; + private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; + private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; protected void startServer() throws IOException { + properties = new Properties(); + properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); m_server = new Server(); - m_server.startServer(); + m_server.startServer(properties); } @Before @@ -57,7 +67,7 @@ public class ServerIntegrationWebSocketTest { client.stop(); m_server.stopServer(); - File dbFile = new File(Server.STORAGE_FILE_PATH); + File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); if (dbFile.exists()) { dbFile.delete(); } diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerLowlevelMessagesIntegrationTests.java b/broker/src/test/java/org/eclipse/moquette/server/ServerLowlevelMessagesIntegrationTests.java index b2a429db..b61452c4 100644 --- a/broker/src/test/java/org/eclipse/moquette/server/ServerLowlevelMessagesIntegrationTests.java +++ b/broker/src/test/java/org/eclipse/moquette/server/ServerLowlevelMessagesIntegrationTests.java @@ -17,8 +17,10 @@ package org.eclipse.moquette.server; import java.io.File; import java.io.IOException; +import java.util.Properties; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; + import org.eclipse.moquette.proto.messages.AbstractMessage; import org.eclipse.moquette.proto.messages.AbstractMessage.QOSType; import org.eclipse.moquette.proto.messages.ConnAckMessage; @@ -30,7 +32,9 @@ import org.fusesource.mqtt.client.Message; import org.fusesource.mqtt.client.QoS; import org.fusesource.mqtt.client.Topic; import org.junit.After; + import static org.junit.Assert.*; + import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; @@ -47,9 +51,15 @@ public class ServerLowlevelMessagesIntegrationTests { Client m_client; MQTT m_subscriberDef; + Properties properties; + private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; + private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; + protected void startServer() throws IOException { + properties = new Properties(); + properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); m_server = new Server(); - m_server.startServer(); + m_server.startServer(properties); } @Before @@ -68,7 +78,7 @@ public class ServerLowlevelMessagesIntegrationTests { Thread.sleep(300); //to let the close event pass before server stop event m_server.stopServer(); LOG.debug("After asked server to stop"); - File dbFile = new File(Server.STORAGE_FILE_PATH); + File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); if (dbFile.exists()) { dbFile.delete(); } diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerRestartIntegrationTest.java b/broker/src/test/java/org/eclipse/moquette/server/ServerRestartIntegrationTest.java index 4702391b..42d7cfc3 100644 --- a/broker/src/test/java/org/eclipse/moquette/server/ServerRestartIntegrationTest.java +++ b/broker/src/test/java/org/eclipse/moquette/server/ServerRestartIntegrationTest.java @@ -17,7 +17,9 @@ package org.eclipse.moquette.server; import java.io.File; import java.io.IOException; +import java.util.Properties; import java.util.concurrent.TimeUnit; + import org.fusesource.mqtt.client.BlockingConnection; import org.fusesource.mqtt.client.MQTT; import org.fusesource.mqtt.client.Message; @@ -26,6 +28,7 @@ import org.fusesource.mqtt.client.Topic; import org.junit.After; import org.junit.Before; import org.junit.Test; + import static org.junit.Assert.*; /** @@ -38,10 +41,15 @@ public class ServerRestartIntegrationTest { MQTT m_mqtt; BlockingConnection m_subscriber; BlockingConnection m_publisher; + Properties properties; + private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; + private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; protected void startServer() throws IOException { + properties = new Properties(); + properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); m_server = new Server(); - m_server.startServer(); + m_server.startServer(properties); } @Before @@ -65,7 +73,7 @@ public class ServerRestartIntegrationTest { } m_server.stopServer(); - File dbFile = new File(Server.STORAGE_FILE_PATH); + File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); if (dbFile.exists()) { dbFile.delete(); } @@ -84,7 +92,7 @@ public class ServerRestartIntegrationTest { //shutdown the server m_server.stopServer(); - File dbFile = new File(Server.STORAGE_FILE_PATH); + File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); if (dbFile.exists()) { dbFile.delete(); } diff --git a/broker/src/test/java/org/eclipse/moquette/spi/impl/MapDBPersistentStoreTest.java b/broker/src/test/java/org/eclipse/moquette/spi/impl/MapDBPersistentStoreTest.java index b5439893..3b56b927 100644 --- a/broker/src/test/java/org/eclipse/moquette/spi/impl/MapDBPersistentStoreTest.java +++ b/broker/src/test/java/org/eclipse/moquette/spi/impl/MapDBPersistentStoreTest.java @@ -17,13 +17,16 @@ package org.eclipse.moquette.spi.impl; import java.io.File; import java.util.List; +import java.util.Properties; + import org.eclipse.moquette.spi.impl.subscriptions.Subscription; import org.eclipse.moquette.spi.persistence.MapDBPersistentStore; import org.eclipse.moquette.proto.messages.AbstractMessage; -import org.eclipse.moquette.server.Server; import org.junit.After; import org.junit.Test; + import static org.junit.Assert.*; + import org.junit.Before; /** @@ -33,13 +36,16 @@ import org.junit.Before; public class MapDBPersistentStoreTest { MapDBPersistentStore m_storageService; + Properties properties; + private final static String PERSISTENT_STORE_PATH = System.getProperty("user.home") + File.separator + "moquette_store.mapdb"; @Before public void setUp() throws Exception { - File dbFile = new File(Server.STORAGE_FILE_PATH); - assertFalse(String.format("The DB storagefile %s already exists", Server.STORAGE_FILE_PATH), dbFile.exists()); + + File dbFile = new File(PERSISTENT_STORE_PATH); + assertFalse(String.format("The DB storagefile %s already exists", PERSISTENT_STORE_PATH), dbFile.exists()); - m_storageService = new MapDBPersistentStore(); + m_storageService = new MapDBPersistentStore(PERSISTENT_STORE_PATH); m_storageService.initStore(); } @@ -49,7 +55,7 @@ public class MapDBPersistentStoreTest { m_storageService.close(); } - File dbFile = new File(Server.STORAGE_FILE_PATH); + File dbFile = new File(PERSISTENT_STORE_PATH); if (dbFile.exists()) { dbFile.delete(); } diff --git a/persistent_store_tests_patch.diff b/persistent_store_tests_patch.diff new file mode 100644 index 00000000..164b1fe4 --- /dev/null +++ b/persistent_store_tests_patch.diff @@ -0,0 +1,429 @@ +diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationFuseTest.java b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationFuseTest.java +index 31bc790..be76cf7 100644 +--- a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationFuseTest.java ++++ b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationFuseTest.java +@@ -17,14 +17,18 @@ package org.eclipse.moquette.server; + + import java.io.File; + import java.io.IOException; ++import java.util.Properties; + import java.util.concurrent.TimeUnit; ++ + import org.fusesource.mqtt.client.BlockingConnection; + import org.fusesource.mqtt.client.MQTT; + import org.fusesource.mqtt.client.Message; + import org.fusesource.mqtt.client.QoS; + import org.fusesource.mqtt.client.Topic; + import org.junit.After; ++ + import static org.junit.Assert.*; ++ + import org.junit.Before; + import org.junit.Test; + import org.slf4j.Logger; +@@ -41,10 +45,15 @@ public class ServerIntegrationFuseTest { + MQTT m_mqtt; + BlockingConnection m_subscriber; + BlockingConnection m_publisher; ++ Properties properties; ++ private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; ++ private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; + + protected void startServer() throws IOException { ++ properties = new Properties(); ++ properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); + m_server = new Server(); +- m_server.startServer(); ++ m_server.startServer(properties); + } + + @Before +@@ -69,7 +78,7 @@ public class ServerIntegrationFuseTest { + } + + m_server.stopServer(); +- File dbFile = new File(Server.STORAGE_FILE_PATH); ++ File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); + if (dbFile.exists()) { + dbFile.delete(); + } +diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationPahoTest.java b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationPahoTest.java +index 1197769..3a8d33d 100644 +--- a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationPahoTest.java ++++ b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationPahoTest.java +@@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory; + + import java.io.File; + import java.io.IOException; ++import java.util.Properties; + + import static org.junit.Assert.*; + +@@ -37,6 +38,9 @@ public class ServerIntegrationPahoTest { + Server m_server; + IMqttClient m_client; + TestCallback m_callback; ++ Properties properties; ++ private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; ++ private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; + + @BeforeClass + public static void beforeTests() { +@@ -46,14 +50,16 @@ public class ServerIntegrationPahoTest { + } + + protected void startServer() throws IOException { ++ properties = new Properties(); ++ properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); + m_server = new Server(); +- m_server.startServer(); ++ m_server.startServer(properties); + } + + @Before + public void setUp() throws Exception { +- File dbFile = new File(Server.STORAGE_FILE_PATH); +- assertFalse(String.format("The DB storagefile %s already exists", Server.STORAGE_FILE_PATH), dbFile.exists()); ++ File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); ++ assertFalse(String.format("The DB storagefile %s already exists", properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)), dbFile.exists()); + + startServer(); + +@@ -69,7 +75,7 @@ public class ServerIntegrationPahoTest { + } + + m_server.stopServer(); +- File dbFile = new File(Server.STORAGE_FILE_PATH); ++ File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); + if (dbFile.exists()) { + dbFile.delete(); + } +diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationQoSValidationTest.java b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationQoSValidationTest.java +index f2c2310..1fd2895 100644 +--- a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationQoSValidationTest.java ++++ b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationQoSValidationTest.java +@@ -18,13 +18,17 @@ package org.eclipse.moquette.server; + + import java.io.File; + import java.io.IOException; ++import java.util.Properties; ++ + import org.eclipse.paho.client.mqttv3.IMqttClient; + import org.eclipse.paho.client.mqttv3.MqttClient; + import org.eclipse.paho.client.mqttv3.MqttClientPersistence; + import org.eclipse.paho.client.mqttv3.MqttMessage; + import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence; + import org.junit.After; ++ + import static org.junit.Assert.assertEquals; ++ + import org.junit.Before; + import org.junit.Test; + import org.junit.BeforeClass; +@@ -46,6 +50,10 @@ public class ServerIntegrationQoSValidationTest { + IMqttClient m_subscriber; + IMqttClient m_publisher; + TestCallback m_callback; ++ ++ Properties properties; ++ private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; ++ private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; + + @BeforeClass + public static void beforeTests() { +@@ -55,8 +63,10 @@ public class ServerIntegrationQoSValidationTest { + } + + protected void startServer() throws IOException { ++ properties = new Properties(); ++ properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); + m_server = new Server(); +- m_server.startServer(); ++ m_server.startServer(properties); + } + + @Before +@@ -85,7 +95,7 @@ public class ServerIntegrationQoSValidationTest { + } + + m_server.stopServer(); +- File dbFile = new File(Server.STORAGE_FILE_PATH); ++ File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); + if (dbFile.exists()) { + dbFile.delete(); + } +diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationSSLTest.java b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationSSLTest.java +index 1e9175f..87ab2b8 100644 +--- a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationSSLTest.java ++++ b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationSSLTest.java +@@ -24,18 +24,23 @@ import java.security.KeyStoreException; + import java.security.NoSuchAlgorithmException; + import java.security.UnrecoverableKeyException; + import java.security.cert.CertificateException; ++import java.util.Properties; ++ + import javax.net.ssl.KeyManagerFactory; + import javax.net.ssl.SSLContext; + import javax.net.ssl.SSLSocketFactory; + import javax.net.ssl.TrustManager; + import javax.net.ssl.TrustManagerFactory; ++ + import org.eclipse.paho.client.mqttv3.IMqttClient; + import org.eclipse.paho.client.mqttv3.MqttClient; + import org.eclipse.paho.client.mqttv3.MqttClientPersistence; + import org.eclipse.paho.client.mqttv3.MqttConnectOptions; + import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence; + import org.junit.After; ++ + import static org.junit.Assert.assertFalse; ++ + import org.junit.Before; + import org.junit.BeforeClass; + import org.junit.Test; +@@ -55,6 +60,10 @@ public class ServerIntegrationSSLTest { + + IMqttClient m_client; + TestCallback m_callback; ++ ++ Properties properties; ++ private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; ++ private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; + + @BeforeClass + public static void beforeTests() { +@@ -65,14 +74,16 @@ public class ServerIntegrationSSLTest { + protected void startServer() throws IOException { + String file = getClass().getResource("/").getPath(); + System.setProperty("moquette.path", file); ++ properties = new Properties(); ++ properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); + m_server = new Server(); +- m_server.startServer(); ++ m_server.startServer(properties); + } + + @Before + public void setUp() throws Exception { +- File dbFile = new File(Server.STORAGE_FILE_PATH); +- assertFalse(String.format("The DB storagefile %s already exists", Server.STORAGE_FILE_PATH), dbFile.exists()); ++ File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); ++ assertFalse(String.format("The DB storagefile %s already exists", properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)), dbFile.exists()); + + startServer(); + +@@ -90,7 +101,7 @@ public class ServerIntegrationSSLTest { + } + + m_server.stopServer(); +- File dbFile = new File(Server.STORAGE_FILE_PATH); ++ File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); + if (dbFile.exists()) { + dbFile.delete(); + } +diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationWebSocketTest.java b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationWebSocketTest.java +index bc4b626..c509296 100644 +--- a/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationWebSocketTest.java ++++ b/broker/src/test/java/org/eclipse/moquette/server/ServerIntegrationWebSocketTest.java +@@ -18,12 +18,16 @@ package org.eclipse.moquette.server; + import java.io.File; + import java.io.IOException; + import java.net.URI; ++import java.util.Properties; + import java.util.concurrent.TimeUnit; ++ + import org.eclipse.jetty.websocket.client.WebSocketClient; + import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; + import org.eclipse.moquette.commons.Constants; + import org.junit.After; ++ + import static org.junit.Assert.assertTrue; ++ + import org.junit.Before; + import org.junit.Test; + import org.slf4j.Logger; +@@ -40,10 +44,16 @@ public class ServerIntegrationWebSocketTest { + + Server m_server; + WebSocketClient client; ++ ++ Properties properties; ++ private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; ++ private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; + + protected void startServer() throws IOException { ++ properties = new Properties(); ++ properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); + m_server = new Server(); +- m_server.startServer(); ++ m_server.startServer(properties); + } + + @Before +@@ -57,7 +67,7 @@ public class ServerIntegrationWebSocketTest { + client.stop(); + + m_server.stopServer(); +- File dbFile = new File(Server.STORAGE_FILE_PATH); ++ File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); + if (dbFile.exists()) { + dbFile.delete(); + } +diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerLowlevelMessagesIntegrationTests.java b/broker/src/test/java/org/eclipse/moquette/server/ServerLowlevelMessagesIntegrationTests.java +index b2a429d..b61452c 100644 +--- a/broker/src/test/java/org/eclipse/moquette/server/ServerLowlevelMessagesIntegrationTests.java ++++ b/broker/src/test/java/org/eclipse/moquette/server/ServerLowlevelMessagesIntegrationTests.java +@@ -17,8 +17,10 @@ package org.eclipse.moquette.server; + + import java.io.File; + import java.io.IOException; ++import java.util.Properties; + import java.util.concurrent.CountDownLatch; + import java.util.concurrent.TimeUnit; ++ + import org.eclipse.moquette.proto.messages.AbstractMessage; + import org.eclipse.moquette.proto.messages.AbstractMessage.QOSType; + import org.eclipse.moquette.proto.messages.ConnAckMessage; +@@ -30,7 +32,9 @@ import org.fusesource.mqtt.client.Message; + import org.fusesource.mqtt.client.QoS; + import org.fusesource.mqtt.client.Topic; + import org.junit.After; ++ + import static org.junit.Assert.*; ++ + import org.junit.Before; + import org.junit.Test; + import org.slf4j.Logger; +@@ -47,9 +51,15 @@ public class ServerLowlevelMessagesIntegrationTests { + Client m_client; + MQTT m_subscriberDef; + ++ Properties properties; ++ private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; ++ private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; ++ + protected void startServer() throws IOException { ++ properties = new Properties(); ++ properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); + m_server = new Server(); +- m_server.startServer(); ++ m_server.startServer(properties); + } + + @Before +@@ -68,7 +78,7 @@ public class ServerLowlevelMessagesIntegrationTests { + Thread.sleep(300); //to let the close event pass before server stop event + m_server.stopServer(); + LOG.debug("After asked server to stop"); +- File dbFile = new File(Server.STORAGE_FILE_PATH); ++ File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); + if (dbFile.exists()) { + dbFile.delete(); + } +diff --git a/broker/src/test/java/org/eclipse/moquette/server/ServerRestartIntegrationTest.java b/broker/src/test/java/org/eclipse/moquette/server/ServerRestartIntegrationTest.java +index 4702391..42d7cfc 100644 +--- a/broker/src/test/java/org/eclipse/moquette/server/ServerRestartIntegrationTest.java ++++ b/broker/src/test/java/org/eclipse/moquette/server/ServerRestartIntegrationTest.java +@@ -17,7 +17,9 @@ package org.eclipse.moquette.server; + + import java.io.File; + import java.io.IOException; ++import java.util.Properties; + import java.util.concurrent.TimeUnit; ++ + import org.fusesource.mqtt.client.BlockingConnection; + import org.fusesource.mqtt.client.MQTT; + import org.fusesource.mqtt.client.Message; +@@ -26,6 +28,7 @@ import org.fusesource.mqtt.client.Topic; + import org.junit.After; + import org.junit.Before; + import org.junit.Test; ++ + import static org.junit.Assert.*; + + /** +@@ -38,10 +41,15 @@ public class ServerRestartIntegrationTest { + MQTT m_mqtt; + BlockingConnection m_subscriber; + BlockingConnection m_publisher; ++ Properties properties; ++ private final static String PERSISTENT_STORE_PROPERTY_NAME = "persistent_store"; ++ private final static String PERSISTENT_STORE_FILE_NAME = "store.mapdb"; + + protected void startServer() throws IOException { ++ properties = new Properties(); ++ properties.put(PERSISTENT_STORE_PROPERTY_NAME, PERSISTENT_STORE_FILE_NAME); + m_server = new Server(); +- m_server.startServer(); ++ m_server.startServer(properties); + } + + @Before +@@ -65,7 +73,7 @@ public class ServerRestartIntegrationTest { + } + + m_server.stopServer(); +- File dbFile = new File(Server.STORAGE_FILE_PATH); ++ File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); + if (dbFile.exists()) { + dbFile.delete(); + } +@@ -84,7 +92,7 @@ public class ServerRestartIntegrationTest { + + //shutdown the server + m_server.stopServer(); +- File dbFile = new File(Server.STORAGE_FILE_PATH); ++ File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME)); + if (dbFile.exists()) { + dbFile.delete(); + } +diff --git a/broker/src/test/java/org/eclipse/moquette/spi/impl/MapDBPersistentStoreTest.java b/broker/src/test/java/org/eclipse/moquette/spi/impl/MapDBPersistentStoreTest.java +index b543989..3b56b92 100644 +--- a/broker/src/test/java/org/eclipse/moquette/spi/impl/MapDBPersistentStoreTest.java ++++ b/broker/src/test/java/org/eclipse/moquette/spi/impl/MapDBPersistentStoreTest.java +@@ -17,13 +17,16 @@ package org.eclipse.moquette.spi.impl; + + import java.io.File; + import java.util.List; ++import java.util.Properties; ++ + import org.eclipse.moquette.spi.impl.subscriptions.Subscription; + import org.eclipse.moquette.spi.persistence.MapDBPersistentStore; + import org.eclipse.moquette.proto.messages.AbstractMessage; +-import org.eclipse.moquette.server.Server; + import org.junit.After; + import org.junit.Test; ++ + import static org.junit.Assert.*; ++ + import org.junit.Before; + + /** +@@ -33,13 +36,16 @@ import org.junit.Before; + public class MapDBPersistentStoreTest { + + MapDBPersistentStore m_storageService; ++ Properties properties; ++ private final static String PERSISTENT_STORE_PATH = System.getProperty("user.home") + File.separator + "moquette_store.mapdb"; + + @Before + public void setUp() throws Exception { +- File dbFile = new File(Server.STORAGE_FILE_PATH); +- assertFalse(String.format("The DB storagefile %s already exists", Server.STORAGE_FILE_PATH), dbFile.exists()); ++ ++ File dbFile = new File(PERSISTENT_STORE_PATH); ++ assertFalse(String.format("The DB storagefile %s already exists", PERSISTENT_STORE_PATH), dbFile.exists()); + +- m_storageService = new MapDBPersistentStore(); ++ m_storageService = new MapDBPersistentStore(PERSISTENT_STORE_PATH); + m_storageService.initStore(); + } + +@@ -49,7 +55,7 @@ public class MapDBPersistentStoreTest { + m_storageService.close(); + } + +- File dbFile = new File(Server.STORAGE_FILE_PATH); ++ File dbFile = new File(PERSISTENT_STORE_PATH); + if (dbFile.exists()) { + dbFile.delete(); + }