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
|
|
|
|
2018-11-11 17:58:19 +01:00
|
|
|
package io.moquette.integration;
|
2015-04-07 07:51:44 +02:00
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.Properties;
|
2018-11-18 10:58:25 +01:00
|
|
|
import static io.moquette.BrokerConstants.DEFAULT_MOQUETTE_STORE_H2_DB_FILENAME;
|
2015-12-08 14:04:35 +01:00
|
|
|
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;
|
2018-11-18 10:58:25 +01:00
|
|
|
import static org.junit.Assert.assertFalse;
|
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
|
|
|
|
2018-11-18 10:58:25 +01:00
|
|
|
static String localH2MvStoreDBPath() {
|
2015-04-07 07:51:44 +02:00
|
|
|
String currentDir = System.getProperty("user.dir");
|
2018-11-18 10:58:25 +01:00
|
|
|
return currentDir + File.separator + "target" + File.separator + DEFAULT_MOQUETTE_STORE_H2_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();
|
2018-11-18 10:58:25 +01:00
|
|
|
testProperties.put(PERSISTENT_STORE_PROPERTY_NAME, IntegrationUtils.localH2MvStoreDBPath());
|
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
|
|
|
|
2017-04-12 17:40:32 +02:00
|
|
|
private IntegrationUtils() {
|
|
|
|
|
}
|
2018-11-18 10:58:25 +01:00
|
|
|
|
|
|
|
|
public static void clearTestStorage() {
|
|
|
|
|
String dbPath = localH2MvStoreDBPath();
|
|
|
|
|
File dbFile = new File(dbPath);
|
|
|
|
|
if (dbFile.exists()) {
|
|
|
|
|
dbFile.delete();
|
|
|
|
|
}
|
|
|
|
|
assertFalse(dbFile.exists());
|
|
|
|
|
}
|
2015-04-07 07:51:44 +02:00
|
|
|
}
|