Package org.ops4j.exec

Examples of org.ops4j.exec.DefaultJavaRunner


        getLog().debug("classpath for forked process:");
        for (String cp : classpathElements) {
            getLog().debug(cp);
        }

        DefaultJavaRunner javaRunner = new DefaultJavaRunner(false);
        String basedirProp = String.format("-D%s=%s", BASEDIR, basedir.getAbsolutePath());
        String[] vmOptions = new String[] { basedirProp };
        String javaHome = System.getProperty("java.home");
        int port = getFreePort();
        String[] args = new String[] { configClass, Integer.toString(port) };

        // inherit working directory from this process
        javaRunner.exec(vmOptions, classpathElements, PaxExamRuntime.class.getName(), args,
            javaHome, null);

        @SuppressWarnings("unchecked")
        Map<String, Object> context = getPluginContext();
View Full Code Here


        Object object = getPluginContext().get(TEST_CONTAINER_RUNNER_KEY + mojoExecution.getExecutionId());
        if (object == null) {
            throw new MojoExecutionException(
                "No Pax Exam container found. Did you run the start-container goal?");
        }
        DefaultJavaRunner javaRunner = (DefaultJavaRunner) object;
       
        object = getPluginContext().get(TEST_CONTAINER_PORT_KEY + mojoExecution.getExecutionId());
        if (object == null) {
            throw new MojoExecutionException(
                "No Pax Exam container port found. Did you run the start-container goal?");
        }
        Integer port = (Integer) object;
        try {
            getLog().debug("stopping test container");
            Socket socket = new Socket((String) null, port);
            OutputStream os = socket.getOutputStream();
            OutputStreamWriter writer = new OutputStreamWriter(os, "UTF-8");
            PrintWriter pw = new PrintWriter(writer, true);
            InputStreamReader isr = new InputStreamReader(socket.getInputStream(), "UTF-8");
            BufferedReader reader = new BufferedReader(isr);

            pw.println("stop");
            getLog().debug("quitting test container");
            reader.readLine();
            pw.println("quit");
            reader.close();
            pw.close();
            socket.close();           
        }
        catch (IOException exc) {
            getLog().info("exception communicating with background process, terminating process");
            getLog().info(exc);
        }
       
        javaRunner.shutdown();
    }
View Full Code Here

            Map<String, String> systemPropsNew = new HashMap<String, String>(systemProperties);
            systemPropsNew.put(RemoteFramework.RMI_PORT_KEY, Integer.toString(port));
            systemPropsNew.put(RemoteFramework.RMI_NAME_KEY, rmiName);
            String[] vmOptions = buildSystemProperties(vmArgs, systemPropsNew);
            String[] args = buildFrameworkProperties(frameworkProperties);
            javaRunner = new DefaultJavaRunner(false);
            javaRunner.exec(vmOptions, buildClasspath(beforeFrameworkClasspath, afterFrameworkClasspath),
                RemoteFrameworkImpl.class.getName(), args, getJavaHome(), null);
            return findRemoteFramework(port, rmiName);
        }
        catch (RemoteException | ExecutionException | URISyntaxException exc) {
View Full Code Here

TOP

Related Classes of org.ops4j.exec.DefaultJavaRunner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.