diff options
author | Ryan Goulding <ryandgoulding@gmail.com> | 2017-08-17 16:15:39 -0400 |
---|---|---|
committer | Ryan Goulding <ryandgoulding@gmail.com> | 2017-09-06 09:05:17 -0400 |
commit | af22e3dbddd5b372e815970ff43cc73e29135218 (patch) | |
tree | b437d5a2853cab8d0682256e518b9c204cf1b7db /dblib/provider/src/test | |
parent | b6ad62d01b1045ff03c03aa05ee1beeaabc633c7 (diff) |
Fix service registration for SDNC
Addresses the inherit race conditions associated with the
BundleActivator abstraction. From lessons learned in OpenDaylight
project, dependency injection and service injection via Aries Blueprint
is faster, more deterministic, and has better error messaging than
using BundleActivator(s).
This change addresses several aspects:
1) DBLIBResourceActivator is changed to DBLIBResourceProvider.
This was done in order to imply that this is no longer an
Activator or subclass of an Activator. The class is a POJO.
2) DBLIBResourceProvider is split from a single monolithic method
into several more manageable and better documented methods.
3) Documentation surrounding the resolution of the DB properties
is added so that a developer can more easily identify the
strategy (priority) used for resolving properties.
4) dblib-blueprint.xml is added. This is used to register the
configuration bean (DBLIBResourceProvider), and pass it as
an argument to the actual Service (DBLIBResourceManager).
5) Tests are added to test the functionality and resolution of
the properties file loading.
Issue-Id: SDNC-54
Change-Id: Ie9d5fb423ae7a67e9aec026c78321537399cc308
Signed-off-by: Ryan Goulding <ryandgoulding@gmail.com>
Diffstat (limited to 'dblib/provider/src/test')
4 files changed, 78 insertions, 0 deletions
diff --git a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java new file mode 100644 index 000000000..41011e55b --- /dev/null +++ b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java @@ -0,0 +1,24 @@ +package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; + +public class DblibDefaultFileResolverTest { + + @Test + public void resolveFile() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); + final Optional<File> file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +}
\ No newline at end of file diff --git a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java new file mode 100644 index 000000000..775898930 --- /dev/null +++ b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java @@ -0,0 +1,23 @@ +package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; + +public class DblibEnvVarFileResolverTest { + @Test + public void resolveFile() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); + final Optional<File> file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +}
\ No newline at end of file diff --git a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java new file mode 100644 index 000000000..117492d0b --- /dev/null +++ b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java @@ -0,0 +1,17 @@ +package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; + +public class DblibJREFileResolverTest { + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibJREFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +}
\ No newline at end of file diff --git a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java new file mode 100644 index 000000000..0a032e8b7 --- /dev/null +++ b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java @@ -0,0 +1,14 @@ +package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class DblibKarafRootFileResolverTest { + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibKarafRootFileResolver("success", null); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +}
\ No newline at end of file |