コード例 #1
0
 public void checkConfiguration() throws RuntimeConfigurationException {
   JavaParametersUtil.checkAlternativeJRE(myConfiguration);
   ProgramParametersUtil.checkWorkingDirectoryExist(
       myConfiguration,
       myConfiguration.getProject(),
       myConfiguration.getConfigurationModule().getModule());
 }
コード例 #2
0
 protected void configureModule(
     final JavaParameters parameters,
     final RunConfigurationModule configurationModule,
     final String mainClassName)
     throws CantRunException {
   int classPathType =
       JavaParametersUtil.getClasspathType(configurationModule, mainClassName, true);
   JavaParametersUtil.configureModule(
       configurationModule,
       parameters,
       classPathType,
       myConfiguration.isAlternativeJrePathEnabled()
           ? myConfiguration.getAlternativeJrePath()
           : null);
 }
コード例 #3
0
 public boolean isConfiguredByElement(
     final JUnitConfiguration configuration,
     PsiClass testClass,
     PsiMethod testMethod,
     PsiPackage testPackage) {
   return testPackage != null
       && Comparing.equal(
           testPackage.getQualifiedName(), configuration.getPersistentData().getPackageName());
 }
コード例 #4
0
 @Override
 public JavaParameters getJavaParameters() throws ExecutionException {
   if (myJavaParameters == null) {
     myJavaParameters = new JavaParameters();
     initialize();
     final Module module = myConfiguration.getConfigurationModule().getModule();
     final Object[] patchers = Extensions.getExtensions(ExtensionPoints.JUNIT_PATCHER);
     for (Object patcher : patchers) {
       ((JUnitPatcher) patcher).patchJavaParameters(module, myJavaParameters);
     }
   }
   return myJavaParameters;
 }
コード例 #5
0
  protected void initialize() throws ExecutionException {
    JavaParametersUtil.configureConfiguration(myJavaParameters, myConfiguration);
    myJavaParameters.setMainClass(JUnitConfiguration.JUNIT_START_CLASS);
    final Module module = myConfiguration.getConfigurationModule().getModule();
    if (myJavaParameters.getJdk() == null) {
      myJavaParameters.setJdk(
          module != null
              ? ModuleRootManager.getInstance(module).getSdk()
              : ProjectRootManager.getInstance(myProject).getProjectSdk());
    }

    myJavaParameters.getClassPath().add(JavaSdkUtil.getIdeaRtJarPath());
    myJavaParameters.getClassPath().add(PathUtil.getJarPathForClass(JUnitStarter.class));
    myJavaParameters
        .getProgramParametersList()
        .add(JUnitStarter.IDE_VERSION + JUnitStarter.VERSION);
    for (RunConfigurationExtension ext :
        Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) {
      ext.updateJavaParameters(myConfiguration, myJavaParameters, getRunnerSettings());
    }

    final Object[] listeners = Extensions.getExtensions(IDEAJUnitListener.EP_NAME);
    final StringBuilder buf = new StringBuilder();
    for (final Object listener : listeners) {
      boolean enabled = true;
      for (RunConfigurationExtension ext :
          Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) {
        if (ext.isListenerDisabled(myConfiguration, listener, getRunnerSettings())) {
          enabled = false;
          break;
        }
      }
      if (enabled) {
        final Class classListener = listener.getClass();
        buf.append(classListener.getName()).append("\n");
        myJavaParameters.getClassPath().add(PathUtil.getJarPathForClass(classListener));
      }
    }
    if (buf.length() > 0) {
      try {
        myListenersFile = FileUtil.createTempFile("junit_listeners_", "");
        myListenersFile.deleteOnExit();
        myJavaParameters.getProgramParametersList().add("@@" + myListenersFile.getPath());
        FileUtil.writeToFile(myListenersFile, buf.toString().getBytes());
      } catch (IOException e) {
        LOG.error(e);
      }
    }
  }
コード例 #6
0
  private void appendForkInfo(Executor executor) throws ExecutionException {
    final String forkMode = myConfiguration.getForkMode();
    if (Comparing.strEqual(forkMode, "none")) {
      return;
    }

    if (getRunnerSettings().getData() != null) {
      final String actionName = executor.getActionName();
      throw new CantRunException(
          actionName
              + " is disabled in fork mode.<br/>Please change fork mode to &lt;none&gt; to "
              + actionName.toLowerCase()
              + ".");
    }

    final JavaParameters javaParameters = getJavaParameters();
    final Sdk jdk = javaParameters.getJdk();
    if (jdk == null) {
      throw new ExecutionException(
          ExecutionBundle.message("run.configuration.error.no.jdk.specified"));
    }

    try {
      final File tempFile = FileUtil.createTempFile("command.line", "", true);
      final PrintWriter writer = new PrintWriter(tempFile, "UTF-8");
      try {
        writer.println(((JavaSdkType) jdk.getSdkType()).getVMExecutablePath(jdk));
        for (String vmParameter : javaParameters.getVMParametersList().getList()) {
          writer.println(vmParameter);
        }
        writer.println("-classpath");
        writer.println(javaParameters.getClassPath().getPathsString());
      } finally {
        writer.close();
      }

      myJavaParameters
          .getProgramParametersList()
          .add("@@@" + forkMode + ',' + tempFile.getAbsolutePath());
    } catch (Exception e) {
      LOG.error(e);
    }
  }
コード例 #7
0
 public SourceScope getSourceScope() {
   return SourceScope.modulesWithDependencies(myConfiguration.getModules());
 }