From 3748b447876019681edce86942089a3652232ecc Mon Sep 17 00:00:00 2001 From: Jorge Hernandez Date: Thu, 21 Mar 2019 07:10:46 -0500 Subject: 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 --- .../drools/persistence/SystemPersistenceTest.java | 66 +++++++++++++++++++--- 1 file changed, 58 insertions(+), 8 deletions(-) (limited to 'policy-management/src/test/java/org') 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,15 +55,30 @@ 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. */ @@ -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 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 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); -- cgit 1.2.3-korg