Update for default configs

Update to allow for default config properties if some are not specified
with the start server and properties passed in.  Updated the tests to
match and also moved a few more things into the Constants.java file.
This commit is contained in:
swarwick
2015-03-14 16:37:41 +01:00
committed by andrea
parent 8aad95525c
commit 6cc5b0edb9
11 changed files with 61 additions and 71 deletions
@@ -45,15 +45,10 @@ 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(properties);
m_server.startServer(new Properties());
}
@Before
@@ -78,7 +73,7 @@ public class ServerIntegrationFuseTest {
}
m_server.stopServer();
File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
File dbFile = new File(m_server.getProperties().getProperty(org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME));
if (dbFile.exists()) {
dbFile.delete();
}
@@ -34,13 +34,9 @@ public class ServerIntegrationPahoTest {
static MqttClientPersistence s_dataStore;
static MqttClientPersistence s_pubDataStore;
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() {
@@ -50,16 +46,14 @@ 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(properties);
m_server.startServer(new Properties());
}
@Before
public void setUp() throws Exception {
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());
File dbFile = new File(m_server.getProperties().getProperty(org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME));
assertFalse(String.format("The DB storagefile %s already exists", m_server.getProperties().getProperty(org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME)), dbFile.exists());
startServer();
@@ -75,7 +69,7 @@ public class ServerIntegrationPahoTest {
}
m_server.stopServer();
File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
File dbFile = new File(m_server.getProperties().getProperty(org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME));
if (dbFile.exists()) {
dbFile.delete();
}
@@ -50,10 +50,6 @@ 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() {
@@ -63,10 +59,8 @@ 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(properties);
m_server.startServer(new Properties());
}
@Before
@@ -95,7 +89,7 @@ public class ServerIntegrationQoSValidationTest {
}
m_server.stopServer();
File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
File dbFile = new File(m_server.getProperties().getProperty(org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME));
if (dbFile.exists()) {
dbFile.delete();
}
@@ -60,10 +60,6 @@ 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() {
@@ -74,16 +70,14 @@ 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(properties);
m_server.startServer(new Properties());
}
@Before
public void setUp() throws Exception {
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());
File dbFile = new File(m_server.getProperties().getProperty(org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME));
assertFalse(String.format("The DB storagefile %s already exists", m_server.getProperties().getProperty(org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME)), dbFile.exists());
startServer();
@@ -101,7 +95,7 @@ public class ServerIntegrationSSLTest {
}
m_server.stopServer();
File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
File dbFile = new File(m_server.getProperties().getProperty(org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME));
if (dbFile.exists()) {
dbFile.delete();
}
@@ -44,16 +44,10 @@ 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(properties);
m_server.startServer(new Properties());
}
@Before
@@ -67,7 +61,7 @@ public class ServerIntegrationWebSocketTest {
client.stop();
m_server.stopServer();
File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
File dbFile = new File(m_server.getProperties().getProperty(org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME));
if (dbFile.exists()) {
dbFile.delete();
}
@@ -50,16 +50,10 @@ public class ServerLowlevelMessagesIntegrationTests {
Server m_server;
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(properties);
m_server.startServer(new Properties());
}
@Before
@@ -78,7 +72,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(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
File dbFile = new File(m_server.getProperties().getProperty(org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME));
if (dbFile.exists()) {
dbFile.delete();
}
@@ -43,7 +43,7 @@ public class ServerRestartIntegrationTest {
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";
private final static String PERSISTENT_STORE_FILE_NAME = System.getProperty("user.home") + File.separator + "moquette_store.mapdb";
protected void startServer() throws IOException {
properties = new Properties();
@@ -73,7 +73,7 @@ public class ServerRestartIntegrationTest {
}
m_server.stopServer();
File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
File dbFile = new File(m_server.getProperties().getProperty(org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME));
if (dbFile.exists()) {
dbFile.delete();
}
@@ -92,7 +92,7 @@ public class ServerRestartIntegrationTest {
//shutdown the server
m_server.stopServer();
File dbFile = new File(properties.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
File dbFile = new File(m_server.getProperties().getProperty(org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME));
if (dbFile.exists()) {
dbFile.delete();
}
@@ -17,8 +17,6 @@ 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;
@@ -36,16 +34,14 @@ 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(PERSISTENT_STORE_PATH);
assertFalse(String.format("The DB storagefile %s already exists", PERSISTENT_STORE_PATH), dbFile.exists());
File dbFile = new File(org.eclipse.moquette.commons.Constants.DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME);
assertFalse(String.format("The DB storagefile %s already exists", org.eclipse.moquette.commons.Constants.DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME), dbFile.exists());
m_storageService = new MapDBPersistentStore(PERSISTENT_STORE_PATH);
m_storageService = new MapDBPersistentStore(org.eclipse.moquette.commons.Constants.DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME);
m_storageService.initStore();
}
@@ -55,7 +51,7 @@ public class MapDBPersistentStoreTest {
m_storageService.close();
}
File dbFile = new File(PERSISTENT_STORE_PATH);
File dbFile = new File(org.eclipse.moquette.commons.Constants.DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME);
if (dbFile.exists()) {
dbFile.delete();
}