use of com.intellij.execution.configurations.JavaParameters in project intellij-community by JetBrains.
the class JUnit4IntegrationTest method ignoredTestMethod.
@Test
public void ignoredTestMethod() throws Throwable {
EdtTestUtil.runInEdtAndWait(() -> {
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
assertNotNull(psiClass);
PsiMethod testMethod = psiClass.findMethodsByName(METHOD_NAME, false)[0];
JUnitConfiguration configuration = createConfiguration(testMethod);
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
RunnerAndConfigurationSettingsImpl settings = new RunnerAndConfigurationSettingsImpl(RunManagerImpl.getInstanceImpl(getProject()), configuration, false);
ExecutionEnvironment environment = new ExecutionEnvironment(executor, ProgramRunnerUtil.getRunner(DefaultRunExecutor.EXECUTOR_ID, settings), settings, getProject());
TestObject state = configuration.getState(executor, environment);
JavaParameters parameters = state.getJavaParameters();
parameters.setUseDynamicClasspath(getProject());
GeneralCommandLine commandLine = parameters.toCommandLine();
StringBuffer buf = new StringBuffer();
StringBuffer err = new StringBuffer();
OSProcessHandler process = new OSProcessHandler(commandLine);
process.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
String text = event.getText();
try {
if (outputType == ProcessOutputTypes.STDOUT && !text.isEmpty() && ServiceMessage.parse(text.trim()) == null) {
buf.append(text);
}
if (outputType == ProcessOutputTypes.STDERR) {
err.append(text);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
});
process.startNotify();
process.waitFor();
process.destroyProcess();
String testOutput = buf.toString();
assertEmpty(err.toString());
switch(myJUnitVersion) {
//shouldn't work for old versions
case "4.4":
//shouldn't work for old versions
case "4.5":
break;
default:
assertTrue(testOutput, testOutput.contains("Test1"));
}
});
}
use of com.intellij.execution.configurations.JavaParameters in project intellij-community by JetBrains.
the class MavenJUnitPatcherTest method testVmPropertiesResolve.
public void testVmPropertiesResolve() throws Exception {
VirtualFile m1 = createModulePom("m1", "<groupId>test</groupId>" + "<artifactId>m1</artifactId>" + "<version>1</version>" + "<dependencies>" + " <dependency>" + " <groupId>test</groupId>" + " <artifactId>m2</artifactId>" + " <version>1</version>" + " </dependency>" + "</dependencies>" + "<build><plugins>" + " <plugin>" + " <groupId>org.apache.maven.plugins</groupId>" + " <artifactId>maven-surefire-plugin</artifactId>" + " <version>2.16</version>" + " <configuration>" + " <argLine>-Xmx2048M -XX:MaxPermSize=512M \"-Dargs=can have spaces\" ${argLineApx}</argLine>" + " </configuration>" + " </plugin>" + "</plugins></build>");
importProjects(m1);
Module module = getModule("m1");
MavenJUnitPatcher mavenJUnitPatcher = new MavenJUnitPatcher();
JavaParameters javaParameters = new JavaParameters();
javaParameters.getVMParametersList().addProperty("argLineApx", "-DsomeKey=someValue");
mavenJUnitPatcher.patchJavaParameters(module, javaParameters);
assertEquals(asList("-DargLineApx=-DsomeKey=someValue", "-Xmx2048M", "-XX:MaxPermSize=512M", "-Dargs=can have spaces", "-DsomeKey=someValue"), javaParameters.getVMParametersList().getList());
}
use of com.intellij.execution.configurations.JavaParameters in project intellij-community by JetBrains.
the class MavenResolveToWorkspaceTest method testIgnoredProject.
public void testIgnoredProject() throws Exception {
createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<modules>" + " <module>moduleA</module>" + " <module>moduleIgnored</module>" + " <module>moduleB</module>" + "</modules>");
VirtualFile moduleA = createModulePom("moduleA", "<groupId>test</groupId>" + "<artifactId>moduleA</artifactId>" + "<version>1</version>");
VirtualFile moduleIgnored = createModulePom("moduleIgnored", "<groupId>test</groupId>" + "<artifactId>moduleIgnored</artifactId>" + "<version>1</version>");
VirtualFile moduleB = createModulePom("moduleB", "<groupId>test</groupId>" + "<artifactId>moduleB</artifactId>" + "<version>1</version>" + "<dependencies>" + " <dependency>" + " <groupId>test</groupId>" + " <artifactId>moduleA</artifactId>" + " <version>1</version>" + " </dependency>" + " <dependency>" + " <groupId>test</groupId>" + " <artifactId>moduleIgnored</artifactId>" + " <version>1</version>" + " </dependency>" + "</dependencies>");
MavenProjectsManager.getInstance(myProject).setIgnoredFilesPaths(Collections.singletonList(moduleIgnored.getPath()));
importProject();
MavenProjectsManager.getInstance(myProject).setIgnoredFilesPaths(Collections.singletonList(moduleIgnored.getPath()));
//assertModules("project", "moduleA", "moduleB");
WriteAction.run(() -> ProjectRootManager.getInstance(myProject).setProjectSdk(createJdk("Java 1.5")));
MavenRunnerParameters runnerParameters = new MavenRunnerParameters(moduleB.getParent().getPath(), false, Collections.singletonList("jetty:run"), Collections.<String, Boolean>emptyMap());
runnerParameters.setResolveToWorkspace(true);
MavenRunnerSettings runnerSettings = MavenRunner.getInstance(myProject).getSettings().clone();
runnerSettings.setJreName(MavenRunnerSettings.USE_INTERNAL_JAVA);
JavaParameters parameters = MavenExternalParameters.createJavaParameters(myProject, runnerParameters, MavenProjectsManager.getInstance(myProject).getGeneralSettings(), runnerSettings);
String resolveMapFile = null;
String prefix = "-D" + MavenModuleMap.PATHS_FILE_PROPERTY + "=";
for (String param : parameters.getVMParametersList().getParameters()) {
if (param.startsWith(prefix)) {
resolveMapFile = param.substring(prefix.length());
break;
}
}
assertNotNull(resolveMapFile);
Properties properties = readProperties(resolveMapFile);
assertEquals(moduleA.getPath(), properties.getProperty("test:moduleA:pom:1"));
assert properties.getProperty("test:moduleA:jar:1").endsWith("/moduleA/target/classes");
assertNull(properties.getProperty("test:moduleIgnored:pom:1"));
assertNull(properties.getProperty("test:moduleIgnored:jar:1"));
}
use of com.intellij.execution.configurations.JavaParameters in project intellij-community by JetBrains.
the class ExecutionTestCase method createJavaParameters.
protected JavaParameters createJavaParameters(String mainClass) {
JavaParameters parameters = new JavaParameters();
parameters.getClassPath().add(getAppOutputPath());
parameters.setMainClass(mainClass);
parameters.setJdk(JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk());
parameters.setWorkingDirectory(getTestAppPath());
return parameters;
}
use of com.intellij.execution.configurations.JavaParameters in project android by JetBrains.
the class AndroidJunitPatcherTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
setUpIdeaAndroidProject();
myPatcher = new AndroidJunitPatcher();
myJavaParameters = new JavaParameters();
myJavaParameters.getClassPath().addAll(getExampleClasspath());
// Adding the facet makes Projects#isBuildWithGradle return 'true'.
createAndAddGradleFacet(myModule);
}
Aggregations