Search in sources :

Example 11 with GatewayTestConfig

use of org.apache.knox.gateway.GatewayTestConfig in project knox by apache.

the class DeploymentFactoryFuncTest method testInvalidGenericProviderDeploymentContributor.

@Test(timeout = LONG_TIMEOUT)
public void testInvalidGenericProviderDeploymentContributor() throws ParserConfigurationException, SAXException, IOException, TransformerException {
    LOG_ENTER();
    GatewayConfig config = new GatewayTestConfig();
    File targetDir = new File(System.getProperty("user.dir"), "target");
    File gatewayDir = new File(targetDir, "gateway-home-" + UUID.randomUUID());
    gatewayDir.mkdirs();
    ((GatewayTestConfig) config).setGatewayHomeDir(gatewayDir.getAbsolutePath());
    File deployDir = new File(config.getGatewayDeploymentDir());
    deployDir.mkdirs();
    DefaultGatewayServices srvcs = new DefaultGatewayServices();
    Map<String, String> options = new HashMap<>();
    options.put("persist-master", "false");
    options.put("master", "password");
    try {
        DeploymentFactory.setGatewayServices(srvcs);
        srvcs.init(config, options);
    } catch (ServiceLifecycleException e) {
        // I18N not required.
        e.printStackTrace();
    }
    Topology topology = new Topology();
    topology.setName("test-cluster");
    Service service = new Service();
    service.setRole("WEBHDFS");
    service.addUrl("http://localhost:50070/test-service-url");
    topology.addService(service);
    Provider provider = new Provider();
    provider.setRole("authentication");
    provider.setName("generic");
    provider.setEnabled(true);
    // = new ProviderParam();
    Param param;
    // Missing filter param.
    // param.setName( "filter" );
    // param.setValue( "org.opensource.ExistingFilter" );
    // provider.addParam( param );
    param = new Param();
    param.setName("test-param-name");
    param.setValue("test-param-value");
    provider.addParam(param);
    topology.addProvider(provider);
    Enumeration<Appender> appenders = NoOpAppender.setUp();
    try {
        DeploymentFactory.createDeployment(config, topology);
        fail("Should have throws IllegalArgumentException");
    } catch (DeploymentException e) {
    // Expected.
    } finally {
        NoOpAppender.tearDown(appenders);
    }
    LOG_EXIT();
}
Also used : NoOpAppender(org.apache.knox.test.log.NoOpAppender) Appender(org.apache.log4j.Appender) HashMap(java.util.HashMap) ServiceLifecycleException(org.apache.knox.gateway.services.ServiceLifecycleException) Service(org.apache.knox.gateway.topology.Service) Topology(org.apache.knox.gateway.topology.Topology) GatewayTestConfig(org.apache.knox.gateway.GatewayTestConfig) Provider(org.apache.knox.gateway.topology.Provider) Param(org.apache.knox.gateway.topology.Param) DefaultGatewayServices(org.apache.knox.gateway.services.DefaultGatewayServices) File(java.io.File) GatewayConfig(org.apache.knox.gateway.config.GatewayConfig) Test(org.junit.Test)

Aggregations

GatewayTestConfig (org.apache.knox.gateway.GatewayTestConfig)11 File (java.io.File)8 HashMap (java.util.HashMap)8 GatewayConfig (org.apache.knox.gateway.config.GatewayConfig)8 DefaultGatewayServices (org.apache.knox.gateway.services.DefaultGatewayServices)8 ServiceLifecycleException (org.apache.knox.gateway.services.ServiceLifecycleException)8 Topology (org.apache.knox.gateway.topology.Topology)8 Test (org.junit.Test)8 Service (org.apache.knox.gateway.topology.Service)7 Param (org.apache.knox.gateway.topology.Param)6 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)6 Document (org.w3c.dom.Document)6 Provider (org.apache.knox.gateway.topology.Provider)5 BeforeClass (org.junit.BeforeClass)3 URL (java.net.URL)2 Application (org.apache.knox.gateway.topology.Application)2 XForwardedHeaderFilter (org.apache.knox.gateway.filter.XForwardedHeaderFilter)1 UrlRewriteServletFilter (org.apache.knox.gateway.filter.rewrite.api.UrlRewriteServletFilter)1 NoOpAppender (org.apache.knox.test.log.NoOpAppender)1 Appender (org.apache.log4j.Appender)1