use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.
the class GatewayGlobalConfigTest method testDefaultAppRedirectPath.
@Test(timeout = TestUtils.SHORT_TIMEOUT)
public void testDefaultAppRedirectPath() {
GatewayConfig config = new GatewayConfigImpl();
assertThat(config.getDefaultAppRedirectPath(), nullValue());
((GatewayConfigImpl) config).set("default.app.topology.name", "test-topo-name");
assertThat(config.getDefaultAppRedirectPath(), is("/gateway/test-topo-name"));
}
use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.
the class DefaultMetricsServiceTest method instrumentationProvidersLoading.
@Test
public void instrumentationProvidersLoading() throws Exception {
DefaultMetricsService service = new DefaultMetricsService();
GatewayConfigImpl config = new GatewayConfigImpl();
config.set(GatewayConfigImpl.METRICS_ENABLED, "true");
service.init(config, null);
Map<Class<?>, InstrumentationProvider> map = service.getInstrumentationProviders();
Assert.assertTrue(map.entrySet().size() >= 2);
Assert.assertNotNull(service.getInstrumented(HttpClientBuilder.class));
}
use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.
the class DefaultMetricsServiceTest method reportersLoading.
@Test
public void reportersLoading() throws Exception {
DefaultMetricsService service = new DefaultMetricsService();
GatewayConfigImpl config = new GatewayConfigImpl();
config.set(GatewayConfigImpl.METRICS_ENABLED, "true");
config.set(GatewayConfigImpl.JMX_METRICS_REPORTING_ENABLED, "false");
service.init(config, null);
List<MetricsReporter> reporters = service.getMetricsReporters();
Assert.assertTrue(reporters.size() >= 2);
for (MetricsReporter reporter : reporters) {
Assert.assertFalse(reporter.isEnabled());
}
config.set(GatewayConfigImpl.JMX_METRICS_REPORTING_ENABLED, "true");
config.set(GatewayConfigImpl.GRAPHITE_METRICS_REPORTING_ENABLED, "true");
service.init(config, null);
reporters = service.getMetricsReporters();
for (MetricsReporter reporter : reporters) {
Assert.assertTrue(reporter.isEnabled());
}
service.start();
service.stop();
}
use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.
the class DefaultMetricsServiceTest method instrumentationProvidersLoadingDefaultIsEmpty.
@Test
public void instrumentationProvidersLoadingDefaultIsEmpty() throws Exception {
DefaultMetricsService service = new DefaultMetricsService();
service.init(new GatewayConfigImpl(), null);
Map<Class<?>, InstrumentationProvider> map = service.getInstrumentationProviders();
Assert.assertTrue(map.entrySet().isEmpty());
Assert.assertNull(service.getInstrumented(HttpClientBuilder.class));
}
use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.
the class KnoxCLITest method testRemoteConfigurationRegistryUploadProviderConfigWithDestinationOverride.
@Test
public void testRemoteConfigurationRegistryUploadProviderConfigWithDestinationOverride() throws Exception {
outContent.reset();
final String providerConfigName = "my-provider-config.xml";
final String entryName = "my-providers.xml";
final String providerConfigContent = "<gateway/>\n";
final File testRoot = TestUtils.createTempDir(this.getClass().getName());
try {
final File testRegistry = new File(testRoot, "registryRoot");
final File testProviderConfig = new File(testRoot, providerConfigName);
final String[] args = { "upload-provider-config", testProviderConfig.getAbsolutePath(), "--entry-name", entryName, "--registry-client", "test_client", "--master", "master" };
FileUtils.writeStringToFile(testProviderConfig, providerConfigContent);
KnoxCLI cli = new KnoxCLI();
Configuration config = new GatewayConfigImpl();
// Configure a client for the test local filesystem registry implementation
config.set("gateway.remote.config.registry.test_client", "type=LocalFileSystem;address=" + testRegistry);
cli.setConf(config);
// Run the test command
int rc = cli.run(args);
// Validate the result
assertEquals(0, rc);
assertFalse((new File(testRegistry, "knox/config/shared-providers/" + providerConfigName)).exists());
File registryFile = new File(testRegistry, "knox/config/shared-providers/" + entryName);
assertTrue(registryFile.exists());
assertEquals(FileUtils.readFileToString(registryFile), providerConfigContent);
} finally {
FileUtils.forceDelete(testRoot);
}
}
Aggregations