Abstracted configuration part to use filesystem or classpath files
This commit is contained in:
@@ -45,20 +45,19 @@ public class ConfigurationClassLoaderTest implements IAuthenticator, IAuthorizat
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ConfigurationClassLoaderTest.class);
|
||||
|
||||
Server m_server;
|
||||
MQTT m_mqtt;
|
||||
BlockingConnection m_subscriber;
|
||||
BlockingConnection m_publisher;
|
||||
IConfig m_config;
|
||||
|
||||
protected void startServer(Properties props) throws IOException {
|
||||
m_server = new Server();
|
||||
m_server.startServer(props);
|
||||
m_server = new Server();
|
||||
m_config = new MemoryConfig(props);
|
||||
m_server.startServer(m_config);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
m_server.stopServer();
|
||||
File dbFile = new File(m_server.getProperties().getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
File dbFile = new File(m_config.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
if (dbFile.exists()) {
|
||||
dbFile.delete();
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ConfigurationParserTest {
|
||||
|
||||
@Test
|
||||
public void parseCompleteFile() throws ParseException {
|
||||
String content = "# This is initial config format \r\n"
|
||||
String content = "# This is initial m_config format \r\n"
|
||||
+ " \r\n"
|
||||
+ "port 1234 \r\n"
|
||||
+ "host localhost \r\n"
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME;
|
||||
@@ -40,10 +41,13 @@ public class ServerIntegrationFuseTest {
|
||||
MQTT m_mqtt;
|
||||
BlockingConnection m_subscriber;
|
||||
BlockingConnection m_publisher;
|
||||
IConfig m_config;
|
||||
|
||||
protected void startServer() throws IOException {
|
||||
m_server = new Server();
|
||||
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||
final Properties configProps = IntegrationUtils.prepareTestPropeties();
|
||||
m_config = new MemoryConfig(configProps);
|
||||
m_server.startServer(m_config);
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -68,7 +72,7 @@ public class ServerIntegrationFuseTest {
|
||||
}
|
||||
|
||||
m_server.stopServer();
|
||||
File dbFile = new File(m_server.getProperties().getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
File dbFile = new File(m_config.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
if (dbFile.exists()) {
|
||||
dbFile.delete();
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public class ServerIntegrationPahoTest {
|
||||
Server m_server;
|
||||
IMqttClient m_client;
|
||||
TestCallback m_callback;
|
||||
IConfig m_config;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeTests() {
|
||||
@@ -54,7 +55,9 @@ public class ServerIntegrationPahoTest {
|
||||
|
||||
protected void startServer() throws IOException {
|
||||
m_server = new Server();
|
||||
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||
final Properties configProps = IntegrationUtils.prepareTestPropeties();
|
||||
m_config = new MemoryConfig(configProps);
|
||||
m_server.startServer(m_config);
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -81,7 +84,7 @@ public class ServerIntegrationPahoTest {
|
||||
|
||||
private void stopServer() {
|
||||
m_server.stopServer();
|
||||
File dbFile = new File(m_server.getProperties().getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
File dbFile = new File(m_config.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
if (dbFile.exists()) {
|
||||
dbFile.delete();
|
||||
}
|
||||
|
||||
+5
-2
@@ -50,6 +50,7 @@ public class ServerIntegrationQoSValidationTest {
|
||||
IMqttClient m_subscriber;
|
||||
IMqttClient m_publisher;
|
||||
TestCallback m_callback;
|
||||
IConfig m_config;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeTests() {
|
||||
@@ -60,7 +61,9 @@ public class ServerIntegrationQoSValidationTest {
|
||||
|
||||
protected void startServer() throws IOException {
|
||||
m_server = new Server();
|
||||
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||
final Properties configProps = IntegrationUtils.prepareTestPropeties();
|
||||
m_config = new MemoryConfig(configProps);
|
||||
m_server.startServer(m_config);
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -89,7 +92,7 @@ public class ServerIntegrationQoSValidationTest {
|
||||
}
|
||||
|
||||
m_server.stopServer();
|
||||
File dbFile = new File(m_server.getProperties().getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
File dbFile = new File(m_config.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
if (dbFile.exists()) {
|
||||
dbFile.delete();
|
||||
}
|
||||
|
||||
+5
-2
@@ -44,10 +44,13 @@ public class ServerIntegrationWebSocketTest {
|
||||
|
||||
Server m_server;
|
||||
WebSocketClient client;
|
||||
IConfig m_config;
|
||||
|
||||
protected void startServer() throws IOException {
|
||||
m_server = new Server();
|
||||
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||
final Properties configProps = IntegrationUtils.prepareTestPropeties();
|
||||
m_config = new MemoryConfig(configProps);
|
||||
m_server.startServer(m_config);
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -61,7 +64,7 @@ public class ServerIntegrationWebSocketTest {
|
||||
client.stop();
|
||||
|
||||
m_server.stopServer();
|
||||
File dbFile = new File(m_server.getProperties().getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
File dbFile = new File(m_config.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
if (dbFile.exists()) {
|
||||
dbFile.delete();
|
||||
}
|
||||
|
||||
+6
-2
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -45,10 +46,13 @@ public class ServerLowlevelMessagesIntegrationTests {
|
||||
Server m_server;
|
||||
Client m_client;
|
||||
MQTT m_subscriberDef;
|
||||
IConfig m_config;
|
||||
|
||||
protected void startServer() throws IOException {
|
||||
m_server = new Server();
|
||||
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||
final Properties configProps = IntegrationUtils.prepareTestPropeties();
|
||||
m_config = new MemoryConfig(configProps);
|
||||
m_server.startServer(m_config);
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -67,7 +71,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(m_server.getProperties().getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
File dbFile = new File(m_config.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
if (dbFile.exists()) {
|
||||
dbFile.delete();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.eclipse.moquette.server;
|
||||
import org.fusesource.mqtt.client.*;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -43,10 +42,13 @@ public class ServerRestartIntegrationTest {
|
||||
MQTT m_mqtt;
|
||||
BlockingConnection m_subscriber;
|
||||
BlockingConnection m_publisher;
|
||||
IConfig m_config;
|
||||
|
||||
protected void startServer() throws IOException {
|
||||
m_server = new Server();
|
||||
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||
final Properties configProps = IntegrationUtils.prepareTestPropeties();
|
||||
m_config = new MemoryConfig(configProps);
|
||||
m_server.startServer(m_config);
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -70,7 +72,7 @@ public class ServerRestartIntegrationTest {
|
||||
}
|
||||
|
||||
m_server.stopServer();
|
||||
File dbFile = new File(m_server.getProperties().getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
File dbFile = new File(m_config.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
if (dbFile.exists()) {
|
||||
dbFile.delete();
|
||||
}
|
||||
@@ -89,7 +91,7 @@ public class ServerRestartIntegrationTest {
|
||||
|
||||
//shutdown the server
|
||||
m_server.stopServer();
|
||||
File dbFile = new File(m_server.getProperties().getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
File dbFile = new File(m_config.getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||
if (dbFile.exists()) {
|
||||
dbFile.delete();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user