diff options
author | Carsten Hammer | 2020-07-18 10:52:54 +0000 |
---|---|---|
committer | Jeff Johnston | 2020-08-05 17:40:28 +0000 |
commit | 194b3d99a1202803784ed439a66db50e7a6aa567 (patch) | |
tree | f63a620c3358f3ac63788a45632bf0d589fe8ff7 | |
parent | f4c06203d6eda015764ab7692f743165cf857220 (diff) | |
download | eclipse.jdt.ui-194b3d99a1202803784ed439a66db50e7a6aa567.tar.gz eclipse.jdt.ui-194b3d99a1202803784ed439a66db50e7a6aa567.tar.xz eclipse.jdt.ui-194b3d99a1202803784ed439a66db50e7a6aa567.zip |
Bug 558313 - update to junit 4
Change-Id: I2ea366af2f294f6ae405d3fca157b78440ccc092
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
11 files changed, 320 insertions, 294 deletions
diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/JdtPerformanceTestCaseCommon.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/JdtPerformanceTestCaseCommon.java new file mode 100644 index 0000000000..e92f4151ff --- /dev/null +++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/JdtPerformanceTestCaseCommon.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * Copyright (c) 2020 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.jdt.ui.tests.performance; + +import org.eclipse.jdt.testplugin.JavaProjectHelper; +import org.eclipse.test.performance.Dimension; +import org.eclipse.test.performance.PerformanceTestCaseJunit4; + +import org.eclipse.swt.widgets.Shell; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.jobs.IJobManager; +import org.eclipse.core.runtime.jobs.Job; + +import org.eclipse.core.resources.ResourcesPlugin; + +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +import org.eclipse.jdt.internal.ui.JavaPlugin; + +public class JdtPerformanceTestCaseCommon extends PerformanceTestCaseJunit4 { + + protected void joinBackgroudActivities() throws CoreException { + // Join Building + boolean interrupted= true; + while (interrupted) { + try { + Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null); + interrupted= false; + } catch (InterruptedException e) { + interrupted= true; + } + } + // Join indexing + JavaProjectHelper.performDummySearch(); + // Join jobs. Maximal wait 1 minute before all jobs have completed + if(!joinJobs(0, 1 * 60 * 1000, 500)) { + JavaPlugin.logErrorMessage("Performance test " + tn.getMethodName() + " started with running background activity"); + } + } + + private static boolean joinJobs(long minTime, long maxTime, long intervalTime) { + long startTime= System.currentTimeMillis() + minTime; + runEventQueue(); + while (System.currentTimeMillis() < startTime) + runEventQueue(intervalTime); + + long endTime= maxTime > 0 && maxTime < Long.MAX_VALUE ? System.currentTimeMillis() + maxTime : Long.MAX_VALUE; + boolean calm= allJobsQuiet(); + while (!calm && System.currentTimeMillis() < endTime) { + runEventQueue(intervalTime); + calm= allJobsQuiet(); + } + return calm; + } + + private static void sleep(int intervalTime) { + try { + Thread.sleep(intervalTime); + } catch (InterruptedException e) { + } + } + + private static boolean allJobsQuiet() { + IJobManager jobManager= Job.getJobManager(); + for (Job job : jobManager.find(null)) { + int state= job.getState(); + if (state == Job.RUNNING || state == Job.WAITING) + return false; + } + return true; + } + + private static void runEventQueue() { + IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) + runEventQueue(window.getShell()); + } + + private static void runEventQueue(Shell shell) { + while (shell.getDisplay().readAndDispatch()) { + // do nothing + } + } + + private static void runEventQueue(long minTime) { + long nextCheck= System.currentTimeMillis() + minTime; + while (System.currentTimeMillis() < nextCheck) { + runEventQueue(); + sleep(1); + } + } + + protected void finishMeasurements() { + stopMeasuring(); + commitMeasurements(); + assertPerformanceInRelativeBand(Dimension.ELAPSED_PROCESS, -100, +10); + } +} diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java index e95a5907e1..a169e522cd 100644 --- a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java +++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -20,10 +20,14 @@ import java.util.List; import java.util.Map; import org.junit.Assert; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExternalResource; +import org.junit.runners.MethodSorters; import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jdt.testplugin.JavaTestPlugin; -import org.eclipse.test.OrderedTestSuite; import org.eclipse.test.performance.Dimension; import org.eclipse.core.runtime.CoreException; @@ -51,7 +55,7 @@ import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.cleanup.CleanUpOptions; import org.eclipse.jdt.ui.cleanup.CleanUpRequirements; import org.eclipse.jdt.ui.cleanup.ICleanUp; -import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase; +import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCaseCommon; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.fix.AbstractCleanUp; @@ -72,22 +76,16 @@ import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager; import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.Profile; import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileStore; -import junit.extensions.TestSetup; -import junit.framework.Test; +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class CleanUpPerfTest extends JdtPerformanceTestCaseCommon { -public class CleanUpPerfTest extends JdtPerformanceTestCase { - - private static class MyTestSetup extends TestSetup { + private static class MyTestSetup extends ExternalResource { public static final String SRC_CONTAINER= "src"; public static IJavaProject fJProject1; - public MyTestSetup(Test test) { - super(test); - } - @Override - protected void setUp() throws Exception { + public void before() throws Throwable { fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin"); Assert.assertNotNull("rt not found", JavaProjectHelper.addRTJar(fJProject1)); File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381); @@ -95,34 +93,18 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { } @Override - protected void tearDown() throws Exception { - if (fJProject1 != null && fJProject1.exists()) - JavaProjectHelper.delete(fJProject1); + public void after() { + try { + if (fJProject1 != null && fJProject1.exists()) + JavaProjectHelper.delete(fJProject1); + } catch (CoreException e) { + e.printStackTrace(); + } } } - public static Test suite() { - return new MyTestSetup(new OrderedTestSuite(CleanUpPerfTest.class, new String[] { - "testNullCleanUp", - "testAllCleanUps", - "testCodeStyleCleanUp", - "testControlStatementsCleanUp", - "testConvertLoopCleanUp", - "testExpressionsCleanUp", - "testJava50CleanUp", - "testStringCleanUp", - "testSortMembersCleanUp", - "testUnnecessaryCodeCleanUp", - "testUnusedCodeCleanUp", - "testVariableDeclarationCleanUp", - "testCodeFormatCleanUp", - "testOrganizeImports", - })); - } - - public static Test setUpTest(Test someTest) { - return new MyTestSetup(someTest); - } + @Rule + public MyTestSetup stup= new MyTestSetup(); private void addAllCUs(CleanUpRefactoring cleanUp, IJavaElement[] children) throws JavaModelException { for (IJavaElement element : children) { @@ -160,6 +142,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { profileStore.writeProfiles(profiles, InstanceScope.INSTANCE); } + @Test public void testNullCleanUp() throws Exception { CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); @@ -177,6 +160,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { doCleanUp(cleanUpRefactoring); } + @Test public void testAllCleanUps() throws Exception { CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); @@ -238,6 +222,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { doCleanUp(cleanUpRefactoring); } + @Test public void testCodeStyleCleanUp() throws Exception { tagAsSummary("Clean Up - Code Style", Dimension.ELAPSED_PROCESS); @@ -263,6 +248,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { doCleanUp(cleanUpRefactoring); } + @Test public void testControlStatementsCleanUp() throws Exception { CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); @@ -280,6 +266,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { doCleanUp(cleanUpRefactoring); } + @Test public void testConvertLoopCleanUp() throws Exception { CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); @@ -296,6 +283,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { doCleanUp(cleanUpRefactoring); } + @Test public void testExpressionsCleanUp() throws Exception { CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); @@ -312,6 +300,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { doCleanUp(cleanUpRefactoring); } + @Test public void testJava50CleanUp() throws Exception { CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); @@ -329,6 +318,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { doCleanUp(cleanUpRefactoring); } + @Test public void testStringCleanUp() throws Exception { CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); @@ -344,6 +334,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { doCleanUp(cleanUpRefactoring); } + @Test public void testSortMembersCleanUp() throws Exception { CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); @@ -360,6 +351,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { doCleanUp(cleanUpRefactoring); } + @Test public void testUnnecessaryCodeCleanUp() throws Exception { CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); @@ -373,6 +365,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { doCleanUp(cleanUpRefactoring); } + @Test public void testUnusedCodeCleanUp() throws Exception { CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); @@ -394,6 +387,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { doCleanUp(cleanUpRefactoring); } + @Test public void testVariableDeclarationCleanUp() throws Exception { CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); @@ -412,6 +406,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { doCleanUp(cleanUpRefactoring); } + @Test public void testCodeFormatCleanUp() throws Exception { CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); @@ -427,6 +422,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase { doCleanUp(cleanUpRefactoring); } + @Test public void testOrganizeImports() throws Exception { CleanUpRefactoring cleanUpRefactoring= new CleanUpRefactoring(); addAllCUs(cleanUpRefactoring, MyTestSetup.fJProject1.getChildren()); diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OpenTypePerfTest.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OpenTypePerfTest.java index 6d54f64611..83dcbcd093 100644 --- a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OpenTypePerfTest.java +++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OpenTypePerfTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,11 +13,15 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.performance.views; -import junit.extensions.TestSetup; -import junit.framework.Test; +import static org.junit.Assert.fail; + +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExternalResource; +import org.junit.runners.MethodSorters; import org.eclipse.jdt.testplugin.util.DisplayHelper; -import org.eclipse.test.OrderedTestSuite; import org.eclipse.test.performance.Dimension; import org.eclipse.test.performance.Performance; @@ -35,71 +39,57 @@ import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.ui.IJavaElementSearchConstants; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.dialogs.TypeSelectionExtension; -import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase; +import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCaseCommon; import org.eclipse.jdt.ui.tests.performance.SWTTestProject; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.util.CoreUtility; -public class OpenTypePerfTest extends JdtPerformanceTestCase { +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class OpenTypePerfTest extends JdtPerformanceTestCaseCommon { private SelectionDialog fOpenTypeDialog; private Shell fShell; - private static class MyTestSetup extends TestSetup { + private static class MyTestSetup extends ExternalResource { private SWTTestProject fTestProject; private boolean fAutoBuilding; - public MyTestSetup(Test test) { - super(test); - } - @Override - protected void setUp() throws Exception { - super.setUp(); + public void before() throws Throwable { fAutoBuilding= CoreUtility.setAutoBuilding(false); fTestProject= new SWTTestProject(); } @Override - protected void tearDown() throws Exception { - fTestProject.delete(); - CoreUtility.setAutoBuilding(fAutoBuilding); - super.tearDown(); + public void after() { + try { + fTestProject.delete(); + CoreUtility.setAutoBuilding(fAutoBuilding); + } catch (Exception e) { + e.printStackTrace(); + } } } - public static Test suite() throws Exception { - OrderedTestSuite testSuite= new OrderedTestSuite( - OpenTypePerfTest.class, - new String[] { - "testColdException", - "testWarmException", - "testWarmException10", - "testWarmS10", - "testWarmOpenSWT", - "testWarmOpenSWTHistory10", - }); - return new MyTestSetup(testSuite); - } + @Rule + public MyTestSetup stup= new MyTestSetup(); - public static Test setUpTest(Test someTest) { - return new MyTestSetup(someTest); - } - - public OpenTypePerfTest(String name) { - super(name); + @Override + public void setUp() throws Exception { + System.out.println("starting " + OpenTypePerfTest.class.getName() + "#" + tn.getMethodName()); + super.setUp(); } @Override - protected void setUp() throws Exception { - System.out.println("starting " + OpenTypePerfTest.class.getName() + "#" + getName()); - super.setUp(); + public void tearDown() throws Exception { + super.tearDown(); } //--- - public void testColdException() throws Exception { + @Test + public void testAColdException() throws Exception { //cold joinBackgroudActivities(); try { @@ -110,7 +100,8 @@ public class OpenTypePerfTest extends JdtPerformanceTestCase { } } - public void testWarmException() throws Exception { + @Test + public void testBWarmException() throws Exception { //warm joinBackgroudActivities(); try { @@ -121,7 +112,8 @@ public class OpenTypePerfTest extends JdtPerformanceTestCase { } } - public void testWarmException10() throws Exception { + @Test + public void testCWarmException10() throws Exception { //warm, repeated joinBackgroudActivities(); try { @@ -134,7 +126,8 @@ public class OpenTypePerfTest extends JdtPerformanceTestCase { } } - public void testWarmS10() throws Exception { + @Test + public void testDWarmS10() throws Exception { //warm, repeated, many matches joinBackgroudActivities(); try { @@ -147,7 +140,8 @@ public class OpenTypePerfTest extends JdtPerformanceTestCase { } } - public void testWarmOpenSWT() throws Exception { + @Test + public void testEWarmOpenSWT() throws Exception { //warm, add SWT to history joinBackgroudActivities(); try { @@ -158,7 +152,8 @@ public class OpenTypePerfTest extends JdtPerformanceTestCase { } } - public void testWarmOpenSWTHistory10() throws Exception { + @Test + public void testFWarmOpenSWTHistory10() throws Exception { //warm, repeated, open SWT from history joinBackgroudActivities(); try { diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OrganizeImportsPerfTest.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OrganizeImportsPerfTest.java index 85246f8024..ff91cb1628 100644 --- a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OrganizeImportsPerfTest.java +++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/OrganizeImportsPerfTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,19 +13,22 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.performance.views; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.util.ArrayList; import java.util.List; -import junit.extensions.TestSetup; -import junit.framework.Test; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExternalResource; import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jdt.testplugin.JavaTestPlugin; -import org.eclipse.test.OrderedTestSuite; import org.eclipse.test.performance.Performance; import org.eclipse.test.performance.PerformanceMeter; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jdt.core.ICompilationUnit; @@ -38,21 +41,17 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.manipulation.OrganizeImportsOperation; import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; -import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase; +import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCaseCommon; -public class OrganizeImportsPerfTest extends JdtPerformanceTestCase { +public class OrganizeImportsPerfTest extends JdtPerformanceTestCaseCommon { - private static class MyTestSetup extends TestSetup { + private static class MyTestSetup extends ExternalResource { public static final String SRC_CONTAINER= "src"; public static IJavaProject fJProject1; - public MyTestSetup(Test test) { - super(test); - } - @Override - protected void setUp() throws Exception { + public void before() throws Throwable { fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin"); assertTrue("rt not found", JavaProjectHelper.addRTJar(fJProject1) != null); File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381); @@ -60,21 +59,19 @@ public class OrganizeImportsPerfTest extends JdtPerformanceTestCase { } @Override - protected void tearDown() throws Exception { - if (fJProject1 != null && fJProject1.exists()) - JavaProjectHelper.delete(fJProject1); + public void after() { + try { + if (fJProject1 != null && fJProject1.exists()) { + JavaProjectHelper.delete(fJProject1); + } + } catch (CoreException e) { + e.printStackTrace(); + } } } - public static Test suite() { - return new MyTestSetup(new OrderedTestSuite(OrganizeImportsPerfTest.class, new String[] { - "testOrganizeImport" - })); - } - - public static Test setUpTest(Test someTest) { - return new MyTestSetup(someTest); - } + @Rule + public MyTestSetup stup= new MyTestSetup(); private void addAllCUs(IJavaElement[] children, List<IJavaElement> result) throws JavaModelException { for (IJavaElement element : children) { @@ -98,6 +95,7 @@ public class OrganizeImportsPerfTest extends JdtPerformanceTestCase { return result; } + @Test public void testOrganizeImport() throws Exception { measure(Performance.getDefault().getNullPerformanceMeter(), 10); measure(fPerformanceMeter, 10); diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerColdPerfTest.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerColdPerfTest.java index f7a8aeb2d2..e0f309703b 100644 --- a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerColdPerfTest.java +++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerColdPerfTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,9 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.performance.views; -import junit.framework.Test; +import org.junit.Test; -import org.eclipse.test.OrderedTestSuite; import org.eclipse.test.performance.Dimension; import org.eclipse.test.performance.Performance; @@ -25,19 +24,9 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; -import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase; +import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCaseCommon; -public class PackageExplorerColdPerfTest extends JdtPerformanceTestCase { - - public static Test suite() { - return new OrderedTestSuite(PackageExplorerColdPerfTest.class, new String[] { - "testOpen" - }); - } - - public PackageExplorerColdPerfTest(String name) { - super(name); - } +public class PackageExplorerColdPerfTest extends JdtPerformanceTestCaseCommon { @Override public final void finishMeasurements() { @@ -51,6 +40,7 @@ public class PackageExplorerColdPerfTest extends JdtPerformanceTestCase { super.startMeasuring(); } + @Test public void testOpen() throws Exception { IWorkbenchWindow activeWorkbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage page= activeWorkbenchWindow.getActivePage(); diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerEmptyPerfTest.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerEmptyPerfTest.java index 5a04a759a3..bce34b7ea4 100644 --- a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerEmptyPerfTest.java +++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerEmptyPerfTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,9 +13,7 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.performance.views; -import junit.framework.Test; - -import org.eclipse.test.OrderedTestSuite; +import org.junit.Test; import org.eclipse.core.resources.ResourcesPlugin; @@ -24,20 +22,11 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase; - -public class PackageExplorerEmptyPerfTest extends JdtPerformanceTestCase { +import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCaseCommon; - public static Test suite() { - return new OrderedTestSuite(PackageExplorerEmptyPerfTest.class, new String[] { - "testOpen" - }); - } - - public PackageExplorerEmptyPerfTest(String name) { - super(name); - } +public class PackageExplorerEmptyPerfTest extends JdtPerformanceTestCaseCommon { + @Test public void testOpen() throws Exception { IWorkbenchWindow activeWorkbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage page= activeWorkbenchWindow.getActivePage(); diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerPerfTest.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerPerfTest.java index f2f4166ccb..cef1b129c1 100644 --- a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerPerfTest.java +++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerPerfTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,16 +14,19 @@ package org.eclipse.jdt.ui.tests.performance.views; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.util.zip.ZipFile; -import junit.extensions.TestSetup; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExternalResource; +import org.junit.runners.MethodSorters; import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jdt.testplugin.JavaTestPlugin; -import org.eclipse.test.OrderedTestSuite; import org.eclipse.core.runtime.CoreException; @@ -44,22 +47,20 @@ import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase; +import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCaseCommon; import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart; -public class PackageExplorerPerfTest extends JdtPerformanceTestCase { +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class PackageExplorerPerfTest extends JdtPerformanceTestCaseCommon { - private static class MyTestSetup extends TestSetup { + private static class MyTestSetup extends ExternalResource { public static final String SRC_CONTAINER= "src"; public static IJavaProject fJProject1; - public MyTestSetup(Test test) { - super(test); - } @Override - protected void setUp() throws Exception { + public void before() throws Throwable { fJProject1= JavaProjectHelper.createJavaProject("Testing", "bin"); // we must make sure that the performance test are compatible to 2.1.3 & 3.0 so use rt13 assertTrue("rt not found", JavaProjectHelper.addRTJar13(fJProject1) != null); @@ -67,29 +68,21 @@ public class PackageExplorerPerfTest extends JdtPerformanceTestCase { JavaProjectHelper.addSourceContainerWithImport(fJProject1, SRC_CONTAINER, junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING); } @Override - protected void tearDown() throws Exception { - if (fJProject1 != null && fJProject1.exists()) - JavaProjectHelper.delete(fJProject1); + public void after() { + try { + if (fJProject1 != null && fJProject1.exists()) + JavaProjectHelper.delete(fJProject1); + } catch (Exception e) { + e.printStackTrace(); + } } } - public static Test suite() { - TestSuite suite= new OrderedTestSuite(PackageExplorerPerfTest.class, new String[] { - "testOpen", "testSelect", "testExpand", - "testRefreshClassFolder" - }); - return new MyTestSetup(suite); - } - - public static Test setUpTest(Test someTest) { - return new MyTestSetup(someTest); - } - - public PackageExplorerPerfTest(String name) { - super(name); - } + @Rule + public MyTestSetup stup= new MyTestSetup(); - public void testOpen() throws Exception { + @Test + public void testAOpen() throws Exception { IWorkbenchWindow activeWorkbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage page= activeWorkbenchWindow.getActivePage(); page.close(); @@ -100,7 +93,8 @@ public class PackageExplorerPerfTest extends JdtPerformanceTestCase { finishMeasurements(); } - public void testSelect() throws Exception { + @Test + public void testBSelect() throws Exception { joinBackgroudActivities(); TreeViewer viewer= getViewer(); StructuredSelection selection= new StructuredSelection(MyTestSetup.fJProject1); @@ -109,7 +103,8 @@ public class PackageExplorerPerfTest extends JdtPerformanceTestCase { finishMeasurements(); } - public void testExpand() throws Exception { + @Test + public void testCExpand() throws Exception { joinBackgroudActivities(); TreeViewer viewer= getViewer(); startMeasuring(); @@ -118,7 +113,8 @@ public class PackageExplorerPerfTest extends JdtPerformanceTestCase { } // test for Bug 311212: [package explorer] Performance problem with refreshing external class folders - public void testRefreshClassFolder() throws Throwable { + @Test + public void testDRefreshClassFolder() throws Throwable { // Import rtstubs a few times. Caveat: Only import class files, but not META-INF. // PackageExplorerContentProvider#processResourceDelta(..) refreshes the parent if a resource changes. // This is not what we want to test. diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWarmPerfTest.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWarmPerfTest.java index 71f37273b2..4dcdc5e13f 100644 --- a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWarmPerfTest.java +++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWarmPerfTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,9 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.performance.views; -import junit.framework.Test; +import org.junit.Test; -import org.eclipse.test.OrderedTestSuite; import org.eclipse.test.performance.Dimension; import org.eclipse.test.performance.Performance; @@ -26,20 +25,11 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase; +import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCaseCommon; -public class PackageExplorerWarmPerfTest extends JdtPerformanceTestCase { - - public static Test suite() { - return new OrderedTestSuite(PackageExplorerWarmPerfTest.class, new String[] { - "testOpen" - }); - } - - public PackageExplorerWarmPerfTest(String name) { - super(name); - } +public class PackageExplorerWarmPerfTest extends JdtPerformanceTestCaseCommon { + @Test public void testOpen() throws Exception { IWorkbenchWindow activeWorkbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage page= activeWorkbenchWindow.getActivePage(); diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspacePerfTest.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspacePerfTest.java index 49e2a28e7d..4e8f05e484 100644 --- a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspacePerfTest.java +++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspacePerfTest.java @@ -14,10 +14,7 @@ package org.eclipse.jdt.ui.tests.performance.views; -import junit.extensions.TestSetup; -import junit.framework.Test; - -import org.eclipse.test.OrderedTestSuite; +import org.junit.Test; import org.eclipse.core.resources.ResourcesPlugin; @@ -26,18 +23,18 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase; - -public class PackageExplorerWorkspacePerfTest extends JdtPerformanceTestCase { +import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCaseCommon; - private static class MyTestSetup extends TestSetup { +public class PackageExplorerWorkspacePerfTest extends JdtPerformanceTestCaseCommon { - public MyTestSetup(Test test) { - super(test); - } - - @Override - protected void setUp() throws Exception { +// private static class MyTestSetup extends TestSetup { +// +// public MyTestSetup(Test test) { +// super(test); +// } +// +// @Override +// protected void setUp() throws Exception { // IJavaModel model= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); // if (model.getJavaProjects().length == 0) { // ExternalModelManager manager= PDECore.getDefault().getExternalModelManager(); @@ -50,28 +47,14 @@ public class PackageExplorerWorkspacePerfTest extends JdtPerformanceTestCase { // }); // ResourcesPlugin.getWorkspace().run(op, new NullProgressMonitor()); // } - } - - @Override - protected void tearDown() throws Exception { - } - } - - public static Test suite() { - OrderedTestSuite suite= new OrderedTestSuite(PackageExplorerWorkspacePerfTest.class, new String[] { - "testOpen" - }); - return new MyTestSetup(suite); - } - - public static Test setUpTest(Test someTest) { - return new MyTestSetup(someTest); - } - - public PackageExplorerWorkspacePerfTest(String name) { - super(name); - } +// } +// +// @Override +// protected void tearDown() throws Exception { +// } +// } + @Test public void testOpen() throws Exception { IWorkbenchWindow activeWorkbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage page= activeWorkbenchWindow.getActivePage(); diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspaceWarmPerfTest.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspaceWarmPerfTest.java index 47727ac08c..996e0a257c 100644 --- a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspaceWarmPerfTest.java +++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/PackageExplorerWorkspaceWarmPerfTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,10 +13,7 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.performance.views; -import junit.extensions.TestSetup; -import junit.framework.Test; - -import org.eclipse.test.OrderedTestSuite; +import org.junit.Test; import org.eclipse.core.resources.ResourcesPlugin; @@ -25,18 +22,18 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase; - -public class PackageExplorerWorkspaceWarmPerfTest extends JdtPerformanceTestCase { +import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCaseCommon; - private static class MyTestSetup extends TestSetup { +public class PackageExplorerWorkspaceWarmPerfTest extends JdtPerformanceTestCaseCommon { - public MyTestSetup(Test test) { - super(test); - } - - @Override - protected void setUp() throws Exception { +// private static class MyTestSetup extends TestSetup { +// +// public MyTestSetup(Test test) { +// super(test); +// } +// +// @Override +// protected void setUp() throws Exception { // IJavaModel model= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); // if (model.getJavaProjects().length == 0) { // ExternalModelManager manager= PDECore.getDefault().getExternalModelManager(); @@ -49,28 +46,14 @@ public class PackageExplorerWorkspaceWarmPerfTest extends JdtPerformanceTestCase // }); // ResourcesPlugin.getWorkspace().run(op, new NullProgressMonitor()); // } - } - - @Override - protected void tearDown() throws Exception { - } - } - - public static Test setUpTest(Test someTest) { - return new MyTestSetup(someTest); - } - - public static Test suite() { - OrderedTestSuite suite= new OrderedTestSuite(PackageExplorerWorkspaceWarmPerfTest.class, new String[] { - "testOpen" - }); - return new MyTestSetup(suite); - } - - public PackageExplorerWorkspaceWarmPerfTest(String name) { - super(name); - } +// } +// +// @Override +// protected void tearDown() throws Exception { +// } +// } + @Test public void testOpen() throws Exception { IWorkbenchWindow activeWorkbenchWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage page= activeWorkbenchWindow.getActivePage(); diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/TypeHierarchyPerfTest.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/TypeHierarchyPerfTest.java index fe6e54d838..40bf40fbf5 100644 --- a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/TypeHierarchyPerfTest.java +++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/TypeHierarchyPerfTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,17 +13,23 @@ *******************************************************************************/ package org.eclipse.jdt.ui.tests.performance.views; +import static org.junit.Assert.assertTrue; + import java.io.File; -import junit.extensions.TestSetup; -import junit.framework.Test; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExternalResource; +import org.junit.runners.MethodSorters; import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jdt.testplugin.JavaTestPlugin; -import org.eclipse.test.OrderedTestSuite; import org.eclipse.test.performance.Dimension; import org.eclipse.test.performance.Performance; +import org.eclipse.core.runtime.CoreException; + import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.ui.IWorkbenchPage; @@ -35,26 +41,23 @@ import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCase; +import org.eclipse.jdt.ui.tests.performance.JdtPerformanceTestCaseCommon; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyViewPart; import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil; -public class TypeHierarchyPerfTest extends JdtPerformanceTestCase { +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TypeHierarchyPerfTest extends JdtPerformanceTestCaseCommon { - private static class MyTestSetup extends TestSetup { + private static class MyTestSetup extends ExternalResource { public static final String SRC_CONTAINER= "src"; public static IJavaProject fJProject1; public static IPackageFragmentRoot fJunitSrcRoot; - public MyTestSetup(Test test) { - super(test); - } - @Override - protected void setUp() throws Exception { + public void before() throws Throwable { fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin"); // we must make sure that the performance test are compatible to 2.1.3 & 3.0 so use rt13 assertTrue("rt not found", JavaProjectHelper.addRTJar13(fJProject1) != null); @@ -63,32 +66,21 @@ public class TypeHierarchyPerfTest extends JdtPerformanceTestCase { } @Override - protected void tearDown() throws Exception { - if (fJProject1 != null && fJProject1.exists()) - JavaProjectHelper.delete(fJProject1); + public void after() { + try { + if (fJProject1 != null && fJProject1.exists()) + JavaProjectHelper.delete(fJProject1); + } catch (CoreException e) { + e.printStackTrace(); + } } } - public static Test suite() { - OrderedTestSuite testSuite= new OrderedTestSuite( - TypeHierarchyPerfTest.class, - new String[] { - "testOpenObjectHierarchy", - "testOpenCollHierarchy", - "testOpenObjectHierarchy2", - }); - return new MyTestSetup(testSuite); - } - - public static Test setUpTest(Test someTest) { - return new MyTestSetup(someTest); - } - - public TypeHierarchyPerfTest(String name) { - super(name); - } + @Rule + public MyTestSetup stup= new MyTestSetup(); - public void testOpenObjectHierarchy() throws Exception { + @Test + public void testAOpenObjectHierarchy() throws Exception { //cold // make sure stuff like the Intro view gets closed and we start with a clean Java perspective: @@ -101,13 +93,15 @@ public class TypeHierarchyPerfTest extends JdtPerformanceTestCase { Performance.getDefault().assertPerformanceInAbsoluteBand(fPerformanceMeter, Dimension.ELAPSED_PROCESS, 0, 2000); } - public void testOpenCollHierarchy() throws Exception { + @Test + public void testBOpenCollHierarchy() throws Exception { //junit source folder measureOpenHierarchy(MyTestSetup.fJunitSrcRoot); Performance.getDefault().assertPerformanceInAbsoluteBand(fPerformanceMeter, Dimension.ELAPSED_PROCESS, 0, 1000); } - public void testOpenObjectHierarchy2() throws Exception { + @Test + public void testCOpenObjectHierarchy2() throws Exception { //warm tagAsSummary("Open type hierarchy on Object", Dimension.ELAPSED_PROCESS); |