summaryrefslogtreecommitdiffstats
path: root/policy-management/src/test/java
diff options
context:
space:
mode:
authorJorge Hernandez <jorge.hernandez-herrero@att.com>2019-03-21 07:10:46 -0500
committerJorge Hernandez <jorge.hernandez-herrero@att.com>2019-03-21 07:52:30 -0500
commit3748b447876019681edce86942089a3652232ecc (patch)
tree156bc390adb4e3cb0404e462fa7681302711c7e6 /policy-management/src/test/java
parentd0715ca90465d0f7b3d090234f6b0098194f0101 (diff)
Support topic properties files.
They will be loaded automatically at startup. Remove POLICY-PAP-PDP topic as is moved to a feature. Remove PDPD-CONFIGURATION topic as it is not used. Change-Id: I55629f885d61ce1cc4e3f24bcae5279e65a96f22 Issue-ID: POLICY-1610 Signed-off-by: Jorge Hernandez <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'policy-management/src/test/java')
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java66
1 files changed, 58 insertions, 8 deletions
diff --git a/policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java b/policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java
index de0a7518..b2771944 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java
@@ -55,16 +55,31 @@ public class SystemPersistenceTest {
private static final String TEST_CONTROLLER_NAME = "foo";
/**
- * Test JUnit Controller Name.
+ * Test JUnit Topic Name.
+ */
+ private static final String TEST_TOPIC_NAME = TEST_CONTROLLER_NAME;
+
+ /**
+ * Test JUnit Controller File.
*/
private static final String TEST_CONTROLLER_FILE = TEST_CONTROLLER_NAME + "-controller.properties";
/**
- * Test JUnit Controller Name Backup.
+ * Test JUnit Controller Backup File.
*/
private static final String TEST_CONTROLLER_FILE_BAK = TEST_CONTROLLER_FILE + ".bak";
/**
+ * Test JUnit Topic File.
+ */
+ private static final String TEST_TOPIC_FILE = TEST_CONTROLLER_NAME + "-topic.properties";
+
+ /**
+ * Test JUnit Controller Name Backup.
+ */
+ private static final String TEST_TOPIC_FILE_BAK = TEST_TOPIC_FILE + ".bak";
+
+ /**
* Test JUnit Environment/Engine properties.
*/
private static final String ENV_PROPS = TEST_CONTROLLER_NAME;
@@ -143,24 +158,53 @@ public class SystemPersistenceTest {
}
@Test
- public void test3Controller() {
+ public void test3Topic() {
+ SystemPersistence.manager.setConfigurationDir(null);
+
+ Path topicPath = Paths
+ .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_TOPIC_FILE);
+
+ Path topicBakPath = Paths
+ .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_TOPIC_FILE_BAK);
+
+ assertTrue(Files.notExists(topicPath));
+ assertTrue(Files.notExists(topicBakPath));
+
+ SystemPersistence.manager.storeTopic(TEST_TOPIC_NAME, new Properties());
+
+ assertTrue(Files.exists(topicPath));
+
+ Properties properties = SystemPersistence.manager.getTopicProperties(TEST_TOPIC_NAME);
+ assertNotNull(properties);
+
+ List<Properties> topicPropsList = SystemPersistence.manager.getTopicProperties();
+ assertEquals(1, topicPropsList.size());
+
+ SystemPersistence.manager.backupTopic(TEST_TOPIC_NAME);
+ assertTrue(Files.exists(topicBakPath));
+
+ SystemPersistence.manager.deleteTopic(TEST_TOPIC_NAME);
+ assertTrue(Files.notExists(topicPath));
+ }
+
+ @Test
+ public void test4Controller() {
SystemPersistence.manager.setConfigurationDir(null);
- final Path controllerPath = Paths
+ Path controllerPath = Paths
.get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE);
- final Path controllerBakPath = Paths
+ Path controllerBakPath = Paths
.get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
assertTrue(Files.notExists(controllerPath));
assertTrue(Files.notExists(controllerBakPath));
- Properties properties = new Properties();
- SystemPersistence.manager.storeController(TEST_CONTROLLER_NAME, properties);
+ SystemPersistence.manager.storeController(TEST_CONTROLLER_NAME, new Properties());
assertTrue(Files.exists(controllerPath));
- properties = SystemPersistence.manager.getControllerProperties(TEST_CONTROLLER_NAME);
+ Properties properties = SystemPersistence.manager.getControllerProperties(TEST_CONTROLLER_NAME);
assertNotNull(properties);
List<Properties> controllerPropsList = SystemPersistence.manager.getControllerProperties();
@@ -188,14 +232,20 @@ public class SystemPersistenceTest {
.getProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME));
}
+ SystemPersistence.manager.deleteTopic(TEST_TOPIC_NAME);
+
final Path testControllerBakPath = Paths
.get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
+ final Path testTopicBakPath = Paths
+ .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_TOPIC_FILE_BAK);
+
final Path policyEnginePath = Paths.get(OTHER_CONFIG_DIR, FileSystemPersistence.PROPERTIES_FILE_ENGINE);
final Path environmentPath = Paths.get(OTHER_CONFIG_DIR, ENV_PROPS_FILE);
final Path systemPath = Paths.get(OTHER_CONFIG_DIR, SYSTEM_PROPS_FILE);
Files.deleteIfExists(testControllerBakPath);
+ Files.deleteIfExists(testTopicBakPath);
Files.deleteIfExists(policyEnginePath);
Files.deleteIfExists(environmentPath);
Files.deleteIfExists(systemPath);