Skip to content

Commit

Permalink
Test adoption for unsupported Java versions
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveeclipse committed Jun 14, 2024
1 parent 1a8a51c commit 64d35b4
Show file tree
Hide file tree
Showing 126 changed files with 2,031 additions and 6,473 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.eclipse.jdt.core.tests.builder.BuilderTests;
import org.eclipse.jdt.core.tests.builder.Problem;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

import com.sun.mirror.apt.AnnotationProcessor;

Expand Down Expand Up @@ -96,7 +97,7 @@ protected IJavaProject getCurrentJavaProject() {
protected IJavaProject createJavaProject(final String projectName )
throws Exception
{
IPath projectPath = env.addProject( projectName, "1.5" );
IPath projectPath = env.addProject( projectName, CompilerOptions.getFirstSupportedJavaVersion() );
env.addExternalJars( projectPath, Util.getJavaClassLibs() );
// remove old package fragment root so that names don't collide
env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

public class AnnotationValueConversionTests extends APTTestBase
{
Expand Down Expand Up @@ -67,7 +68,7 @@ private IProject setupTest() throws Exception
{
ProcessorTestStatus.reset();
// project will be deleted by super-class's tearDown() method
IPath projectPath = env.addProject( getUniqueProjectName(), "1.5" ); //$NON-NLS-1$
IPath projectPath = env.addProject( getUniqueProjectName(), CompilerOptions.getFirstSupportedJavaVersion() ); //$NON-NLS-1$
env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$
env.addExternalJars( projectPath, Util.getJavaClassLibs() );
fullBuild( projectPath );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

public class AptBuilderTests extends APTTestBase
{
Expand All @@ -53,7 +54,7 @@ public void setUp() throws Exception
// project will be deleted by super-class's tearDown() method
// create a project with a src directory as the project root directory
//
IPath projectPath = env.addProject( getProjectName_ProjectRootAsSrcDir(), "1.5" );
IPath projectPath = env.addProject( getProjectName_ProjectRootAsSrcDir(), CompilerOptions.getFirstSupportedJavaVersion() );
env.addExternalJars( projectPath, Util.getJavaClassLibs() );
fullBuild( projectPath );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.WorkingCopyOwner;
import org.eclipse.jdt.core.tests.model.ModifyingResourceTests;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

public class AptReconcileTests extends ModifyingResourceTests
{
Expand Down Expand Up @@ -490,8 +491,8 @@ public void setUp() throws Exception
this._problemRequestor = new ProblemRequestor();

final IJavaProject project = createJavaProject( _testProject,
new String[] { "src" }, new String[] { "JCL15_LIB" },
"bin", "1.5" );
new String[] { "src" }, new String[] { "JCL18_LIB" },
"bin", CompilerOptions.getFirstSupportedJavaVersion() );
TestUtil.createAndAddAnnotationJar(project);
AptConfig.setEnabled(project, true);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.jdt.apt.tests.annotations.mirrortest.CodeExample;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

public class MirrorTests extends APTTestBase {

Expand Down Expand Up @@ -66,7 +67,7 @@ public void testMirror() throws Exception {

public void testTypeParmaterAPI() throws Exception{
final String projName = MirrorTests.class.getName() + "TypeParameter.Project"; //$NON-NLS-1$
IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
IPath projectPath = env.addProject( projName, CompilerOptions.getFirstSupportedJavaVersion() ); //$NON-NLS-1$
env.addExternalJars( projectPath, Util.getJavaClassLibs() );

env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.tests.builder.BuilderTests;
import org.eclipse.jdt.core.tests.builder.Problem;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

import junit.framework.Test;
import junit.framework.TestSuite;
Expand Down Expand Up @@ -75,7 +76,7 @@ public void setUp() throws Exception
}

// project will be deleted by super-class's tearDown() method
projectPath = env.addProject( "org.eclipse.jdt.core", "1.4" ); //$NON-NLS-1$ //$NON-NLS-2$
projectPath = env.addProject( "org.eclipse.jdt.core", CompilerOptions.getFirstSupportedJavaVersion() ); //$NON-NLS-1$ //$NON-NLS-2$

System.out.println("Performing full build..."); //$NON-NLS-1$
fullBuild( projectPath );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

public class PreferencesTests extends APTTestBase {

Expand Down Expand Up @@ -264,7 +265,7 @@ public void testGenSrcDir() throws Exception {
public void testConfigGenSrcDir() throws Exception {

final String projectName = "ConfigTestProj";
IPath projectPath = env.addProject( projectName, "1.5" );
IPath projectPath = env.addProject( projectName, CompilerOptions.getFirstSupportedJavaVersion() );
env.addExternalJars( projectPath, Util.getJavaClassLibs() );
final IJavaProject javaProj = env.getJavaProject(projectName);
// APT is not enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.tests.builder.BuilderTests;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

/**
* This test the dom layer of annotation support. No APT involved.
Expand Down Expand Up @@ -138,7 +139,7 @@ private void addAllSources()
private IProject setupTest() throws Exception
{
// project will be deleted by super-class's tearDown() method
IPath projectPath = env.addProject( getUniqueProjectName(), "1.5" ); //$NON-NLS-1$
IPath projectPath = env.addProject( getUniqueProjectName(), CompilerOptions.getFirstSupportedJavaVersion() ); //$NON-NLS-1$
env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$
env.addExternalJars( projectPath, Util.getJavaClassLibs() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.jdt.apt.core.util.IFactoryPath;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

public class RegressionTests extends APTTestBase {

Expand All @@ -53,7 +54,7 @@ public void testBugzilla104032() throws Exception
{
// set up project with unique name
final String projName = RegressionTests.class.getName() + "104032.Project"; //$NON-NLS-1$
IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
IPath projectPath = env.addProject( projName, CompilerOptions.getFirstSupportedJavaVersion() ); //$NON-NLS-1$
env.addExternalJars( projectPath, Util.getJavaClassLibs() );

env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$
Expand Down Expand Up @@ -99,7 +100,7 @@ public void testBugzilla104032() throws Exception
public void testBugzilla106541() throws Exception
{
final String projName = RegressionTests.class.getName() + "104032.Project"; //$NON-NLS-1$
IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
IPath projectPath = env.addProject( projName, "1.8" ); //$NON-NLS-1$
env.addExternalJars( projectPath, Util.getJavaClassLibs() );

env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$
Expand Down Expand Up @@ -131,7 +132,7 @@ public void testBugzilla106541() throws Exception
// doesn't work because of a jdt.core type system universe problem.
public void testBugzilla120255() throws Exception{
final String projName = RegressionTests.class.getName() + "120255.Project"; //$NON-NLS-1$
IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
IPath projectPath = env.addProject( projName, "1.8" ); //$NON-NLS-1$
env.addExternalJars( projectPath, Util.getJavaClassLibs() );

env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$
Expand Down Expand Up @@ -175,7 +176,7 @@ public void testBugzilla120255() throws Exception{
*/
public void testBugzilla206591A() throws Exception {
final String projName = RegressionTests.class.getName() + "206591.Project"; //$NON-NLS-1$
IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
IPath projectPath = env.addProject( projName, "1.8" ); //$NON-NLS-1$
env.addExternalJars( projectPath, Util.getJavaClassLibs() );

env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$
Expand Down Expand Up @@ -244,7 +245,7 @@ public void testBugzilla206591A() throws Exception {
*/
public void testBugzilla206591B() throws Exception {
final String projName = RegressionTests.class.getName() + "206591.Project"; //$NON-NLS-1$
IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
IPath projectPath = env.addProject( projName, "1.8" ); //$NON-NLS-1$
env.addExternalJars( projectPath, Util.getJavaClassLibs() );

env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$
Expand Down Expand Up @@ -298,7 +299,7 @@ public void testBugzilla206591B() throws Exception {
public void testBugzilla423254() throws Exception {
final String projName = RegressionTests.class.getName()
+ "423254.Project"; //$NON-NLS-1$
IPath projectPath = env.addProject(projName, "1.5"); //$NON-NLS-1$
IPath projectPath = env.addProject(projName, "1.8"); //$NON-NLS-1$
env.addExternalJars(projectPath, Util.getJavaClassLibs());

env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.jdt.apt.core.util.AptConfig;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

/**
*
Expand Down Expand Up @@ -61,7 +62,7 @@ public void testGeneratingLotsOfFiles() throws Exception

// set up project with unique name
final String projName = ScalingTests.class.getName() + "LotsOfFilesProject"; //$NON-NLS-1$
IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
IPath projectPath = env.addProject( projName, CompilerOptions.getFirstSupportedJavaVersion() ); //$NON-NLS-1$
env.addExternalJars( projectPath, Util.getJavaClassLibs() );

env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

/**
* Tests for processors that return '*' from getSupportedAnnotations
Expand All @@ -57,7 +58,7 @@ public void setUp() throws Exception
// project will be deleted by super-class's tearDown() method
// create a project with a src directory as the project root directory
//
IPath projectPath = env.addProject( getProjectName_ProjectRootAsSrcDir(), "1.5" );
IPath projectPath = env.addProject( getProjectName_ProjectRootAsSrcDir(), CompilerOptions.getFirstSupportedJavaVersion());
env.addExternalJars( projectPath, Util.getJavaClassLibs() );
fullBuild( projectPath );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public static Test suite()
suite.addTest(MirrorDeclarationTests.suite());
suite.addTest(MirrorUtilTests.suite());
suite.addTest(AnnotationValueConversionTests.suite());
suite.addTest(JavaVersionTests.suite());
suite.addTest(RegressionTests.suite());
suite.addTest(FileGenerationTests.suite());
suite.addTest(MixedModeTesting.suite());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
import javax.tools.StandardLocation;

import org.eclipse.jdt.internal.compiler.batch.Main;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

import junit.framework.Test;

Expand All @@ -57,7 +57,7 @@ public CompilerInvocationTests(String name) {
super(name);
}
public static Test suite() {
return buildUniqueComplianceTestSuite(CompilerInvocationTests.class, ClassFileConstants.JDK1_8);
return buildUniqueComplianceTestSuite(CompilerInvocationTests.class, CompilerOptions.getFirstSupportedJdkLevel());
}
public static Class<CompilerInvocationTests> testClass() {
return CompilerInvocationTests.class;
Expand All @@ -81,7 +81,7 @@ protected void checkClassFiles(String[] fileNames) {
fail("IO exception for file " + fileNames[i]);
}
assertNotNull("Could not read " + fileNames[i], reader);
assertEquals("Wrong Java version for " + fileNames[i], ClassFileConstants.JDK1_8, reader.getVersion());
assertEquals("Wrong Java version for " + fileNames[i], CompilerOptions.getFirstSupportedJdkLevel(), reader.getVersion());
}
}
void runTest(
Expand Down
Loading

0 comments on commit 64d35b4

Please sign in to comment.