mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
switch off testng serialization protocol
This commit is contained in:
@@ -228,4 +228,6 @@ ide.goto.implementation.show.interfaces.description=Whether to show sub-interfac
|
||||
|
||||
ide.open.editors.asynchronously=true
|
||||
ide.open.editors.asynchronously.description=Prepare editors in background thread
|
||||
file.colors.in.commit.dialog=false
|
||||
file.colors.in.commit.dialog=false
|
||||
|
||||
testng.serialized.protocol.enabled=false
|
||||
+6
-22
@@ -52,6 +52,7 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Getter;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
@@ -140,7 +141,7 @@ public class TestNGRunnableState extends JavaCommandLineState {
|
||||
task.finish();
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
final Runnable notificationRunnable = new Runnable() {
|
||||
public void run() {
|
||||
final Project project = config.getProject();
|
||||
if (project.isDisposed()) return;
|
||||
@@ -150,15 +151,6 @@ public class TestNGRunnableState extends JavaCommandLineState {
|
||||
final String testRunDebugId = consoleProperties.isDebug() ? ToolWindowId.DEBUG : ToolWindowId.RUN;
|
||||
final TestNGResults resultsView = console.getResultsView();
|
||||
final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
|
||||
final GlobalSearchScope librariesScope = config.getPersistantData().getScope().getSourceScope(config).getLibrariesScope();
|
||||
|
||||
final String incompatibilityMessage = TestNGVersionChecker.getVersionIncompatibilityMessage(project, librariesScope,
|
||||
PathUtil.getJarPathForClass(AfterClass.class));
|
||||
if (incompatibilityMessage != null) {
|
||||
toolWindowManager.notifyByBalloon(testRunDebugId, MessageType.ERROR, incompatibilityMessage, null, new TestNGVersionChecker.MyCopyJarListener(librariesScope, project));
|
||||
TestsUIUtil.NOTIFICATION_GROUP.createNotification(incompatibilityMessage, MessageType.ERROR).notify(project);
|
||||
}
|
||||
|
||||
if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) {
|
||||
final MessageType type = resultsView == null || resultsView.getStatus() == MessageHelper.SKIPPED_TEST
|
||||
? MessageType.WARNING
|
||||
@@ -170,7 +162,8 @@ public class TestNGRunnableState extends JavaCommandLineState {
|
||||
TestsUIUtil.NOTIFICATION_GROUP.createNotification(message, type).notify(project);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
SwingUtilities.invokeLater(notificationRunnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -246,13 +239,6 @@ public class TestNGRunnableState extends JavaCommandLineState {
|
||||
LOG.info("Language level is " + effectiveLanguageLevel.toString());
|
||||
LOG.info("is15 is " + is15);
|
||||
final String pathToBundledJar = PathUtil.getJarPathForClass(AfterClass.class);
|
||||
final SourceScope sourceScope = config.getPersistantData().getScope().getSourceScope(config);
|
||||
final String incompatibilityMessage = sourceScope != null ?
|
||||
TestNGVersionChecker.getVersionIncompatibilityMessage(project, sourceScope.getLibrariesScope(), pathToBundledJar) :
|
||||
null;
|
||||
if (incompatibilityMessage != null) {
|
||||
javaParameters.getClassPath().add(pathToBundledJar);
|
||||
}
|
||||
|
||||
// Configure rest of jars
|
||||
JavaParametersUtil.configureConfiguration(javaParameters, config);
|
||||
@@ -281,9 +267,7 @@ public class TestNGRunnableState extends JavaCommandLineState {
|
||||
config.ALTERNATIVE_JRE_PATH_ENABLED ? config.ALTERNATIVE_JRE_PATH : null);
|
||||
}
|
||||
|
||||
if (incompatibilityMessage == null) {
|
||||
javaParameters.getClassPath().add(pathToBundledJar);
|
||||
}
|
||||
javaParameters.getClassPath().add(pathToBundledJar);
|
||||
|
||||
try {
|
||||
port = NetUtils.findAvailableSocketPort();
|
||||
@@ -401,6 +385,6 @@ public class TestNGRunnableState extends JavaCommandLineState {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return Registry.is("testng.serialized.protocol.enabled") && !TestNGVersionChecker.isVersionIncompatible(project, scopeToDetermineTestngIn);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-152
@@ -15,47 +15,19 @@
|
||||
*/
|
||||
package com.theoryinpractice.testng.configuration;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.execution.testframework.TestsUIUtil;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.libraries.JarVersionDetectionUtil;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.updateSettings.impl.PluginDownloader;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.PathUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.remote.strprotocol.TestResultMessage;
|
||||
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: 3/15/12
|
||||
*/
|
||||
public class TestNGVersionChecker {
|
||||
private static final Logger LOG = Logger.getInstance("#" + TestNGVersionChecker.class.getName());
|
||||
|
||||
private static final String TEST_NG_VERSIONS_INCOMPATIBILITY = "<html><b>!!!TestNG protocol incompatibility!!!</b><br>";
|
||||
private static final String COPY_MESSAGE = "In order to use your project testng.jar, please, <a href=\"copy\">copy</a> it in the plugin lib directory.";
|
||||
|
||||
@Nullable
|
||||
public static String getVersionIncompatibilityMessage(Project project, GlobalSearchScope scope, String pathToBundledJar) {
|
||||
public static boolean isVersionIncompatible(Project project, GlobalSearchScope scope) {
|
||||
final String protocolClassMessageClass = TestResultMessage.class.getName();
|
||||
final PsiClass psiProtocolClass = JavaPsiFacade.getInstance(project).findClass(protocolClassMessageClass, scope);
|
||||
if (psiProtocolClass != null) {
|
||||
@@ -72,132 +44,11 @@ public class TestNGVersionChecker {
|
||||
ideaHasNewJar = false;
|
||||
}
|
||||
|
||||
if (userHasNewJar != ideaHasNewJar) {
|
||||
return getIncompatibilityMessage(project, scope, pathToBundledJar);
|
||||
}
|
||||
return userHasNewJar != ideaHasNewJar;
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getIncompatibilityMessage(Project project, GlobalSearchScope scope, String pathToBundledJar) {
|
||||
final String protocolClassMessageClass = TestResultMessage.class.getName();
|
||||
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
|
||||
final PsiClass psiProtocolClass = psiFacade.findClass(protocolClassMessageClass, scope);
|
||||
if (psiProtocolClass != null) {
|
||||
final ZipFile workingLibrary = getZipLibrary(project, scope);
|
||||
if (workingLibrary != null) {
|
||||
final VirtualFile bundledJar = LocalFileSystem.getInstance().findFileByPath(pathToBundledJar);
|
||||
if (bundledJar != null) {
|
||||
final String jarVersion = JarVersionDetectionUtil.detectJarVersion(workingLibrary);
|
||||
final VirtualFile bundledJarJar = JarFileSystem.getInstance().getJarRootForLocalFile(bundledJar);
|
||||
if (bundledJarJar == null) return null;
|
||||
String bundledVersion;
|
||||
try {
|
||||
bundledVersion = JarVersionDetectionUtil.detectJarVersion(JarFileSystem.getInstance().getJarFile(bundledJarJar));
|
||||
}
|
||||
catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
final boolean ableToStartWithUserJar = psiFacade.findClass("com.beust.jcommander.JCommander", scope) != null;
|
||||
return TEST_NG_VERSIONS_INCOMPATIBILITY +
|
||||
"Right now " + ApplicationNamesInfo.getInstance().getFullProductName() +
|
||||
" does not support testng version (v." + jarVersion + ") used in your project due to the protocol changes on the TestNG side.<br>" +
|
||||
"Bundled jar (v." + bundledVersion + ") was used instead to run your tests.<br>" +
|
||||
(ableToStartWithUserJar ? COPY_MESSAGE
|
||||
: "In order to use your project testng.jar, please, download & copy it in the plugin lib directory.") +
|
||||
"</html>";
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile getWorkingLibrary(Project project, GlobalSearchScope scope) {
|
||||
final VirtualFile library = getLibrary(project, scope);
|
||||
if (library != null) {
|
||||
return JarFileSystem.getInstance().getVirtualFileForJar(library);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ZipFile getZipLibrary(Project project, GlobalSearchScope scope) {
|
||||
final VirtualFile library = getLibrary(project, scope);
|
||||
if (library != null) {
|
||||
try {
|
||||
return JarFileSystem.getInstance().getJarFile(library);
|
||||
}
|
||||
catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile getLibrary(Project project, GlobalSearchScope scope) {
|
||||
final String protocolClassMessageClass = TestResultMessage.class.getName();
|
||||
final PsiClass psiProtocolClass = JavaPsiFacade.getInstance(project).findClass(protocolClassMessageClass, scope);
|
||||
if (psiProtocolClass != null) {
|
||||
final PsiFile containingFile = psiProtocolClass.getContainingFile();
|
||||
if (containingFile != null) {
|
||||
final VirtualFile file = containingFile.getVirtualFile();
|
||||
if (file != null) {
|
||||
final VirtualFileSystem fileSystem = file.getFileSystem();
|
||||
if (fileSystem instanceof JarFileSystem) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static class MyCopyJarListener implements HyperlinkListener {
|
||||
private final GlobalSearchScope myScope;
|
||||
private final Project myProject;
|
||||
|
||||
public MyCopyJarListener(GlobalSearchScope scope, Project project) {
|
||||
myScope = scope;
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
final String testNGPluginLibPath = PathManager.getHomePath() + File.separator + "plugins" + File.separator + "testng" + File.separator + "lib";
|
||||
|
||||
final VirtualFile library = getWorkingLibrary(myProject, myScope);
|
||||
if (library != null) {
|
||||
try {
|
||||
final String jarName = new File(PathUtil.getJarPathForClass(AfterClass.class)).getName();
|
||||
PluginDownloader.replaceLib(testNGPluginLibPath, jarName, VfsUtil.virtualToIoFile(library));
|
||||
final Application app = ApplicationManager.getApplication();
|
||||
final String updateSuccessfullyMessage = "Internal testng.jar was successfully updated. ";
|
||||
if (app.isRestartCapable()) {
|
||||
final String restartMessage = updateSuccessfullyMessage +
|
||||
"Would you like to restart " + ApplicationNamesInfo.getInstance().getFullProductName() + " to apply changes?";
|
||||
if (Messages.showOkCancelDialog(myProject, restartMessage, CommonBundle.getWarningTitle(), "Restart", "Postpone",
|
||||
Messages.getWarningIcon()) == DialogWrapper.OK_EXIT_CODE) {
|
||||
ApplicationManager.getApplication().restart();
|
||||
}
|
||||
}
|
||||
else {
|
||||
final String message = updateSuccessfullyMessage +
|
||||
"Restart " + ApplicationNamesInfo.getInstance().getFullProductName() + " in order to apply changes.";
|
||||
TestsUIUtil.NOTIFICATION_GROUP.createNotification(message, MessageType.INFO).notify(myProject);
|
||||
}
|
||||
}
|
||||
catch (IOException e1) {
|
||||
LOG.info(e1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user