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); } } }
private static boolean userApprovesStopForIncompatibleConfigurations( Project project, String configName, List<RunContentDescriptor> runningIncompatibleDescriptors) { RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project); final RunManagerConfig config = runManager.getConfig(); if (!config.isStopIncompatibleRequiresConfirmation()) return true; DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() { @Override public boolean isToBeShown() { return config.isStopIncompatibleRequiresConfirmation(); } @Override public void setToBeShown(boolean value, int exitCode) { config.setStopIncompatibleRequiresConfirmation(value); } @Override public boolean canBeHidden() { return true; } @Override public boolean shouldSaveOptionsOnCancel() { return false; } @NotNull @Override public String getDoNotShowMessage() { return CommonBundle.message("dialog.options.do.not.show"); } }; final StringBuilder names = new StringBuilder(); for (final RunContentDescriptor descriptor : runningIncompatibleDescriptors) { String name = descriptor.getDisplayName(); if (names.length() > 0) { names.append(", "); } names.append( StringUtil.isEmpty(name) ? ExecutionBundle.message("run.configuration.no.name") : String.format("'%s'", name)); } //noinspection DialogTitleCapitalization return Messages.showOkCancelDialog( project, ExecutionBundle.message( "stop.incompatible.confirmation.message", configName, names.toString(), runningIncompatibleDescriptors.size()), ExecutionBundle.message( "incompatible.configuration.is.running.dialog.title", runningIncompatibleDescriptors.size()), ExecutionBundle.message("stop.incompatible.confirmation.button.text"), CommonBundle.message("button.cancel"), Messages.getQuestionIcon(), option) == Messages.OK; }
/* * (non-Javadoc) * * @see java.lang.Runnable#run() */ public void run() { String line = null; try { int c; StringBuilder buf = new StringBuilder(); while ((c = this.stderr.read()) != -1) { String s = String.valueOf((char) c); // consoleView.print(s, ConsoleViewContentType.NORMAL_OUTPUT); if ((char) c == '\n') { line = buf.toString(); try { this.consoleSemaphore.acquire(); consoleView.print(line + "\n", ConsoleViewContentType.NORMAL_OUTPUT); } catch (InterruptedException e) { e.printStackTrace(); } finally { this.consoleSemaphore.release(); } buf = new StringBuilder(); if (isError) { log.error("*\t" + line); } else { log.debug("*\t" + line); } checkLine(line); } else { buf.append(s); } } // this.isr = new InputStreamReader(this.stderr); // this.br = new BufferedReader(this.isr); // // log.debug("awaiting input..."); // // while ((line = this.br.readLine()) != null) { // // consoleView.print(line + "\n", ConsoleViewContentType.NORMAL_OUTPUT); // // NB. this is not a logger as we don't want to be able to turn // // this off // // If the level of logging from the child process is verbose, // // change the logging level of the spawned process. // // if (isError){ // log.error("*\t" + line); // } // else { // log.debug("*\t" + line); // } // checkLine(line); // // } } catch (final IOException e) { e.printStackTrace(); } finally { doFinalCheck(); } }