Author: akazakov
Date: 2011-11-03 21:43:51 -0400 (Thu, 03 Nov 2011)
New Revision: 36169
Added:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWebProjectWizardTest.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIProjectWizard.java
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
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java
Log:
https://issues.jboss.org/browse/JBIDE-9581 Create vanilla CDI getting started project
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF 2011-11-03 23:31:04 UTC
(rev 36168)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/META-INF/MANIFEST.MF 2011-11-04 01:43:51 UTC
(rev 36169)
@@ -39,6 +39,10 @@
org.eclipse.jst.servlet.ui;bundle-version="1.1.500",
org.eclipse.wst.web.ui;bundle-version="1.1.400",
org.eclipse.jst.j2ee.ui;bundle-version="1.1.500",
+ org.eclipse.wst.common.project.facet.core;bundle-version="1.4.200",
+ org.eclipse.wst.common.frameworks;bundle-version="1.2.100",
+ org.eclipse.jst.jsf.ui;bundle-version="1.3.2",
+ org.eclipse.jst.jsf.core;bundle-version="1.3.5",
org.eclipse.wst.common.frameworks.ui;bundle-version="1.2.100"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIProjectWizard.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIProjectWizard.java 2011-11-03
23:31:04 UTC (rev 36168)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/CDIProjectWizard.java 2011-11-04
01:43:51 UTC (rev 36169)
@@ -39,6 +39,7 @@
private static final String CDI_TEMPALTE = "template.jboss.tools.cdi10";
private IPreset oldPreset;
+ public static final String ID =
"org.jboss.tools.cdi.ui.wizard.NewCDIProjectWizard";
public CDIProjectWizard() {
super();
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-11-03 23:31:04
UTC (rev 36168)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/META-INF/MANIFEST.MF 2011-11-04 01:43:51
UTC (rev 36169)
@@ -25,12 +25,19 @@
org.eclipse.ui.ide,
org.jboss.tools.jst.jsp.base.test,
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.eclipse.search,
+ org.jboss.tools.common.el.core,
org.jboss.tools.jst.web.kb,
- org.eclipse.wst.validation;bundle-version="1.2.300",
+ org.eclipse.wst.validation,
org.jboss.tools.jst.web.kb.test,
org.jboss.tools.common.validation,
org.jboss.tools.jst.jsp,
- org.eclipse.ltk.ui.refactoring;bundle-version="3.6.0"
+ org.eclipse.ltk.ui.refactoring,
+ org.eclipse.wst.web.ui,
+ org.eclipse.wst.common.project.facet.core,
+ org.eclipse.wst.common.project.facet.ui,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.jst.jsf.ui,
+ org.eclipse.jst.jsf.core,
+ org.eclipse.wst.common.frameworks.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 2011-11-03
23:31:04 UTC (rev 36168)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java 2011-11-04
01:43:51 UTC (rev 36169)
@@ -24,6 +24,7 @@
import org.jboss.tools.cdi.ui.test.search.ELReferencesQueryParticipantTest;
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.NewCDIWebProjectWizardTest;
import org.jboss.tools.cdi.ui.test.wizard.NewCDIWizardTest;
import org.jboss.tools.cdi.ui.test.wizard.OpenCDINamedBeanDialogTest;
import org.jboss.tools.test.util.ResourcesUtils;
@@ -51,6 +52,7 @@
suiteAll.addTestSuite(NewCDIClassWizardFactoryTest.class);
suiteAll.addTestSuite(CDIPreferencePageTest.class);
suiteAll.addTestSuite(NewCDIWizardTest.class);
+ suiteAll.addTestSuite(NewCDIWebProjectWizardTest.class);
suite.addTestSuite(CAELProposalFilteringTest.class);
suite.addTestSuite(CDISearchParticipantTest.class);
@@ -61,7 +63,7 @@
suiteAll.addTest(new CDICoreTestSetup(suite));
suiteAll.addTestSuite(AddQualifiersToBeanWizardTest.class);
-
+
suiteAll.addTestSuite(CDIRefactoringTest.class);
return suiteAll;
Added:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWebProjectWizardTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWebProjectWizardTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWebProjectWizardTest.java 2011-11-04
01:43:51 UTC (rev 36169)
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jst.jsf.ui.internal.project.facet.JSFFacetInstallPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.PlatformUI;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
+import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard;
+import org.jboss.tools.cdi.ui.wizard.CDIProjectWizard;
+import org.jboss.tools.test.util.WorkbenchUtils;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class NewCDIWebProjectWizardTest extends TestCase{
+
+ NewProjectDataModelFacetWizard wizard;
+ WizardDialog dialog;
+
+ public NewCDIWebProjectWizardTest() {
+ super("New CDI Web Project tests");
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ wizard =
(NewProjectDataModelFacetWizard)WorkbenchUtils.findWizardByDefId(CDIProjectWizard.ID);
+ dialog = new WizardDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ wizard);
+ dialog.create();
+ dialog.setBlockOnOpen(false);
+ dialog.open();
+ cleanDefferedEvents();
+ }
+
+ private void cleanDefferedEvents() {
+ while (Display.getCurrent().readAndDispatch());
+ }
+
+ public void testCDIProjectNewWizardInstanceIsCreated() {
+ try {
+ IWizardPage startCDIPrjWzPg = wizard.getStartingPage();
+
+ wizard.getDataModel().setStringProperty("IProjectCreationPropertiesNew.PROJECT_NAME",
"testName");
+ assertNotNull("Cannot create start wizard page", startCDIPrjWzPg);
+
+ IWizardPage javaModuleWizPg = wizard.getNextPage(startCDIPrjWzPg);
+ assertNotNull("Cannot create java project wizard page", javaModuleWizPg);
+
+ IWizardPage webModuleWizPg = wizard.getNextPage(javaModuleWizPg);
+ assertNotNull("Cannot create dynamic web project wizard page",
webModuleWizPg);
+
+ IWizardPage cdiWizPg = wizard.getNextPage(webModuleWizPg);
+ assertNotNull("Cannot create cdi facet wizard page", cdiWizPg);
+
+ IWizardPage jsfCapabilitiesWizPg = wizard.getNextPage(cdiWizPg);
+ assertNotNull("Cannot create JSF capabilities wizard page",
jsfCapabilitiesWizPg);
+ } finally {
+ wizard.performCancel();
+ dialog.close();
+ }
+ }
+
+ public void testCDIProjectNewWizardFinisDisableByDefaul() {
+ try {
+ // Disable Library Configuration
+ disableLibraryConfiguration();
+ cleanDefferedEvents();
+
+ boolean canFinish = wizard.canFinish();
+ assertFalse("Finish button is enabled at first wizard page before all requerd
fileds are valid.", canFinish);
+ } finally {
+ wizard.performCancel();
+ dialog.close();
+ }
+ }
+
+ /**
+ * If all fields of all pages are valid then
+ * first page of New CDI Project Wizard must enable Finish button.
+ */
+ public void testCDIProjectNewWizardFinisEnabled() {
+ try {
+ // Disable Library Configuration
+ disableLibraryConfiguration();
+ cleanDefferedEvents();
+
+ // Set project name
+ wizard.getDataModel().setProperty(IFacetDataModelProperties.FACET_PROJECT_NAME,
"testSeamProject");
+ cleanDefferedEvents();
+
+ assertTrue("Finish button is disabled at first wizard page in spite of valid
project name.", wizard.canFinish());
+ } finally {
+ wizard.performCancel();
+ dialog.close();
+ }
+ }
+
+ private void disableLibraryConfiguration(){
+ for(IWizardPage page : wizard.getPages()){
+ if(page instanceof JSFFacetInstallPage){
+ JSFFacetInstallPage jsfPage = (JSFFacetInstallPage)page;
+ Control control = page.getControl();
+ if(control instanceof Composite){
+ processComposite((Composite)control);
+ }
+ }
+ }
+ }
+
+ private void processComposite(Composite parent){
+ for(Control child : parent.getChildren()){
+ if(child instanceof Combo){
+ Combo combo = (Combo)child;
+
+ int index = -1;
+ for(int i=0; i < combo.getItemCount();i++){
+ String item = combo.getItem(i);
+ if("Disable Library Configuration".equals(item)){
+ index = i;
+ break;
+ }
+ }
+ if(index >= 0){
+ combo.select(index);
+ try{
+ Method method = Widget.class.getDeclaredMethod("sendEvent",new
Class[]{int.class});
+ if(method != null){
+ method.setAccessible(true);
+ method.invoke(combo, new Object[]{SWT.Selection});
+ }
+ }catch(NoSuchMethodException ex){
+ ex.printStackTrace();
+ }catch(InvocationTargetException ex){
+ ex.printStackTrace();
+ }catch(IllegalAccessException ex){
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ if(child instanceof Composite)
+ processComposite((Composite)child);
+ }
+ }
+}
\ 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/NewCDIWebProjectWizardTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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-11-03
23:31:04 UTC (rev 36168)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java 2011-11-04
01:43:51 UTC (rev 36169)
@@ -519,5 +519,4 @@
context.close();
}
}
-
}
\ No newline at end of file