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 testRunThirdPartyApplication() throws ExecutionException {
   ApplicationConfiguration configuration =
       new ApplicationConfiguration(
           "Third party", myProject, ApplicationConfigurationType.getInstance());
   configuration.setModule(getModule1());
   configuration.MAIN_CLASS_NAME = "third.party.Main";
   checkCanRun(configuration);
 }
  protected ProcessHandler runProcess(
      String className,
      Module module,
      final Class<? extends Executor> executorClass,
      final ProcessListener listener,
      final ProgramRunner runner)
      throws ExecutionException {
    final ApplicationConfiguration configuration =
        new ApplicationConfiguration(
            "app", getProject(), ApplicationConfigurationType.getInstance());
    configuration.setModule(module);
    configuration.setMainClassName(className);
    final Executor executor = Executor.EXECUTOR_EXTENSION_NAME.findExtension(executorClass);
    final ExecutionEnvironment environment =
        new ExecutionEnvironment(
            configuration,
            getProject(),
            new RunnerSettings<JDOMExternalizable>(null, null),
            null,
            null);
    final Semaphore semaphore = new Semaphore();
    semaphore.down();

    final AtomicReference<ProcessHandler> processHandler = new AtomicReference<ProcessHandler>();
    runner.execute(
        executor,
        environment,
        new ProgramRunner.Callback() {
          @Override
          public void processStarted(final RunContentDescriptor descriptor) {
            disposeOnTearDown(
                new Disposable() {
                  @Override
                  public void dispose() {
                    Disposer.dispose(descriptor);
                  }
                });
            final ProcessHandler handler = descriptor.getProcessHandler();
            assert handler != null;
            handler.addProcessListener(listener);
            processHandler.set(handler);
            semaphore.up();
          }
        });
    semaphore.waitFor();
    return processHandler.get();
  }
  public void testCreatingApplicationConfiguration() throws ConfigurationException {
    if (PlatformTestUtil.COVERAGE_ENABLED_BUILD) return;

    ApplicationConfiguration configuration =
        new ApplicationConfiguration(null, myProject, ApplicationConfigurationType.getInstance());
    ApplicationConfigurable editor = new ApplicationConfigurable(myProject);
    try {
      editor.getComponent(); // To get all the watchers installed.
      Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
      configurable.reset();
      CommonJavaParametersPanel javaParameters = editor.getCommonProgramParameters();
      javaParameters.setProgramParameters("prg");
      javaParameters.setVMParameters("vm");
      javaParameters.setWorkingDirectory("dir");
      assertTrue(configurable.isModified());
      configurable.apply();
      assertEquals("prg", configuration.getProgramParameters());
      assertEquals("vm", configuration.getVMParameters());
      assertEquals("dir", configuration.getWorkingDirectory());
    } finally {
      Disposer.dispose(editor);
    }
  }