diff options
Diffstat (limited to 'core')
19 files changed, 301 insertions, 70 deletions
diff --git a/core/sli/common/pom.xml b/core/sli/common/pom.xml index 34db3104c..716bef397 100755 --- a/core/sli/common/pom.xml +++ b/core/sli/common/pom.xml @@ -6,7 +6,7 @@ <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> <version>2.1.1-SNAPSHOT</version> - <relativePath/> + <relativePath /> </parent> <groupId>org.onap.ccsdk.sli.core</groupId> @@ -18,8 +18,8 @@ <description>The SLI Common package includes common classes used by the various SLI subcomponents, as well as classes used by clients to interface with the service logic interpreter</description> <properties> - <!-- Ignore deprecated classes in coverage counts --> - <sonar.coverage.exclusions>**/MessageWriter.java</sonar.coverage.exclusions> + <!-- Ignore deprecated classes in coverage counts --> + <sonar.coverage.exclusions>**/MessageWriter.java</sonar.coverage.exclusions> </properties> @@ -124,6 +124,28 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <environmentVariables> + <MYSQL_USER>dummyUser</MYSQL_USER> + <MYSQL_PASSWORD>dummyPassword</MYSQL_PASSWORD> + <MYSQL_DATABASE>dummyDatabase</MYSQL_DATABASE> + </environmentVariables> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <configuration> + <environmentVariables> + <MYSQL_USER>dummyUser</MYSQL_USER> + <MYSQL_PASSWORD>dummyPassword</MYSQL_PASSWORD> + <MYSQL_DATABASE>dummyDatabase</MYSQL_DATABASE> + </environmentVariables> + </configuration> + </plugin> </plugins> </build> </project> diff --git a/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java b/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java index 5ededb9eb..1b9b17951 100644 --- a/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java +++ b/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java @@ -30,6 +30,7 @@ import java.util.Date; import java.util.Properties; import javax.sql.rowset.CachedRowSet; import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,7 +63,7 @@ public class MessageWriter { initialized = true; // Read properties - Properties props = new Properties(); + Properties props = new EnvProperties(); String propPath = System.getenv(SVCLOGIC_PROP_VAR); if (propPath == null) { diff --git a/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java b/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java index e0eb57304..9076901a2 100644 --- a/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java +++ b/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java @@ -27,6 +27,7 @@ import java.io.InputStream; import java.util.Properties; import org.onap.ccsdk.sli.core.dblib.DBResourceManager; import org.onap.ccsdk.sli.core.utils.PathValidator; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +59,7 @@ public class SvcLogicStoreFactory { public static SvcLogicStore getSvcLogicStore(InputStream inStr) throws SvcLogicException { - Properties props = new Properties(); + Properties props = new EnvProperties(); try { props.load(inStr); diff --git a/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index 50eb917f8..715af9e8a 100644 --- a/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -43,6 +43,7 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.sli.core.dblib.DBResourceManager; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,7 +65,7 @@ public class ITCaseSvcLogicParser { InputStream propStr = ITCaseSvcLogicParser.class.getResourceAsStream("/svclogic.properties"); - Properties props = new Properties(); + Properties props = new EnvProperties(); props.load(propStr); @@ -150,7 +151,7 @@ public class ITCaseSvcLogicParser { InputStream propStr = ITCaseSvcLogicParser.class.getResourceAsStream("/dblib.properties"); - Properties props = new Properties(); + Properties props = new EnvProperties(); props.load(propStr); diff --git a/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java b/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java index 2dd83e86d..c868c8a81 100644 --- a/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java +++ b/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java @@ -7,6 +7,7 @@ import java.io.InputStream; import java.net.URL; import java.util.Properties; import org.junit.Test; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; public class TestSvcLogicLoader { @@ -16,7 +17,7 @@ public class TestSvcLogicLoader { InputStream propStr = ITCaseSvcLogicParser.class.getResourceAsStream("/svclogic.properties"); - Properties props = new Properties(); + Properties props = new EnvProperties(); props.load(propStr); diff --git a/core/sli/common/src/test/resources/svclogic.properties b/core/sli/common/src/test/resources/svclogic.properties index 426960f76..85818d7b6 100644 --- a/core/sli/common/src/test/resources/svclogic.properties +++ b/core/sli/common/src/test/resources/svclogic.properties @@ -20,8 +20,8 @@ ### org.onap.ccsdk.sli.dbtype = jdbc -org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:${MYSQL_DATABASE};create=true org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver -org.onap.ccsdk.sli.jdbc.database = sdnctl -org.onap.ccsdk.sli.jdbc.user = test -org.onap.ccsdk.sli.jdbc.password = test +org.onap.ccsdk.sli.jdbc.database = ${MYSQL_DATABASE} +org.onap.ccsdk.sli.jdbc.user = ${MYSQL_USER} +org.onap.ccsdk.sli.jdbc.password = ${MYSQL_PASSWORD} diff --git a/core/sli/provider/pom.xml b/core/sli/provider/pom.xml index d45b2e0f4..5f236809a 100755 --- a/core/sli/provider/pom.xml +++ b/core/sli/provider/pom.xml @@ -6,7 +6,7 @@ <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> <version>2.1.1-SNAPSHOT</version> - <relativePath/> + <relativePath /> </parent> <groupId>org.onap.ccsdk.sli.core</groupId> @@ -68,31 +68,31 @@ <artifactId>mdsal-binding-api</artifactId> <scope>provided</scope> </dependency> - <dependency> - <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId> - <artifactId>rfc6991</artifactId> + <dependency> + <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId> + <artifactId>rfc6991</artifactId> <scope>provided</scope> - </dependency> + </dependency> <dependency> <groupId>org.opendaylight.bgpcep</groupId> <artifactId>bgp-concepts</artifactId> <scope>provided</scope> <optional>true</optional> </dependency> - <dependency> - <groupId>org.opendaylight.mdsal</groupId> - <artifactId>mdsal-dom-api</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.opendaylight.mdsal</groupId> - <artifactId>yang-binding</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.google.code.findbugs</groupId> - <artifactId>annotations</artifactId> - </dependency> + <dependency> + <groupId>org.opendaylight.mdsal</groupId> + <artifactId>mdsal-dom-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.opendaylight.mdsal</groupId> + <artifactId>yang-binding</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>annotations</artifactId> + </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> @@ -146,6 +146,28 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <environmentVariables> + <MYSQL_USER>dummyUser</MYSQL_USER> + <MYSQL_PASSWORD>dummyPassword</MYSQL_PASSWORD> + <MYSQL_DATABASE>dummyDatabase</MYSQL_DATABASE> + </environmentVariables> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <configuration> + <environmentVariables> + <MYSQL_USER>dummyUser</MYSQL_USER> + <MYSQL_PASSWORD>dummyPassword</MYSQL_PASSWORD> + <MYSQL_DATABASE>dummyDatabase</MYSQL_DATABASE> + </environmentVariables> + </configuration> + </plugin> </plugins> </build> </project> diff --git a/core/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java b/core/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java index aad7a5a6d..40d305610 100644 --- a/core/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java +++ b/core/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java @@ -35,6 +35,7 @@ import org.onap.ccsdk.sli.core.utils.JREFileResolver; import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,9 +70,10 @@ public class SvcLogicPropertiesProviderImpl implements SvcLogicPropertiesProvide private Vector<PropertiesFileResolver> sliPropertiesFileResolvers = new Vector<>(); /** - * The configuration properties for the db connection. + * The configuration properties for the db connection. Use EnvProperties class, which + * extends Properties and resolves env variable references in values */ - private Properties properties; + private EnvProperties properties; /** * Set up the prioritized list of strategies for resolving dblib properties @@ -91,7 +93,7 @@ public class SvcLogicPropertiesProviderImpl implements SvcLogicPropertiesProvide final File propertiesFile = determinePropertiesFile(this); if (propertiesFile != null) { try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); + properties = new EnvProperties(); properties.load(fileInputStream); } catch (final IOException e) { log.error("Failed to load properties for file: {}", propertiesFile.toString(), @@ -103,7 +105,7 @@ public class SvcLogicPropertiesProviderImpl implements SvcLogicPropertiesProvide InputStream propStr = getClass().getResourceAsStream("/" + SVCLOGIC_PROP_FILE_NAME); if (propStr != null) { - properties = new Properties(); + properties = new EnvProperties(); try { properties.load(propStr); propStr.close(); diff --git a/core/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/core/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index ad439cdb4..02582269a 100644 --- a/core/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/core/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -65,6 +65,7 @@ import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider; import org.onap.ccsdk.sli.core.sli.provider.base.SwitchNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.UpdateNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.WhileNodeExecutor; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -106,7 +107,7 @@ public class ITCaseSvcLogicGraphExecutor { InputStream propStr = ITCaseSvcLogicGraphExecutor.class.getResourceAsStream("/svclogic.properties"); - Properties svcprops = new Properties(); + Properties svcprops = new EnvProperties(); svcprops.load(propStr); SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); @@ -152,7 +153,7 @@ public class ITCaseSvcLogicGraphExecutor { InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); - Properties svcprops = new Properties(); + Properties svcprops = new EnvProperties(); svcprops.load(propStr); diff --git a/core/sli/provider/src/test/resources/svclogic.properties b/core/sli/provider/src/test/resources/svclogic.properties index 426960f76..85818d7b6 100644 --- a/core/sli/provider/src/test/resources/svclogic.properties +++ b/core/sli/provider/src/test/resources/svclogic.properties @@ -20,8 +20,8 @@ ### org.onap.ccsdk.sli.dbtype = jdbc -org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:${MYSQL_DATABASE};create=true org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver -org.onap.ccsdk.sli.jdbc.database = sdnctl -org.onap.ccsdk.sli.jdbc.user = test -org.onap.ccsdk.sli.jdbc.password = test +org.onap.ccsdk.sli.jdbc.database = ${MYSQL_DATABASE} +org.onap.ccsdk.sli.jdbc.user = ${MYSQL_USER} +org.onap.ccsdk.sli.jdbc.password = ${MYSQL_PASSWORD} diff --git a/core/sliapi/model/swagger/src/main/json/sliapi.json b/core/sliapi/model/swagger/src/main/json/sliapi.json index 3848cb551..284defcc8 100644 --- a/core/sliapi/model/swagger/src/main/json/sliapi.json +++ b/core/sliapi/model/swagger/src/main/json/sliapi.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"description":"This module contains a collection of generally useful derived\nYANG data types for Internet addresses and related things.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.,Defines API to service logic interpreter,This module contains a collection of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.","version":"1.2.0-SNAPSHOT","title":"ietf-inet-types,SLI-API,ietf-yang-types API"},"consumes":["application/json","application/xml"],"produces":["application/json","application/xml"],"paths":{"/config/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/config/SLI-API:test-results/SLI-API:test-result/":{"post":{"description":"creates sli.api.testresults.TestResult","parameters":[{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}}},"/config/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/operational/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}}},"/operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}}},"/operations/SLI-API:execute-graph/":{"post":{"tags":["SLI-API"],"parameters":[{"in":"body","name":"sli.api.executegraph.Input.body-param","required":false,"schema":{"properties":{"input":{"originalRef":"#/definitions/sli.api.executegraph.Input","$ref":"#/definitions/sli.api.executegraph.Input"}}}}],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"},"schema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"}},"201":{"description":"No response"}}}},"/operations/SLI-API:healthcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"},"schema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"}},"201":{"description":"No response"}}}},"/operations/SLI-API:vlbcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"},"schema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"}},"201":{"description":"No response"}}}}},"definitions":{"sli.api.ExecuteGraph":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.Healthcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.ModeEnumeration":{"type":"string","enum":["sync","async"]},"sli.api.ParameterSetting":{"type":"object","properties":{"string-value":{"type":"string"},"boolean-value":{"type":"boolean"},"parameter-name":{"type":"string","description":"Parameter name"},"int-value":{"type":"integer","format":"int32"}}},"sli.api.ResponseFields":{"type":"object","properties":{"response-code":{"type":"string"},"response-message":{"type":"string"},"context-memory-json":{"type":"string"},"ack-final-indicator":{"type":"string"}}},"sli.api.TestResults":{"type":"object","properties":{"test-result":{"type":"array","items":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"sli.api.Vlbcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.executegraph.Input":{"type":"object","properties":{"mode":{"originalRef":"#/definitions/sli.api.ModeEnumeration","$ref":"#/definitions/sli.api.ModeEnumeration"},"module-name":{"type":"string"},"sli-parameter":{"type":"array","items":{"originalRef":"#/definitions/sli.api.ParameterSetting","$ref":"#/definitions/sli.api.ParameterSetting"}},"rpc-name":{"type":"string"}}},"sli.api.testresults.TestResult":{"type":"object","properties":{"results":{"type":"array","items":{"type":"string"}},"test-identifier":{"type":"string"}}}}}
\ No newline at end of file +{"swagger":"2.0","info":{"description":"Defines API to service logic interpreter,This module contains a collection of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.,This module contains a collection of generally useful derived\nYANG data types for Internet addresses and related things.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.","version":"1.2.0-SNAPSHOT","title":"SLI-API,ietf-yang-types,ietf-inet-types API"},"consumes":["application/json","application/xml"],"produces":["application/json","application/xml"],"paths":{"/config/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/config/SLI-API:test-results/SLI-API:test-result/":{"post":{"description":"creates sli.api.testresults.TestResult","parameters":[{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}}},"/config/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/operational/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}}},"/operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}}},"/operations/SLI-API:execute-graph/":{"post":{"tags":["SLI-API"],"parameters":[{"in":"body","name":"sli.api.executegraph.Input.body-param","required":false,"schema":{"properties":{"input":{"originalRef":"#/definitions/sli.api.executegraph.Input","$ref":"#/definitions/sli.api.executegraph.Input"}}}}],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"},"responseSchema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"}},"201":{"description":"No response"}}}},"/operations/SLI-API:healthcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"},"responseSchema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"}},"201":{"description":"No response"}}}},"/operations/SLI-API:vlbcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"},"responseSchema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"}},"201":{"description":"No response"}}}}},"definitions":{"sli.api.ExecuteGraph":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.Healthcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.ModeEnumeration":{"type":"string","enum":["sync","async"]},"sli.api.ParameterSetting":{"type":"object","properties":{"string-value":{"type":"string"},"boolean-value":{"type":"boolean"},"parameter-name":{"type":"string","description":"Parameter name"},"int-value":{"type":"integer","format":"int32"}}},"sli.api.ResponseFields":{"type":"object","properties":{"response-code":{"type":"string"},"response-message":{"type":"string"},"context-memory-json":{"type":"string"},"ack-final-indicator":{"type":"string"}}},"sli.api.TestResults":{"type":"object","properties":{"test-result":{"type":"array","items":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"sli.api.Vlbcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.executegraph.Input":{"type":"object","properties":{"mode":{"originalRef":"#/definitions/sli.api.ModeEnumeration","$ref":"#/definitions/sli.api.ModeEnumeration"},"module-name":{"type":"string"},"sli-parameter":{"type":"array","items":{"originalRef":"#/definitions/sli.api.ParameterSetting","$ref":"#/definitions/sli.api.ParameterSetting"}},"rpc-name":{"type":"string"}}},"sli.api.testresults.TestResult":{"type":"object","properties":{"results":{"type":"array","items":{"type":"string"}},"test-identifier":{"type":"string"}}}}}
\ No newline at end of file diff --git a/core/sliapi/model/swagger/src/main/yaml/sliapi.yaml b/core/sliapi/model/swagger/src/main/yaml/sliapi.yaml index b97b1325a..d323e1058 100644 --- a/core/sliapi/model/swagger/src/main/yaml/sliapi.yaml +++ b/core/sliapi/model/swagger/src/main/yaml/sliapi.yaml @@ -1,25 +1,25 @@ --- swagger: "2.0" info: - description: "This module contains a collection of generally useful derived\nYANG\ - \ data types for Internet addresses and related things.\n\nCopyright (c) 2013\ - \ IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\ - \nRedistribution and use in source and binary forms, with or\nwithout modification,\ + description: "Defines API to service logic interpreter,This module contains a collection\ + \ of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust\ + \ and the persons identified as\nauthors of the code. All rights reserved.\n\n\ + Redistribution and use in source and binary forms, with or\nwithout modification,\ \ is permitted pursuant to, and subject\nto the license terms contained in, the\ \ Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\n\ Relating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version\ \ of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal\ - \ notices.,Defines API to service logic interpreter,This module contains a collection\ - \ of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust\ - \ and the persons identified as\nauthors of the code. All rights reserved.\n\n\ - Redistribution and use in source and binary forms, with or\nwithout modification,\ + \ notices.,This module contains a collection of generally useful derived\nYANG\ + \ data types for Internet addresses and related things.\n\nCopyright (c) 2013\ + \ IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\ + \nRedistribution and use in source and binary forms, with or\nwithout modification,\ \ is permitted pursuant to, and subject\nto the license terms contained in, the\ \ Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\n\ Relating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version\ \ of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal\ \ notices." version: "1.2.0-SNAPSHOT" - title: "ietf-inet-types,SLI-API,ietf-yang-types API" + title: "SLI-API,ietf-yang-types,ietf-inet-types API" consumes: - "application/json" - "application/xml" @@ -38,10 +38,10 @@ paths: description: "Internal error" 200: description: "sli.api.TestResults" - responseSchema: + schema: originalRef: "#/definitions/sli.api.TestResults" $ref: "#/definitions/sli.api.TestResults" - schema: + responseSchema: originalRef: "#/definitions/sli.api.TestResults" $ref: "#/definitions/sli.api.TestResults" post: @@ -126,10 +126,10 @@ paths: description: "Internal error" 200: description: "sli.api.testresults.TestResult" - responseSchema: + schema: originalRef: "#/definitions/sli.api.testresults.TestResult" $ref: "#/definitions/sli.api.testresults.TestResult" - schema: + responseSchema: originalRef: "#/definitions/sli.api.testresults.TestResult" $ref: "#/definitions/sli.api.testresults.TestResult" post: @@ -206,10 +206,10 @@ paths: description: "Internal error" 200: description: "sli.api.TestResults" - responseSchema: + schema: originalRef: "#/definitions/sli.api.TestResults" $ref: "#/definitions/sli.api.TestResults" - schema: + responseSchema: originalRef: "#/definitions/sli.api.TestResults" $ref: "#/definitions/sli.api.TestResults" /operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/: @@ -228,10 +228,10 @@ paths: description: "Internal error" 200: description: "sli.api.testresults.TestResult" - responseSchema: + schema: originalRef: "#/definitions/sli.api.testresults.TestResult" $ref: "#/definitions/sli.api.testresults.TestResult" - schema: + responseSchema: originalRef: "#/definitions/sli.api.testresults.TestResult" $ref: "#/definitions/sli.api.testresults.TestResult" /operations/SLI-API:execute-graph/: @@ -252,10 +252,10 @@ paths: description: "Internal error" 200: description: "Correct response" - responseSchema: + schema: originalRef: "#/definitions/sli.api.ExecuteGraph" $ref: "#/definitions/sli.api.ExecuteGraph" - schema: + responseSchema: originalRef: "#/definitions/sli.api.ExecuteGraph" $ref: "#/definitions/sli.api.ExecuteGraph" 201: @@ -270,10 +270,10 @@ paths: description: "Internal error" 200: description: "Correct response" - responseSchema: + schema: originalRef: "#/definitions/sli.api.Healthcheck" $ref: "#/definitions/sli.api.Healthcheck" - schema: + responseSchema: originalRef: "#/definitions/sli.api.Healthcheck" $ref: "#/definitions/sli.api.Healthcheck" 201: @@ -288,10 +288,10 @@ paths: description: "Internal error" 200: description: "Correct response" - responseSchema: + schema: originalRef: "#/definitions/sli.api.Vlbcheck" $ref: "#/definitions/sli.api.Vlbcheck" - schema: + responseSchema: originalRef: "#/definitions/sli.api.Vlbcheck" $ref: "#/definitions/sli.api.Vlbcheck" 201: diff --git a/core/sliapi/provider/pom.xml b/core/sliapi/provider/pom.xml index 5bccec9b6..d22ec5803 100755 --- a/core/sliapi/provider/pom.xml +++ b/core/sliapi/provider/pom.xml @@ -95,4 +95,20 @@ <scope>test</scope> </dependency> </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <environmentVariables> + <MYSQL_USER>dummyUser</MYSQL_USER> + <MYSQL_PASSWORD>dummyPassword</MYSQL_PASSWORD> + <MYSQL_DATABASE>dummyDatabase</MYSQL_DATABASE> + </environmentVariables> + </configuration> + </plugin> + </plugins> + </build> </project> diff --git a/core/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java b/core/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java index b731423c5..cd7dd2058 100644 --- a/core/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java +++ b/core/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java @@ -62,6 +62,7 @@ import org.onap.ccsdk.sli.core.sli.provider.base.SetNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.SwitchNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.UpdateNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.WhileNodeExecutor; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.dom.api.DOMDataBroker; @@ -123,7 +124,7 @@ public class TestSliapiProvider { // Load svclogic.properties and get a SvcLogicStore InputStream propStr = TestSliapiProvider.class.getResourceAsStream("/svclogic.properties"); - Properties svcprops = new Properties(); + Properties svcprops = new EnvProperties(); svcprops.load(propStr); SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); diff --git a/core/sliapi/provider/src/test/resources/svclogic.properties b/core/sliapi/provider/src/test/resources/svclogic.properties index 426960f76..85818d7b6 100644 --- a/core/sliapi/provider/src/test/resources/svclogic.properties +++ b/core/sliapi/provider/src/test/resources/svclogic.properties @@ -20,8 +20,8 @@ ### org.onap.ccsdk.sli.dbtype = jdbc -org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:${MYSQL_DATABASE};create=true org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver -org.onap.ccsdk.sli.jdbc.database = sdnctl -org.onap.ccsdk.sli.jdbc.user = test -org.onap.ccsdk.sli.jdbc.password = test +org.onap.ccsdk.sli.jdbc.database = ${MYSQL_DATABASE} +org.onap.ccsdk.sli.jdbc.user = ${MYSQL_USER} +org.onap.ccsdk.sli.jdbc.password = ${MYSQL_PASSWORD} diff --git a/core/utils/provider/pom.xml b/core/utils/provider/pom.xml index e3a805f82..a94183479 100644 --- a/core/utils/provider/pom.xml +++ b/core/utils/provider/pom.xml @@ -46,4 +46,20 @@ <scope>test</scope> </dependency> </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <environmentVariables> + <MYSQL_USER>dummyUser</MYSQL_USER> + <MYSQL_PASSWORD>dummyPassword</MYSQL_PASSWORD> + <MYSQL_DATABASE>dummyDatabase</MYSQL_DATABASE> + </environmentVariables> + </configuration> + </plugin> + </plugins> + </build> </project> diff --git a/core/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/EnvProperties.java b/core/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/EnvProperties.java new file mode 100644 index 000000000..2e9f2673d --- /dev/null +++ b/core/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/EnvProperties.java @@ -0,0 +1,61 @@ +package org.onap.ccsdk.sli.core.utils.common; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.util.Enumeration; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class EnvProperties extends Properties { + + @Override + public synchronized void load(Reader reader) throws IOException { + super.load(reader); + resolveAllValues(); + } + + @Override + public synchronized void load(InputStream inStream) throws IOException { + super.load(inStream); + resolveAllValues(); + } + + @Override + public synchronized Object setProperty(String key, String value) { + return super.setProperty(key, EnvProperties.resolveValue(value)); + } + + private void resolveAllValues() { + Enumeration<?> propNames = propertyNames(); + + while (propNames.hasMoreElements()) { + String propName = (String) propNames.nextElement(); + super.setProperty(propName, EnvProperties.resolveValue(getProperty(propName))); + } + + } + + public static String resolveValue(String value) { + if (value == null) { + return null; + } + + Pattern p = Pattern.compile("\\$\\{(\\w+)((?:\\:\\-)([^\\}]*))?\\}"); + Matcher m = p.matcher(value); + + StringBuffer sb = new StringBuffer(); + while (m.find()) { + String envVarName = null == m.group(1) ? m.group(2) : m.group(1); + String envVarDefault = null == m.group(3) ? "" : m.group(3); + String envVarValue = System.getenv(envVarName); + + m.appendReplacement(sb, + null == envVarValue ? Matcher.quoteReplacement(envVarDefault) : Matcher.quoteReplacement(envVarValue)); + } + m.appendTail(sb); + return sb.toString(); + + } +} diff --git a/core/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/EnvPropertiesTest.java b/core/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/EnvPropertiesTest.java new file mode 100644 index 000000000..bee432577 --- /dev/null +++ b/core/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/EnvPropertiesTest.java @@ -0,0 +1,59 @@ +package org.onap.ccsdk.sli.core.utils.common; + +import static org.junit.Assert.*; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; + +public class EnvPropertiesTest { + + @Test + public void loadStreamTest() throws IOException { + InputStream testStr = getClass().getResourceAsStream("/svclogic.properties"); + + Properties props = new EnvProperties(); + props.load(testStr); + + assertEquals("jdbc", props.getProperty("org.onap.ccsdk.sli.dbtype")); + String dbUrl = "jdbc:derby:memory:"+System.getenv("MYSQL_DATABASE")+";create=true"; + assertEquals(dbUrl, props.getProperty("org.onap.ccsdk.sli.jdbc.url")); + assertEquals("org.apache.derby.jdbc.EmbeddedDriver", props.getProperty("org.onap.ccsdk.sli.jdbc.driver")); + assertEquals(System.getenv("MYSQL_DATABASE"), props.getProperty("org.onap.ccsdk.sli.jdbc.database")); + assertEquals(System.getenv("MYSQL_USER"), props.getProperty("org.onap.ccsdk.sli.jdbc.user") ); + assertEquals(System.getenv("MYSQL_PASSWORD"), props.getProperty("org.onap.ccsdk.sli.jdbc.password")); + } + + @Test + public void loadReaderTest() throws IOException { + InputStream testStr = getClass().getResourceAsStream("/svclogic.properties"); + BufferedReader testReader = new BufferedReader(new InputStreamReader(testStr)); + + Properties props = new EnvProperties(); + props.load(testReader); + + assertEquals("jdbc", props.getProperty("org.onap.ccsdk.sli.dbtype")); + String dbUrl = "jdbc:derby:memory:"+System.getenv("MYSQL_DATABASE")+";create=true"; + assertEquals(dbUrl, props.getProperty("org.onap.ccsdk.sli.jdbc.url")); + assertEquals("org.apache.derby.jdbc.EmbeddedDriver", props.getProperty("org.onap.ccsdk.sli.jdbc.driver")); + assertEquals(System.getenv("MYSQL_DATABASE"), props.getProperty("org.onap.ccsdk.sli.jdbc.database")); + assertEquals(System.getenv("MYSQL_USER"), props.getProperty("org.onap.ccsdk.sli.jdbc.user")); + assertEquals(System.getenv("MYSQL_PASSWORD"), props.getProperty("org.onap.ccsdk.sli.jdbc.password")); + } + + @Test + public void setPropertyTest() { + Properties props = new EnvProperties(); + + props.setProperty("path", "${PATH}"); + props.setProperty("dummy", "${UNSET_DUMMY:-dummyvalue}"); + assertEquals(System.getenv("PATH"), props.getProperty("path")); + assertEquals("dummyvalue", props.getProperty("dummy")); + } + +} diff --git a/core/utils/provider/src/test/resources/svclogic.properties b/core/utils/provider/src/test/resources/svclogic.properties new file mode 100644 index 000000000..0d62389f2 --- /dev/null +++ b/core/utils/provider/src/test/resources/svclogic.properties @@ -0,0 +1,27 @@ +### +# ============LICENSE_START======================================================= +# ONAP : CCSDK +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights +# reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +org.onap.ccsdk.sli.dbtype = jdbc +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:${MYSQL_DATABASE};create=true +org.onap.ccsdk.sli.jdbc.driver=${MYSQL_DRIVER:-org.apache.derby.jdbc.EmbeddedDriver} +org.onap.ccsdk.sli.jdbc.database = ${MYSQL_DATABASE} +org.onap.ccsdk.sli.jdbc.user = ${MYSQL_USER} +org.onap.ccsdk.sli.jdbc.password = ${MYSQL_PASSWORD} |