use canonical canonical NB naming

This commit is contained in:
Jonathan Shook
2021-02-04 17:47:18 -06:00
parent 9526208af8
commit 808a69ace7
6 changed files with 21 additions and 26 deletions

View File

@@ -2,7 +2,6 @@ package io.nosqlbench.nb.api;
import io.nosqlbench.nb.api.errors.BasicError;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import java.util.*;
import java.util.regex.Matcher;
@@ -35,14 +34,14 @@ import java.util.regex.Pattern;
* The first location to return a non-null value is used. Null values are considered
* invalid in this API, except when provided as a default value.
*/
public class Environment {
public class NBEnvironment {
private Logger logger;
// package private for testing
Environment() {
NBEnvironment() {
}
public final static Environment INSTANCE = new Environment();
public final static NBEnvironment INSTANCE = new NBEnvironment();
private final LinkedHashMap<String, String> references = new LinkedHashMap<>();
@@ -54,7 +53,7 @@ public class Environment {
"LOGNAME", "user.name" // *n*x
);
public Environment resetRefs() {
public NBEnvironment resetRefs() {
this.references.clear();
return this;
}
@@ -124,11 +123,7 @@ public class Environment {
}
value = System.getenv(name);
if (value != null) {
return value;
}
return null;
return value;
}
/**

View File

@@ -1,6 +1,6 @@
package io.nosqlbench.nb.api.config;
import io.nosqlbench.nb.api.Environment;
import io.nosqlbench.nb.api.NBEnvironment;
import java.util.LinkedHashMap;
import java.util.Optional;
@@ -16,7 +16,7 @@ public class ConfigReader extends LinkedHashMap<String, Object> {
public <T> T paramEnv(String name, Class<? extends T> vclass) {
T param = param(name, vclass);
if (param instanceof String) {
Optional<String> interpolated = Environment.INSTANCE.interpolate(param.toString());
Optional<String> interpolated = NBEnvironment.INSTANCE.interpolate(param.toString());
if (interpolated.isEmpty()) {
throw new RuntimeException("Unable to interpolate env and sys props in '" + param + "'");
}

View File

@@ -4,15 +4,15 @@ import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class EnvironmentTest {
public class NBEnvironmentTest {
@Test
public void testInterpolation() {
Environment env = new Environment();
NBEnvironment env = new NBEnvironment();
String home1 = env.interpolate("home is '$HOME'").orElse(null);
assertThat(home1).matches(".+");
String home2 = env.interpolate("home is '${home}'").orElse(null);
assertThat(home1).matches(".+");
}
}
}