diff --git a/events_test/src/main/java/com/adobe/aio/event/management/RegistrationServiceTester.java b/events_test/src/main/java/com/adobe/aio/event/management/RegistrationServiceTester.java index a492ce65..4216a700 100644 --- a/events_test/src/main/java/com/adobe/aio/event/management/RegistrationServiceTester.java +++ b/events_test/src/main/java/com/adobe/aio/event/management/RegistrationServiceTester.java @@ -15,7 +15,6 @@ import com.adobe.aio.event.management.model.EventsOfInterestInputModel; import com.adobe.aio.event.management.model.Registration; import com.adobe.aio.event.management.model.RegistrationCreateModel; -import com.adobe.aio.event.management.model.RegistrationUpdateModel; import com.adobe.aio.util.WorkspaceUtil; import com.adobe.aio.workspace.Workspace; import java.net.MalformedURLException; diff --git a/events_test/src/test/java/com/adobe/aio/event/management/ProviderServiceIntegrationTest.java b/events_test/src/test/java/com/adobe/aio/event/management/ProviderServiceIntegrationTest.java index 3aa81039..917da2e8 100644 --- a/events_test/src/test/java/com/adobe/aio/event/management/ProviderServiceIntegrationTest.java +++ b/events_test/src/test/java/com/adobe/aio/event/management/ProviderServiceIntegrationTest.java @@ -11,12 +11,10 @@ */ package com.adobe.aio.event.management; -import com.adobe.aio.event.management.model.ProviderInputModel; import java.util.Collections; import java.util.List; import java.util.Optional; -import com.adobe.aio.event.management.feign.ConflictException; import com.adobe.aio.event.management.model.EventMetadata; import com.adobe.aio.event.management.model.Provider; import com.adobe.aio.util.WorkspaceUtil; diff --git a/ims/src/main/java/com/adobe/aio/util/WorkspaceUtil.java b/ims/src/main/java/com/adobe/aio/util/WorkspaceUtil.java index 99438a31..7c6967fc 100644 --- a/ims/src/main/java/com/adobe/aio/util/WorkspaceUtil.java +++ b/ims/src/main/java/com/adobe/aio/util/WorkspaceUtil.java @@ -88,15 +88,30 @@ public static String getSystemProperty(String key) { return getSystemProperty(key,DEFAULT_TEST_PROPERTIES); } + /** + * Loads a property from either one and only one of the following sources, probing them first to + * check that all the required properties are given, in order: + *
    + *
  1. System Properties
  2. + *
  3. Environment Variables
  4. + *
  5. classpath:{@code propertyClassPath}
  6. + *
+ * + * @param key the property name + * @param propertyClassPath the classpath of the property file + * @return the value of the property + */ public static String getSystemProperty(String key, String propertyClassPath) { - String value = System.getProperty(key); - if (StringUtils.isBlank(value)) { - logger.debug("loading property `{}` from classpath `{}`", key, propertyClassPath); - value = FileUtil.readPropertiesFromClassPath(propertyClassPath).getProperty(key); - } else { + if (StringUtils.isNotBlank(System.getProperty(key))) { logger.debug("loading property `{}`from JVM System Properties", key); + return System.getProperty(key); + } if (StringUtils.isNotBlank(System.getenv(key))) { + logger.debug("loading property `{}` from Environment Variables", key); + return System.getenv(key); + } else { + logger.debug("loading property `{}` from classpath `{}`", key, propertyClassPath); + return FileUtil.readPropertiesFromClassPath(propertyClassPath).getProperty(key); } - return value; } private static Workspace.Builder getWorkspaceBuilder(String propertyFileClassPath) {