use of com.newrelic.weave.weavepackage.WeavePackageConfig in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method weavePackageConfigNameSystemPropertyOverride.
@Test
public void weavePackageConfigNameSystemPropertyOverride() {
final String moduleName = "com.newrelic.instrumentation.mymodule-1.0";
HashMap<String, Object> props = new HashMap<>();
ClassTransformerConfig config = new ClassTransformerConfigImpl(props, true);
System.setProperty("newrelic.config.class_transformer." + moduleName + ".enabled", "false");
WeavePackageConfig weaveConfig = WeavePackageConfig.builder().name(moduleName).enabled(true).build();
Assert.assertFalse(config.isWeavePackageEnabled(weaveConfig));
System.clearProperty("newrelic.config.class_transformer." + moduleName + ".enabled");
}
use of com.newrelic.weave.weavepackage.WeavePackageConfig in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method weavePackageConfigAliasOverride.
@Test
public void weavePackageConfigAliasOverride() {
final String moduleName = "com.newrelic.instrumentation.mymodule-1.0";
final String aliasName = "my_alias";
HashMap<String, Object> props = new HashMap<>();
props.put(aliasName, ImmutableMap.of("enabled", false));
ClassTransformerConfig config = new ClassTransformerConfigImpl(props, true);
WeavePackageConfig weaveConfig = WeavePackageConfig.builder().name(moduleName).alias(aliasName).enabled(true).build();
Assert.assertFalse(config.isWeavePackageEnabled(weaveConfig));
}
use of com.newrelic.weave.weavepackage.WeavePackageConfig in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method weavePackageConfigNameAndAliasSystemPropertyOverride.
@Test
public void weavePackageConfigNameAndAliasSystemPropertyOverride() {
// if both alias and name are present, both must be set to enabled for the module to be loaded
final String moduleName = "com.newrelic.instrumentation.mymodule-1.0";
final String aliasName = "my_alias";
HashMap<String, Object> props = new HashMap<>();
ClassTransformerConfig config = new ClassTransformerConfigImpl(props, true);
System.setProperty("newrelic.config.class_transformer." + moduleName + ".enabled", "true");
System.setProperty("newrelic.config.class_transformer." + aliasName + ".enabled", "false");
WeavePackageConfig weaveConfig = WeavePackageConfig.builder().name(moduleName).alias(aliasName).enabled(true).build();
Assert.assertFalse(config.isWeavePackageEnabled(weaveConfig));
System.clearProperty("newrelic.config.class_transformer." + moduleName + ".enabled");
System.clearProperty("newrelic.config.class_transformer." + aliasName + ".enabled");
}
use of com.newrelic.weave.weavepackage.WeavePackageConfig in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method weavePackageConfigNameOverride.
@Test
public void weavePackageConfigNameOverride() {
final String moduleName = "com.newrelic.instrumentation.mymodule-1.0";
HashMap<String, Object> props = new HashMap<>();
props.put(moduleName, ImmutableMap.of("enabled", false));
ClassTransformerConfig config = new ClassTransformerConfigImpl(props, true);
WeavePackageConfig weaveConfig = WeavePackageConfig.builder().name(moduleName).enabled(true).build();
Assert.assertFalse(config.isWeavePackageEnabled(weaveConfig));
}
use of com.newrelic.weave.weavepackage.WeavePackageConfig in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method weavePackageConfigNameAndAliasOverride.
@Test
public void weavePackageConfigNameAndAliasOverride() {
// if both alias and name are present, both must be set to enabled for the module to be loaded
final String moduleName = "com.newrelic.instrumentation.mymodule-1.0";
final String aliasName = "my_alias";
Map<String, Object> configuration = new HashMap<>();
configuration.put(moduleName + ":enabled", true);
configuration.put(aliasName + ":enabled", false);
configuration = buildConfigMap(configuration);
ClassTransformerConfig ctConfig = new ClassTransformerConfigImpl(configuration, true);
WeavePackageConfig weaveConfig = WeavePackageConfig.builder().name(moduleName).alias(aliasName).enabled(true).build();
Assert.assertFalse(ctConfig.isWeavePackageEnabled(weaveConfig));
}
Aggregations