use of org.apache.knox.gateway.services.DefaultGatewayServices in project knox by apache.
the class GatewayHealthFuncTest method setupGateway.
public static void setupGateway() throws Exception {
File targetDir = new File(System.getProperty("user.dir"), "target");
File gatewayDir = new File(targetDir, "gateway-home-" + UUID.randomUUID());
gatewayDir.mkdirs();
GatewayTestConfig testConfig = new GatewayTestConfig();
config = testConfig;
testConfig.setGatewayHomeDir(gatewayDir.getAbsolutePath());
File topoDir = new File(testConfig.getGatewayTopologyDir());
topoDir.mkdirs();
File deployDir = new File(testConfig.getGatewayDeploymentDir());
deployDir.mkdirs();
File descriptor = new File(topoDir, "test-cluster.xml");
FileOutputStream stream = new FileOutputStream(descriptor);
createTopology().toStream(stream);
stream.close();
DefaultGatewayServices srvcs = new DefaultGatewayServices();
Map<String, String> options = new HashMap<String, String>();
options.put("persist-master", "false");
options.put("master", "password");
try {
srvcs.init(testConfig, options);
} catch (ServiceLifecycleException e) {
// I18N not required.
e.printStackTrace();
}
gateway = GatewayServer.startGateway(testConfig, srvcs);
MatcherAssert.assertThat("Failed to start gateway.", gateway, notNullValue());
LOG.info("Gateway port = " + gateway.getAddresses()[0].getPort());
gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
clusterUrl = gatewayUrl + "/test-cluster";
}
use of org.apache.knox.gateway.services.DefaultGatewayServices in project knox by apache.
the class GatewayLdapPosixGroupFuncTest method setupGateway.
public static void setupGateway() throws Exception {
File targetDir = new File(System.getProperty("user.dir"), "target");
File gatewayDir = new File(targetDir, "gateway-home-" + UUID.randomUUID());
gatewayDir.mkdirs();
GatewayTestConfig testConfig = new GatewayTestConfig();
config = testConfig;
testConfig.setGatewayHomeDir(gatewayDir.getAbsolutePath());
File topoDir = new File(testConfig.getGatewayTopologyDir());
topoDir.mkdirs();
File deployDir = new File(testConfig.getGatewayDeploymentDir());
deployDir.mkdirs();
DefaultGatewayServices srvcs = new DefaultGatewayServices();
Map<String, String> options = new HashMap<>();
options.put("persist-master", "true");
options.put("master", "hadoop");
try {
srvcs.init(testConfig, options);
} catch (ServiceLifecycleException e) {
// I18N not required.
e.printStackTrace();
}
gateway = GatewayServer.startGateway(testConfig, srvcs);
MatcherAssert.assertThat("Failed to start gateway.", gateway, notNullValue());
LOG.info("Gateway port = " + gateway.getAddresses()[0].getPort());
gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
clusterUrl = gatewayUrl + "/test-cluster";
serviceUrl = clusterUrl + "/test-service-path/test-service-resource";
GatewayServices services = GatewayServer.getGatewayServices();
AliasService aliasService = (AliasService) services.getService(GatewayServices.ALIAS_SERVICE);
aliasService.addAliasForCluster("test-cluster", "ldcSystemPassword", "guest-password");
char[] password1 = aliasService.getPasswordFromAliasForCluster("test-cluster", "ldcSystemPassword");
File descriptor = new File(topoDir, "test-cluster.xml");
OutputStream stream = new FileOutputStream(descriptor);
createTopology().toStream(stream);
stream.close();
}
use of org.apache.knox.gateway.services.DefaultGatewayServices in project knox by apache.
the class GatewayMultiFuncTest method startGatewayServer.
public static void startGatewayServer() throws Exception {
services = new DefaultGatewayServices();
Map<String, String> options = new HashMap<>();
options.put("persist-master", "false");
options.put("master", "password");
try {
services.init(config, options);
} catch (ServiceLifecycleException e) {
// I18N not required.
e.printStackTrace();
}
topos = services.getService(GatewayServices.TOPOLOGY_SERVICE);
gateway = GatewayServer.startGateway(config, services);
MatcherAssert.assertThat("Failed to start gateway.", gateway, notNullValue());
gatewayPort = gateway.getAddresses()[0].getPort();
gatewayUrl = "http://localhost:" + gatewayPort + "/" + config.getGatewayPath();
LOG.info("Gateway port = " + gateway.getAddresses()[0].getPort());
params = new Properties();
params.put("LDAP_URL", driver.getLdapUrl());
}
use of org.apache.knox.gateway.services.DefaultGatewayServices in project knox by apache.
the class GatewaySampleFuncTest method setupGateway.
public static void setupGateway() throws Exception {
File targetDir = new File(System.getProperty("user.dir"), "target");
File gatewayDir = new File(targetDir, "gateway-home-" + UUID.randomUUID());
gatewayDir.mkdirs();
GatewayTestConfig testConfig = new GatewayTestConfig();
config = testConfig;
testConfig.setGatewayHomeDir(gatewayDir.getAbsolutePath());
File topoDir = new File(testConfig.getGatewayTopologyDir());
topoDir.mkdirs();
File deployDir = new File(testConfig.getGatewayDeploymentDir());
deployDir.mkdirs();
File descriptor = new File(topoDir, "test-cluster.xml");
FileOutputStream stream = new FileOutputStream(descriptor);
createTopology().toStream(stream);
stream.close();
DefaultGatewayServices srvcs = new DefaultGatewayServices();
Map<String, String> options = new HashMap<>();
options.put("persist-master", "false");
options.put("master", "password");
try {
srvcs.init(testConfig, options);
} catch (ServiceLifecycleException e) {
// I18N not required.
e.printStackTrace();
}
gateway = GatewayServer.startGateway(testConfig, srvcs);
MatcherAssert.assertThat("Failed to start gateway.", gateway, notNullValue());
LOG.info("Gateway port = " + gateway.getAddresses()[0].getPort());
gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
clusterUrl = gatewayUrl + "/test-cluster";
}
use of org.apache.knox.gateway.services.DefaultGatewayServices in project knox by apache.
the class GatewaySslFuncTest method startGatewayServer.
public static void startGatewayServer() throws Exception {
instantiateGatewayServices();
services = new DefaultGatewayServices();
Map<String, String> options = new HashMap<>();
options.put("persist-master", "false");
options.put("master", "password");
try {
services.init(config, options);
} catch (ServiceLifecycleException e) {
// I18N not required.
e.printStackTrace();
}
topos = services.getService(GatewayServices.TOPOLOGY_SERVICE);
gateway = GatewayServer.startGateway(config, services);
MatcherAssert.assertThat("Failed to start gateway.", gateway, notNullValue());
gatewayScheme = config.isSSLEnabled() ? "https" : "http";
gatewayPort = gateway.getAddresses()[0].getPort();
gatewayUrl = gatewayScheme + "://localhost:" + gatewayPort + "/" + config.getGatewayPath();
LOG.info("Gateway port = " + gateway.getAddresses()[0].getPort());
params = new Properties();
params.put("LDAP_URL", driver.getLdapUrl());
params.put("WEBHDFS_URL", "http://localhost:" + mockWebHdfs.getPort());
}
Aggregations