[jbosstools-commits] JBoss Tools SVN: r20534 - in trunk/cdi/tests: org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test and 3 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Sat Feb 27 15:40:02 EST 2010


Author: akazakov
Date: 2010-02-27 15:40:00 -0500 (Sat, 27 Feb 2010)
New Revision: 20534

Added:
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSetup.java
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSuite.java
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTestUtil.java
Modified:
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/META-INF/MANIFEST.MF
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/DefinitionTest.java
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
   trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointHyperlinkDetectorTest.java
   trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CATest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5808

Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/META-INF/MANIFEST.MF	2010-02-27 15:15:07 UTC (rev 20533)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/META-INF/MANIFEST.MF	2010-02-27 20:40:00 UTC (rev 20534)
@@ -10,6 +10,8 @@
  org.eclipse.core.resources,
  org.junit,
  org.jboss.tools.cdi.core,
- org.jboss.tools.common
+ org.jboss.tools.common,
+ org.eclipse.ui,
+ org.eclipse.jdt.core
 Export-Package: org.jboss.tools.cdi.core.test,
  org.jboss.tools.cdi.core.test.tck

Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java	2010-02-27 15:15:07 UTC (rev 20533)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java	2010-02-27 20:40:00 UTC (rev 20534)
@@ -13,8 +13,6 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.jboss.tools.cdi.core.test.tck.DefinitionTest;
-import org.jboss.tools.cdi.core.test.tck.ValidationTest;
 import org.jboss.tools.tests.AbstractPluginsLoadTest;
 
 /**
@@ -24,8 +22,7 @@
 
 	public static Test suite() {
 		TestSuite suite = new TestSuite("CDI Core Tests");
-		suite.addTestSuite(DefinitionTest.class);
-		suite.addTestSuite(ValidationTest.class);
+		suite.addTest(new CDICoreTestSetup(CDICoreTestSuite.suite()));
 		return suite;
 	}
 

Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSetup.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSetup.java	                        (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSetup.java	2010-02-27 20:40:00 UTC (rev 20534)
@@ -0,0 +1,45 @@
+/******************************************************************************* 
+ * Copyright (c) 2010 Red Hat, Inc. 
+ * Distributed under license by Red Hat, Inc. All rights reserved. 
+ * This program is made available under the terms of the 
+ * Eclipse Public License v1.0 which accompanies this distribution, 
+ * and is available at http://www.eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors: 
+ * Red Hat, Inc. - initial API and implementation 
+ ******************************************************************************/ 
+package org.jboss.tools.cdi.core.test;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.eclipse.core.resources.IProject;
+import org.jboss.tools.cdi.core.test.tck.TCKTest;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.ResourcesUtils;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class CDICoreTestSetup extends TestSetup {
+
+	protected IProject tckProject; 
+
+	public CDICoreTestSetup(Test test) {
+		super(test);
+	}
+
+	@Override
+	protected void setUp() throws Exception {
+		tckProject = TCKTest.importPreparedProject("/");
+	}
+
+	@Override
+	protected void tearDown() throws Exception {
+		boolean saveAutoBuild = ResourcesUtils.setBuildAutomatically(false);
+		JobUtils.waitForIdle();
+		tckProject.delete(true, true, null);
+		JobUtils.waitForIdle();
+		ResourcesUtils.setBuildAutomatically(saveAutoBuild);
+	}
+}
\ No newline at end of file


Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSetup.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSuite.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSuite.java	                        (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSuite.java	2010-02-27 20:40:00 UTC (rev 20534)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/ 
+package org.jboss.tools.cdi.core.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.tools.cdi.core.test.tck.DefinitionTest;
+import org.jboss.tools.cdi.core.test.tck.ValidationTest;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class CDICoreTestSuite extends TestSuite {
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite("CDI Core Tests");
+		suite.addTestSuite(DefinitionTest.class);
+		suite.addTestSuite(ValidationTest.class);
+		return suite;
+	}
+}
\ No newline at end of file


Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSuite.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/DefinitionTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/DefinitionTest.java	2010-02-27 15:15:07 UTC (rev 20533)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/DefinitionTest.java	2010-02-27 20:40:00 UTC (rev 20534)
@@ -10,22 +10,25 @@
  ******************************************************************************/ 
 package org.jboss.tools.cdi.core.test.tck;
 
