diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/TestKindRegistry.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/TestKindRegistry.java index 62da7d931b0..4bbcdbcdaad 100644 --- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/TestKindRegistry.java +++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/TestKindRegistry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2018 IBM Corporation and others. + * Copyright (c) 2006, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -108,18 +108,14 @@ public ITestKind getKind(String testKindId) { public static String getContainerTestKindId(IJavaElement element) { if (element != null) { IJavaProject project= element.getJavaProject(); - if (CoreTestSearchEngine.is50OrHigher(project)) { - if (CoreTestSearchEngine.is18OrHigher(project)) { - if (isRunWithJUnitPlatform(element)) { - return JUNIT4_TEST_KIND_ID; - } - if (CoreTestSearchEngine.hasJUnit5TestAnnotation(project)) { - return JUNIT5_TEST_KIND_ID; - } - } - if (CoreTestSearchEngine.hasJUnit4TestAnnotation(project)) { - return JUNIT4_TEST_KIND_ID; - } + if (isRunWithJUnitPlatform(element)) { + return JUNIT4_TEST_KIND_ID; + } + if (CoreTestSearchEngine.hasJUnit5TestAnnotation(project)) { + return JUNIT5_TEST_KIND_ID; + } + if (CoreTestSearchEngine.hasJUnit4TestAnnotation(project)) { + return JUNIT4_TEST_KIND_ID; } } return JUNIT3_TEST_KIND_ID; diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/util/CoreTestSearchEngine.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/util/CoreTestSearchEngine.java index c28ccd2445e..913c799b430 100644 --- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/util/CoreTestSearchEngine.java +++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/util/CoreTestSearchEngine.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2021 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -268,49 +268,4 @@ public static void findSuiteMethods(IJavaElement element, Set result, IPr SearchParticipant[] participants= new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }; new SearchEngine().search(suitePattern, participants, scope, requestor, pm); } - - -// --- copied from org.eclipse.jdt.internal.corext.util.JavaModelUtil: --- - /** - * @param version1 the first version - * @param version2 the second version - * @return true iff version1 is less than version2 - */ - public static boolean isVersionLessThan(String version1, String version2) { - return JavaCore.compareJavaVersions(version1, version2) < 0; - } - - - public static boolean is50OrHigher(String compliance) { - return !isVersionLessThan(compliance, JavaCore.VERSION_1_5); - } - - /** - * Checks if the given project or workspace has source compliance 5.0 or greater. - * - * @param project the project to test or null to test the workspace settings - * @return true if the given project or workspace has source compliance 5.0 or greater. - */ - public static boolean is50OrHigher(IJavaProject project) { - String source= project != null ? project.getOption(JavaCore.COMPILER_SOURCE, true) : JavaCore.getOption(JavaCore.COMPILER_SOURCE); - return is50OrHigher(source); - } - - public static boolean is18OrHigher(String compliance) { - return !isVersionLessThan(compliance, JavaCore.VERSION_1_8); - } - - /** - * Checks if the given project or workspace has source compliance 1.8 or greater. - * - * @param project the project to test or null to test the workspace settings - * @return true if the given project or workspace has source compliance 1.8 or - * greater. - */ - public static boolean is18OrHigher(IJavaProject project) { - String source= project != null ? project.getOption(JavaCore.COMPILER_SOURCE, true) : JavaCore.getOption(JavaCore.COMPILER_SOURCE); - return is18OrHigher(source); - } -// --- - } diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitClasspathFixProcessor.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitClasspathFixProcessor.java index 397827abba0..b8669693a41 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitClasspathFixProcessor.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitClasspathFixProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 IBM Corporation and others. + * Copyright (c) 2007, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -30,7 +30,6 @@ import org.eclipse.jdt.internal.junit.JUnitCorePlugin; import org.eclipse.jdt.internal.junit.buildpath.BuildPathSupport; -import org.eclipse.jdt.internal.junit.util.JUnitStubUtility; import org.eclipse.jdt.ui.ISharedImages; import org.eclipse.jdt.ui.JavaUI; @@ -182,10 +181,10 @@ public ClasspathFixProposal[] getFixImportProposals(IJavaProject project, String } if (res != 0) { ArrayList proposals= new ArrayList<>(); - if ((res & JUNIT5) != 0 && JUnitStubUtility.is18OrHigher(project)) { + if ((res & JUNIT5) != 0) { proposals.add(new JUnitClasspathFixProposal(project, 5, 15)); } - if ((res & JUNIT4) != 0 && JUnitStubUtility.is50OrHigher(project)) { + if ((res & JUNIT4) != 0) { proposals.add(new JUnitClasspathFixProposal(project, 4, 15)); } if ((res & JUNIT3) != 0) { diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.java index 306d679b2f0..f7338c03ac7 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.java @@ -106,10 +106,6 @@ public final class JUnitMessages extends NLS { public static String JUnitLaunchConfigurationTab_error_invalidProjectName; - public static String JUnitLaunchConfigurationTab_error_JDK15_required; - - public static String JUnitLaunchConfigurationTab_error_JDK18_required; - public static String JUnitLaunchConfigurationTab_error_noContainer; public static String JUnitLaunchConfigurationTab_error_notJavaProject; diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties index 8d4e1dcee71..62c63c18d64 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties @@ -182,8 +182,6 @@ JUnitLaunchConfigurationTab_excludetag_empty_error=Enter a tag to exclude JUnitContainerWizardPage_error_title=JUnit Library JUnitContainerWizardPage_combo_label=&JUnit library version: JUnitLaunchConfigurationTab_error_invalidProjectName=''{0}'' is not a valid project name -JUnitLaunchConfigurationTab_error_JDK15_required=JUnit 4 requires a JDK version of 1.5 or higher -JUnitLaunchConfigurationTab_error_JDK18_required=JUnit 5 requires a JDK version of 1.8 or higher JUnitContainerWizardPage_wizard_title=JUnit Library JUnitContainerWizardPage_option_junit3=JUnit 3 JUnitContainerWizardPage_option_junit4=JUnit 4 diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitQuickFixProcessor.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitQuickFixProcessor.java index 5752217a3bb..413e6421229 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitQuickFixProcessor.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitQuickFixProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -60,7 +60,6 @@ import org.eclipse.jdt.internal.junit.JUnitCorePlugin; import org.eclipse.jdt.internal.junit.Messages; import org.eclipse.jdt.internal.junit.util.ExceptionHandler; -import org.eclipse.jdt.internal.junit.util.JUnitStubUtility; import org.eclipse.jdt.ui.CodeStyleConfiguration; import org.eclipse.jdt.ui.ISharedImages; @@ -214,10 +213,6 @@ private ImportRewrite getImportRewrite(CompilationUnit astRoot, String typeToImp } private boolean isInsideJUnit4Test(IInvocationContext context) { - if (!JUnitStubUtility.is50OrHigher(context.getCompilationUnit().getJavaProject())) { - return false; - } - ASTNode node= context.getCoveringNode(); while (node != null && !(node instanceof BodyDeclaration)) { node= node.getParent(); diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/JUnitStubUtility.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/JUnitStubUtility.java index 39cecdec8c7..7df9f495b1e 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/JUnitStubUtility.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/JUnitStubUtility.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -357,22 +357,6 @@ public static boolean isVisible(IMember member, IPackageFragment pack) throws Ja return (pack != null && otherpack != null && pack.getElementName().equals(otherpack.getElementName())); } - public static boolean is50OrHigher(IJavaProject project) { - return CoreTestSearchEngine.is50OrHigher(project); - } - - public static boolean is50OrHigher(String compliance) { - return CoreTestSearchEngine.is50OrHigher(compliance); - } - - public static boolean is18OrHigher(IJavaProject project) { - return CoreTestSearchEngine.is18OrHigher(project); - } - - public static boolean is18OrHigher(String compliance) { - return CoreTestSearchEngine.is18OrHigher(compliance); - } - public static String[] getParameterTypeNamesForSeeTag(IMethod overridden) { try { ASTParser parser= ASTParser.newParser(IASTSharedValues.SHARED_AST_LEVEL); diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/wizards/WizardMessages.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/wizards/WizardMessages.java index e68fbe998fb..f5fc62d1ae3 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/wizards/WizardMessages.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/wizards/WizardMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2022 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -26,13 +26,9 @@ private WizardMessages() { public static String NewTestCaseWizardPageOne__error_junit4NotOnbuildpath; public static String NewTestCaseWizardPageOne__error_junit5NotOnbuildpath; - public static String NewTestCaseWizardPageOne_error_java5required; - public static String NewTestCaseWizardPageOne_error_java8required; public static String NewTestCaseWizardPageOne_junit3_radio_label; public static String NewTestCaseWizardPageOne_junit4_radio_label; public static String NewTestCaseWizardPageOne_junit5_radio_label; - public static String NewTestCaseWizardPageOne_linkedtext_java5required; - public static String NewTestCaseWizardPageOne_linkedtext_java8required; public static String NewTestCaseWizardPageOne_methodStub_setUpBeforeClass; public static String NewTestCaseWizardPageOne_methodStub_tearDownAfterClass; public static String NewTestCaseWizardPageOne_not_yet_implemented_string; diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/wizards/WizardMessages.properties b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/wizards/WizardMessages.properties index 0fb766e0869..dfce186e467 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/wizards/WizardMessages.properties +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/wizards/WizardMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2022 IBM Corporation and others. +# Copyright (c) 2000, 2025 IBM Corporation and others. # # This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 @@ -54,8 +54,6 @@ NewTestCaseWizardPageOne__error_junit5NotOnbuildpath=JUnit 5 library is not on t NewTestCaseWizardPageOne_error_superclass_is_interface=Superclass is an interface. NewTestCaseWizardPageOne_error_superclass_not_implementing_test_interface=Superclass does not implement the ''{0}'' interface. NewTestCaseWizardPageOne_error_superclass_empty=Super class name is empty. -NewTestCaseWizardPageOne_error_java5required=JUnit 4 requires a project with 1.5 compliance or more. -NewTestCaseWizardPageOne_error_java8required=JUnit 5 requires a project with 1.8 compliance or more. NewTestCaseWizardPageOne_error_class_to_test_not_valid=Class under test is not valid. NewTestCaseWizardPageOne_error_class_to_test_not_exist=Class under test does not exist in current project. NewTestCaseWizardPageOne_warning_class_to_test_is_interface=Warning: Class under test ''{0}'' is an interface. @@ -150,8 +148,6 @@ UpdateTestSuite_error=Error occurred UpdateTestSuite_update=Update JUnit Test Suite UpdateTestSuite_could_not_update=The test suite could not be updated -NewTestCaseWizardPageOne_linkedtext_java5required=JUnit 4 requires a Java 5 project. Configure project compliance and the project build path. -NewTestCaseWizardPageOne_linkedtext_java8required=JUnit 5 requires a Java 8 project. Configure project compliance and the project build path. NewTestCaseWizardPageOne_not_yet_implemented_string=Not yet implemented NewTestCaseWizardPageOne_junit3_radio_label=New JUnit &3 test NewTestCaseWizardPageOne_junit4_radio_label=New JUnit &4 test diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java index 197afbb59ad..d94d88ccba0 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -98,14 +98,10 @@ import org.eclipse.jdt.internal.junit.ui.JUnitMessages; import org.eclipse.jdt.internal.junit.ui.JUnitPlugin; import org.eclipse.jdt.internal.junit.util.CoreTestSearchEngine; -import org.eclipse.jdt.internal.junit.util.JUnitStubUtility; import org.eclipse.jdt.internal.junit.util.LayoutUtil; import org.eclipse.jdt.internal.junit.util.TestSearchEngine; -import org.eclipse.jdt.launching.AbstractVMInstall; import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; -import org.eclipse.jdt.launching.IVMInstall; -import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.jdt.ui.IJavaElementSearchConstants; import org.eclipse.jdt.ui.JavaElementComparator; @@ -1000,8 +996,6 @@ private void validatePage() { JUnitPlugin.log(e); } } - - validateTestLoaderJVM(); } private void validateJavaProject(IJavaProject javaProject) { @@ -1025,33 +1019,6 @@ private void validateJavaProject(IJavaProject javaProject) { } - private void validateTestLoaderJVM() { - if (fLaunchConfiguration == null) - return; - - TestKind testKind= getSelectedTestKind(); - if (testKind == null || TestKindRegistry.JUNIT3_TEST_KIND_ID.equals(testKind.getId())) - return; - try { - String path= fLaunchConfiguration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String) null); - if (path != null) { - IVMInstall vm= JavaRuntime.getVMInstall(Path.fromPortableString(path)); - if (vm instanceof AbstractVMInstall) { - String compliance= ((AbstractVMInstall) vm).getJavaVersion(); - if (compliance != null) { - String testKindId= testKind.getId(); - if (TestKindRegistry.JUNIT4_TEST_KIND_ID.equals(testKindId) && !JUnitStubUtility.is50OrHigher(compliance)) { - setErrorMessage(JUnitMessages.JUnitLaunchConfigurationTab_error_JDK15_required); - } else if (TestKindRegistry.JUNIT5_TEST_KIND_ID.equals(testKindId) && !JUnitStubUtility.is18OrHigher(compliance)) { - setErrorMessage(JUnitMessages.JUnitLaunchConfigurationTab_error_JDK18_required); - } - } - } - } - } catch (CoreException e) { - } - } - private void setEnableContainerTestGroup(boolean enabled) { fContainerSearchButton.setEnabled(enabled); fContainerText.setEnabled(enabled); diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/wizards/NewTestCaseWizardPageOne.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/wizards/NewTestCaseWizardPageOne.java index 0bd483eed1d..36488c90abb 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/wizards/NewTestCaseWizardPageOne.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/wizards/NewTestCaseWizardPageOne.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2021 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -293,11 +293,7 @@ public void init(IStructuredSelection selection) { isJunit4= CoreTestSearchEngine.hasJUnit4TestAnnotation(project); if (!isJunit4) { if (!CoreTestSearchEngine.hasTestCaseType(project)) { - if (JUnitStubUtility.is18OrHigher(project)) { - isJunit5= true; - } else if (JUnitStubUtility.is50OrHigher(project)) { - isJunit4= true; - } + isJunit5= true; } } } @@ -708,28 +704,9 @@ private void updateBuildPathMessage() { return; } - String message= null; - IPackageFragmentRoot root= getPackageFragmentRoot(); - if (root != null) { - IJavaProject project= root.getJavaProject(); - if (project.exists()) { - if (fJUnitVersion == JUnitVersion.VERSION_4) { - if (!JUnitStubUtility.is50OrHigher(project)) { - message= WizardMessages.NewTestCaseWizardPageOne_linkedtext_java5required; - } - } else if (fJUnitVersion == JUnitVersion.VERSION_5) { - if (!JUnitStubUtility.is18OrHigher(project)) { - message= WizardMessages.NewTestCaseWizardPageOne_linkedtext_java8required; - } - } - } - } - fLink.setVisible(message != null); - fImage.setVisible(message != null); + fLink.setVisible(false); + fImage.setVisible(false); - if (message != null) { - fLink.setText(message); - } } @@ -1260,20 +1237,12 @@ protected IStatus validateIfJUnitProject() { if (fJUnitVersion != null) { switch (fJUnitVersion) { case VERSION_5: - if (!JUnitStubUtility.is18OrHigher(project)) { - status.setError(WizardMessages.NewTestCaseWizardPageOne_error_java8required); - return status; - } if (project.findType(JUnitCorePlugin.JUNIT5_TESTABLE_ANNOTATION_NAME) == null) { status.setWarning(WizardMessages.NewTestCaseWizardPageOne__error_junit5NotOnbuildpath); return status; } break; case VERSION_4: - if (!JUnitStubUtility.is50OrHigher(project)) { - status.setError(WizardMessages.NewTestCaseWizardPageOne_error_java5required); - return status; - } if (project.findType(JUnitCorePlugin.JUNIT4_ANNOTATION_NAME) == null) { status.setWarning(WizardMessages.NewTestCaseWizardPageOne__error_junit4NotOnbuildpath); return status; diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/wizards/NewTestSuiteWizardPage.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/wizards/NewTestSuiteWizardPage.java index 64333c631d8..11491ecfc23 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/wizards/NewTestSuiteWizardPage.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/wizards/NewTestSuiteWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2022 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -193,7 +193,7 @@ public void init(IStructuredSelection selection) { if (jelem != null && jelem.getElementType() != IJavaElement.JAVA_MODEL) { IJavaProject project= jelem.getJavaProject(); isJunit4= CoreTestSearchEngine.hasJUnit4TestAnnotation(project); - if (!isJunit4 && !CoreTestSearchEngine.hasTestCaseType(project) && JUnitStubUtility.is50OrHigher(project)) { + if (!isJunit4 && !CoreTestSearchEngine.hasTestCaseType(project)) { isJunit4= true; } isJunit5= CoreTestSearchEngine.hasJUnit5TestAnnotation(project); diff --git a/org.eclipse.jdt.ui.unittest.junit/.settings/.api_filters b/org.eclipse.jdt.ui.unittest.junit/.settings/.api_filters index 8aa4826e3e7..e6173530db2 100644 --- a/org.eclipse.jdt.ui.unittest.junit/.settings/.api_filters +++ b/org.eclipse.jdt.ui.unittest.junit/.settings/.api_filters @@ -17,4 +17,18 @@ + + + + + + + + + + + + + + diff --git a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/JUnitTestPlugin.java b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/JUnitTestPlugin.java index 7d7cf509881..39ffbb3ad1c 100644 --- a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/JUnitTestPlugin.java +++ b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/JUnitTestPlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020 Red Hat Inc. and others. + * Copyright (c) 2020, 2025 Red Hat Inc. and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -130,18 +130,14 @@ public Object getService(String serviceName) { public static JUnitVersion getJUnitVersion(IJavaElement element) { if (element != null) { IJavaProject project = element.getJavaProject(); - if (CoreTestSearchEngine.is50OrHigher(project)) { - if (CoreTestSearchEngine.is18OrHigher(project)) { - if (isRunWithJUnitPlatform(element)) { - return JUnitVersion.JUNIT4; - } - if (CoreTestSearchEngine.hasJUnit5TestAnnotation(project)) { - return JUnitVersion.JUNIT5; - } - } - if (CoreTestSearchEngine.hasJUnit4TestAnnotation(project)) { - return JUnitVersion.JUNIT4; - } + if (isRunWithJUnitPlatform(element)) { + return JUnitVersion.JUNIT4; + } + if (CoreTestSearchEngine.hasJUnit5TestAnnotation(project)) { + return JUnitVersion.JUNIT5; + } + if (CoreTestSearchEngine.hasJUnit4TestAnnotation(project)) { + return JUnitVersion.JUNIT4; } } return JUnitVersion.JUNIT3; diff --git a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/JUnitLaunchConfigurationTab.java b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/JUnitLaunchConfigurationTab.java index 895b2e23870..1dc61d43b21 100644 --- a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/JUnitLaunchConfigurationTab.java +++ b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/JUnitLaunchConfigurationTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -23,18 +23,61 @@ import java.util.HashSet; import java.util.Set; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.unittest.ui.ConfigureViewerSupport; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.jface.window.Window; + +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.ElementListSelectionDialog; +import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; +import org.eclipse.ui.dialogs.SelectionDialog; + import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; + import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; + import org.eclipse.jdt.core.IAnnotation; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaModel; @@ -50,6 +93,7 @@ import org.eclipse.jdt.core.dom.Modifier; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; + import org.eclipse.jdt.internal.junit.JUnitCorePlugin; import org.eclipse.jdt.internal.junit.launcher.ITestKind; import org.eclipse.jdt.internal.junit.launcher.JUnitLaunchConfigurationConstants; @@ -58,13 +102,9 @@ import org.eclipse.jdt.internal.junit.util.JUnitStubUtility; import org.eclipse.jdt.internal.junit.util.LayoutUtil; import org.eclipse.jdt.internal.junit.util.TestSearchEngine; -import org.eclipse.jdt.internal.ui.util.SWTUtil; -import org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator; -import org.eclipse.jdt.internal.ui.wizards.TypedViewerFilter; -import org.eclipse.jdt.launching.AbstractVMInstall; + import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; -import org.eclipse.jdt.launching.IVMInstall; -import org.eclipse.jdt.launching.JavaRuntime; + import org.eclipse.jdt.ui.IJavaElementSearchConstants; import org.eclipse.jdt.ui.JavaElementComparator; import org.eclipse.jdt.ui.JavaElementLabelProvider; @@ -76,41 +116,10 @@ import org.eclipse.jdt.ui.unittest.junit.JUnitTestPlugin; import org.eclipse.jdt.ui.unittest.junit.JUnitTestPlugin.JUnitVersion; import org.eclipse.jdt.ui.unittest.junit.ui.BasicElementLabels; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ComboViewer; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ElementListSelectionDialog; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.dialogs.SelectionDialog; -import org.eclipse.unittest.ui.ConfigureViewerSupport; + +import org.eclipse.jdt.internal.ui.util.SWTUtil; +import org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator; +import org.eclipse.jdt.internal.ui.wizards.TypedViewerFilter; /** * The launch configuration tab for JUnit. @@ -988,8 +997,6 @@ private void validatePage() { JUnitTestPlugin.log(e); } } - - validateTestLoaderJVM(); } private void validateJavaProject(IJavaProject javaProject) { @@ -1013,33 +1020,6 @@ private void validateJavaProject(IJavaProject javaProject) { } - private void validateTestLoaderJVM() { - if (fLaunchConfiguration == null) - return; - - JUnitVersion junitVersion = getSelectedJUnitVersion(); - if (junitVersion == null || junitVersion == JUnitVersion.JUNIT3) - return; - try { - String path = fLaunchConfiguration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, - (String) null); - if (path != null) { - IVMInstall vm = JavaRuntime.getVMInstall(Path.fromPortableString(path)); - if (vm instanceof AbstractVMInstall) { - String compliance = ((AbstractVMInstall) vm).getJavaVersion(); - if (compliance != null) { - if (junitVersion == JUnitVersion.JUNIT4 && !JUnitStubUtility.is50OrHigher(compliance)) { - setErrorMessage(Messages.JUnitLaunchConfigurationTab_error_JDK15_required); - } else if (junitVersion == JUnitVersion.JUNIT5 && !JUnitStubUtility.is18OrHigher(compliance)) { - setErrorMessage(Messages.JUnitLaunchConfigurationTab_error_JDK18_required); - } - } - } - } - } catch (CoreException e) { - } - } - private void setEnableContainerTestGroup(boolean enabled) { fContainerSearchButton.setEnabled(enabled); fContainerText.setEnabled(enabled); diff --git a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/JUnitTestKindUtil.java b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/JUnitTestKindUtil.java index dc2f223ebf8..949008da694 100644 --- a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/JUnitTestKindUtil.java +++ b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/JUnitTestKindUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2020 IBM Corporation and others. + * Copyright (c) 2006, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -37,18 +37,14 @@ private JUnitTestKindUtil() { public static String getContainerTestKindId(IJavaElement element) { if (element != null) { IJavaProject project = element.getJavaProject(); - if (CoreTestSearchEngine.is50OrHigher(project)) { - if (CoreTestSearchEngine.is18OrHigher(project)) { - if (isRunWithJUnitPlatform(element)) { - return JUNIT4_TEST_KIND_ID; - } - if (CoreTestSearchEngine.hasJUnit5TestAnnotation(project)) { - return JUNIT5_TEST_KIND_ID; - } - } - if (CoreTestSearchEngine.hasJUnit4TestAnnotation(project)) { - return JUNIT4_TEST_KIND_ID; - } + if (isRunWithJUnitPlatform(element)) { + return JUNIT4_TEST_KIND_ID; + } + if (CoreTestSearchEngine.hasJUnit5TestAnnotation(project)) { + return JUNIT5_TEST_KIND_ID; + } + if (CoreTestSearchEngine.hasJUnit4TestAnnotation(project)) { + return JUNIT4_TEST_KIND_ID; } } return JUNIT3_TEST_KIND_ID; diff --git a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/Messages.java b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/Messages.java index 243734c1b35..76fec0548fc 100644 --- a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/Messages.java +++ b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/Messages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020 Red Hat Inc. and others. + * Copyright (c) 2020,2025 Red Hat Inc. and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -21,10 +21,6 @@ public final class Messages extends NLS { public static String JUnitLaunchConfigurationTab_error_invalidProjectName; - public static String JUnitLaunchConfigurationTab_error_JDK15_required; - - public static String JUnitLaunchConfigurationTab_error_JDK18_required; - public static String JUnitLaunchConfigurationTab_error_noContainer; public static String JUnitLaunchConfigurationTab_error_notJavaProject; diff --git a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/Messages.properties b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/Messages.properties index 768f6a03f6a..ebb262aa961 100644 --- a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/Messages.properties +++ b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/launcher/Messages.properties @@ -1,5 +1,5 @@ ################################################################################# -# Copyright (c) 2020 Red Hat, Inc. +# Copyright (c) 2020, 2025 Red Hat, Inc. # # This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 @@ -74,8 +74,6 @@ JUnitLaunchConfigurationTab_addincludeexcludetagdialog_title=Configure Tags JUnitLaunchConfigurationTab_includetag_empty_error=Enter a tag to include JUnitLaunchConfigurationTab_excludetag_empty_error=Enter a tag to exclude JUnitLaunchConfigurationTab_error_invalidProjectName=''{0}'' is not a valid project name -JUnitLaunchConfigurationTab_error_JDK15_required=JUnit 4 requires a JDK version of 1.5 or higher -JUnitLaunchConfigurationTab_error_JDK18_required=JUnit 5 requires a JDK version of 1.8 or higher JUnitLaunchConfigurationTab_error_noContainer=No project, source folder or package is specified UnitTestLaunchShortcut_dialog_title=JUnit Launch