2015-04-07 07:51:44 +02:00
|
|
|
/*
|
2018-04-27 20:17:47 +02:00
|
|
|
* Copyright (c) 2012-2018 The original author or authors
|
2015-04-07 07:51:44 +02:00
|
|
|
* ------------------------------------------------------
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2017-02-01 16:11:21 +01:00
|
|
|
|
2015-11-20 20:54:27 +01:00
|
|
|
package io.moquette.server;
|
2015-04-07 07:51:44 +02:00
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.Properties;
|
2015-12-08 14:04:35 +01:00
|
|
|
import static io.moquette.BrokerConstants.DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME;
|
|
|
|
|
import static io.moquette.BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME;
|
2016-05-18 00:09:40 +02:00
|
|
|
import static io.moquette.BrokerConstants.PORT_PROPERTY_NAME;
|
2015-04-07 07:51:44 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Used to carry integration configurations.
|
|
|
|
|
*/
|
2017-04-12 17:40:32 +02:00
|
|
|
public final class IntegrationUtils {
|
2017-02-01 16:11:21 +01:00
|
|
|
|
2015-04-07 07:51:44 +02:00
|
|
|
static String localMapDBPath() {
|
|
|
|
|
String currentDir = System.getProperty("user.dir");
|
2017-03-25 15:38:10 +01:00
|
|
|
return currentDir + File.separator + "target" + File.separator + DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME;
|
2015-04-07 07:51:44 +02:00
|
|
|
}
|
|
|
|
|
|
2016-07-22 12:09:10 +02:00
|
|
|
static String localClusterMapDBPath(int port) {
|
|
|
|
|
String currentDir = System.getProperty("user.dir");
|
2017-03-25 15:38:10 +01:00
|
|
|
return currentDir + File.separator + "target" + File.separator + port + DEFAULT_MOQUETTE_STORE_MAP_DB_FILENAME;
|
2016-07-22 12:09:10 +02:00
|
|
|
}
|
|
|
|
|
|
2016-05-18 00:09:40 +02:00
|
|
|
public static Properties prepareTestProperties() {
|
2015-04-07 07:51:44 +02:00
|
|
|
Properties testProperties = new Properties();
|
|
|
|
|
testProperties.put(PERSISTENT_STORE_PROPERTY_NAME, IntegrationUtils.localMapDBPath());
|
2016-05-18 00:09:40 +02:00
|
|
|
testProperties.put(PORT_PROPERTY_NAME, "1883");
|
2015-04-07 07:51:44 +02:00
|
|
|
return testProperties;
|
|
|
|
|
}
|
2015-11-08 18:25:55 +01:00
|
|
|
|
2016-07-22 12:09:10 +02:00
|
|
|
public static Properties prepareTestClusterProperties(int port) {
|
|
|
|
|
Properties testProperties = new Properties();
|
|
|
|
|
testProperties.put(PERSISTENT_STORE_PROPERTY_NAME, IntegrationUtils.localClusterMapDBPath(port));
|
|
|
|
|
testProperties.put(PORT_PROPERTY_NAME, Integer.toString(port));
|
|
|
|
|
return testProperties;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-25 16:05:45 +01:00
|
|
|
/*public static void cleanPersistenceFile(IConfig config) {
|
2015-11-08 18:25:55 +01:00
|
|
|
String fileName = config.getProperty(PERSISTENT_STORE_PROPERTY_NAME);
|
|
|
|
|
cleanPersistenceFile(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void cleanPersistenceFile(String fileName) {
|
|
|
|
|
File dbFile = new File(fileName);
|
|
|
|
|
if (dbFile.exists()) {
|
|
|
|
|
dbFile.delete();
|
|
|
|
|
new File(fileName + ".p").delete();
|
|
|
|
|
new File(fileName + ".t").delete();
|
|
|
|
|
}
|
|
|
|
|
assertFalse(dbFile.exists());
|
2017-03-25 16:05:45 +01:00
|
|
|
}*/
|
2017-04-12 17:40:32 +02:00
|
|
|
|
|
|
|
|
private IntegrationUtils() {
|
|
|
|
|
}
|
2015-04-07 07:51:44 +02:00
|
|
|
}
|