Author: scabanovich
Date: 2010-12-10 10:58:59 -0500 (Fri, 10 Dec 2010)
New Revision: 27365
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java
Log:
JBIDE-7842
https://issues.jboss.org/browse/JBIDE-7842
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 2010-12-10
15:41:02 UTC (rev 27364)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java 2010-12-10
15:58:59 UTC (rev 27365)
@@ -27,13 +27,16 @@
import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.core.ICDIAnnotation;
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
//import org.jboss.tools.cdi.ui.wizard.NewCDIAnnotationWizardPage;
+import org.jboss.tools.cdi.ui.wizard.NewBeansXMLCreationWizard;
import org.jboss.tools.cdi.ui.wizard.NewDecoratorWizardPage;
import org.jboss.tools.cdi.ui.wizard.NewInterceptorBindingWizardPage;
import org.jboss.tools.cdi.ui.wizard.NewInterceptorWizardPage;
@@ -118,6 +121,30 @@
}
+ static class NewBeansXMLWizardContext {
+ NewBeansXMLCreationWizard wizard;
+ IProject tck;
+ IJavaProject jp;
+ WizardDialog dialog;
+
+
+ public void init(String wizardId) {
+ wizard = (NewBeansXMLCreationWizard)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();
+ }
+
+ public void close() {
+ dialog.close();
+ }
+ }
+
public void testNewQualifierWizard() {
WizardContext context = new WizardContext();
context.init("org.jboss.tools.cdi.ui.wizard.NewQualifierCreationWizard",
@@ -263,4 +290,33 @@
}
}
+ public void testNewBeansXMLWizard() throws CoreException {
+ NewBeansXMLWizardContext context = new NewBeansXMLWizardContext();
+ context.init("org.jboss.tools.cdi.ui.wizard.NewBeansXMLCreationWizard");
+ JobUtils.waitForIdle(2000);
+
+ try {
+
+ WizardNewFileCreationPage page =
(WizardNewFileCreationPage)context.wizard.getPage("newFilePage1");
+ String s = page.getFileName();
+ assertEquals("beans.xml", s);
+ assertFalse(context.wizard.canFinish());
+ page.setFileName("beans2.xml");
+ assertTrue(context.wizard.canFinish());
+ String c = page.getContainerFullPath().toString();
+ assertEquals("/tck/WebContent/WEB-INF", c);
+
+ context.wizard.performFinish();
+
+ IFile f =
context.tck.getParent().getFile(page.getContainerFullPath().append(page.getFileName()));
+ assertTrue(f.exists());
+
+ String text = FileUtil.readStream(f.getContents());
+
assertTrue(text.indexOf("http://java.sun.com/xml/ns/javaee") > 0);
+
+ } finally {
+ context.close();
+ }
+ }
+
}
\ No newline at end of file