public void testTestClassPathWhenRunningConfigurations() throws IOException, ExecutionException { addModule("module4", false); Module module4 = getModule4(); assignJdk(module4); addSourcePath(module4, "testSrc", true); addSourcePath(module4, "src", false); String output = setCompilerOutput(module4, "classes", false); String testOuput = setCompilerOutput(module4, "testClasses", true); ApplicationConfiguration applicationConfiguration = createConfiguration(findClass(module4, "Application")); JavaParameters parameters = checkCanRun(applicationConfiguration); String classPath = parameters.getClassPath().getPathsString(); checkDoesNotContain(classPath, testOuput); checkContains(classPath, output); JUnitConfiguration junitConfiguration = createJUnitConfiguration( findClass(module4, "TestApplication"), TestClassConfigurationProducer.class, new MapDataContext()); parameters = checkCanRun(junitConfiguration); classPath = parameters.getClassPath().getPathsString(); checkContains(classPath, testOuput); checkContains(classPath, output); applicationConfiguration.MAIN_CLASS_NAME = junitConfiguration.getPersistentData().getMainClassName(); classPath = checkCanRun(applicationConfiguration).getClassPath().getPathsString(); checkContains(classPath, testOuput); checkContains(classPath, output); }
public void testAllInPackageForProject() throws IOException, ExecutionException { // module1 -> module2 -> module3 // module5 addModule("module5"); addDependency(getModule1(), getModule2()); addDependency(getModule2(), getModule3()); String[][] outputs = new String[4][]; for (int i = 0; i < 4; i++) { outputs[i] = addOutputs(getModule(i), i + 1); } PsiPackage defaultPackage = JavaPsiFacade.getInstance(myProject).findPackage(""); JUnitConfiguration configuration = createJUnitConfiguration( defaultPackage, AllInPackageConfigurationProducer.class, new MapDataContext()); configuration.getPersistentData().setScope(TestSearchScope.WHOLE_PROJECT); JavaParameters javaParameters = checkCanRun(configuration); String classPath = javaParameters.getClassPath().getPathsString(); assertEquals(-1, classPath.indexOf(JarFileSystem.PROTOCOL_PREFIX)); assertEquals(-1, classPath.indexOf(LocalFileSystem.PROTOCOL_PREFIX)); for (int i = 0; i < 4; i++) { checkContains(classPath, outputs[i][0]); checkContains(classPath, outputs[i][1]); } }
public void testClasspathConfiguration() throws CantRunException { JavaParameters parameters = new JavaParameters(); RunConfigurationModule module = new JavaRunConfigurationModule(myProject, false); Module module1 = getModule1(); Module module2 = getModule2(); addDependency(module1, module2); Module module3 = getModule3(); addDependency(module2, module3); addDependency(module1, module3); addOutputs(module1, 1); addOutputs(module2, 2); addOutputs(module3, 3); module.setModule(module1); parameters.configureByModule(module.getModule(), JavaParameters.JDK_AND_CLASSES_AND_TESTS); ArrayList<String> classPath = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(parameters.getClassPath().getPathsString(), File.pathSeparator); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); classPath.add(token); } CHECK.singleOccurence(classPath, getOutput(module1, false)); CHECK.singleOccurence(classPath, getOutput(module1, false)); CHECK.singleOccurence(classPath, getOutput(module1, true)); CHECK.singleOccurence(classPath, getOutput(module2, false)); CHECK.singleOccurence(classPath, getOutput(module2, true)); CHECK.singleOccurence(classPath, getOutput(module3, false)); CHECK.singleOccurence(classPath, getOutput(module3, true)); CHECK.singleOccurence(classPath, getFSPath(findFile(MOCK_JUNIT))); }
public void testSameTestAndCommonOutput() throws IOException, ExecutionException { addModule("module4", false); Module module = getModule4(); assignJdk(module); addSourcePath(module, "src", false); addSourcePath(module, "testSrc", false); String output = setCompilerOutput(module, "classes", false); assertEquals(output, setCompilerOutput(module, "classes", true)); RunConfiguration configuration = createConfiguration(findClass(module, "Application")); JavaParameters javaParameters = checkCanRun(configuration); checkContains(javaParameters.getClassPath().getPathsString(), output); configuration = createConfiguration(findClass(module, "TestApplication")); javaParameters = checkCanRun(configuration); checkContains(javaParameters.getClassPath().getPathsString(), output); }
protected JavaParameters createJavaParameters() throws ExecutionException { log.debug("createJavaParameters"); SubstepsRunConfiguration runConfig = (SubstepsRunConfiguration) this.getEnvironment().getRunProfile(); SubstepsRunnerConfigurationModel model = runConfig.getModel(); JavaParameters params = model.getJavaParameters(); params.setWorkingDirectory(model.getWorkingDir()); if (params.getJdk() == null) { log.debug("params on the jdk is null"); params.setJdk( JavaSdkImpl.getInstance().createJdk(model.getVersionString(), model.getHomePath())); params.getClassPath().add(model.getClassPathString()); } params.getProgramParametersList().add("prog-args-env", "prg-localhost"); ParametersList vmParametersList = params.getVMParametersList(); vmParametersList.addParametersString("-Dfile.encoding=UTF-8"); vmParametersList.addParametersString("-Dcom.sun.management.jmxremote.port=" + jmxPort); vmParametersList.addParametersString("-Dcom.sun.management.jmxremote.authenticate=false"); vmParametersList.addParametersString("-Dcom.sun.management.jmxremote.ssl=false"); vmParametersList.addParametersString("-Djava.rmi.server.hostname=localhost"); // String rmiClasspathString = "\"file://" + // model.getClassPathString().replaceAll(File.pathSeparator, " file://") + "\""; // log.debug("rmi classpath: " + rmiClasspathString); // vmParametersList.addParametersString("-Djava.rmi.server.codebase=" + // rmiClasspathString); vmParametersList.addParametersString("-Dsun.io.serialization.extendedDebugInfo=true"); // System.setProperty("java.rmi.server.codebase", rmiClasspathString); // createServerSocket(params); // // // if (myServerSocket != null) { // params.getProgramParametersList().add(ForkedDebuggerHelper.DEBUG_SOCKET + // myServerSocket.getLocalPort()); // } // log.debug( "launching substeps runner with classpath: " + params.getClassPath().getPathsString() + "\njvm info: " + model.getHomePath() + " version: " + model.getVersionString()); return params; }