Author: dazarov
Date: 2009-02-16 13:57:25 -0500 (Mon, 16 Feb 2009)
New Revision: 13635
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/FacesConfigNewWizardTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3500
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/FacesConfigNewWizardTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/FacesConfigNewWizardTest.java 2009-02-16
16:21:21 UTC (rev 13634)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/FacesConfigNewWizardTest.java 2009-02-16
18:57:25 UTC (rev 13635)
@@ -1,6 +1,21 @@
package org.jboss.tools.jsf.ui.test;
+import java.io.File;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.common.meta.action.impl.SpecialWizardSupport;
+import org.jboss.tools.common.model.ui.wizard.newfile.NewFileContextEx;
+import org.jboss.tools.common.model.ui.wizard.newfile.NewFileWizardEx;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.common.util.WorkbenchUtils;
+import org.jboss.tools.test.util.JobUtils;
public class FacesConfigNewWizardTest extends WizardTest {
@@ -25,9 +40,109 @@
}
public void testFacesConfigNewWizardResults() {
+ ArrayList<IProject> list = new ArrayList<IProject>();
+
+ StructuredSelection selection = new StructuredSelection(list);
+
+ IWizard wizard = WorkbenchUtils.findWizardByDefId(id);
+
+ NewFileWizardEx wiz = (NewFileWizardEx)wizard;
+
+ NewFileContextEx context = wiz.getFileContext();
+
+ SpecialWizardSupport support = context.getSupport();
+
+ ((IWorkbenchWizard)wizard).init(PlatformUI.getWorkbench(), selection);
+
+ support.setAttributeValue(0, "name", "faces-config11");
+ support.setAttributeValue(0, "folder",
"/TestWizards/WebContent/WEB-INF");
+ support.setAttributeValue(0, "register in web.xml", "no");
+
+ dialog = new WizardDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ wizard);
+ dialog.setBlockOnOpen(false);
+ dialog.open();
+
// Assert file with name from Name field created in folder with name form Folder field
+
+
+ boolean canFinish = wizard.canFinish();
+
+ assertTrue("Finish button is disabled.", canFinish);
+
+ wizard.performFinish();
+
+ dialog.close();
+
+ JobUtils.waitForIdle();
+
+ IResource res =
project.findMember("/WebContent/WEB-INF/faces-config11.xml");
+
+ assertNotNull(res);
+
// Assert that new file was not registered in web.xml if 'Register in web.xml'
is not set
+
+ IResource webXml = project.findMember("/WebContent/WEB-INF/web.xml");
+
+ assertNotNull(webXml);
+
+ String webXmlContent = FileUtil.readFile(new File(webXml.getLocation().toString()));
+
+ int p = webXmlContent.indexOf("faces-config11.xml");
+
+ assertTrue("File faces-config11.xml is registered in web.xml", p < 0);
+ }
+
+ public void testFacesConfigNewWizardResults2() {
// Assert that new file was registered in web.xml if 'Register in web.xml is
set'
- fail("Not implemented yet");
+
+ ArrayList<IProject> list = new ArrayList<IProject>();
+
+ StructuredSelection selection = new StructuredSelection(list);
+
+ IWizard wizard = WorkbenchUtils.findWizardByDefId(id);
+
+ NewFileWizardEx wiz = (NewFileWizardEx)wizard;
+
+ NewFileContextEx context = wiz.getFileContext();
+
+ SpecialWizardSupport support = context.getSupport();
+
+ ((IWorkbenchWizard)wizard).init(PlatformUI.getWorkbench(), selection);
+
+ support.setAttributeValue(0, "name", "faces-config22");
+ support.setAttributeValue(0, "folder",
"/TestWizards/WebContent/WEB-INF");
+ support.setAttributeValue(0, "register in web.xml", "yes");
+
+ dialog = new WizardDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ wizard);
+ dialog.setBlockOnOpen(false);
+ dialog.open();
+
+ boolean canFinish = wizard.canFinish();
+
+ assertTrue("Finish button is disabled.", canFinish);
+
+ wizard.performFinish();
+
+ JobUtils.waitForIdle();
+
+ IResource res =
project.findMember("/WebContent/WEB-INF/faces-config22.xml");
+
+ assertNotNull(res);
+
+ IResource webXml = project.findMember("/WebContent/WEB-INF/web.xml");
+
+ assertNotNull(webXml);
+
+ String webXmlContent = FileUtil.readFile(new File(webXml.getLocation().toString()));
+
+ System.out.println("WebXML - "+webXmlContent);
+
+ int p = webXmlContent.indexOf("faces-config22.xml");
+
+ assertTrue("File faces-config22.xml is not registered in web.xml", p >=
0);
}
}