Ejemplo n.º 1
0
  @BeforeClass
  public static void createProcessController() throws IOException, URISyntaxException {
    if (File.pathSeparatorChar == ':') {
      processUtil = new UnixProcessUtil();
    } else {
      processUtil = new WindowsProcessUtil();
    }

    String jbossHome = System.getProperty("jboss.home");
    if (jbossHome == null) {
      throw new IllegalStateException("-Djboss.home must be set");
    }

    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    URL url = tccl.getResource("domain-configs/domain-standard.xml");
    Assert.assertNotNull(url);
    File domainXml = new File(url.toURI());
    url = tccl.getResource("host-configs/respawn-master.xml");
    File hostXml = new File(url.toURI());

    Assert.assertTrue(domainXml.exists());
    Assert.assertTrue(hostXml.exists());

    List<String> args = new ArrayList<String>();
    args.add("-jboss-home");
    args.add(jbossHome);
    args.add("-jvm");
    args.add(processUtil.getJavaCommand());
    args.add("--");
    args.add("-Dorg.jboss.boot.log.file=" + jbossHome + "/domain/log/host-controller/boot.log");
    args.add(
        "-Dlogging.configuration=file:" + jbossHome + "/domain/configuration/logging.properties");
    args.add(
        "-Djboss.test.host.master.address="
            + System.getProperty("jboss.test.host.master.address", "127.0.0.1"));
    args.add("-Xms64m");
    args.add("-Xmx512m");
    args.add("-XX:MaxPermSize=256m");
    args.add("-Dorg.jboss.resolver.warning=true");
    args.add("-Dsun.rmi.dgc.client.gcInterval=3600000");
    args.add("-Dsun.rmi.dgc.server.gcInterval=3600000");
    args.add("--");
    args.add("-default-jvm");
    args.add(processUtil.getJavaCommand());
    args.add("--host-config=" + hostXml.getAbsolutePath());
    args.add("--domain-config=" + domainXml.getAbsolutePath());
    args.add(
        "-Djboss.test.host.master.address="
            + System.getProperty("jboss.test.host.master.address", "127.0.0.1"));

    processController = Main.start(args.toArray(new String[args.size()]));
  }
Ejemplo n.º 2
0
  @BeforeClass
  public static void createProcessController()
      throws IOException, URISyntaxException, NoSuchAlgorithmException {

    final String testName = RespawnTestCase.class.getSimpleName();
    final File domains =
        new File("target" + File.separator + "domains" + File.separator + testName);
    final File masterDir = new File(domains, "master");
    final String masterDirPath = masterDir.getAbsolutePath();
    final File domainConfigDir = new File(masterDir, "configuration");
    // TODO this should not be necessary
    domainConfigDir.mkdirs();

    if (File.pathSeparatorChar == ':') {
      processUtil = new UnixProcessUtil();
    } else {
      processUtil = new WindowsProcessUtil();
    }

    String jbossHome = System.getProperty("jboss.home");
    if (jbossHome == null) {
      throw new IllegalStateException("-Djboss.home must be set");
    }

    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    URL url = tccl.getResource("domain-configs/domain-respawn.xml");
    Assert.assertNotNull(url);
    File domainXml = new File(url.toURI());
    url = tccl.getResource("host-configs/respawn-master.xml");
    File hostXml = new File(url.toURI());

    Assert.assertTrue(domainXml.exists());
    Assert.assertTrue(hostXml.exists());
    copyFile(domainXml, domainConfigDir);
    copyFile(hostXml, domainConfigDir);

    // No point backing up the file in a test scenario, just write what we need.
    File usersFile = new File(domainConfigDir, "mgmt-users.properties");
    FileOutputStream fos = new FileOutputStream(usersFile);
    PrintWriter pw = new PrintWriter(fos);
    pw.println(
        "slave="
            + new UsernamePasswordHashUtil()
                .generateHashedHexURP(
                    "slave", "ManagementRealm", "slave_user_password".toCharArray()));
    pw.close();
    fos.close();
    final String address = System.getProperty("jboss.test.host.master.address", "127.0.0.1");

    List<String> args = new ArrayList<String>();
    args.add("-jboss-home");
    args.add(jbossHome);
    args.add("-jvm");
    args.add(processUtil.getJavaCommand());
    args.add("--");
    args.add("-Dorg.jboss.boot.log.file=" + masterDirPath + "/log/host-controller.log");
    args.add(
        "-Dlogging.configuration=file:" + jbossHome + "/domain/configuration/logging.properties");
    args.add("-Djboss.test.host.master.address=" + address);
    TestSuiteEnvironment.getIpv6Args(args);
    args.add("-Xms64m");
    args.add("-Xmx512m");
    args.add("-XX:MaxPermSize=256m");
    args.add("-Dorg.jboss.resolver.warning=true");
    args.add("-Dsun.rmi.dgc.client.gcInterval=3600000");
    args.add("-Dsun.rmi.dgc.server.gcInterval=3600000");
    args.add("--");
    args.add("-default-jvm");
    args.add(processUtil.getJavaCommand());
    args.add("--host-config=" + hostXml.getName());
    args.add("--domain-config=" + domainXml.getName());
    args.add("-Djboss.test.host.master.address=" + address);
    args.add("-Djboss.domain.base.dir=" + masterDir.getAbsolutePath());
    args.add("--interprocess-hc-address");
    args.add(address);
    args.add("--pc-address");
    args.add(address);

    processController = Main.start(args.toArray(new String[args.size()]));
  }