Skip to content

Commit

Permalink
Merge pull request #8 from eBay/byarger/logger
Browse files Browse the repository at this point in the history
Fix for ISSUE 7 - Custom logger runtime argument needs default package value
  • Loading branch information
yarg0007 authored Dec 6, 2022
2 parents 9761d7c + ba07cb5 commit 8a8306e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 14 deletions.
11 changes: 0 additions & 11 deletions NST/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@ NST is deployed to [Maven Central](https://search.maven.org/search?q=a:nstest).
## Running Locally
NST is setup to sign the jar for deployment. Include `-Dgpg.skip=true` in your mvn command to avoid the password prompt.

## Release Notes:

<details>
<summary>Click to expand!</summary>

| Version | Notes |
|---|---|
| 5.0.0 | Open source release. |

</details>

## Tutorials - Videos

This video sequence walks you through the NST, what it is, how to begin using it and examples. If you are new to NST please start at the beginning with the first video (NST Overview) and continue in sequence. You can always come back and reference videos out-of-sequence to refresh yourself on specific details of NST.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
public class CustomLoggersLocationArgument implements RuntimeConfigValue<String> {

public static final String KEY = "customLoggersPackage";

private static final String DEFAULT_LOGGER_PACKAGE = "com.ebay.custom.loggers";
private String packageWithCustomLoggers;

@Override
Expand All @@ -14,7 +16,7 @@ public String getRuntimeArgumentKey() {

@Override
public String getRuntimeArgumentValue() {
return packageWithCustomLoggers;
return (packageWithCustomLoggers == null) ? DEFAULT_LOGGER_PACKAGE : packageWithCustomLoggers;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public void customLoggersPackageDefaultValue() {

RuntimeConfigManager.getInstance().reinitialize();
String actualPackageValue = RuntimeConfigManager.getInstance().getCustomLoggerFormatPackage();
assertThat(actualPackageValue, is(nullValue()));
assertThat(actualPackageValue, is(equalTo("com.ebay.custom.loggers")));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.ebay.runtime.arguments;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class CustomLoggersLocationArgumentTest {

private CustomLoggersLocationArgument logger;

@BeforeMethod(alwaysRun = true)
public void reset() {
logger = new CustomLoggersLocationArgument();
}

@Test
public void getKey() {
String key = logger.getRuntimeArgumentKey();
assertThat(key, is(equalTo(CustomLoggersLocationArgument.KEY)));
}

@Test
public void defaultPackageReturned() {
String value = logger.getRuntimeArgumentValue();
assertThat(value, is(equalTo("com.ebay.custom.loggers")));
}

@Test
public void customPackageReturned() {
String input = "com.ebay.test";
logger.parseRuntimeArgument(input);
String value = logger.getRuntimeArgumentValue();
assertThat(value, is(equalTo(input)));
}

@Test
public void overridePackage() {
String input = "com.ebay.test";
String override = "com.ebay.override";
logger.parseRuntimeArgument(input);
logger.override(override);
String value = logger.getRuntimeArgumentValue();
assertThat(value, is(equalTo(override)));
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<maven.compiler.plugin.version>3.6.0</maven.compiler.plugin.version>
<maven.surefire.plugin.version>2.9</maven.surefire.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nstest.version>1.0.1</nstest.version>
<nstest.version>1.0.2</nstest.version>
<testng.version>7.5</testng.version>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
Expand Down

0 comments on commit 8a8306e

Please sign in to comment.