use of org.apache.commons.configuration.AbstractConfiguration in project java-chassis by ServiceComb.
the class TestConfigUtil method testConvertEnvVariable.
@Test
public void testConvertEnvVariable() {
String someProperty = "cse_service_registry_address";
AbstractConfiguration config = new DynamicConfiguration();
config.addProperty(someProperty, "testing");
AbstractConfiguration result = ConfigUtil.convertEnvVariable(config);
assertThat(result.getString("cse.service.registry.address"), equalTo("testing"));
assertThat(result.getString("cse_service_registry_address"), equalTo("testing"));
}
use of org.apache.commons.configuration.AbstractConfiguration in project java-chassis by ServiceComb.
the class TestConfigUtil method testAddConfig.
@Test
public void testAddConfig() {
Map<String, Object> config = new HashMap<>();
config.put("service_description.name", "service_name_test");
ConfigUtil.setConfigs(config);
ConfigUtil.addConfig("service_description.version", "1.0.2");
ConfigUtil.addConfig("cse.test.enabled", true);
ConfigUtil.addConfig("cse.test.num", 10);
AbstractConfiguration configuration = ConfigUtil.createLocalConfig();
Assert.assertEquals(configuration.getString("service_description.name"), "service_name_test");
Assert.assertTrue(configuration.getBoolean("cse.test.enabled"));
Assert.assertEquals(configuration.getInt("cse.test.num"), 10);
}
use of org.apache.commons.configuration.AbstractConfiguration in project java-chassis by ServiceComb.
the class TestConfigUtil method duplicateServiceCombConfigToCseListValue.
@Test
public void duplicateServiceCombConfigToCseListValue() {
List<String> list = Arrays.asList("a", "b");
AbstractConfiguration config = new DynamicConfiguration();
config.addProperty("cse.list", list);
Deencapsulation.invoke(ConfigUtil.class, "duplicateCseConfigToServicecomb", config);
Object result = config.getProperty("servicecomb.list");
assertThat(result, instanceOf(List.class));
assertThat(result, equalTo(list));
}
use of org.apache.commons.configuration.AbstractConfiguration in project zuul by Netflix.
the class ServerTest method beforeTest.
@Before
public void beforeTest() {
final AbstractConfiguration config = ConfigurationManager.getConfigInstance();
config.setProperty("zuul.server.netty.socket.force_nio", "true");
config.setProperty("zuul.server.netty.socket.force_io_uring", "false");
}
use of org.apache.commons.configuration.AbstractConfiguration in project zuul by Netflix.
the class ZuulFiltersModule method findClassNames.
// Get compiled filter classes to be found on classpath.
@VisibleForTesting
String[] findClassNames(AbstractConfiguration config) {
// Find individually-specified filter classes.
String[] filterClassNamesStrArray = config.getStringArray("zuul.filters.classes");
Stream<String> classNameStream = Arrays.stream(filterClassNamesStrArray).map(String::trim).filter(blank.negate());
// Find filter classes in specified packages.
String[] packageNamesStrArray = config.getStringArray("zuul.filters.packages");
ClassPath cp;
try {
cp = ClassPath.from(this.getClass().getClassLoader());
} catch (IOException e) {
throw new RuntimeException("Error attempting to read classpath to find filters!", e);
}
Stream<String> packageStream = Arrays.stream(packageNamesStrArray).map(String::trim).filter(blank.negate()).flatMap(packageName -> cp.getTopLevelClasses(packageName).stream()).map(ClassPath.ClassInfo::load).filter(ZuulFilter.class::isAssignableFrom).map(Class::getCanonicalName);
String[] filterClassNames = Stream.concat(classNameStream, packageStream).toArray(String[]::new);
if (filterClassNames.length != 0) {
LOG.info("Using filter classnames: ");
for (String location : filterClassNames) {
LOG.info(" " + location);
}
}
return filterClassNames;
}
Aggregations