Fixed constructor of ConfigurationParser to do mergind of provided properties

This commit is contained in:
andrea
2015-03-14 17:31:11 +01:00
parent 34c668714a
commit 0aad3cbbf3
3 changed files with 19 additions and 9 deletions
+1
View File
@@ -7,6 +7,7 @@ Version 0.7:
Refactored the publish logic for QoS 1 2 to try to be more readable
Added packetIdentifier storage and generation
Fixed issue #16, bad packetId for will messages with qos > 0
Added store path variable "persistent_store" to configuration file (picked from Steven Warwick fork)
Version 0.6:
Fix issue #42, bad password file path composition
@@ -46,13 +46,14 @@ class ConfigurationParser {
ConfigurationParser() {
createDefaults();
}
/**
* Crate a ConfigurationParser merging the default properties with the provided ones.
* */
ConfigurationParser(Properties properties) {
createDefaults();
for (Entry<Object, Object> entrySet : m_properties.entrySet()) {
if (properties.containsKey(entrySet.getKey())) {
entrySet.setValue(properties.get(entrySet.getKey()));
}
this();
for (Entry<Object, Object> entrySet : properties.entrySet()) {
m_properties.put(entrySet.getKey(), entrySet.getValue());
}
}
@@ -32,6 +32,8 @@ import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import org.eclipse.moquette.commons.*;
import org.eclipse.moquette.commons.Constants;
import org.eclipse.paho.client.mqttv3.IMqttClient;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttClientPersistence;
@@ -71,14 +73,20 @@ public class ServerIntegrationSSLTest {
String file = getClass().getResource("/").getPath();
System.setProperty("moquette.path", file);
m_server = new Server();
m_server.startServer(new Properties());
Properties sslProps = new Properties();
sslProps.put(org.eclipse.moquette.commons.Constants.SSL_PORT_PROPERTY_NAME, "8883");
sslProps.put(org.eclipse.moquette.commons.Constants.JKS_PATH_PROPERTY_NAME, "serverkeystore.jks");
sslProps.put(org.eclipse.moquette.commons.Constants.KEY_STORE_PASSWORD_PROPERTY_NAME, "passw0rdsrv");
sslProps.put(Constants.KEY_MANAGER_PASSWORD_PROPERTY_NAME, "passw0rdsrv");
m_server.startServer(sslProps);
}
@Before
public void setUp() throws Exception {
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());
assertFalse(String.format("The DB storage file %s already exists",org.eclipse.moquette.commons.Constants.DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME), dbFile.exists());
startServer();
m_client = new MqttClient("ssl://localhost:8883", "TestClient", s_dataStore);