[jbosstools-commits] JBoss Tools SVN: r22700 - in trunk/cdi/tests/org.jboss.tools.cdi.ui.test: src/org/jboss/tools/cdi/ui/test and 1 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Jun 9 08:13:39 EDT 2010


Author: scabanovich
Date: 2010-06-09 08:13:39 -0400 (Wed, 09 Jun 2010)
New Revision: 22700

Added:
   trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/
   trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java
Modified:
   trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF
   trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java
Log:
https://jira.jboss.org/browse/JBIDE-6414


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	2010-06-09 12:12:18 UTC (rev 22699)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF	2010-06-09 12:13:39 UTC (rev 22700)
@@ -8,10 +8,14 @@
 Require-Bundle: org.junit,
  org.jboss.tools.tests,
  org.jboss.tools.cdi.core.test,
+ org.jboss.tools.cdi.ui,
  org.eclipse.core.resources,
  org.jboss.tools.jst.jsp.test,
  org.jboss.tools.common,
  org.eclipse.core.runtime,
+ org.eclipse.ui,
+ org.eclipse.jface,
  org.eclipse.jface.text;bundle-version="3.5.2",
- org.eclipse.jdt.core;bundle-version="3.5.2"
+ org.eclipse.jdt.core;bundle-version="3.5.2",
+ org.eclipse.jdt.ui
 Export-Package: org.jboss.tools.cdi.ui.test

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	2010-06-09 12:12:18 UTC (rev 22699)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java	2010-06-09 12:13:39 UTC (rev 22700)
@@ -11,6 +11,7 @@
 package org.jboss.tools.cdi.ui.test;
 
 import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.jboss.tools.cdi.ui.test.wizard.NewCDIWizardTest;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -26,6 +27,7 @@
 		
 		TestSuite suite = new TestSuite("CDI UI Tests");
 		suite.addTestSuite(CATest.class);
+		suite.addTestSuite(NewCDIWizardTest.class);
 		return suite;
 	}
 }
\ No newline at end of file

Added: 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	                        (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java	2010-06-09 12:13:39 UTC (rev 22700)
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.ui.test.wizard;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.cdi.ui.CDIUIPlugin;
+import org.jboss.tools.cdi.ui.wizard.NewCDIAnnotationCreationWizard;
+import org.jboss.tools.cdi.ui.wizard.NewCDIAnnotationWizardPage;
+import org.jboss.tools.cdi.ui.wizard.NewQualifierWizardPage;
+import org.jboss.tools.cdi.ui.wizard.NewStereotypeWizardPage;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.test.util.JUnitUtils;
+import org.jboss.tools.test.util.WorkbenchUtils;
+
+/**
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class NewCDIWizardTest extends TestCase {
+	
+	static String PACK_NAME = "test";
+	static String QUALIFIER_NAME = "MyQualifier";
+	static String STEREOTYPE_NAME = "MyStereotype";
+	
+	static class WizardContext {
+		NewCDIAnnotationCreationWizard wizard;
+		IProject tck;
+		IJavaProject jp;
+		WizardDialog dialog;
+		NewCDIAnnotationWizardPage page;
+		String packName;
+		String typeName;
+		
+
+		public void init(String wizardId, String packName, String typeName) {
+			this.packName = packName;
+			this.typeName = typeName;
+			wizard = (NewCDIAnnotationCreationWizard)WorkbenchUtils.findWizardByDefId(wizardId);
+			tck = ResourcesPlugin.getWorkspace().getRoot().getProject("tck");
+			jp = EclipseUtil.getJavaProject(tck);
+			wizard.init(CDIUIPlugin.getDefault().getWorkbench(), new StructuredSelection(jp));
+			dialog = new WizardDialog(
+					PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+					wizard);
+			dialog.setBlockOnOpen(false);
+			dialog.open();
+
+			page = (NewCDIAnnotationWizardPage)dialog.getSelectedPage();
+
+			page.setTypeName(typeName, true);
+			IPackageFragment pack = page.getPackageFragmentRoot().getPackageFragment(PACK_NAME);
+			page.setPackageFragment(pack, true);
+		}
+
+		public String getNewTypeContent() {
+			IType type = null;
+			try {
+				type = jp.findType(packName + "." + typeName);
+			} catch (JavaModelException e) {
+				JUnitUtils.fail("Cannot find type " + typeName, e);
+			}
+			
+			IFile file = (IFile)type.getResource();
+			assertNotNull(file);
+			String text = null;
+			try {
+				text = FileUtil.readStream(file.getContents());
+			} catch (CoreException e) {
+				JUnitUtils.fail("Cannot read from " + file, e);
+			}
+			return text;
+		}
+
+		public void close() {
+			dialog.close();
+		}
+		
+	}
+
+	public void testNewQualifierWizard() {
+		WizardContext context = new WizardContext();
+		context.init("org.jboss.tools.cdi.ui.wizard.NewQualifierCreationWizard",
+				PACK_NAME, QUALIFIER_NAME);
+
+		try {
+			NewQualifierWizardPage page = (NewQualifierWizardPage)context.page;
+			page.setInherited(true);
+			
+			context.wizard.performFinish();
+			
+			String text = context.getNewTypeContent();
+			
+			assertTrue(text.contains("@Qualifier"));
+			assertTrue(text.contains("@Inherited"));
+			assertTrue(text.contains("@Target( { TYPE, METHOD, PARAMETER, FIELD })"));
+			assertTrue(text.contains("@Retention(RUNTIME)"));
+			
+		} finally {
+			context.close();
+		}
+	}
+
+	public void testNewStereotypeWizard() {
+		WizardContext context = new WizardContext();
+		context.init("org.jboss.tools.cdi.ui.wizard.NewStereotypeCreationWizard",
+				PACK_NAME, STEREOTYPE_NAME);
+
+		try {
+			NewStereotypeWizardPage page = (NewStereotypeWizardPage)context.page;
+			page.setInherited(true);
+			page.setTarget("METHOD,FIELD");
+			page.setNamed(true);
+			
+			context.wizard.performFinish();
+			
+			String text = context.getNewTypeContent();
+			
+			assertTrue(text.contains("@Stereotype"));
+			assertTrue(text.contains("@Inherited"));
+			assertTrue(text.contains("@Named"));
+			assertTrue(text.contains("@Target( { METHOD, FIELD })"));
+			assertTrue(text.contains("@Retention(RUNTIME)"));
+			
+		} finally {
+			context.close();
+		}
+
+	}
+
+}
\ No newline at end of file


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



More information about the jbosstools-commits mailing list