Search in sources :

Example 21 with GatewayConfigImpl

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"));
}
Also used : GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl) GatewayConfig(org.apache.knox.gateway.config.GatewayConfig) Test(org.junit.Test)

Example 22 with GatewayConfigImpl

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));
}
Also used : InstrumentationProvider(org.apache.knox.gateway.services.metrics.InstrumentationProvider) HttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder) GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl) Test(org.junit.Test)

Example 23 with GatewayConfigImpl

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();
}
Also used : MetricsReporter(org.apache.knox.gateway.services.metrics.MetricsReporter) GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl) Test(org.junit.Test)

Example 24 with GatewayConfigImpl

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));
}
Also used : InstrumentationProvider(org.apache.knox.gateway.services.metrics.InstrumentationProvider) HttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder) GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl) Test(org.junit.Test)

Example 25 with GatewayConfigImpl

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);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl) Test(org.junit.Test)

Aggregations

GatewayConfigImpl (org.apache.knox.gateway.config.impl.GatewayConfigImpl)45 Test (org.junit.Test)42 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)20 GatewayConfig (org.apache.knox.gateway.config.GatewayConfig)19 File (java.io.File)13 Configuration (org.apache.hadoop.conf.Configuration)10 MasterService (org.apache.knox.gateway.services.security.MasterService)3 HttpClientBuilder (org.apache.http.impl.client.HttpClientBuilder)2 InstrumentationProvider (org.apache.knox.gateway.services.metrics.InstrumentationProvider)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 UnknownHostException (java.net.UnknownHostException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1