Author: scabanovich
Date: 2011-08-23 20:10:45 -0400 (Tue, 23 Aug 2011)
New Revision: 34196
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/AddJSFCapabilitiesTest.java
Log:
JBIDE-9198
https://issues.jboss.org/browse/JBIDE-9198
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/AddJSFCapabilitiesTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/AddJSFCapabilitiesTest.java 2011-08-24
00:02:47 UTC (rev 34195)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/AddJSFCapabilitiesTest.java 2011-08-24
00:10:45 UTC (rev 34196)
@@ -7,29 +7,14 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IRuntimeType;
-import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
-import org.eclipse.wst.server.core.ServerCore;
-import org.jboss.tools.common.meta.key.WizardKeys;
-import org.jboss.tools.common.model.ui.ModelUIPlugin;
-import org.jboss.tools.common.model.ui.action.AddNatureActionDelegate;
-import org.jboss.tools.common.model.ui.util.ExtensionPointUtils;
-import org.jboss.tools.jst.web.ui.wizards.project.ImportWebProjectWizard;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.jboss.tools.jsf.ui.action.AddJSFNatureActionDelegate;
import org.jboss.tools.test.util.JobUtils;
import org.jboss.tools.test.util.ProjectImportTestSetup;
-
public class AddJSFCapabilitiesTest extends TestCase {
IProject project = null;
- IProject fake_as = null;
public AddJSFCapabilitiesTest() {
super("Add JSF Capabilities Test");
@@ -52,98 +37,29 @@
}
this.project = project.getProject();
- IResource fake_as =
ResourcesPlugin.getWorkspace().getRoot().findMember("fake_as");
- if(fake_as == null) {
- ProjectImportTestSetup setup = new ProjectImportTestSetup(
- this,
- "org.jboss.tools.jsf.ui.test",
- "projects/fake_as",
- "fake_as");
- fake_as = setup.importProject();
- }
- this.fake_as = fake_as.getProject();
JobUtils.waitForIdle();
}
public void testAddJSFCapabilities() {
- IPerspectiveDescriptor p =
PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId("org.jboss.tools.jst.web.ui.WebDevelopmentPerspective");
- if(p != null)
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setPerspective(p);
+ IFile f = project.getFile(new
Path(".settings/org.eclipse.wst.common.project.facet.core.xml"));
+ assertFalse(f.exists());
- ImportWebProjectWizard wizard = (ImportWebProjectWizard)new Act().getWizard(project);
- WizardDialog dialog = new WizardDialog(
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
- wizard);
- dialog.setBlockOnOpen(false);
- dialog.open();
-
- IRuntime r0 = createRuntime();
- ((ImportWebProjectWizard)wizard).setRuntimeName(r0.getName());
-
- assertTrue(wizard.canFinish());
-
- boolean b = wizard.performFinish();
-
- assertTrue(b);
-
try {
- assertTrue(project.hasNature("org.jboss.tools.jsf.jsfnature"));
+ assertFalse(project.hasNature("org.jboss.tools.jsf.jsfnature"));
} catch (CoreException e) {
fail(e.getMessage());
}
-
- IFile f = project.getFile(new
Path(".settings/org.eclipse.wst.common.project.facet.core.xml"));
- assertNotNull(f);
- assertTrue(f.exists());
- dialog.close();
- }
-
- static String RUNTIME = "org.eclipse.jst.server.tomcat.runtime.60";
-
- IRuntime createRuntime() {
- IRuntimeType t = ServerCore.findRuntimeType(RUNTIME);
+ AddJSFNatureActionDelegate action = new AddJSFNatureActionDelegate(false);
+ action.selectionChanged(null, new StructuredSelection(project));
+ action.run(null);
- IPath location = fake_as.getLocation();
try {
- IRuntimeWorkingCopy r = t.createRuntime(RUNTIME, new NullProgressMonitor());
- r.setName("myRuntime");
- r.setLocation(location);
- return r.save(true, new NullProgressMonitor());
-
+ assertTrue(project.hasNature("org.jboss.tools.jsf.jsfnature"));
} catch (CoreException e) {
fail(e.getMessage());
- return null;
}
- }
-
- private void refreshProject(IProject project){
- try {
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- JobUtils.waitForIdle();
- JobUtils.delay(2000);
- } catch (CoreException e) {
- // ignore
- }
- }
-
- class Act extends AddNatureActionDelegate {
-
- protected IWizard getWizard(IProject project) {
- ImportWebProjectWizard wizard =
(ImportWebProjectWizard)ExtensionPointUtils.findImportWizardsItem(
- "org.jboss.tools.jsf",
- "org.jboss.tools.jsf.ui.wizard.project.ImportProjectWizard" //$NON-NLS-1$
- );
- if (wizard == null) throw new IllegalArgumentException("Wizard
org.jboss.tools.common.model.ui.wizards.ImportProjectWizard is not found.");
//$NON-NLS-1$
- wizard.setInitialName(project.getName());
- wizard.setInitialLocation(findWebXML(project.getLocation().toString()));
- wizard.init(ModelUIPlugin.getDefault().getWorkbench(), null);
- wizard.setWindowTitle(WizardKeys.getString("ADD_JSF_NATURE"));
//$NON-NLS-1$
- return wizard;
- }
-
- protected String getNatureID() {
- return null;
- }
+ assertTrue(f.exists());
}
}