-import org.eclipse.core.resources.IProject;
+import java.util.Set;
 
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.cdi.core.IBean;
+
 /**
+ * Section 2 - Concepts
+ *
  * @author Alexey Kazakov
  */
 public class DefinitionTest extends TCKTest {
 
-	protected void setUp() throws Exception {
-		IProject p = importPreparedProject("/definition/qualifier");
+	/**
+	 * a) A bean comprises of a (nonempty) set of bean types.
+	 */
+	public void testBeanTypesNonEmpty() {
+		IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/bean/RedSnapper.java");
+		Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
+		assertEquals("There should be the only bean in org.jboss.jsr299.tck.tests.definition.bean.RedSnapper", 1, beans.size());
+		assertTrue("No legal types were found for org.jboss.jsr299.tck.tests.definition.bean.RedSnapper bean.", beans.iterator().next().getLegalTypes().size() > 0);
 	}
-
-	public void test1() {
-		
-	}
-
-	protected void tearDown() throws Exception {
-		cleanProject("/definition/qualifier");
-	}
 }
\ No newline at end of file

Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java	2010-02-27 15:15:07 UTC (rev 20533)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java	2010-02-27 20:40:00 UTC (rev 20534)
@@ -11,6 +11,8 @@
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.ICDIProject;
 import org.jboss.tools.common.util.FileUtil;
 import org.jboss.tools.test.util.JobUtils;
 import org.jboss.tools.test.util.ResourcesUtils;
@@ -32,7 +34,34 @@
 
 	protected static String TCK_RESOURCES_PREFIX = "/resources/tck";
 
-	public IProject importPreparedProject(String packPath) throws Exception {
+	protected IProject tckProject;
+	protected ICDIProject cdiProject;
+
+	public TCKTest() {
+		tckProject = getTestProject();
+		cdiProject = CDICorePlugin.getCDIProject(tckProject, false);
+	}
+
+	public IProject getTestProject() {
+		if(tckProject==null) {
+			try {
+				tckProject = findTestProject();
+				if(tckProject==null || !tckProject.exists()) {
+					tckProject = importPreparedProject("/");
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				fail("Can't import CDI test project: " + e.getMessage());
+			}
+		}
+		return tckProject;
+	}
+
+	public static IProject findTestProject() {
+		return ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
+	}
+
+	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()) {
@@ -57,28 +86,28 @@
 		return project;
 	}
 
-	class JavaFileFilter implements FileFilter {
+	static class JavaFileFilter implements FileFilter {
 		public boolean accept(File pathname) {
 			String name = pathname.getName();
-			return pathname.isDirectory() || (name.endsWith(".java") && !name.endsWith("Test.java"));
-		}		
+			return (pathname.isDirectory() && !name.endsWith(".svn")) || (name.endsWith(".java") && !name.endsWith("Test.java"));
+		}
 	}
 
-	class XmlFileFilter implements FileFilter {
+	static class XmlFileFilter implements FileFilter {
 		public boolean accept(File pathname) {
 			String name = pathname.getName();
-			return pathname.isDirectory() || name.endsWith(".xml");
+			return (pathname.isDirectory() && !name.endsWith(".svn")) || name.endsWith(".xml");
 		}		
 	}
 
-	class PageFileFilter implements FileFilter {
+	static class PageFileFilter implements FileFilter {
 		public boolean accept(File pathname) {
 			String name = pathname.getName();
-			return pathname.isDirectory() || !name.endsWith(".java") && !name.endsWith(".xml");
+			return (pathname.isDirectory() && !name.endsWith(".svn")) && !name.endsWith(".xml");
 		}		
 	}
 
-	public void cleanProject(String _resourcePath) throws Exception {
+	public static void cleanProject(String _resourcePath) throws Exception {
 		Bundle b = Platform.getBundle(PLUGIN_ID);
 		String projectPath = FileLocator.resolve(b.getEntry(PROJECT_PATH)).getFile();
 		
@@ -108,4 +137,4 @@
 			FileUtil.remove(fs[i]);
 		}
 	}
-}
+}
\ No newline at end of file

Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTestUtil.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTestUtil.java	                        (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTestUtil.java	2010-02-27 20:40:00 UTC (rev 20534)
@@ -0,0 +1,18 @@
+/******************************************************************************* 
+ * Copyright (c) 2010 Red Hat, Inc. 
+ * Distributed under license by Red Hat, Inc. All rights reserved. 
+ * This program is made available under the terms of the 
+ * Eclipse Public License v1.0 which accompanies this distribution, 
+ * and is available at http://www.eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors: 
+ * Red Hat, Inc. - initial API and implementation 
+ ******************************************************************************/ 
+package org.jboss.tools.cdi.core.test.tck;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class TCKTestUtil {
+
+}
\ No newline at end of file


Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTestUtil.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java	2010-02-27 15:15:07 UTC (rev 20533)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java	2010-02-27 20:40:00 UTC (rev 20534)
@@ -11,7 +11,6 @@
 package org.jboss.tools.cdi.core.test.tck;
 
 import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.jboss.tools.tests.AbstractResourceMarkerTest;
 
@@ -21,48 +20,40 @@
 public class ValidationTest extends TCKTest {
 
 	public void testLegalTypesInTyped() throws Exception {
-		IProject p = importPreparedProject("/tests/lookup/typesafe/resolution");
-		IFile petShopFile = p.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/PetShop.java");
+		IFile petShopFile = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/PetShop.java");
 		AbstractResourceMarkerTest.assertMarkerIsCreated(petShopFile, AbstractResourceMarkerTest.MARKER_TYPE, "Bean class or producer method or field specifies a @Typed annotation, and the value member specifies a class which does not correspond to a type in the unrestricted set of bean types of a bean", 25);
 		int markerNumbers = getMarkersNumber(petShopFile);
 		assertEquals("PetShop.java should has the only error marker.", markerNumbers, 1);
-		cleanProject("/lookup/typesafe/resolution");
 	}
 
 	/*
 	 * 	 2.7.1.3. Stereotype declares a non-empty @Named annotation (Non-Portable behavior)
 	 */
 	public void testNonEmptyNamedForStereotype() throws Exception {
-		IProject p = importPreparedProject("/tests/definition/stereotype");
-		IFile file = p.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/stereotype/broken/nonEmptyNamed/StereotypeWithNonEmptyNamed_Broken.java");
+		IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/stereotype/broken/nonEmptyNamed/StereotypeWithNonEmptyNamed_Broken.java");
 		AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, "Stereotype declares a non-empty @Named annotation", 31);
 		int markerNumbers = getMarkersNumber(file);
 		assertEquals("StereotypeWithNonEmptyNamed_Broken.java should has the only error marker.", markerNumbers, 1);
-		cleanProject("/definition/stereotype");
 	}
 
 	/*
 	 * 	 2.7.1.3. Stereotype declares any other qualifier annotation
 	 */
 	public void testAnnotatedStereotype() throws Exception {
-		IProject p = importPreparedProject("/tests/definition/stereotype");
-		IFile file = p.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/stereotype/broken/withBindingType/StereotypeWithBindingTypes_Broken.java");
+		IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/stereotype/broken/withBindingType/StereotypeWithBindingTypes_Broken.java");
 		AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, "Stereotype declares any qualifier annotation other than @Named", 30);
 		int markerNumbers = getMarkersNumber(file);
 		assertEquals("StereotypeWithBindingTypes_Broken.java should has the only error marker.", markerNumbers, 1);
-		cleanProject("/definition/stereotype");
 	}
 
 	/*
 	 * 	 2.7.1.3. Stereotype is annotated @Typed
 	 */
 	public void testTypedStereotype() throws Exception {
-		IProject p = importPreparedProject("/tests/definition/stereotype");
-		IFile file = p.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/stereotype/broken/withBindingType/StereotypeWithTyped_Broken.java");
+		IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/stereotype/broken/withBindingType/StereotypeWithTyped_Broken.java");
 		AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, "Stereotype is annotated @Typed", 15);
 		int markerNumbers = getMarkersNumber(file);
 		assertEquals("StereotypeWithTyped_Broken.java should has the only error marker.", markerNumbers, 1);
-		cleanProject("/definition/stereotype");
 	}
 
 	/*
@@ -70,12 +61,10 @@
 	 *           - stereotype declares more than one scope
 	 */
 	public void testStereotypeScope() throws Exception {
-		IProject p = importPreparedProject("/tests/definition/stereotype");
-		IFile file = p.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/stereotype/broken/tooManyScopes/StereotypeWithTooManyScopeTypes_Broken.java");
+		IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/stereotype/broken/tooManyScopes/StereotypeWithTooManyScopeTypes_Broken.java");
 		AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, "Stereotype declares more than one scope", 32, 33);
 		int markerNumbers = getMarkersNumber(file);
 		assertEquals("StereotypeWithTooManyScopeTypes_Broken.java should has two error markers.", markerNumbers, 2);
-		cleanProject("/definition/stereotype");
 	}
 
 	/*
@@ -83,12 +72,10 @@
 	 *         - bean class or producer method or field specifies multiple scope type annotations
 	 */
 	public void testMultipleBeanScope() throws Exception {
-		IProject p = importPreparedProject("/tests/definition/scope");
-		IFile file = p.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/scope/broken/tooManyScopes/BeanWithTooManyScopeTypes_Broken.java");
+		IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/scope/broken/tooManyScopes/BeanWithTooManyScopeTypes_Broken.java");
 		AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, "Bean class or producer method or field specifies multiple scope type annotations", 22, 23);
 		int markerNumbers = getMarkersNumber(file);
 		assertEquals("StereotypeWithTyped_Broken.java should has two error markers.", markerNumbers, 2);
