Search in sources :

Example 81 with GatewayConfig

use of org.apache.knox.gateway.config.GatewayConfig in project knox by apache.

the class GatewayGlobalConfigTest method testForDefaultDataDir.

@Test
public void testForDefaultDataDir() {
    String homeDirName = getHomeDirName("conf-site/conf/gateway-site.xml");
    System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, homeDirName);
    System.clearProperty(GatewayConfigImpl.GATEWAY_DATA_HOME_VAR);
    GatewayConfig config = new GatewayConfigImpl();
    assertTrue((homeDirName + File.separator + "data").equalsIgnoreCase(config.getGatewayDataDir()));
}
Also used : GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl) GatewayConfig(org.apache.knox.gateway.config.GatewayConfig) Test(org.junit.Test)

Example 82 with GatewayConfig

use of org.apache.knox.gateway.config.GatewayConfig in project knox by apache.

the class GatewayGlobalConfigTest method testDefaultTopologyName.

@Test(timeout = TestUtils.SHORT_TIMEOUT)
public void testDefaultTopologyName() {
    GatewayConfig config = new GatewayConfigImpl();
    assertThat(config.getDefaultTopologyName(), is(nullValue()));
    ((GatewayConfigImpl) config).set("default.app.topology.name", "test-topo-name");
    assertThat(config.getDefaultTopologyName(), is("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 83 with GatewayConfig

use of org.apache.knox.gateway.config.GatewayConfig in project knox by apache.

the class GatewayGlobalConfigTest method testDefaultCompressGzipMimeTypes.

/**
 * Test for the default Mime Types for Gzip compression.
 *
 * @since 0.12
 */
@Test
public void testDefaultCompressGzipMimeTypes() {
    final List<String> expected = Arrays.asList("text/javascript", "text/html", "text/plain", "text/xml", "text/css", "application/javascript", "application/x-javascript");
    String homeDirName = getHomeDirName("conf-site/conf/gateway-site.xml");
    System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, homeDirName);
    System.setProperty(GatewayConfigImpl.GATEWAY_DATA_HOME_VAR, homeDirName);
    GatewayConfig config = new GatewayConfigImpl();
    assertTrue("Default MIME Types for Gzip compression failed to match", config.getMimeTypesToCompress().containsAll(expected));
}
Also used : GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl) GatewayConfig(org.apache.knox.gateway.config.GatewayConfig) Test(org.junit.Test)

Example 84 with GatewayConfig

use of org.apache.knox.gateway.config.GatewayConfig in project knox by apache.

the class GatewayGlobalConfigTest method testDemoConfig.

@Test
public void testDemoConfig() {
    System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, getHomeDirName("conf-demo/conf/gateway-default.xml"));
    GatewayConfig config = new GatewayConfigImpl();
    assertThat(config.getGatewayPort(), is(8888));
    assertTrue(config.getExcludedSSLProtocols().get(0).equals("SSLv3"));
// assertThat( config.getShiroConfigFile(), is( "full-shiro.ini") );
}
Also used : GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl) GatewayConfig(org.apache.knox.gateway.config.GatewayConfig) Test(org.junit.Test)

Example 85 with GatewayConfig

use of org.apache.knox.gateway.config.GatewayConfig in project knox by apache.

the class DeploymentFactoryTest method testEmptyTopology.

@Test(timeout = TestUtils.MEDIUM_TIMEOUT)
public void testEmptyTopology() throws IOException, SAXException, ParserConfigurationException, TransformerException {
    GatewayConfig config = new GatewayConfigImpl();
    Topology topology = new Topology();
    topology.setName("test-topology");
    EnterpriseArchive archive = DeploymentFactory.createDeployment(config, topology);
    Document xml = XmlUtils.readXml(archive.get("/META-INF/topology.xml").getAsset().openStream());
    assertThat(xml, hasXPath("/topology/gateway"));
    assertThat(xml, hasXPath("/topology/name", equalTo("test-topology")));
}
Also used : EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) Topology(org.apache.knox.gateway.topology.Topology) Document(org.w3c.dom.Document) GatewayConfigImpl(org.apache.knox.gateway.config.impl.GatewayConfigImpl) GatewayConfig(org.apache.knox.gateway.config.GatewayConfig) Test(org.junit.Test)

Aggregations

GatewayConfig (org.apache.knox.gateway.config.GatewayConfig)90 Test (org.junit.Test)67 File (java.io.File)31 HashMap (java.util.HashMap)24 GatewayConfigImpl (org.apache.knox.gateway.config.impl.GatewayConfigImpl)19 Topology (org.apache.knox.gateway.topology.Topology)17 ServiceLifecycleException (org.apache.knox.gateway.services.ServiceLifecycleException)13 HttpServletRequest (javax.servlet.http.HttpServletRequest)12 AliasService (org.apache.knox.gateway.services.security.AliasService)12 DefaultGatewayServices (org.apache.knox.gateway.services.DefaultGatewayServices)11 IOException (java.io.IOException)9 Service (org.apache.knox.gateway.topology.Service)9 Document (org.w3c.dom.Document)9 ArrayList (java.util.ArrayList)8 GatewayTestConfig (org.apache.knox.gateway.GatewayTestConfig)8 MasterService (org.apache.knox.gateway.services.security.MasterService)8 TopologyService (org.apache.knox.gateway.services.topology.TopologyService)8 KeystoreService (org.apache.knox.gateway.services.security.KeystoreService)7 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)7 List (java.util.List)6