Author: vpakan(a)redhat.com
Date: 2011-11-28 11:11:30 -0500 (Mon, 28 Nov 2011)
New Revision: 36702
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AbstractFacesConfigEditingTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTestJSF2.java
Removed:
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/DndSupport.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAllBotTests.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTest.java
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
Log:
Added test of faces-config.xml file editing within JSF2 project
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAllBotTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAllBotTests.java 2011-11-28
15:48:05 UTC (rev 36701)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAllBotTests.java 2011-11-28
16:11:30 UTC (rev 36702)
@@ -14,6 +14,7 @@
import org.jboss.tools.jsf.ui.bot.test.smoke.CreateNewJSFProjectTest;
import org.jboss.tools.jsf.ui.bot.test.smoke.FacesConfigCodeCompletionTest;
import org.jboss.tools.jsf.ui.bot.test.smoke.FacesConfigEditingTest;
+import org.jboss.tools.jsf.ui.bot.test.smoke.FacesConfigEditingTestJSF2;
import org.jboss.tools.jsf.ui.bot.test.smoke.MarkersTest;
import org.jboss.tools.jsf.ui.bot.test.smoke.OpenOnTest;
import org.jboss.tools.jsf.ui.bot.test.smoke.WebXmlEditorTest;
@@ -47,6 +48,7 @@
OpenOnTest.class,
CodeCompletionTest.class,
FacesConfigEditingTest.class,
+ FacesConfigEditingTestJSF2.class,
FacesConfigCodeCompletionTest.class,
MarkersTest.class,
WebXmlEditorTest.class,
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AbstractFacesConfigEditingTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AbstractFacesConfigEditingTest.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AbstractFacesConfigEditingTest.java 2011-11-28
16:11:30 UTC (rev 36702)
@@ -0,0 +1,565 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.ui.bot.test.smoke;
+
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefViewer;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.jsf.ui.bot.test.JSFAutoTestCase;
+import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorBot;
+import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorPartMatcher;
+import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorUtil;
+import org.jboss.tools.ui.bot.ext.Assertions;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+import org.jboss.tools.ui.bot.ext.helper.DragAndDropHelper;
+import org.jboss.tools.ui.bot.ext.parts.SWTBotEditorExt;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.ui.bot.ext.view.ProblemsView;
+/** Parent test for editing of faces-config.xml file
+ * @author Vladimir Pakan
+ *
+ */
+public abstract class AbstractFacesConfigEditingTest extends JSFAutoTestCase{
+
+ protected static final String FACES_CONFIG_FILE_NAME = "faces-config.xml";
+ private SWTBotEditor facesConfigEditor;
+ private String originalContent;
+ private SWTBotEditorExt facesConfigEditorExt;
+ private SWTBotExt botExt;
+ private SWTBotGefEditPart gefObjectAddedViaViewTool = null;
+ private SWTBotGefEditPart gefObjectAddedViaDnDTool = null;
+ private SWTBotGefViewer gefViewer = null;
+ private String testProjectName = null;
+
+ protected static enum TestProjectType {
+ JSF,
+ JSF2;
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ eclipse.closeAllEditors();
+ intializeTestProject();
+ facesConfigEditor = getFacesConfigEditor();
+ testProjectName = getTestProjectName();
+ originalContent = facesConfigEditor.toTextEditor().getText();
+ facesConfigEditorExt = new
SWTBotEditorExt(facesConfigEditor.toTextEditor().getReference(),bot);
+ botExt = new SWTBotExt();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ if (gefViewer != null){
+ if (gefObjectAddedViaViewTool != null){
+ gefObjectAddedViaViewTool.click();
+ bot.sleep(Timing.time1S());
+ gefViewer.clickContextMenu(IDELabel.Menu.DELETE);
+ confirmViewDelete();
+ bot.sleep(Timing.time1S());
+ }
+ if (gefObjectAddedViaDnDTool != null){
+ gefObjectAddedViaDnDTool.click();
+ bot.sleep(Timing.time1S());
+ gefViewer.clickContextMenu(IDELabel.Menu.DELETE);
+ confirmViewDelete();
+ bot.sleep(Timing.time1S());
+ }
+ }
+ if (facesConfigEditor != null) {
+ facesConfigEditor.toTextEditor().setText(originalContent);
+ facesConfigEditor.saveAndClose();
+ bot.sleep(Timing.time1S());
+ }
+ super.tearDown();
+ }
+ /**
+ * Test Managed Bean editing
+ */
+ public void testManagedBean(){
+ facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.TREE_TAB_LABEL);
+ SWTBot editorBot = facesConfigEditorExt.bot();
+ SWTBotTree tree = editorBot.tree();
+ final String managedBeanName = "TestBean";
+ final String managedBeanClass = "TestBeanClass";
+ SWTBotTreeItem tiFacesConfigXml =
tree.expandNode(AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ SWTBotTreeItem tiManagedbean =
tiFacesConfigXml.getNode(IDELabel.FacesConfigEditor.MANAGED_BEANS_NODE);
+ tiManagedbean.select();
+ bot.sleep(Timing.time1S());
+ // Add managed bean
+ editorBot.button(IDELabel.Button.ADD).click();
+
bot.shell(AbstractFacesConfigEditingTest.getAddManagedBeanDialogTitle(getTestProjectType())).activate();
+ bot.textWithLabel(IDELabel.FacesConfigEditor.NEW_MANAGED_BEAN_CLASS_LABEL)
+ .setText(managedBeanClass);
+ bot.textWithLabel(IDELabel.FacesConfigEditor.NEW_MANAGED_BEAN_NAME_LABEL)
+ .setText(managedBeanName);
+ bot.button(IDELabel.Button.FINISH).click();
+ facesConfigEditorExt.save();
+ bot.sleep(Timing.time1S());
+ assertFacesConfigXmlHasNoErrors(botExt);
+ final String selectedNode = tree.selection().get(0,0);
+ assertTrue ("Selected node has to have label '" + managedBeanName
+"'\n" +
+ "but has '" + selectedNode + "'.",
+ selectedNode.equals(managedBeanName));
+ Assertions.assertFileExistsInWorkspace(managedBeanClass + ".java",
+ testProjectName,"JavaSource");
+
Assertions.assertSourceEditorContains(stripXMLSourceText(facesConfigEditorExt.getText()),
+ "<managed-bean><managed-bean-name>" + managedBeanName +
"</managed-bean-name>" +
+ "<managed-bean-class>" + managedBeanClass +
"</managed-bean-class>" +
+
"<managed-bean-scope>request</managed-bean-scope></managed-bean>",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ // Modify Managed Bean
+ editorBot.textWithLabel(IDELabel.FacesConfigEditor.MANAGED_BEAN_CLASS_LABEL)
+ .setText(managedBeanClass + "xxqq");
+ facesConfigEditorExt.save();
+ bot.sleep(Timing.time1S());
+ if (getCheckForExistingManagedBeanClass()){
+ assertFacesConfigXmlHasErrors(botExt);
+ }
+ editorBot.textWithLabel(IDELabel.FacesConfigEditor.MANAGED_BEAN_CLASS_LABEL)
+ .setText(managedBeanClass);
+ facesConfigEditorExt.save();
+ bot.sleep(Timing.time1S());
+ // Delete Managed Bean
+ tiManagedbean.select();
+ editorBot.table().select(managedBeanName);
+ editorBot.button(IDELabel.Button.REMOVE_WITH_DOTS).click();
+ bot.shell(IDELabel.Shell.CONFIRMATION).activate();
+ bot.checkBox(IDELabel.FacesConfigEditor.DELETE_JAVA_SOURCE_CHECK_BOX).select();
+ bot.button(IDELabel.Button.OK).click();
+ boolean managedBeanWasDeleted = false;
+ try{
+ editorBot.table().select(managedBeanName);
+ } catch (WidgetNotFoundException wnfe){
+ managedBeanWasDeleted = true;
+ } catch (IllegalArgumentException iae){
+ managedBeanWasDeleted = true;
+ }
+ assertTrue("Managed bean " + managedBeanName + " was not deleted
properly.",
+ managedBeanWasDeleted);
+ Assertions.assertFileNotExistsInWorkspace(managedBeanClass + ".java",
+ testProjectName,"JavaSource");
+ Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
+ "<managed-bean-name>" + managedBeanName +
"</managed-bean-name>",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
+ "<managed-bean-class>" + managedBeanClass +
"</managed-bean-class>",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ }
+ /**
+ * Tests Component editing
+ */
+ public void testComponent (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.COMPONENTS_NODE,
+ IDELabel.Shell.ADD_COMPONENT,
+ IDELabel.FacesConfigEditor.NEW_COMPONENT_TYPE_LABEL,
+ "TestComponentType",
+ IDELabel.FacesConfigEditor.NEW_COMPONENT_CLASS_LABEL,
+ "TestComponentClass",
+ "component",
+ "component-type",
+ "component-class",
+ true);
+ }
+ /**
+ * Tests Converter editing
+ */
+ public void testConverter (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.CONVERTERS_NODE,
+ IDELabel.Shell.ADD_CONVERTER,
+ IDELabel.FacesConfigEditor.NEW_CONVERTER_ID_LABEL,
+ "TestConverterID",
+ IDELabel.FacesConfigEditor.NEW_CONVERTER_CLASS_LABEL,
+ "TestConverterClass",
+ "converter",
+ "converter-id",
+ "converter-class",
+ true);
+ }
+ /**
+ * Tests Referenced Bean editing
+ */
+ public void testReferencedBean (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.REFERENCED_BEAN_NODE,
+ IDELabel.Shell.ADD_REFERENCED_BEAN,
+ IDELabel.FacesConfigEditor.NEW_REFERENCED_BEAN_NAME_LABEL,
+ "TestReferencedBeanName",
+ IDELabel.FacesConfigEditor.NEW_REFERENCED_BEAN_CLASS_LABEL,
+ "TestReferencedBeanClass",
+ "referenced-bean",
+ "referenced-bean-name",
+ "referenced-bean-class",
+ true);
+ }
+ /**
+ * Tests Render Kit editing
+ */
+ public void testRenderKit (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.RENDER_KITS_NODE,
+ AbstractFacesConfigEditingTest.getAddRenderKitDialogTitle(getTestProjectType()),
+ IDELabel.FacesConfigEditor.NEW_RENDER_KIT_ID_LABEL,
+ "TestRenderKitID",
+ IDELabel.FacesConfigEditor.NEW_RENDER_KIT_CLASS_LABEL,
+ "TestRenderKitClass",
+ "render-kit",
+ "render-kit-id",
+ "render-kit-class",
+ false);
+ }
+ /**
+ * Tests Validator editing
+ */
+ public void testValidator (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.VALIDATOR_NODE,
+ IDELabel.Shell.ADD_VALIDATOR,
+ IDELabel.FacesConfigEditor.NEW_VALIDATOR_ID_LABEL,
+ "TestValidatorID",
+ IDELabel.FacesConfigEditor.NEW_VALIDATOR_CLASS_LABEL,
+ "TestValidatorClass",
+ "validator",
+ "validator-id",
+ "validator-class",
+ false);
+ }
+ /**
+ * Asserts if faces-config.xml has no errors
+ * @param botExt
+ */
+ protected static void assertFacesConfigXmlHasNoErrors (SWTBotExt botExt){
+
+ SWTBotTreeItem[] errors = ProblemsView.getFilteredErrorsTreeItems(botExt, null, null,
AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME, null);
+ boolean areThereNoErrors = ((errors == null) || (errors.length == 0));
+ assertTrue("There are errors in Problems view: " +
+ (areThereNoErrors ? "" : errors[0].getText()),
+ areThereNoErrors);
+ }
+ /**
+ * Asserts if faces-config.xml has errors
+ * @param botExt
+ */
+ protected static void assertFacesConfigXmlHasErrors (SWTBotExt botExt){
+
+ SWTBotTreeItem[] errors = ProblemsView.getFilteredErrorsTreeItems(botExt, null, null,
AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME, null);
+ boolean areThereErrors = ((errors != null) && (errors.length > 0));
+ assertTrue("There are missing errors in Problems view for " +
AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME + " file.",
+ areThereErrors);
+ }
+ /**
+ * Check editing of particular tree node within Face Config Editor Tree
+ * @param treeNodeLabel
+ * @param addWizardTitle
+ * @param nameTextLabel
+ * @param typeTextValue
+ * @param classTextLabel
+ * @param classTextValue
+ * @param xmlNodeName
+ * @param nameXmlNodeName
+ * @param classXmlNodeName
+ * @param checkForValdiationErrors
+ */
+ protected void checkFacesConfigNodeEditing(String treeNodeLabel,
+ String addWizardTitle,
+ String nameTextLabel,
+ String typeTextValue,
+ String classTextLabel,
+ String classTextValue,
+ String xmlNodeName,
+ String nameXmlNodeName,
+ String classXmlNodeName,
+ boolean checkForValdiationErrors){
+
+ facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.TREE_TAB_LABEL);
+ SWTBot editorBot = facesConfigEditorExt.bot();
+ SWTBotTree tree = editorBot.tree();
+ SWTBotTreeItem tiFacesConfigXml =
tree.expandNode(AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ SWTBotTreeItem tiNodeToCheck = tiFacesConfigXml.getNode(treeNodeLabel);
+ tiNodeToCheck.select();
+ bot.sleep(Timing.time1S());
+ // Add Node
+ editorBot.button(IDELabel.Button.ADD).click();
+ bot.shell(addWizardTitle).activate();
+ bot.textWithLabel(nameTextLabel).setText(typeTextValue);
+ bot.textWithLabel(classTextLabel).setText(classTextValue);
+ bot.button(IDELabel.Button.FINISH).click();
+ facesConfigEditorExt.save();
+ bot.sleep(Timing.time1S());
+ if (checkForValdiationErrors){
+ assertFacesConfigXmlHasErrors(botExt);
+ }
+ final String selectedNode = tree.selection().get(0,0);
+ assertTrue ("Selected node has to have label '" + typeTextValue
+"'\n" +
+ "but has '" + selectedNode + "'.",
+ selectedNode.equals(typeTextValue));
+
Assertions.assertSourceEditorContains(stripXMLSourceText(facesConfigEditorExt.getText()),
+ "<" + xmlNodeName + ">" +
+ "<" + nameXmlNodeName + ">" + typeTextValue +
"</" + nameXmlNodeName +">" +
+ "<" + classXmlNodeName + ">" + classTextValue +
"</" + classXmlNodeName +">" +
+ "</" + xmlNodeName + ">",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ // Delete Node
+ tiNodeToCheck.select();
+ editorBot.table().select(typeTextValue);
+ editorBot.button(IDELabel.Button.REMOVE_WITH_DOTS).click();
+ bot.shell(IDELabel.Shell.CONFIRMATION).activate();
+ bot.button(IDELabel.Button.OK).click();
+ boolean nodeWasDeleted = false;
+ try{
+ editorBot.table().select(typeTextValue);
+ } catch (WidgetNotFoundException wnfe){
+ nodeWasDeleted = true;
+ } catch (IllegalArgumentException iae){
+ nodeWasDeleted = true;
+ }
+ assertTrue(typeTextValue + " was not deleted properly.",
+ nodeWasDeleted);
+ Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
+ "<" + nameXmlNodeName + ">" + typeTextValue +
"</" + nameXmlNodeName +">",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
+ "<" + classXmlNodeName + ">" + classTextValue +
"</" + classXmlNodeName +">",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ }
+ /**
+ * Test editing via Diagram tab
+ */
+ public void testDiagramEditing(){
+ final int verticalSpacing = 100;
+ facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.DIAGRAM_TAB_LABEL);
+ final FacesConfigGefEditorBot gefEditorBot = new
FacesConfigGefEditorBot(facesConfigEditorExt.getReference());
+ gefViewer = gefEditorBot.getViewer();
+ SWTBotGefEditPart mainPart = gefViewer.mainEditPart();
+ // add View to diagram via pallete tool
+ gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_VIEW_TEMPLATE_TOOL);
+ SWTBotGefEditPart gefObjectPart = mainPart.descendants(
+ new
FacesConfigGefEditorPartMatcher(AbstractFacesConfigEditingTest.getInputNamePageName(getTestProjectType()))).get(0);
+ gefViewer.click(FacesConfigGefEditorUtil.getGefPartPosition(gefObjectPart).x,
+ FacesConfigGefEditorUtil.getGefPartPosition(gefObjectPart).y + verticalSpacing);
+ final String viewAddedViaToolName = "addedViaTool";
+ handleNewViewWizard(viewAddedViaToolName +
+ AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()));
+ bot.sleep(Timing.time3S());
+ facesConfigEditor.save();
+ bot.sleep(Timing.time3S());
+ assertFacesConfigXmlHasNoErrors(botExt);
+ Assertions.assertFileExistsInWorkspace(viewAddedViaToolName +
+ AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()),
+ getTestProjectName(),
+ "WebContent");
+ gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_CREATE_NEW_CONNECTION_TOOL);
+ gefObjectPart.click();
+ bot.sleep(Timing.time1S());
+ gefObjectAddedViaViewTool = mainPart.descendants(new
FacesConfigGefEditorPartMatcher("/" + viewAddedViaToolName +
+
AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()))).get(0);
+ gefObjectAddedViaViewTool.click();
+ bot.sleep(Timing.time1S());
+ facesConfigEditor.save();
+ bot.sleep(Timing.time3S());
+
Assertions.assertSourceEditorContains(AbstractFacesConfigEditingTest.stripXMLSourceText(facesConfigEditorExt.getText()),
+ "<navigation-case><from-outcome>" + viewAddedViaToolName +
+ "</from-outcome><to-view-id>/" + viewAddedViaToolName +
+ AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()) +
+ "</to-view-id></navigation-case>",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ // add View to Diagram via D'n'D
+ final String dndPageName = "testDnDPage";
+ createTestPage(dndPageName +
+ AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()));
+ facesConfigEditor.show();
+ facesConfigEditor.setFocus();
+ SWTBotTreeItem tiPage =
SWTEclipseExt.selectTreeLocation(open.viewOpen(ActionItem.View.JBossToolsWebWebProjects.LABEL).bot(),
+ getTestProjectName(),
+ "WebContent",
+ "pages",
+ dndPageName +
AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()));
+ DragAndDropHelper.dnd((TreeItem)tiPage.widget, (FigureCanvas)
gefEditorBot.getControl());
+ facesConfigEditor.save();
+ bot.sleep(Timing.time3S());
+ assertFacesConfigXmlHasNoErrors(botExt);
+ gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_CREATE_NEW_CONNECTION_TOOL);
+ gefObjectPart.click();
+ bot.sleep(Timing.time1S());
+ gefObjectAddedViaDnDTool = mainPart.descendants(new
FacesConfigGefEditorPartMatcher("/pages/" + dndPageName +
+
AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()))).get(0);
+ gefObjectAddedViaDnDTool.click();
+ bot.sleep(Timing.time1S());
+
gefViewer.click(FacesConfigGefEditorUtil.getGefPartPosition(gefObjectAddedViaDnDTool).x,
+ FacesConfigGefEditorUtil.getGefPartPosition(gefObjectAddedViaDnDTool).y +
verticalSpacing);
+ gefViewer.clickContextMenu(IDELabel.Menu.AUTO_LAYOUT);
+ bot.shell(IDELabel.Shell.AUTO_LAYOUT).activate();
+ bot.button(IDELabel.Button.OK).click();
+ facesConfigEditor.save();
+ bot.sleep(Timing.time3S());
+
Assertions.assertSourceEditorContains(AbstractFacesConfigEditingTest.stripXMLSourceText(facesConfigEditorExt.getText()),
+ "<navigation-case><from-outcome>" + dndPageName +
+ "</from-outcome><to-view-id>/pages/" + dndPageName +
+ AbstractFacesConfigEditingTest.getNewPagesExtension(getTestProjectType()) +
+ "</to-view-id></navigation-case>",
+ AbstractFacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ }
+ /**
+ * Handle adding new View
+ * @param fromViewID
+ */
+ protected void handleNewViewWizard(String fromViewID){
+ SWTBot dialogBot = bot.shell(IDELabel.Shell.NEW_VIEW).activate().bot();
+ dialogBot.textWithLabel(IDELabel.NewViewDialog.FROM_VIEW_ID_TEXT_LABEL)
+ .setText(fromViewID);
+ dialogBot.checkBox(IDELabel.NewViewDialog.CREATE_FILE_ON_DISK_CHECKBOX_LABEL)
+ .select();
+ dialogBot.button(IDELabel.Button.FINISH).click();
+
+ }
+ /**
+ * Returns XNL Source striped from spaces, tabs and EOL
+ *
+ * @return String
+ */
+ protected static String stripXMLSourceText(String editorText) {
+ return editorText.replaceAll("\n", "").replaceAll("\t",
"")
+ .replaceAll("\b", "").replaceAll(" ",
"").replaceAll("\r", "")
+ .replaceAll("\f", "");
+ }
+ /**
+ * Confirm deletion of View from Diagram Editor
+ */
+ protected void confirmViewDelete(){
+ bot.shell(IDELabel.Shell.CONFIRMATION).activate();
+ bot.checkBox(IDELabel.FacesConfigEditor.DELETE_FILE_FROM_DISK_CHECK_BOX).select();
+ bot.button(IDELabel.Button.OK).click();
+ }
+ /**
+ * Returns proper Add Managed Bean Dialog Title
+ * @param testProjectType
+ * @return
+ */
+ private static String getAddManagedBeanDialogTitle(TestProjectType testProjectType){
+ String result;
+ if (testProjectType.equals(TestProjectType.JSF)){
+ result = IDELabel.Shell.NEW_MANAGED_BEAN;
+ }
+ else if (testProjectType.equals(TestProjectType.JSF2)){
+ result = IDELabel.Shell.NEW_MANAGED_BEAN_JSF2;
+ }
+ else {
+ throw new IllegalArgumentException("Not supported TestProjectType " +
testProjectType);
+ }
+
+ return result;
+
+ }
+ /**
+ * Returns proper Add Render Kit Dialog Title
+ * @param testProjectType
+ * @return
+ */
+ private static String getAddRenderKitDialogTitle(TestProjectType testProjectType){
+ String result;
+ if (testProjectType.equals(TestProjectType.JSF)){
+ result = IDELabel.Shell.ADD_RENDER_KIT;
+ }
+ else if (testProjectType.equals(TestProjectType.JSF2)){
+ result = IDELabel.Shell.ADD_RENDER_KIT_JSF2;
+ }
+ else {
+ throw new IllegalArgumentException("Not supported TestProjectType " +
testProjectType);
+ }
+
+ return result;
+
+ }
+ /**
+ * Returns proper Input Name Page Name
+ * @param testProjectType
+ * @return
+ */
+ private static String getInputNamePageName(TestProjectType testProjectType){
+ String result;
+ if (testProjectType.equals(TestProjectType.JSF)){
+ result = "/pages/inputUserName.jsp";
+ }
+ else if (testProjectType.equals(TestProjectType.JSF2)){
+ result = "/pages/inputname.xhtml";
+ }
+ else {
+ throw new IllegalArgumentException("Not supported TestProjectType " +
testProjectType);
+ }
+
+ return result;
+
+ }
+ /**
+ * Returns proper Extension for new Web Pages
+ * @param testProjectType
+ * @return
+ */
+ private static String getNewPagesExtension(TestProjectType testProjectType){
+ String result;
+ if (testProjectType.equals(TestProjectType.JSF)){
+ result = ".jsp";
+ }
+ else if (testProjectType.equals(TestProjectType.JSF2)){
+ result = ".xhtml";
+ }
+ else {
+ throw new IllegalArgumentException("Not supported TestProjectType " +
testProjectType);
+ }
+
+ return result;
+
+ }
+
+ private void createTestPage (String testPageName){
+ if (testPageName.endsWith(".jsp")){
+ createJspPage(testPageName, getTestProjectName(), "WebContent",
"pages");
+ }
+ else if (testPageName.endsWith(".xhtml")){
+ createXhtmlPage(testPageName, getTestProjectName(), "WebContent",
"pages");
+ }
+ else {
+ throw new IllegalArgumentException("Not supported Test Page Extension when
creating page " + testPageName);
+ }
+ }
+ /**
+ * Returns current SWTBotEditor
+ * @return
+ */
+ protected abstract SWTBotEditor getFacesConfigEditor();
+ /**
+ * Returns Test Project Name
+ * @return
+ */
+ protected abstract String getTestProjectName();
+ /**
+ * Initializes Test Project
+ */
+ protected abstract void intializeTestProject();
+ /**
+ * Returns Test Project Type
+ * @return
+ */
+ protected abstract TestProjectType getTestProjectType();
+ /**
+ * Returns true when test has to check if Managed Class exists
+ * @return
+ */
+ protected abstract boolean getCheckForExistingManagedBeanClass();
+
+}
+
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AbstractFacesConfigEditingTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java 2011-11-28
15:48:05 UTC (rev 36701)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java 2011-11-28
16:11:30 UTC (rev 36702)
@@ -200,6 +200,10 @@
IDELabel.Menu.ADD_JSF_CAPABILITIES).click();
}
+ bot.shell("Add JSF Capabilities").activate();
+ bot.button(WidgetVariables.NEXT_BUTTON).click();
+ bot.button(WidgetVariables.FINISH_BUTTON).click();
+
delay();
assertTrue("JSF Capabilities were not added to project "
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTest.java 2011-11-28
15:48:05 UTC (rev 36701)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTest.java 2011-11-28
16:11:30 UTC (rev 36702)
@@ -10,418 +10,36 @@
******************************************************************************/
package org.jboss.tools.jsf.ui.bot.test.smoke;
-import org.eclipse.draw2d.FigureCanvas;
-import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
-import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefViewer;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.jsf.ui.bot.test.JSFAutoTestCase;
-import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorBot;
-import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorPartMatcher;
-import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorUtil;
-import org.jboss.tools.ui.bot.ext.Assertions;
-import org.jboss.tools.ui.bot.ext.SWTBotExt;
-import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
-import org.jboss.tools.ui.bot.ext.Timing;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem;
-import org.jboss.tools.ui.bot.ext.helper.DragAndDropHelper;
-import org.jboss.tools.ui.bot.ext.parts.SWTBotEditorExt;
-import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.jboss.tools.ui.bot.ext.view.ProblemsView;
import org.jboss.tools.vpe.ui.bot.test.VPEAutoTestCase;
-/** Test Editing of faces-config.xml file
+/** Test Editing of faces-config.xml file for JSF 1.2 project
* @author Vladimir Pakan
*
*/
-public class FacesConfigEditingTest extends JSFAutoTestCase{
+public class FacesConfigEditingTest extends AbstractFacesConfigEditingTest{
- private static final String FACES_CONFIG_FILE_NAME = "faces-config.xml";
- private SWTBotEditor facesConfigEditor;
- private String originalContent;
- private SWTBotEditorExt facesConfigEditorExt;
- private SWTBotExt botExt;
- private SWTBotGefEditPart gefObjectAddedViaViewTool = null;
- private SWTBotGefEditPart gefObjectAddedViaDnDTool = null;
- private SWTBotGefViewer gefViewer = null;
-
@Override
- public void setUp() throws Exception {
- super.setUp();
- facesConfigEditor = eclipse.openFile(VPEAutoTestCase.JBT_TEST_PROJECT_NAME,
+ protected SWTBotEditor getFacesConfigEditor() {
+ return eclipse.openFile(getTestProjectName(),
"WebContent",
"WEB-INF",
FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- originalContent = facesConfigEditor.toTextEditor().getText();
- facesConfigEditorExt = new
SWTBotEditorExt(facesConfigEditor.toTextEditor().getReference(),bot);
- botExt = new SWTBotExt();
}
-
@Override
- public void tearDown() throws Exception {
- if (gefViewer != null){
- if (gefObjectAddedViaViewTool != null){
- gefObjectAddedViaViewTool.click();
- bot.sleep(Timing.time1S());
- gefViewer.clickContextMenu(IDELabel.Menu.DELETE);
- confirmViewDelete();
- bot.sleep(Timing.time1S());
- }
- if (gefObjectAddedViaDnDTool != null){
- gefObjectAddedViaDnDTool.click();
- bot.sleep(Timing.time1S());
- gefViewer.clickContextMenu(IDELabel.Menu.DELETE);
- confirmViewDelete();
- bot.sleep(Timing.time1S());
- }
- }
- if (facesConfigEditor != null) {
- facesConfigEditor.toTextEditor().setText(originalContent);
- facesConfigEditor.saveAndClose();
- bot.sleep(Timing.time1S());
- }
- super.tearDown();
+ protected String getTestProjectName(){
+ return VPEAutoTestCase.JBT_TEST_PROJECT_NAME;
}
- /**
- * Test Managed Bean editing
- */
- public void testManagedBean(){
- facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.TREE_TAB_LABEL);
- SWTBot editorBot = facesConfigEditorExt.bot();
- SWTBotTree tree = editorBot.tree();
- final String managedBeanName = "TestBean";
- final String managedBeanClass = "TestBeanClass";
- SWTBotTreeItem tiFacesConfigXml =
tree.expandNode(FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- SWTBotTreeItem tiManagedbean =
tiFacesConfigXml.getNode(IDELabel.FacesConfigEditor.MANAGED_BEANS_NODE);
- tiManagedbean.select();
- bot.sleep(Timing.time1S());
- // Add managed bean
- editorBot.button(IDELabel.Button.ADD).click();
- bot.shell(IDELabel.Shell.NEW_MANAGED_BEAN).activate();
- bot.textWithLabel(IDELabel.FacesConfigEditor.NEW_MANAGED_BEAN_CLASS_LABEL)
- .setText(managedBeanClass);
- bot.textWithLabel(IDELabel.FacesConfigEditor.NEW_MANAGED_BEAN_NAME_LABEL)
- .setText(managedBeanName);
- bot.button(IDELabel.Button.FINISH).click();
- facesConfigEditorExt.save();
- bot.sleep(Timing.time1S());
- assertFacesConfigXmlHasNoErrors(botExt);
- final String selectedNode = tree.selection().get(0,0);
- assertTrue ("Selected node has to have label '" + managedBeanName
+"'\n" +
- "but has '" + selectedNode + "'.",
- selectedNode.equals(managedBeanName));
- Assertions.assertFileExistsInWorkspace(managedBeanClass + ".java",
- JBT_TEST_PROJECT_NAME,"JavaSource");
-
Assertions.assertSourceEditorContains(stripXMLSourceText(facesConfigEditorExt.getText()),
- "<managed-bean><managed-bean-name>" + managedBeanName +
"</managed-bean-name>" +
- "<managed-bean-class>" + managedBeanClass +
"</managed-bean-class>" +
-
"<managed-bean-scope>request</managed-bean-scope></managed-bean>",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- // Modify Managed Bean
- editorBot.textWithLabel(IDELabel.FacesConfigEditor.MANAGED_BEAN_CLASS_LABEL)
- .setText(managedBeanClass + "xxqq");
- facesConfigEditorExt.save();
- bot.sleep(Timing.time1S());
- assertFacesConfigXmlHasErrors(botExt);
- editorBot.textWithLabel(IDELabel.FacesConfigEditor.MANAGED_BEAN_CLASS_LABEL)
- .setText(managedBeanClass);
- facesConfigEditorExt.save();
- bot.sleep(Timing.time1S());
- // Delete Managed Bean
- tiManagedbean.select();
- editorBot.table().select(managedBeanName);
- editorBot.button(IDELabel.Button.REMOVE_WITH_DOTS).click();
- bot.shell(IDELabel.Shell.CONFIRMATION).activate();
- bot.checkBox(IDELabel.FacesConfigEditor.DELETE_JAVA_SOURCE_CHECK_BOX).select();
- bot.button(IDELabel.Button.OK).click();
- boolean managedBeanWasDeleted = false;
- try{
- editorBot.table().select(managedBeanName);
- } catch (WidgetNotFoundException wnfe){
- managedBeanWasDeleted = true;
- } catch (IllegalArgumentException iae){
- managedBeanWasDeleted = true;
- }
- assertTrue("Managed bean " + managedBeanName + " was not deleted
properly.",
- managedBeanWasDeleted);
- Assertions.assertFileNotExistsInWorkspace(managedBeanClass + ".java",
- JBT_TEST_PROJECT_NAME,"JavaSource");
- Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
- "<managed-bean-name>" + managedBeanName +
"</managed-bean-name>",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
- "<managed-bean-class>" + managedBeanClass +
"</managed-bean-class>",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ @Override
+ protected void intializeTestProject() {
+ // This test is using default JSF 1.2 project which is already created
}
- /**
- * Tests Component editing
- */
- public void testComponent (){
- checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.COMPONENTS_NODE,
- IDELabel.Shell.ADD_COMPONENT,
- IDELabel.FacesConfigEditor.NEW_COMPONENT_TYPE_LABEL,
- "TestComponentType",
- IDELabel.FacesConfigEditor.NEW_COMPONENT_CLASS_LABEL,
- "TestComponentClass",
- "component",
- "component-type",
- "component-class",
- true);
+ @Override
+ protected TestProjectType getTestProjectType() {
+ return TestProjectType.JSF;
}
- /**
- * Tests Converter editing
- */
- public void testConverter (){
- checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.CONVERTERS_NODE,
- IDELabel.Shell.ADD_CONVERTER,
- IDELabel.FacesConfigEditor.NEW_CONVERTER_ID_LABEL,
- "TestConverterID",
- IDELabel.FacesConfigEditor.NEW_CONVERTER_CLASS_LABEL,
- "TestConverterClass",
- "converter",
- "converter-id",
- "converter-class",
- true);
+ @Override
+ protected boolean getCheckForExistingManagedBeanClass() {
+ return true;
}
- /**
- * Tests Referenced Bean editing
- */
- public void testReferencedBean (){
- checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.REFERENCED_BEAN_NODE,
- IDELabel.Shell.ADD_REFERENCED_BEAN,
- IDELabel.FacesConfigEditor.NEW_REFERENCED_BEAN_NAME_LABEL,
- "TestReferencedBeanName",
- IDELabel.FacesConfigEditor.NEW_REFERENCED_BEAN_CLASS_LABEL,
- "TestReferencedBeanClass",
- "referenced-bean",
- "referenced-bean-name",
- "referenced-bean-class",
- true);
- }
- /**
- * Tests Render Kit editing
- */
- public void testRenderKit (){
- checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.RENDER_KITS_NODE,
- IDELabel.Shell.ADD_RENDER_KIT,
- IDELabel.FacesConfigEditor.NEW_RENDER_KIT_ID_LABEL,
- "TestRenderKitID",
- IDELabel.FacesConfigEditor.NEW_RENDER_KIT_CLASS_LABEL,
- "TestRenderKitClass",
- "render-kit",
- "render-kit-id",
- "render-kit-class",
- false);
- }
- /**
- * Tests Validator editing
- */
- public void testValidator (){
- checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.VALIDATOR_NODE,
- IDELabel.Shell.ADD_VALIDATOR,
- IDELabel.FacesConfigEditor.NEW_VALIDATOR_ID_LABEL,
- "TestValidatorID",
- IDELabel.FacesConfigEditor.NEW_VALIDATOR_CLASS_LABEL,
- "TestValidatorClass",
- "validator",
- "validator-id",
- "validator-class",
- false);
- }
- /**
- * Asserts if faces-config.xml has no errors
- * @param botExt
- */
- private static void assertFacesConfigXmlHasNoErrors (SWTBotExt botExt){
-
- SWTBotTreeItem[] errors = ProblemsView.getFilteredErrorsTreeItems(botExt, null, null,
FacesConfigEditingTest.FACES_CONFIG_FILE_NAME, null);
- boolean areThereNoErrors = ((errors == null) || (errors.length == 0));
- assertTrue("There are errors in Problems view: " +
- (areThereNoErrors ? "" : errors[0].getText()),
- areThereNoErrors);
- }
- /**
- * Asserts if faces-config.xml has errors
- * @param botExt
- */
- private static void assertFacesConfigXmlHasErrors (SWTBotExt botExt){
-
- SWTBotTreeItem[] errors = ProblemsView.getFilteredErrorsTreeItems(botExt, null, null,
FacesConfigEditingTest.FACES_CONFIG_FILE_NAME, null);
- boolean areThereErrors = ((errors != null) && (errors.length > 0));
- assertTrue("There are missing errors in Problems view for " +
FacesConfigEditingTest.FACES_CONFIG_FILE_NAME + " file.",
- areThereErrors);
- }
- /**
- * Check editing of particular tree node within Face Config Editor Tree
- * @param treeNodeLabel
- * @param addWizardTitle
- * @param nameTextLabel
- * @param typeTextValue
- * @param classTextLabel
- * @param classTextValue
- * @param xmlNodeName
- * @param nameXmlNodeName
- * @param classXmlNodeName
- * @param checkForValdiationErrors
- */
- private void checkFacesConfigNodeEditing(String treeNodeLabel,
- String addWizardTitle,
- String nameTextLabel,
- String typeTextValue,
- String classTextLabel,
- String classTextValue,
- String xmlNodeName,
- String nameXmlNodeName,
- String classXmlNodeName,
- boolean checkForValdiationErrors){
-
- facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.TREE_TAB_LABEL);
- SWTBot editorBot = facesConfigEditorExt.bot();
- SWTBotTree tree = editorBot.tree();
- SWTBotTreeItem tiFacesConfigXml =
tree.expandNode(FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- SWTBotTreeItem tiNodeToCheck = tiFacesConfigXml.getNode(treeNodeLabel);
- tiNodeToCheck.select();
- bot.sleep(Timing.time1S());
- // Add Node
- editorBot.button(IDELabel.Button.ADD).click();
- bot.shell(addWizardTitle).activate();
- bot.textWithLabel(nameTextLabel).setText(typeTextValue);
- bot.textWithLabel(classTextLabel).setText(classTextValue);
- bot.button(IDELabel.Button.FINISH).click();
- facesConfigEditorExt.save();
- bot.sleep(Timing.time1S());
- if (checkForValdiationErrors){
- assertFacesConfigXmlHasErrors(botExt);
- }
- final String selectedNode = tree.selection().get(0,0);
- assertTrue ("Selected node has to have label '" + typeTextValue
+"'\n" +
- "but has '" + selectedNode + "'.",
- selectedNode.equals(typeTextValue));
-
Assertions.assertSourceEditorContains(stripXMLSourceText(facesConfigEditorExt.getText()),
- "<" + xmlNodeName + ">" +
- "<" + nameXmlNodeName + ">" + typeTextValue +
"</" + nameXmlNodeName +">" +
- "<" + classXmlNodeName + ">" + classTextValue +
"</" + classXmlNodeName +">" +
- "</" + xmlNodeName + ">",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- // Delete Node
- tiNodeToCheck.select();
- editorBot.table().select(typeTextValue);
- editorBot.button(IDELabel.Button.REMOVE_WITH_DOTS).click();
- bot.shell(IDELabel.Shell.CONFIRMATION).activate();
- bot.button(IDELabel.Button.OK).click();
- boolean nodeWasDeleted = false;
- try{
- editorBot.table().select(typeTextValue);
- } catch (WidgetNotFoundException wnfe){
- nodeWasDeleted = true;
- } catch (IllegalArgumentException iae){
- nodeWasDeleted = true;
- }
- assertTrue(typeTextValue + " was not deleted properly.",
- nodeWasDeleted);
- Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
- "<" + nameXmlNodeName + ">" + typeTextValue +
"</" + nameXmlNodeName +">",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
- "<" + classXmlNodeName + ">" + classTextValue +
"</" + classXmlNodeName +">",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- }
- /**
- * Test editing via Diagram tab
- */
- public void testDiagramEditing(){
- final int verticalSpacing = 100;
- facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.DIAGRAM_TAB_LABEL);
- final FacesConfigGefEditorBot gefEditorBot = new
FacesConfigGefEditorBot(facesConfigEditorExt.getReference());
- gefViewer = gefEditorBot.getViewer();
- SWTBotGefEditPart mainPart = gefViewer.mainEditPart();
- // add View to diagram via pallete tool
- gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_VIEW_TEMPLATE_TOOL);
- SWTBotGefEditPart gefObjectPart = mainPart.descendants(new
FacesConfigGefEditorPartMatcher("/pages/inputUserName.jsp")).get(0);
- gefViewer.click(FacesConfigGefEditorUtil.getGefPartPosition(gefObjectPart).x,
- FacesConfigGefEditorUtil.getGefPartPosition(gefObjectPart).y + verticalSpacing);
- final String viewAddedViaToolName = "addedViaTool";
- handleNewViewWizard(viewAddedViaToolName + ".jsp");
- bot.sleep(Timing.time3S());
- facesConfigEditor.save();
- bot.sleep(Timing.time3S());
- assertFacesConfigXmlHasNoErrors(botExt);
- Assertions.assertFileExistsInWorkspace(viewAddedViaToolName + ".jsp",
- JBT_TEST_PROJECT_NAME,"WebContent");
- gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_CREATE_NEW_CONNECTION_TOOL);
- gefObjectPart.click();
- bot.sleep(Timing.time1S());
- gefObjectAddedViaViewTool = mainPart.descendants(new
FacesConfigGefEditorPartMatcher("/" + viewAddedViaToolName +
".jsp")).get(0);
- gefObjectAddedViaViewTool.click();
- bot.sleep(Timing.time1S());
- facesConfigEditor.save();
- bot.sleep(Timing.time3S());
-
Assertions.assertSourceEditorContains(FacesConfigEditingTest.stripXMLSourceText(facesConfigEditorExt.getText()),
- "<navigation-case><from-outcome>" + viewAddedViaToolName +
- "</from-outcome><to-view-id>/" + viewAddedViaToolName +
".jsp</to-view-id></navigation-case>",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- // add View to Diagram via D'n'D
- final String dndPageName = "testDnDPage";
- createJspPage(dndPageName + ".jsp");
- facesConfigEditor.show();
- facesConfigEditor.setFocus();
- SWTBotTreeItem tiPage =
SWTEclipseExt.selectTreeLocation(open.viewOpen(ActionItem.View.JBossToolsWebWebProjects.LABEL).bot(),
-
VPEAutoTestCase.JBT_TEST_PROJECT_NAME,"WebContent","pages",dndPageName
+ ".jsp");
- DragAndDropHelper.dnd((TreeItem)tiPage.widget, (FigureCanvas)
gefEditorBot.getControl());
- facesConfigEditor.save();
- bot.sleep(Timing.time3S());
- assertFacesConfigXmlHasNoErrors(botExt);
- gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_CREATE_NEW_CONNECTION_TOOL);
- gefObjectPart.click();
- bot.sleep(Timing.time1S());
- gefObjectAddedViaDnDTool = mainPart.descendants(new
FacesConfigGefEditorPartMatcher("/pages/" + dndPageName +
".jsp")).get(0);
- gefObjectAddedViaDnDTool.click();
- bot.sleep(Timing.time1S());
-
gefViewer.click(FacesConfigGefEditorUtil.getGefPartPosition(gefObjectAddedViaDnDTool).x,
- FacesConfigGefEditorUtil.getGefPartPosition(gefObjectAddedViaDnDTool).y +
verticalSpacing);
- gefViewer.clickContextMenu(IDELabel.Menu.AUTO_LAYOUT);
- bot.shell(IDELabel.Shell.AUTO_LAYOUT).activate();
- bot.button(IDELabel.Button.OK).click();
- facesConfigEditor.save();
- bot.sleep(Timing.time3S());
-
Assertions.assertSourceEditorContains(FacesConfigEditingTest.stripXMLSourceText(facesConfigEditorExt.getText()),
- "<navigation-case><from-outcome>" + dndPageName +
- "</from-outcome><to-view-id>/pages/" + dndPageName +
".jsp</to-view-id></navigation-case>",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- }
- /**
- * Handle adding new View
- * @param fromViewID
- */
- private void handleNewViewWizard(String fromViewID){
- SWTBot dialogBot = bot.shell(IDELabel.Shell.NEW_VIEW).activate().bot();
- dialogBot.textWithLabel(IDELabel.NewViewDialog.FROM_VIEW_ID_TEXT_LABEL)
- .setText(fromViewID);
- dialogBot.checkBox(IDELabel.NewViewDialog.CREATE_FILE_ON_DISK_CHECKBOX_LABEL)
- .select();
- dialogBot.button(IDELabel.Button.FINISH).click();
-
- }
- /**
- * Returns XNL Source striped from spaces, tabs and EOL
- *
- * @return String
- */
- protected static String stripXMLSourceText(String editorText) {
- return editorText.replaceAll("\n", "").replaceAll("\t",
"")
- .replaceAll("\b", "").replaceAll(" ",
"").replaceAll("\r", "")
- .replaceAll("\f", "");
- }
- /**
- * Confirm deletion of View from Diagram Editor
- */
- private void confirmViewDelete(){
- bot.shell(IDELabel.Shell.CONFIRMATION).activate();
- bot.checkBox(IDELabel.FacesConfigEditor.DELETE_FILE_FROM_DISK_CHECK_BOX).select();
- bot.button(IDELabel.Button.OK).click();
- }
}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTestJSF2.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTestJSF2.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTestJSF2.java 2011-11-28
16:11:30 UTC (rev 36702)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.ui.bot.test.smoke;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+/** Test Editing of faces-config.xml file for JSF 1.2 project
+ * @author Vladimir Pakan
+ *
+ */
+public class FacesConfigEditingTestJSF2 extends AbstractFacesConfigEditingTest{
+
+ @Override
+ protected SWTBotEditor getFacesConfigEditor() {
+ return eclipse.openFile(getTestProjectName(),
+ "WebContent",
+ "WEB-INF",
+ FacesConfigEditingTestJSF2.FACES_CONFIG_FILE_NAME);
+ }
+ @Override
+ protected String getTestProjectName(){
+ return JSF2_TEST_PROJECT_NAME;
+ }
+ @Override
+ protected void intializeTestProject() {
+ createJSF2Project(getTestProjectName());
+ }
+ @Override
+ protected TestProjectType getTestProjectType() {
+ return TestProjectType.JSF2;
+ }
+ @Override
+ protected boolean getCheckForExistingManagedBeanClass() {
+ return false;
+ }
+}
+
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTestJSF2.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java
===================================================================
---
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java 2011-11-28
15:48:05 UTC (rev 36701)
+++
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java 2011-11-28
16:11:30 UTC (rev 36702)
@@ -45,7 +45,6 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.ui.IEditorReference;
import org.hamcrest.Description;
-import org.jboss.tools.struts.ui.bot.test.utils.DndSupport;
import org.jboss.tools.struts.ui.bot.test.utils.PartMatcher;
import org.jboss.tools.struts.ui.bot.test.utils.StrutsUIEditorBot;
import org.jboss.tools.struts.ui.bot.test.utils.ValidationUIEditorBot;
@@ -58,6 +57,7 @@
import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.helper.DragAndDropHelper;
import org.jboss.tools.ui.bot.ext.parts.SWTBotBrowserExt;
import org.jboss.tools.ui.bot.ext.types.EntityType;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
@@ -158,11 +158,11 @@
Widget w1 = s.widget;
s.select();
- DndSupport.dnd((TreeItem) w1, (FigureCanvas) c);
+ DragAndDropHelper.dnd((TreeItem) w1, (FigureCanvas) c);
s = webRootNode.getNode("pages").getNode("greeting.jsp");
s.select();
w1 = s.widget;
- DndSupport.dnd((TreeItem) w1, (FigureCanvas) c);
+ DragAndDropHelper.dnd((TreeItem) w1, (FigureCanvas) c);
bot.sleep(500);
ge.clickContextMenu("Auto-Layout");
SWTBotShell sh = bot.activeShell();
@@ -375,7 +375,7 @@
sh.bot().button("Finish").click();
SWTBotTreeItem item = projectNode.getNode("Resource
Bundles").getNode("sample.applResources");
nodeContextMenu(tree, item, "New", "Default Error
Messages").click();
- DndSupport.dnd(item.widget, config.getNode("resources").widget);
+ DragAndDropHelper.dnd(item.widget,
config.getNode("resources").widget);
nodeContextMenu(tree,
projectNode.expandNode("Validation").getNode("validation.xml"),
"Open").click();
SWTBotEditor editor = bot.activeEditor();
@@ -392,7 +392,7 @@
return config.expandNode("form-beans");
}
}).getNode("GetNameForm").select();
- DndSupport.dnd(item.widget, ti.widget);
+ DragAndDropHelper.dnd(item.widget, ti.widget);
ti = t.expandNode("formset
(default)").getNode("GetNameForm").select();
vb.toolbarButton("Create Field").click();
sh = bot.activeShell();
Deleted:
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/DndSupport.java
===================================================================
---
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/DndSupport.java 2011-11-28
15:48:05 UTC (rev 36701)
+++
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/DndSupport.java 2011-11-28
16:11:30 UTC (rev 36702)
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * 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.struts.ui.bot.test.utils;
-
-import java.awt.AWTException;
-import java.awt.Robot;
-import java.awt.event.InputEvent;
-import java.text.MessageFormat;
-
-import org.apache.log4j.Logger;
-import org.eclipse.draw2d.FigureCanvas;
-import org.eclipse.jface.util.Geometry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
-import org.eclipse.swtbot.swt.finder.results.Result;
-import org.eclipse.swtbot.swt.finder.results.VoidResult;
-
-/**
- * Drag and Drop implementation based on the last patch available
- * at
https://bugs.eclipse.org/bugs/show_bug.cgi?id=285271
- *
- * @author jlukas
- * @see <a
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=285271#c10"...
Patch</a>
- */
-public class DndSupport {
-
- private static final Logger L = Logger.getLogger(DndSupport.class.getName());
- private static final int robotDelay =
Integer.getInteger("org.jboss.tools.struts.ui.bot.test.dndDelay", 150);
-
- public static void dnd(final TreeItem ti, final TreeItem ti2) {
- Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
-
- public Rectangle run() {
- return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
- }
- });
- final Point slightOffset = Geometry.add(Geometry.getLocation(r1),
- new Point(10, 10));
-
- Rectangle r2 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
-
- public Rectangle run() {
- return ti2.getDisplay().map(ti2.getParent(), null,
- ti2.getBounds());
- }
- });
-
- doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset),
- Geometry.centerPoint(r2));
- }
-
- public static void dnd(final TreeItem ti, final FigureCanvas fc) {
- Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
-
- public Rectangle run() {
- return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
- }
- });
- final Point slightOffset = Geometry.add(Geometry.getLocation(r1),
- new Point(10, 10));
-
- Rectangle r2 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
-
- public Rectangle run() {
- return fc.getDisplay().map(fc.getParent(), null, fc.getBounds());
- }
- });
-
- doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset),
- Geometry.centerPoint(r2));
- }
-
- public static void dnd(final TreeItem ti, final Control fc, final int x,
- final int y) {
- Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
-
- public Rectangle run() {
- return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
- }
- });
- final Point slightOffset = Geometry.add(Geometry.getLocation(r1),
- new Point(10, 10));
-
- Point r2 = UIThreadRunnable.syncExec(new Result<Point>() {
-
- public Point run() {
- L.info("xxx: " + fc.getLocation().x + ":"
- + fc.getLocation().y);
- return fc.getDisplay().map(fc, null, x, y);
- }
- });
-
- doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset), r2);
- }
-
- /**
- *
- */
- private static void doDragAndDrop(final Point source, final Point dest) {
- L.info(MessageFormat.format(
- "Drag-and-dropping from ({0},{1}) to ({2},{3})", source.x,
- source.y, dest.x, dest.y));
- try {
- final Robot awtRobot = new Robot();
- awtRobot.setAutoDelay(robotDelay);
- // the x+10 motion is needed to let native functions register a drag
- // detect. It did not work under Windows
- // otherwise and has been reported to be required for linux, too.
- // But I could not test that.
- UIThreadRunnable.syncExec(new VoidResult() {
-
- public void run() {
- awtRobot.mouseMove(source.x, source.y);
- awtRobot.mousePress(InputEvent.BUTTON1_MASK);
- awtRobot.mouseMove((source.x + 10), source.y);
- }
- });
-
- // now pause the test until all runnables on the Display thread have
- // run this is necessary for the pick up
- // to register on linux
- waitForIdle(awtRobot);
-
- UIThreadRunnable.syncExec(new VoidResult() {
-
- public void run() {
- awtRobot.mouseMove((dest.x + 10), dest.y);
- awtRobot.mouseMove(dest.x, dest.y);
- }
- });
-
- waitForIdle(awtRobot);
-
- UIThreadRunnable.syncExec(new VoidResult() {
-
- public void run() {
- awtRobot.mouseRelease(InputEvent.BUTTON1_MASK);
- }
- });
- waitForIdle(awtRobot);
- } catch (final AWTException e) {
- L.info(e.getMessage(), e);
- throw new RuntimeException(e);
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- //ignore
- }
- }
-
- private static void waitForIdle(final Robot robot) {
- if (SWT.getPlatform().equals("gtk")) {
- robot.waitForIdle();
- }
- }
-}
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2011-11-28
15:48:05 UTC (rev 36701)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2011-11-28
16:11:30 UTC (rev 36702)
@@ -169,10 +169,12 @@
public static final String SECURE_STORAGE = "Secure Storage";
public static final String ADD_JSF_PROJECT_TEMPLATE = "Add JSF Project
Template";
public static final String NEW_MANAGED_BEAN = "New Managed Bean";
+ public static final String NEW_MANAGED_BEAN_JSF2 = "Managed Bean...";
public static final String ADD_COMPONENT = "Add Component";
public static final String ADD_CONVERTER = "Add Converter";
public static final String ADD_REFERENCED_BEAN = "Add Referenced Bean";
public static final String ADD_RENDER_KIT = "Add Render Kit";
+ public static final String ADD_RENDER_KIT_JSF2 = "Render Kit...";
public static final String ADD_VALIDATOR = "Add Validator";
public static final String NEW_VIEW = "New View";
public static final String AUTO_LAYOUT = "Auto Layout";