-		cleanProject("/definition/scope");
 	}
 
 	/*
@@ -97,12 +84,10 @@
 	 *         (there are two different stereotypes declared by the bean that declare different default scopes)
 	 */
 	public void testBeanWithMultipleScopedStereotypes() throws Exception {
-		IProject p = importPreparedProject("/tests/definition/stereotype");
-		IFile file = p.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/stereotype/broken/scopeConflict/Scallop_Broken.java");
+		IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/definition/stereotype/broken/scopeConflict/Scallop_Broken.java");
 		AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, "Bean does not explicitly declare a scope when there is no default scope", 24, 25);
 		int markerNumbers = getMarkersNumber(file);
 		assertEquals("Scallop_Broken.java should has two error markers.", markerNumbers, 2);
-		cleanProject("/definition/stereotype");
 	}
 
 	public static int getMarkersNumber(IResource resource) {

Modified: trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointHyperlinkDetectorTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointHyperlinkDetectorTest.java	2010-02-27 15:15:07 UTC (rev 20533)
+++ trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointHyperlinkDetectorTest.java	2010-02-27 20:40:00 UTC (rev 20534)
@@ -3,6 +3,7 @@
 import java.util.ArrayList;
 
 import junit.framework.Test;
+import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 import org.eclipse.core.resources.IFile;
@@ -32,28 +33,28 @@
 import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
 import org.jboss.tools.common.text.ext.util.AxisUtil;
 
-public class InjectedPointHyperlinkDetectorTest extends TCKTest {
+public class InjectedPointHyperlinkDetectorTest extends TestCase {
 	private static final String PROJECT_NAME = "/tests/lookup/injectionpoint";
 	private static final String FILE_NAME = "JavaSource/org/jboss/jsr299/tck/tests/lookup/injectionpoint/LoggerConsumer.java";
 
 	public static Test suite() {
 		return new TestSuite(InjectedPointHyperlinkDetectorTest.class);
 	}
-	
+
 	public void testInjectedPointHyperlinkDetector()  throws Exception {
-		IProject project = importPreparedProject(PROJECT_NAME);
+		IProject project = TCKTest.importPreparedProject(PROJECT_NAME);
 		doTest(project);
-		cleanProject(PROJECT_NAME);
+		TCKTest.cleanProject(PROJECT_NAME);
 	}
 
 	private void doTest(IProject project) throws Exception {
 		IFile javaFile = project.getFile(FILE_NAME);
 
-		assertTrue("The file \"" + FILE_NAME + "\" is not found", (javaFile != null));
-		assertTrue("The file \"" + FILE_NAME + "\" is not found", (javaFile.exists()));
+		TCKTest.assertTrue("The file \"" + FILE_NAME + "\" is not found", (javaFile != null));
+		TCKTest.assertTrue("The file \"" + FILE_NAME + "\" is not found", (javaFile.exists()));
 
 		FileEditorInput editorInput = new FileEditorInput(javaFile);
-		
+
 		IDocumentProvider documentProvider = null;
 		Throwable exception = null;
 		try {
@@ -74,41 +75,40 @@
 			assertTrue("The document provider is not able to be initialized with the editor input", false);
 		}
 		assertNull("An exception caught: " + (exception != null? exception.getMessage() : ""), exception);
-		
+
 		IDocument document = documentProvider.getDocument(editorInput);
 
 		assertNotNull("The document for the file \"" + FILE_NAME + "\" is not loaded", document);
-		
+
 		InjectedPointHyperlinkDetector elPartitioner = new InjectedPointHyperlinkDetector();
-		
+
 		ArrayList<Region> regionList = new ArrayList<Region>();
 		regionList.add(new Region(115, 6)); // Inject
 		regionList.add(new Region(140, 6)); // logger
 		regionList.add(new Region(196, 6)); // logger
 		regionList.add(new Region(250, 6)); // logger
 
-		
 		IEditorPart part = openFileInEditor(javaFile);
 		ISourceViewer viewer = null;
 		if(part instanceof JavaEditor){
 			viewer = ((JavaEditor)part).getViewer();
 		}
-		
+
 		elPartitioner.setContext(new TestContext((ITextEditor)part));
-		
+
 		int counter = 0;
 		for (int i = 0; i < document.getLength(); i++) {
 			TestData testData = new TestData(document, i);
 			IHyperlink[] links = elPartitioner.detectHyperlinks(viewer, testData.getHyperlinkRegion(), true);
 
 			boolean recognized = links != null;
-			
+
 			if (recognized) {
 				counter++;
 				if(!findOffsetInRegions(i, regionList)){
 					fail("Wrong detection for offset - "+i);
 				}
-			}else{
+			} else {
 				for(Region region : regionList){
 					if(i >= region.getOffset() && i <= region.getOffset()+region.getLength())
 						fail("Wrong detection for region - "+region.getOffset()+" : "+region.getLength()+region.getLength()+" region - "+i);
@@ -117,10 +117,10 @@
 		}
 
 		assertEquals("Wrong recognized region count: ", 28,  counter);
-		
+
 		documentProvider.disconnect(editorInput);
 	}
-	
+
 	private boolean findOffsetInRegions(int offset, ArrayList<Region> regionList){
 		for(Region region : regionList){
 			if(offset >= region.getOffset() && offset <= region.getOffset()+region.getLength())
@@ -128,7 +128,7 @@
 		}
 		return false;
 	}
-	
+
 	private IEditorPart openFileInEditor(IFile input) {
 		if (input != null && input.exists()) {
 			try {
@@ -141,26 +141,26 @@
 		}
 		return null;
 	}
-	
+
 	class TestData {
 		IDocument document;
 		int offset;
 		IRegion region;
 		String contentType;
 		private IHyperlinkRegion hyperlinkRegion = null;
-	
+
 		TestData (IDocument document, int offset) {
 			this.document = document;
 			this.offset = offset;
 			init();
 		}
-		
+
 		private void init() {
 			this.region = getDocumentRegion();
 			this.contentType = getContentType();
 			this.hyperlinkRegion = getHyperlinkRegion();
 		}
-		
+
 		private IRegion getDocumentRegion() {
 			IRegion region = null;
 			try {
@@ -169,11 +169,11 @@
 			
 			return region;
 		}
-		
+
 		public IHyperlinkRegion getHyperlinkRegion() {
 			if (hyperlinkRegion != null)
 				return hyperlinkRegion;
-			
+
 			return new IHyperlinkRegion() {
 		        public String getAxis() {
                     return AxisUtil.getAxis(document, region.getOffset());
@@ -195,8 +195,7 @@
                 }
             };
 		}
-		
-		
+
 		/**
 		 * Returns the content type of document
 		 * 
@@ -222,19 +221,18 @@
 			return type;
 		}
 	}
-	
+
 	class TestContext implements IAdaptable{
 		ITextEditor editor;
-		
+
 		public TestContext(ITextEditor editor){
 			this.editor = editor;
 		}
-		
+
 		public Object getAdapter(Class adapter) {
 			if(adapter.equals(ITextEditor.class))
 				return editor;
 			return null;
 		}
 	}
-
-}
+}
\ No newline at end of file

Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CATest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CATest.java	2010-02-27 15:15:07 UTC (rev 20533)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CATest.java	2010-02-27 20:40:00 UTC (rev 20534)
@@ -12,6 +12,8 @@
 
 import java.io.File;
 
+import junit.framework.TestCase;
+
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.FileLocator;
@@ -26,7 +28,7 @@
 /**
  * @author Alexey Kazakov
  */
-public class CATest extends TCKTest {
+public class CATest extends TestCase {
 
 	private IProject project;
 	private ContentAssistantTestCase caTest = new ContentAssistantTestCase();
@@ -39,7 +41,7 @@
 	public CATest() {
 		super();
 		try {
-			project = importPreparedProject("/tests/lookup");
+			project = TCKTest.importPreparedProject("/tests/lookup");
 			Bundle ui = Platform.getBundle(UI_TEST_PLUGIN_ID);
 			String projectPath = project.getLocation().toString();
 			String resourcePath = FileLocator.resolve(ui.getEntry(RESOURCE_NAME)).getFile();



More information about the jbosstools-commits mailing list