Moved the default store path to project home (only for tests)
This commit is contained in:
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2012-2014 The original author or authors
|
||||||
|
* ------------------------------------------------------
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* and Apache License v2.0 which accompanies this distribution.
|
||||||
|
*
|
||||||
|
* The Eclipse Public License is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* The Apache License v2.0 is available at
|
||||||
|
* http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
*
|
||||||
|
* You may elect to redistribute this code under either of these licenses.
|
||||||
|
*/
|
||||||
|
package org.eclipse.moquette.server;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static org.eclipse.moquette.commons.Constants.DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME;
|
||||||
|
import static org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to carry integration configurations.
|
||||||
|
*
|
||||||
|
* Created by andrea on 4/7/15.
|
||||||
|
*/
|
||||||
|
class IntegrationUtils {
|
||||||
|
static String localMapDBPath() {
|
||||||
|
String currentDir = System.getProperty("user.dir");
|
||||||
|
return currentDir + File.separator + DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Properties prepareTestPropeties() {
|
||||||
|
Properties testProperties = new Properties();
|
||||||
|
testProperties.put(PERSISTENT_STORE_PROPERTY_NAME, IntegrationUtils.localMapDBPath());
|
||||||
|
return testProperties;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,7 +44,7 @@ public class ServerIntegrationFuseTest {
|
|||||||
|
|
||||||
protected void startServer() throws IOException {
|
protected void startServer() throws IOException {
|
||||||
m_server = new Server();
|
m_server = new Server();
|
||||||
m_server.startServer(new Properties());
|
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import static org.eclipse.moquette.commons.Constants.DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME;
|
import static org.eclipse.moquette.commons.Constants.*;
|
||||||
import static org.eclipse.moquette.commons.Constants.PERSISTENT_STORE_PROPERTY_NAME;
|
import static org.eclipse.moquette.commons.Constants.KEY_MANAGER_PASSWORD_PROPERTY_NAME;
|
||||||
|
import static org.eclipse.moquette.commons.Constants.KEY_STORE_PASSWORD_PROPERTY_NAME;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class ServerIntegrationPahoTest {
|
public class ServerIntegrationPahoTest {
|
||||||
@@ -52,13 +53,14 @@ public class ServerIntegrationPahoTest {
|
|||||||
|
|
||||||
protected void startServer() throws IOException {
|
protected void startServer() throws IOException {
|
||||||
m_server = new Server();
|
m_server = new Server();
|
||||||
m_server.startServer(new Properties());
|
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
File dbFile = new File(DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME);
|
String dbPath = IntegrationUtils.localMapDBPath();
|
||||||
assertFalse(String.format("The DB storagefile %s already exists", DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME), dbFile.exists());
|
File dbFile = new File(dbPath);
|
||||||
|
assertFalse(String.format("The DB storagefile %s already exists", dbPath), dbFile.exists());
|
||||||
|
|
||||||
startServer();
|
startServer();
|
||||||
|
|
||||||
@@ -73,6 +75,10 @@ public class ServerIntegrationPahoTest {
|
|||||||
m_client.disconnect();
|
m_client.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stopServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopServer() {
|
||||||
m_server.stopServer();
|
m_server.stopServer();
|
||||||
File dbFile = new File(m_server.getProperties().getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
File dbFile = new File(m_server.getProperties().getProperty(PERSISTENT_STORE_PROPERTY_NAME));
|
||||||
if (dbFile.exists()) {
|
if (dbFile.exists()) {
|
||||||
@@ -164,7 +170,7 @@ public class ServerIntegrationPahoTest {
|
|||||||
|
|
||||||
m_server.stopServer();
|
m_server.stopServer();
|
||||||
|
|
||||||
m_server.startServer();
|
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||||
|
|
||||||
//reconnect and publish
|
//reconnect and publish
|
||||||
m_client.connect(options);
|
m_client.connect(options);
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ public class ServerIntegrationQoSValidationTest {
|
|||||||
|
|
||||||
protected void startServer() throws IOException {
|
protected void startServer() throws IOException {
|
||||||
m_server = new Server();
|
m_server = new Server();
|
||||||
m_server.startServer(new Properties());
|
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|||||||
@@ -68,13 +68,15 @@ public class ServerIntegrationSSLTest {
|
|||||||
sslProps.put(JKS_PATH_PROPERTY_NAME, "serverkeystore.jks");
|
sslProps.put(JKS_PATH_PROPERTY_NAME, "serverkeystore.jks");
|
||||||
sslProps.put(KEY_STORE_PASSWORD_PROPERTY_NAME, "passw0rdsrv");
|
sslProps.put(KEY_STORE_PASSWORD_PROPERTY_NAME, "passw0rdsrv");
|
||||||
sslProps.put(KEY_MANAGER_PASSWORD_PROPERTY_NAME, "passw0rdsrv");
|
sslProps.put(KEY_MANAGER_PASSWORD_PROPERTY_NAME, "passw0rdsrv");
|
||||||
|
sslProps.put(PERSISTENT_STORE_PROPERTY_NAME, IntegrationUtils.localMapDBPath());
|
||||||
m_server.startServer(sslProps);
|
m_server.startServer(sslProps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
File dbFile = new File(DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME);
|
String dbPath = IntegrationUtils.localMapDBPath();
|
||||||
assertFalse(String.format("The DB storage file %s already exists", DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME), dbFile.exists());
|
File dbFile = new File(dbPath);
|
||||||
|
assertFalse(String.format("The DB storagefile %s already exists", dbPath), dbFile.exists());
|
||||||
|
|
||||||
startServer();
|
startServer();
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ public class ServerIntegrationWebSocketTest {
|
|||||||
|
|
||||||
protected void startServer() throws IOException {
|
protected void startServer() throws IOException {
|
||||||
m_server = new Server();
|
m_server = new Server();
|
||||||
m_server.startServer(new Properties());
|
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ public class ServerLowlevelMessagesIntegrationTests {
|
|||||||
|
|
||||||
protected void startServer() throws IOException {
|
protected void startServer() throws IOException {
|
||||||
m_server = new Server();
|
m_server = new Server();
|
||||||
m_server.startServer(new Properties());
|
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import org.fusesource.mqtt.client.*;
|
|||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -34,6 +36,7 @@ import static org.junit.Assert.assertNull;
|
|||||||
* @author andrea
|
* @author andrea
|
||||||
*/
|
*/
|
||||||
public class ServerRestartIntegrationTest {
|
public class ServerRestartIntegrationTest {
|
||||||
|
private static Logger LOG = LoggerFactory.getLogger(ServerRestartIntegrationTest.class);
|
||||||
|
|
||||||
Server m_server;
|
Server m_server;
|
||||||
MQTT m_mqtt;
|
MQTT m_mqtt;
|
||||||
@@ -42,7 +45,7 @@ public class ServerRestartIntegrationTest {
|
|||||||
|
|
||||||
protected void startServer() throws IOException {
|
protected void startServer() throws IOException {
|
||||||
m_server = new Server();
|
m_server = new Server();
|
||||||
m_server.startServer(new Properties());
|
m_server.startServer(IntegrationUtils.prepareTestPropeties());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|||||||
Reference in New Issue
Block a user