public static void setupGateway() throws Exception {

    File targetDir = new File(System.getProperty("user.dir"), "target");
    File gatewayDir = new File(targetDir, "gateway-home-" + uuid);
    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();

    createTopology(topoDir, "test-cluster.xml", true);
    createTopology(topoDir, "bad-cluster.xml", false);

    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) {
      e.printStackTrace(); // I18N not required.
    }
  }
Пример #2
0
  /** Creates a GATEWAY_HOME, starts a gateway instance and deploys a test topology. */
  public void setupGateway(GatewayTestConfig config, String cluster, XMLTag topology, boolean use)
      throws Exception {
    this.useGateway = use;
    this.config = config;

    File targetDir = new File(System.getProperty("user.dir"), "target");
    File gatewayDir = new File(targetDir, "gateway-home-" + UUID.randomUUID());
    gatewayDir.mkdirs();

    config.setGatewayHomeDir(gatewayDir.getAbsolutePath());

    File topoDir = new File(config.getGatewayTopologyDir());
    topoDir.mkdirs();

    File deployDir = new File(config.getGatewayDeploymentDir());
    deployDir.mkdirs();

    File descriptor = new File(topoDir, cluster + ".xml");
    FileOutputStream stream = new FileOutputStream(descriptor);
    topology.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(config, options);
    } catch (ServiceLifecycleException e) {
      e.printStackTrace(); // I18N not required.
    }
    File stacksDir = new File(config.getGatewayServicesDir());
    stacksDir.mkdirs();
    // TODO: [sumit] This is a hack for now, need to find a better way to locate the source
    // resources for 'stacks' to be tested
    String pathToStacksSource = "gateway-service-definitions/src/main/resources/services";
    File stacksSourceDir = new File(targetDir.getParent(), pathToStacksSource);
    if (!stacksSourceDir.exists()) {
      stacksSourceDir = new File(targetDir.getParentFile().getParent(), pathToStacksSource);
    }
    if (stacksSourceDir.exists()) {
      FileUtils.copyDirectoryToDirectory(stacksSourceDir, stacksDir);
    }

    gateway = GatewayServer.startGateway(config, srvcs);
    MatcherAssert.assertThat("Failed to start gateway.", gateway, notNullValue());

    log.info("Gateway port = " + gateway.getAddresses()[0].getPort());
  }
Пример #3
0
  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) {
      e.printStackTrace(); // I18N not required.
    }

    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";
  }