Author: dgolovin
Date: 2011-08-03 21:03:43 -0400 (Wed, 03 Aug 2011)
New Revision: 33578
Added:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/TCKUITest.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/pom.xml
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIMarkerResolutionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/CDISearchParticipantTest.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java
Log:
performance fix for CDI UI tests:
1. manual build process without waiting
2. Incremental validation on demand inside main thread
3. 4+ times faster than previous version
4. Stable execution time because of all removed waiting cycles
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF 2011-08-04 01:01:20
UTC (rev 33577)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF 2011-08-04 01:03:43
UTC (rev 33578)
@@ -27,5 +27,6 @@
org.eclipse.ltk.core.refactoring,
org.eclipse.search;bundle-version="3.7.0",
org.jboss.tools.common.el.core;bundle-version="3.3.0",
- org.jboss.tools.jst.web.kb
+ org.jboss.tools.jst.web.kb,
+ org.eclipse.wst.validation;bundle-version="1.2.300"
Export-Package: org.jboss.tools.cdi.ui.test
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/pom.xml
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/pom.xml 2011-08-04 01:01:20 UTC (rev
33577)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/pom.xml 2011-08-04 01:03:43 UTC (rev
33578)
@@ -22,6 +22,7 @@
<groupId>org.sonatype.tycho</groupId>
<artifactId>maven-osgi-test-plugin</artifactId>
<configuration>
+ <product>org.jboss.tools.tests.product</product>
<explodedBundles>
<bundle>org.jboss.tools.cdi.core.test</bundle>
</explodedBundles>
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java 2011-08-04
01:01:20 UTC (rev 33577)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java 2011-08-04
01:03:43 UTC (rev 33578)
@@ -13,9 +13,23 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.apache.xerces.impl.validation.ValidationManager;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
+import org.eclipse.jst.jsp.core.internal.contentproperties.JSPFContentPropertiesManager;
import org.eclipse.jst.jsp.core.internal.java.search.JSPIndexManager;
+import org.eclipse.jst.jsp.core.internal.taglib.TaglibHelperManager;
+import org.eclipse.jst.jsp.core.taglib.TaglibIndex;
+import org.eclipse.wst.sse.core.internal.validate.ValidationMessage;
+import org.eclipse.wst.validation.ValidationFramework;
import org.jboss.tools.cdi.core.test.CDICoreTestSetup;
+import org.jboss.tools.cdi.core.test.tck.TCKTest;
import org.jboss.tools.cdi.ui.test.marker.CDIMarkerResolutionTest;
import org.jboss.tools.cdi.ui.test.perspective.CDIPerspectiveTest;
import org.jboss.tools.cdi.ui.test.preferences.CDIPreferencePageTest;
@@ -23,6 +37,8 @@
import org.jboss.tools.cdi.ui.test.wizard.AddQualifiersToBeanWizardTest;
import org.jboss.tools.cdi.ui.test.wizard.NewCDIClassWizardFactoryTest;
import org.jboss.tools.cdi.ui.test.wizard.NewCDIWizardTest;
+import org.jboss.tools.test.util.ResourcesUtils;
+import org.jboss.tools.test.util.WorkbenchUtils;
/**
* @author Alexey Kazakov
@@ -32,28 +48,50 @@
public static Test suite() {
// it could be done here because it is not needed to be enabled back
JavaModelManager.getIndexManager().shutdown();
+
+ new Job("Shutodwn what is not needed") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ JSPIndexManager.getDefault().stop();
+ } catch (InterruptedException e) {
+ // print it and ignore it
+ e.printStackTrace();
+ }
+ JSPFContentPropertiesManager.shutdown();
+ JavaCore.removeElementChangedListener(TaglibHelperManager.getInstance());
+ TaglibController.shutdown();
+ TaglibIndex.shutdown();
+ return Status.OK_STATUS;
+ }
+ }.schedule(3000);
try {
- JSPIndexManager.getDefault().stop();
- } catch (InterruptedException e) {
- // print it and ignore it
+ ResourcesUtils.setBuildAutomatically(false);
+ ValidationFramework.getDefault().suspendAllValidation(true);
+ } catch (CoreException e) {
e.printStackTrace();
}
-
TestSuite suiteAll = new TestSuite("CDI UI Tests");
+ TestSuite suite = new TestSuite("TCK Tests");
- TestSuite suite = new TestSuite("TCK Tests");
- suite.addTestSuite(CDISearchParticipantTest.class);
suiteAll.addTestSuite(CDIMarkerResolutionTest.class);
-
-
+
suiteAll.addTestSuite(CDIPerspectiveTest.class);
suiteAll.addTestSuite(NewCDIClassWizardFactoryTest.class);
suiteAll.addTestSuite(CDIPreferencePageTest.class);
suiteAll.addTestSuite(NewCDIWizardTest.class);
suiteAll.addTestSuite(CATest.class);
- suiteAll.addTest(new CDICoreTestSetup(suite));
+ suite.addTestSuite(CDISearchParticipantTest.class);
+ suiteAll.addTest(new CDICoreTestSetup(suite) {
+ @Override
+ protected void setUp() throws Exception {
+ tckProject = TCKUITest.importPreparedProject("/");
+ }
+ }
+ );
+
suiteAll.addTestSuite(AddQualifiersToBeanWizardTest.class);
return suiteAll;
Added:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/TCKUITest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/TCKUITest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/TCKUITest.java 2011-08-04
01:03:43 UTC (rev 33578)
@@ -0,0 +1,70 @@
+package org.jboss.tools.cdi.ui.test;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.tools.cdi.core.test.tck.TCKTest;
+import org.jboss.tools.cdi.core.test.tck.TCKTest.JavaFileFilter;
+import org.jboss.tools.cdi.core.test.tck.TCKTest.PageFileFilter;
+import org.jboss.tools.cdi.core.test.tck.TCKTest.XmlFileFilter;
+import org.jboss.tools.cdi.core.test.tck.validation.CoreValidationTest;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.java.IParametedType;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.jst.jsp.test.TestUtil;
+import org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager;
+import org.jboss.tools.test.util.ResourcesUtils;
+import org.osgi.framework.Bundle;
+
+public class TCKUITest extends TCKTest {
+ public IProject getTestProject() {
+ try {
+ if(tckProject==null) {
+ tckProject = findTestProject();
+ if(tckProject==null || !tckProject.exists()) {
+ ValidatorManager.setStatus(CoreValidationTest.VALIDATION_STATUS);
+ tckProject = importPreparedProject("/");
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Can't import CDI test project: " + e.getMessage());
+ }
+
+ return tckProject;
+ }
+
+ public static IProject importPreparedProject(String packPath) throws Exception {
+ Bundle b = Platform.getBundle(PLUGIN_ID);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
+ if(project==null || !project.exists()) {
+ project = ResourcesUtils.importProject(b, PROJECT_PATH);
+ }
+ String projectPath = project.getLocation().toOSString();
+ String resourcePath = FileLocator.resolve(b.getEntry(TCK_RESOURCES_PREFIX)).getFile();
+
+ File from = new File(resourcePath + packPath);
+ if(from.isDirectory()) {
+ File javaSourceTo = new File(projectPath + JAVA_SOURCE_SUFFIX + PACKAGE + packPath);
+ FileUtil.copyDir(from, javaSourceTo, true, true, true, new JavaFileFilter());
+
+ File webContentTo = new File(projectPath + WEB_CONTENT_SUFFIX);
+ FileUtil.copyDir(from, webContentTo, true, true, true, new PageFileFilter());
+
+ File webInfTo = new File(projectPath + WEB_CONTENT_SUFFIX + WEB_INF_SUFFIX);
+ FileUtil.copyDir(from, webInfTo, true, true, true, new XmlFileFilter());
+ }
+ project.build(IncrementalProjectBuilder.CLEAN_BUILD,null);
+ project.build(IncrementalProjectBuilder.FULL_BUILD,null);
+ TestUtil._waitForValidation(project);
+
+ return project;
+ }
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/TCKUITest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIMarkerResolutionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIMarkerResolutionTest.java 2011-08-04
01:01:20 UTC (rev 33577)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIMarkerResolutionTest.java 2011-08-04
01:03:43 UTC (rev 33578)
@@ -40,6 +40,7 @@
import org.jboss.tools.cdi.ui.marker.MakeMethodBusinessMarkerResolution;
import org.jboss.tools.cdi.ui.marker.MakeMethodPublicMarkerResolution;
import org.jboss.tools.cdi.ui.marker.TestableResolutionWithRefactoringProcessor;
+import org.jboss.tools.cdi.ui.test.TCKUITest;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager;
@@ -48,7 +49,7 @@
* @author Daniel Azarov
*
*/
-public class CDIMarkerResolutionTest extends ValidationTest {
+public class CDIMarkerResolutionTest extends TCKUITest {
private void checkResolution(IProject project, String[] fileNames, String markerType,
String idName, int id, Class<? extends IMarkerResolution> resolutionClass) throws
CoreException {
checkResolution(project, fileNames, new String[]{}, markerType, idName, id,
resolutionClass);
@@ -59,9 +60,8 @@
assertTrue("File - "+file.getFullPath()+" must be
exist",file.exists());
- ValidatorManager.setStatus("TESTING");
copyFiles(project, fileNames);
- TestUtil.waitForValidation();
+ TestUtil.validate(file);
try{
file = project.getFile(fileNames[0]);
@@ -80,8 +80,6 @@
IMarkerResolution resolution = resolutions[j];
if (resolution.getClass().equals(resolutionClass)) {
- ValidatorManager.setStatus("TESTING");
-
if(resolution instanceof TestableResolutionWithRefactoringProcessor){
RefactoringProcessor processor =
((TestableResolutionWithRefactoringProcessor)resolution).getRefactoringProcessor();
@@ -110,7 +108,7 @@
resolution.run(marker);
}
- TestUtil.waitForValidation();
+ TestUtil.validate(file);
file = project.getFile(fileNames[0]);
IMarker[] newMarkers = file.findMarkers(markerType,
true, IResource.DEPTH_INFINITE);
@@ -129,7 +127,7 @@
fail("Problem marker with id: "+id+" not found");
}finally{
restoreFiles(project, fileNames);
- TestUtil.waitForValidation();
+ TestUtil.validate(file);
}
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/CDISearchParticipantTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/CDISearchParticipantTest.java 2011-08-04
01:01:20 UTC (rev 33577)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/CDISearchParticipantTest.java 2011-08-04
01:03:43 UTC (rev 33578)
@@ -30,9 +30,10 @@
import org.jboss.tools.cdi.ui.search.CDIBeanQueryParticipant;
import org.jboss.tools.cdi.ui.search.CDIMatch;
import org.jboss.tools.cdi.ui.search.InjectionPointQueryParticipant;
+import org.jboss.tools.cdi.ui.test.TCKUITest;
import org.jboss.tools.common.EclipseUtil;
-public class CDISearchParticipantTest extends TCKTest {
+public class CDISearchParticipantTest extends TCKUITest {
private static final int FIELD_SEARCH = 1;
private static final int METHOD_SEARCH = 2;
private static final int TYPE_SEARCH = 3;
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java 2011-08-04
01:01:20 UTC (rev 33577)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java 2011-08-04
01:03:43 UTC (rev 33578)
@@ -224,7 +224,11 @@
WizardContext context = new WizardContext();
context.init("org.jboss.tools.cdi.ui.wizard.NewStereotypeCreationWizard",
PACK_NAME, STEREOTYPE2_NAME);
- JobUtils.waitForIdle(2000);
+ try {
+ context.tck.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
ICDIProject cdi = CDICorePlugin.getCDIProject(context.tck, true);
IStereotype s = cdi.getStereotype(PACK_NAME + "." + STEREOTYPE_NAME);
IStereotype d = cdi.getStereotype(CDIConstants.DECORATOR_STEREOTYPE_TYPE_NAME);
@@ -309,8 +313,8 @@
WizardContext context = new WizardContext();
context.init("org.jboss.tools.cdi.ui.wizard.NewInterceptorBindingCreationWizard",
PACK_NAME, INTERCEPTOR_BINDING2_NAME);
- JobUtils.waitForIdle(2000);
+
try {
NewInterceptorBindingWizardPage page = (NewInterceptorBindingWizardPage)context.page;
ICDIProject cdi = CDICorePlugin.getCDIProject(context.tck, true);
@@ -342,8 +346,8 @@
public void testNewInterceptorWizard() {
WizardContext context = new WizardContext();
context.init("org.jboss.tools.cdi.ui.wizard.NewInterceptorCreationWizard",
- PACK_NAME, INTERCEPTOR_NAME);JobUtils.waitForIdle(2000);
- JobUtils.waitForIdle(2000);
+ PACK_NAME, INTERCEPTOR_NAME);
+
ICDIProject cdi = CDICorePlugin.getCDIProject(context.tck, true);
ICDIAnnotation a = cdi.getInterceptorBinding(PACK_NAME + "." +
INTERCEPTOR_BINDING_NAME);
@@ -373,8 +377,8 @@
public void testNewDecoratorWizard() {
WizardContext context = new WizardContext();
context.init("org.jboss.tools.cdi.ui.wizard.NewDecoratorCreationWizard",
- PACK_NAME, DECORATOR_NAME);JobUtils.waitForIdle(2000);
- JobUtils.waitForIdle(2000);
+ PACK_NAME, DECORATOR_NAME);
+
ICDIProject cdi = CDICorePlugin.getCDIProject(context.tck, true);
try {
@@ -399,8 +403,8 @@
public void testNewBeanWizard() throws Exception {
WizardContext context = new WizardContext();
context.init("org.jboss.tools.cdi.ui.wizard.NewBeanCreationWizard",
- PACK_NAME, BEAN_NAME);JobUtils.waitForIdle(2000);
- JobUtils.waitForIdle(2000);
+ PACK_NAME, BEAN_NAME);
+
ICDIProject cdi = CDICorePlugin.getCDIProject(context.tck, true);
try {
@@ -439,8 +443,8 @@
public void testNewAnnotationLiteralWizard() {
WizardContext context = new WizardContext();
context.init("org.jboss.tools.cdi.ui.wizard.NewAnnotationLiteralCreationWizard",
- PACK_NAME, QUALIFIER_NAME + "Literal");JobUtils.waitForIdle(2000);
- JobUtils.waitForIdle(2000);
+ PACK_NAME, QUALIFIER_NAME + "Literal");
+
ICDIProject cdi = CDICorePlugin.getCDIProject(context.tck, true);
try {
@@ -462,8 +466,8 @@
public void testNewAnnotationLiteralWizardWithMembers() {
WizardContext context = new WizardContext();
context.init("org.jboss.tools.cdi.ui.wizard.NewAnnotationLiteralCreationWizard",
- PACK_NAME, "NewLiteral");JobUtils.waitForIdle(2000);
- JobUtils.waitForIdle(2000);
+ PACK_NAME, "NewLiteral");
+
ICDIProject cdi = CDICorePlugin.getCDIProject(context.tck, true);
try {
@@ -486,7 +490,6 @@
public void testNewBeansXMLWizard() throws CoreException {
NewBeansXMLWizardContext context = new NewBeansXMLWizardContext();
context.init("org.jboss.tools.cdi.ui.wizard.NewBeansXMLCreationWizard");
- JobUtils.waitForIdle(2000);
try {