Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
tests for the env var lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
pb82 committed May 2, 2018
1 parent 7b5f5fa commit 5e15a63
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
17 changes: 17 additions & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<artifactId>unifiedpush-common</artifactId>
<name>UnifiedPush Common classes and utils</name>


<dependencies>

<dependency>
Expand All @@ -48,6 +49,21 @@
<activeByDefault>true</activeByDefault>
</activation>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<environmentVariables>
<TEST_ENV_VAR>Ok</TEST_ENV_VAR>
</environmentVariables>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>junit</groupId>
Expand All @@ -74,6 +90,7 @@


</dependencies>

</profile>
</profiles>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static Integer tryGetIntegerProperty(String key, Integer defaultValue) {
* @param key String System Property Key
* @return String Key as environment variable
*/
private static String formatEnvironmentVariable(String key) {
public static String formatEnvironmentVariable(String key) {
return key.toUpperCase().replaceAll("\\.", "_");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,15 @@ public void testNonExistingTryGetIntegerPropertyWithDefaultValue() {
assertThat(ConfigurationUtils.tryGetGlobalIntegerProperty(TEST_PROPERTY_NAME, 123)).isEqualTo(123);
}

@Test
public void testEnvVarFormat() {
assertThat(ConfigurationUtils.formatEnvironmentVariable("custom.aerogear.apns.push.host"))
.isEqualTo("CUSTOM_AEROGEAR_APNS_PUSH_HOST");
}

@Test
public void testEnvVarLookup() {
assertThat(ConfigurationUtils.tryGetGlobalProperty("test.env.var"))
.isEqualTo("Ok");
}
}

0 comments on commit 5e15a63

Please sign in to comment.