Author: dgolovin
Date: 2011-12-30 13:42:24 -0500 (Fri, 30 Dec 2011)
New Revision: 37595
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/NewJSFProjectTest.java
Log:
added test project removal operation to avoid unattended project in test workspace
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/NewJSFProjectTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/NewJSFProjectTest.java 2011-12-30
17:37:03 UTC (rev 37594)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/NewJSFProjectTest.java 2011-12-30
18:42:24 UTC (rev 37595)
@@ -12,41 +12,48 @@
import org.jboss.tools.jsf.ui.operation.JSFProjectCreationOperation;
import org.jboss.tools.jsf.web.helpers.context.NewProjectWizardContext;
import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
+import org.jboss.tools.test.util.ResourcesUtils;
+import org.jboss.tools.test.util.WorkbenchUtils;
import junit.framework.TestCase;
public class NewJSFProjectTest extends TestCase {
+
static String PROJECT_NAME = "NewTestProject";
public void testNewJSFProjectOperation() throws Exception {
- NewProjectWizardContext context = new NewProjectWizardContext();
- IProject project = getProjectHandle();
- context.setProject(project);
- IPath defaultPath = ModelUIPlugin.getWorkspace().getRoot().getLocation();
- IPath locationPath = defaultPath.append(PROJECT_NAME);
- context.setServletVersion("2.5");
- context.setProjectLocation(locationPath.toOSString());
- context.setProjectTemplate("JSFKickStartWithoutLibs");
- context.setJSFVersion("JSF 1.2");
-
- JSFProjectCreationOperation operation = new JSFProjectCreationOperation(context);
- IWorkbenchWindow window =
JsfUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
- window.run(false, false, operation);
-
- IModelNature nature = EclipseResourceUtil.getModelNature(project);
- assertNotNull(nature);
- XModelObject webxml = nature.getModel().getByPath("/web.xml");
- assertNotNull(webxml);
-
- XModelObject[] s = WebAppHelper.getServlets(webxml);
- assertTrue(s.length > 0);
- String servletName = s[0].getAttributeValue("servlet-name");
- assertEquals("Faces Servlet", servletName);
-
- XModelObject facesConfig = nature.getModel().getByPath("/faces-config.xml");
- assertNotNull(facesConfig);
- XModelObject userBean = facesConfig.getChildByPath("Managed Beans/user");
- assertNotNull(userBean);
+ try {
+ NewProjectWizardContext context = new NewProjectWizardContext();
+ IProject project = getProjectHandle();
+ context.setProject(project);
+ IPath defaultPath = ModelUIPlugin.getWorkspace().getRoot().getLocation();
+ IPath locationPath = defaultPath.append(PROJECT_NAME);
+ context.setServletVersion("2.5");
+ context.setProjectLocation(locationPath.toOSString());
+ context.setProjectTemplate("JSFKickStartWithoutLibs");
+ context.setJSFVersion("JSF 1.2");
+
+ JSFProjectCreationOperation operation = new JSFProjectCreationOperation(context);
+ IWorkbenchWindow window =
JsfUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ window.run(false, false, operation);
+
+ IModelNature nature = EclipseResourceUtil.getModelNature(project);
+ assertNotNull(nature);
+ XModelObject webxml = nature.getModel().getByPath("/web.xml");
+ assertNotNull(webxml);
+
+ XModelObject[] s = WebAppHelper.getServlets(webxml);
+ assertTrue(s.length > 0);
+ String servletName = s[0].getAttributeValue("servlet-name");
+ assertEquals("Faces Servlet", servletName);
+
+ XModelObject facesConfig =
nature.getModel().getByPath("/faces-config.xml");
+ assertNotNull(facesConfig);
+ XModelObject userBean = facesConfig.getChildByPath("Managed Beans/user");
+ assertNotNull(userBean);
+ } finally {
+ ResourcesUtils.deleteProject(PROJECT_NAME);
+ }
}
private IProject getProjectHandle() {