From 03235aa6cc35871630ee3e09fe467eca79ce315e Mon Sep 17 00:00:00 2001 From: Ryan Goulding Date: Tue, 19 Sep 2017 11:14:41 -0400 Subject: Abstract utility classes for re-use When looking at the existing uses of BundleActivator(s), it became immediately clear that other parts of the code have a strategy based properties file resolution very similar to those abstracted by dblib. This change aggregates a separate utils bundle for this functionality, which is further abstracted for potential reuse with other use cases. The next use case is in the sli bundle, which will be handled in a follow-up patch. Issue-Id: SDNC-54 Change-Id: Ie4d4bb679617474b1983e6044c08cca1742b9893 Signed-off-by: Ryan Goulding --- .../ccsdk/sli/core/utils/JREFileResolverTest.java | 15 +++++++++++++ .../sli/core/utils/KarafRootFileResolverTest.java | 14 ++++++++++++ .../utils/dblib/DblibDefaultFileResolverTest.java | 25 ++++++++++++++++++++++ .../utils/dblib/DblibEnvVarFileResolverTest.java | 24 +++++++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 utils/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java create mode 100644 utils/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java create mode 100644 utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java create mode 100644 utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java (limited to 'utils/src/test') diff --git a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java new file mode 100644 index 00000000..e5051d65 --- /dev/null +++ b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java @@ -0,0 +1,15 @@ +package org.onap.ccsdk.sli.core.utils; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class JREFileResolverTest { + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new JREFileResolver("success", JREFileResolverTest.class); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java new file mode 100644 index 00000000..5e407daf --- /dev/null +++ b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java @@ -0,0 +1,14 @@ +package org.onap.ccsdk.sli.core.utils; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class KarafRootFileResolverTest { + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new KarafRootFileResolver("success", null); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java new file mode 100644 index 00000000..4b28d449 --- /dev/null +++ b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java @@ -0,0 +1,25 @@ +package org.onap.ccsdk.sli.core.utils.dblib; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; + +public class DblibDefaultFileResolverTest { + + @Test + public void resolveFile() throws Exception { + final PropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); + final Optional file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java new file mode 100644 index 00000000..bae4168d --- /dev/null +++ b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java @@ -0,0 +1,24 @@ +package org.onap.ccsdk.sli.core.utils.dblib; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; + +public class DblibEnvVarFileResolverTest { + @Test + public void resolveFile() throws Exception { + final PropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); + final Optional file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file -- cgit 1.2.3-korg