[embjopr-commits] EMBJOPR SVN: r145 - in trunk/jsfunit: src/test/java/org/jboss/jopr/jsfunit/as4 and 4 other directories.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Thu Feb 12 12:05:49 EST 2009


Author: ozizka at redhat.com
Date: 2009-02-12 12:05:48 -0500 (Thu, 12 Feb 2009)
New Revision: 145

Added:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS4.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/WarTest.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/WarTest.java
   trunk/jsfunit/testdata/ear/
   trunk/jsfunit/testdata/ear/eardeployment.ear
   trunk/jsfunit/testdata/ejb/
   trunk/jsfunit/testdata/ejb/deployment-ejb.jar
Log:
Adding Shelly's App base class and the test data.

Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java	                        (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java	2009-02-12 17:05:48 UTC (rev 145)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jopr.jsfunit;
+
+public interface AppConstants {
+    
+    // Navigation
+    public static final String NAV_EJB = "EJB Application (EJB JAR)s";
+    public static final String NAV_EAR = "Enterprise Application (EAR)s";
+    public static final String NAV_SAR = "JBoss Service (SAR)s";
+    public static final String NAV_MC = "Microconainer Beans (MC_Bean)s";
+    public static final String NAV_PAR = "Persistence Unit (PAR)s";
+    public static final String NAV_RAR = "Resource Adaptor (RAR)s";
+    public static final String NAV_WAR = "Web Application (WAR)s";
+
+    // Test Archives
+    public static final String BASIC_JAR = "deployment-ejb.jar";
+    public static final String BASIC_EAR = "eardeployment.ear";
+    public static final String BASIC_WAR = "hellothere.war";
+
+    // Defaults
+    public static final String[] WAR_DEFAULTS = new String[]{"ROOT.war", "invoker.war",
+			"jbas5-admin-console.war", "jbossws-management.war",
+                        "jmx-console.war", "web-console.war"};
+    public static final String[] SAR_DEFAULTS = new String[]{"cache-invalidation-service.xml",
+			"connection-factories-service.xml", "console-mgr.sar",
+			"destinations-service.xml", "ejb2-timer-service.xml",
+			"hsqldb-ds.xml", "hsqldb-persistence-service.xml",
+			"http-invoker.sar", "jboss-service.xml", "jms-ds.xml",
+			"jmx-invoker-service.xml", "jmx-remoting.sar", "jsr88-service.xml",
+			"legacy-invokers-service.xml", "legacy-service.xml",
+			"mail-service.xml", "messaging-service.xml", "monitoring-service.xml",
+			"properties-service.xml", "remoting-bisocket-service.xml",
+			"schedule-manager-service.xml", "scheduler-service.xml",
+			"sqlexception-service.xml", "transaction-service.xml", "uuid-key-generator.sar"};
+}

Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS4.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS4.java	                        (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS4.java	2009-02-12 17:05:48 UTC (rev 145)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jopr.jsfunit;
+
+import com.gargoylesoftware.htmlunit.html.*;
+import com.gargoylesoftware.htmlunit.BrowserVersion;
+import com.gargoylesoftware.htmlunit.WebClient;
+import java.io.File;
+import java.io.IOException;
+import org.jboss.mx.util.MBeanServerLocator;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.input.SAXBuilder;
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import org.jboss.jopr.jsfunit.AppConstants;
+
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.servlet.http.HttpServletRequest;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.cactus.ServletTestCase;
+import org.jboss.jsfunit.framework.WebClientSpec;
+import org.jboss.jsfunit.jsfsession.JSFClientSession;
+import org.jboss.jsfunit.jsfsession.JSFServerSession;
+import org.jboss.jsfunit.jsfsession.JSFSession;
+import org.jboss.mx.util.MBeanServerLocator;
+
+/**
+ * This is the base test class for Embedded Jopr Application tests.
+ * 
+ * @author Shelly McGowan
+ *
+ */
+public abstract class ApplicationTestBaseAS4 extends EmbjoprTestCase
+		implements AppConstants {
+
+	protected String label = null;
+	protected final String serviceName = null;
+	protected final String xmlElementName = null;
+	protected final String templateHtmlSelectValue = null;
+ 	public boolean isJBoss4;
+
+	protected abstract boolean isWarDeployed(String warName) throws RuntimeException;
+
+   /**
+    * Start a JSFUnit session by logging in to the main page.  Note that
+    * because setUp() is called before each test, a new HttpSession will be
+    * created each time a test is run.
+    */
+	public void setUp() throws IOException
+	{
+	isJBoss4 = Package.getPackage("org.jboss.system.server")
+                        .getImplementationVersion()
+                        .startsWith("4");
+      
+	// Initial JSF request
+	WebClientSpec wcSpec = new WebClientSpec("/", BrowserVersion.FIREFOX_3);
+	// This is temporary because embedded Jopr can't find /js/rhq.js
+	wcSpec.getWebClient().setThrowExceptionOnFailingStatusCode(false);
+	// Always press OK for confirm dialogs
+	wcSpec.getWebClient().setConfirmHandler(new SimpleConfirmHandler(true));
+      
+	wcSpec.setInitialRequestStrategy(new JoprLoginStrategy()); // logs in
+      
+	JSFSession jsfSession = new JSFSession(wcSpec);
+	this.client = jsfSession.getJSFClientSession();
+	this.server = jsfSession.getJSFServerSession();
+	}
+   
+   
+	// need a standard JSFUnit API to replace this cod
+	public HtmlAnchor getNavTreeLink(String linkLabel)
+	{
+   
+      		return getLinkInsideForm("navTreeForm", linkLabel);
+	} 
+
+	public HtmlButtonInput getAppDeleteButton(String resourceName)
+	{
+		HtmlAnchor link = getLinkInsideForm("resourceSummaryForm", resourceName);
+		// The id will look like "resourceSummaryForm:dataTable:2:resourceName"
+		// I need the row number. (2 in the above example)
+		String id = link.getIdAttribute(); 
+		String[] idElements = id.split(":");
+		String row = idElements[idElements.length - 2];
+
+		return (HtmlButtonInput)client.getElement(row + ":removeButton");
+	}
+   
+	// finds a <a> tag inside a form that has a particular label
+	public HtmlAnchor getLinkInsideForm(String formId, String linkLabel)
+	{
+		HtmlForm form = (HtmlForm)client.getElement(formId);
+		List links = form.getByXPath(".//a"); // get all <a> tags inside form
+
+		for (Iterator i = links.iterator(); i.hasNext();)
+		{
+			HtmlAnchor link = (HtmlAnchor)i.next();
+			String linkText = link.getTextContent();
+
+			if (linkText.contains(linkLabel)) return link;
+		}
+   
+		throw new IllegalStateException("Nav Tree link for '" +
+			linkLabel + "' not found.");
+	}
+   
+}

Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java	                        (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java	2009-02-12 17:05:48 UTC (rev 145)
@@ -0,0 +1,215 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jopr.jsfunit;
+
+import com.gargoylesoftware.htmlunit.html.*;
+import com.gargoylesoftware.htmlunit.BrowserVersion;
+import com.gargoylesoftware.htmlunit.WebClient;
+import java.io.File;
+import java.io.IOException;
+import org.jboss.mx.util.MBeanServerLocator;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.input.SAXBuilder;
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import org.jboss.jopr.jsfunit.AppConstants;
+
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.servlet.http.HttpServletRequest;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.cactus.ServletTestCase;
+import org.jboss.jsfunit.framework.WebClientSpec;
+import org.jboss.jsfunit.jsfsession.JSFClientSession;
+import org.jboss.jsfunit.jsfsession.JSFServerSession;
+import org.jboss.jsfunit.jsfsession.JSFSession;
+import org.jboss.mx.util.MBeanServerLocator;
+
+/**
+ * This is the base test class for Embedded Jopr Application tests.
+ * 
+ * @author Shelly McGowan
+ *
+ */
+public abstract class ApplicationTestBaseAS5 extends EmbjoprTestCase
+		implements AppConstants {
+
+	protected String label = null;
+	protected final String serviceName = null;
+	protected final String xmlElementName = null;
+	protected final String templateHtmlSelectValue = null;
+
+
+   /**
+    * Start a JSFUnit session by logging in to the main page.  Note that
+    * because setUp() is called before each test, a new HttpSession will be
+    * created each time a test is run.
+    */
+	public void setUp() throws IOException
+	{
+	// Initial JSF request
+	WebClientSpec wcSpec = new WebClientSpec("/", BrowserVersion.FIREFOX_3);
+	// This is temporary because embedded Jopr can't find /js/rhq.js
+	wcSpec.getWebClient().setThrowExceptionOnFailingStatusCode(false);
+	// Always press OK for confirm dialogs
+	wcSpec.getWebClient().setConfirmHandler(new SimpleConfirmHandler(true));
+      
+	wcSpec.setInitialRequestStrategy(new JoprLoginStrategy()); // logs in
+      
+	JSFSession jsfSession = new JSFSession(wcSpec);
+	this.client = jsfSession.getJSFClientSession();
+	this.server = jsfSession.getJSFServerSession();
+	}
+   
+   
+	// need a standard JSFUnit API to replace this cod
+	public HtmlAnchor getNavTreeLink(String linkLabel)
+	{
+   
+      		return getLinkInsideForm("navTreeForm", linkLabel);
+	} 
+
+	public HtmlButtonInput getAppDeleteButton(String resourceName)
+	{
+		HtmlAnchor link = getLinkInsideForm("resourceSummaryForm", resourceName);
+		// The id will look like "resourceSummaryForm:dataTable:2:resourceName"
+		// I need the row number. (2 in the above example)
+		String id = link.getIdAttribute(); 
+		String[] idElements = id.split(":");
+		String row = idElements[idElements.length - 2];
+
+		return (HtmlButtonInput)client.getElement(row + ":removeButton");
+	}
+   
+	// finds a <a> tag inside a form that has a particular label
+	public HtmlAnchor getLinkInsideForm(String formId, String linkLabel)
+	{
+		HtmlForm form = (HtmlForm)client.getElement(formId);
+		List links = form.getByXPath(".//a"); // get all <a> tags inside form
+
+		for (Iterator i = links.iterator(); i.hasNext();)
+		{
+			HtmlAnchor link = (HtmlAnchor)i.next();
+			String linkText = link.getTextContent();
+
+			if (linkText.contains(linkLabel)) return link;
+		}
+   
+		throw new IllegalStateException("Nav Tree link for '" +
+			linkLabel + "' not found.");
+	}
+   
+
+	public boolean isEJBDeployed(String ejbJarName) throws RuntimeException
+        {
+
+        try {
+                MBeanServer jmxServer = MBeanServerLocator.locateJBoss();
+                ObjectName objName =
+                           new ObjectName("jboss.j2ee:module=\"" +
+                                        ejbJarName + "\",service=EjbModule");
+               Set mBeans = jmxServer.queryNames(objName, null);
+
+                if (mBeans.size() != 1) return false;
+
+                ObjectName deploymentMBean = (ObjectName)mBeans.iterator().next();
+
+                // returns org.jboss.deployers.spi.DeploymentState
+                Object state = jmxServer.getAttribute(deploymentMBean, "StateString");
+
+                        return "Started".equals(state.toString());
+
+                } catch (Exception e) {
+                        throw new RuntimeException(e);
+                }
+        }
+
+
+        public boolean isWarDeployed(String warName) throws RuntimeException
+        {
+
+        if (warName.endsWith(".war"))
+        {
+                warName = warName.substring(0, warName.lastIndexOf(".war"));
+        } else {
+                warName = warName.substring(0, warName.lastIndexOf(".WAR"));
+        }
+
+                try {
+                        MBeanServer jmxServer = MBeanServerLocator.locateJBoss();
+                        ObjectName objName =
+                           new ObjectName("jboss.deployment:id=\"jboss.web.deployment:war=/" +
+                                        warName + "\",*");
+                        Set mBeans = jmxServer.queryNames(objName, null);
+
+                        if (mBeans.size() != 1) return false;
+
+                        ObjectName deploymentMBean = (ObjectName)mBeans.iterator().next();
+
+                        // returns org.jboss.deployers.spi.DeploymentState
+                        Object state = jmxServer.getAttribute(deploymentMBean, "State");
+
+                                return "DEPLOYED".equals(state.toString());
+
+                } catch (Exception e) {
+                        throw new RuntimeException(e);
+                }
+ 	}
+     
+        public boolean isEarDeployed(String earName) throws RuntimeException
+        {
+
+        try {
+
+                MBeanServer jmxServer = MBeanServerLocator.locateJBoss();
+                ObjectName objName =
+                        new ObjectName("jboss.deployment:id=\"vfszip:" +
+                                        System.getProperty("jsfunit.deploy.dir") + "/" + earName + "\",*");
+
+                Set mBeans = jmxServer.queryNames(objName, null);
+
+                if (mBeans.size() != 1) return false;
+
+                ObjectName deploymentMBean = (ObjectName)mBeans.iterator().next();
+
+                // returns org.jboss.deployers.spi.DeploymentState
+                Object state = jmxServer.getAttribute(deploymentMBean, "State");
+
+                        return "DEPLOYED".equals(state.toString());
+
+                } catch (Exception e) {
+                        throw new RuntimeException(e);
+                }
+        }
+}

Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/WarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/WarTest.java	                        (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/WarTest.java	2009-02-12 17:05:48 UTC (rev 145)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jopr.jsfunit.as4;
+
+import org.jboss.jopr.jsfunit.*;
+import com.gargoylesoftware.htmlunit.html.*;
+import java.io.IOException;
+import java.util.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import java.util.Map;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+import com.gargoylesoftware.htmlunit.WebClient;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import org.jboss.mx.util.MBeanServerLocator;
+
+
+/**
+ * This class contains tests for testing the EmbJopr Application
+ * Management Functions for WAR components with JBoss EAP 4.
+ * 
+ * @author Shelly McGowan
+ *
+ */
+public class WarTest extends ApplicationTestBaseAS4 {
+
+	/**
+	  * @return the suite of tests being tested
+	*/
+
+	public static Test suite()
+	{
+		return new TestSuite(WarTest.class);
+	}
+
+	public void testBasicWarDeployment() throws IOException
+	{
+		// click the nave tree
+		HtmlAnchor warLink = getNavTreeLink(NAV_WAR);
+		warLink.click();
+
+		// click on the "Add new resource" button
+		client.click("actionHeaderForm:addNewContent");  // 404 if setThrowExceptionOnFailingStatusCode(true) above
+
+		// upload hellothere.war
+		HtmlFileInput fileInput = (HtmlFileInput)client.getElement("createContentForm:file");
+		fileInput.setContentType("application/war");
+		fileInput.setValueAttribute(System.getProperty("jsfunit.testdata") + "/war/hellothere.war");
+		client.click("createContentForm:addButton");
+
+		// assert that the success message appeared on the client side
+		assertTrue(client.getPageAsText().contains("hellothere.war created successfully"));
+
+		// assert text and sevrity level for FacesMessage on server side
+		assertTrue(server.getFacesMessages().hasNext());
+		FacesMessage successMessage = server.getFacesMessages().next();
+		assertTrue(FacesMessage.SEVERITY_INFO.equals(successMessage.getSeverity()));
+		assertTrue(successMessage.getDetail().contains("hellothere.war created successfully"));
+
+		// Use JMX to assert that the WAR really did deploy successfully
+		assertTrue(isWarDeployed("hellothere.war"));
+
+		// use HtmlUnit to test the newly deployed war in a new WebClient session
+		// note that I have full access to the FacesContext and the previous request
+		HttpServletRequest request =
+			 (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
+		int port = request.getLocalPort();
+		WebClient webClient = new WebClient();
+		HtmlPage page = (HtmlPage)webClient.getPage("http://localhost:" + port + "/hellothere/hello.jsp");
+		assertTrue(page.asText().contains("HELLO WORLD"));
+
+		// Undeploy the WAR
+		HtmlButtonInput deleteButton = getAppDeleteButton("hellothere.war");
+		deleteButton.click();
+
+		// This assert doesn't work.  jopr does remove the WAR, but for some
+		// reason, JBoss doesn't undeploy the MBeans
+		//assertFalse(isWarDeployed("hellothere.war"));
+	}
+
+
+	// Helper Methods
+
+	@Override
+        protected boolean isWarDeployed (String warName)
+        {
+                try {
+                        MBeanServer jmxServer = MBeanServerLocator.locateJBoss();
+                        ObjectName objName = new ObjectName("jboss.web.deployment:war=" +
+                                warName + ",*");
+                        Set mBeans = jmxServer.queryNames(objName, null);
+
+                        if (mBeans.size() != 1) return false;
+
+                        ObjectName deploymentMBean = (ObjectName)mBeans.iterator().next();
+                        String state = (String)jmxServer.getAttribute(deploymentMBean, "StateString");
+
+                        return "Started".equals(state);
+
+                } catch (Exception e) {
+                        throw new RuntimeException(e);
+                }
+        }
+
+}
+

Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java	                        (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java	2009-02-12 17:05:48 UTC (rev 145)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jopr.jsfunit.as5;
+
+import org.jboss.jopr.jsfunit.*;
+import com.gargoylesoftware.htmlunit.html.*;
+import java.io.IOException;
+import java.util.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import java.util.Map;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+import com.gargoylesoftware.htmlunit.WebClient;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import org.jboss.mx.util.MBeanServerLocator;
+
+
+
+/**
+ * This class contains tests for testing the EmbJopr Application
+ * Management Functions for Enterprise Application archives with JBoss AS 5.
+ * 
+ * @author Shelly McGowan
+ *
+ */
+public class EarTest extends ApplicationTestBaseAS5 {
+
+	/**
+	  * @return the suite of tests being tested
+	*/
+
+	public static Test suite()
+	{
+		return new TestSuite(EarTest.class);
+	}
+
+
+	/*
+	 * testName: testBasicEarDeployment
+         * assertion:  verify basic deployment of Enterprise Archive
+	 * test Strategy:  Navigate to Enterprise Applications.
+	 *	Add a new resource.  Verify the resource was successfully
+	 *	deployed.  Undeploy the archive for test clean up purposes.
+	 *
+	 */ 
+	public void testBasicEarDeployment() throws IOException
+	{
+		// Navigate to Enterprise Archives
+		HtmlAnchor earLink = getNavTreeLink(NAV_EAR);
+		earLink.click();
+
+		// click on the "Add new resource" button
+		client.click("actionHeaderForm:addNewContent");  // 404 if setThrowExceptionOnFailingStatusCode(true) above
+
+		// upload hellothere.war
+		HtmlFileInput fileInput = (HtmlFileInput)client.getElement("createContentForm:file");
+		fileInput.setContentType("application/ear");
+		fileInput.setValueAttribute(System.getProperty("jsfunit.testdata") + "/ear/eardeployment.ear");
+		client.click("createContentForm:addButton");
+
+		// assert that the success message appeared on the client side
+		assertTrue(client.getPageAsText().contains("eardeployment.ear created successfully"));
+
+		// assert text and sevrity level for FacesMessage on server side
+		assertTrue(server.getFacesMessages().hasNext());
+		FacesMessage successMessage = server.getFacesMessages().next();
+		assertTrue(FacesMessage.SEVERITY_INFO.equals(successMessage.getSeverity()));
+		assertTrue(successMessage.getDetail().contains("eardeployment.ear created successfully"));
+
+		// Use JMX to assert that the EAR components really did deploy successfully
+		assertTrue(isEarDeployed("eardeployment.ear"));
+		assertTrue(isEJBDeployed("sessiona.jar"));
+		assertTrue(isEJBDeployed("sessionb.jar"));
+
+		// Undeploy the EAR
+		HtmlButtonInput deleteButton = getAppDeleteButton("eardeployment.ear");
+		deleteButton.click();
+
+		assertTrue(client.getPageAsText().contains("Successfully deleted Enterprise Application (EAR) 'eardeployment.ear'."));
+
+		// This assert doesn't work. The JXM view is not consistent with the mananaged view. 
+		// JBAS-XXXX
+		//assertFalse(isEarDeployed("eardeployment.ear"));
+		//assertFalse(isEJBDeployed("sessiona.jar"));
+		//assertFalse(isEJBDeployed("sessionb.jar"));
+	}
+
+
+}

Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java	                        (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java	2009-02-12 17:05:48 UTC (rev 145)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jopr.jsfunit.as5;
+
+import org.jboss.jopr.jsfunit.*;
+import com.gargoylesoftware.htmlunit.html.*;
+import java.io.IOException;
+import java.util.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import java.util.Map;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+import com.gargoylesoftware.htmlunit.WebClient;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import org.jboss.mx.util.MBeanServerLocator;
+
+
+
+/**
+ * This class contains tests for testing the EmbJopr Application
+ * Management Functions for Enterprise JavaBean archives with JBoss AS 5.
+ * 
+ * @author Shelly McGowan
+ *
+ */
+public class EjbTest extends ApplicationTestBaseAS5 {
+
+	/**
+	  * @return the suite of tests being tested
+	*/
+
+	public static Test suite()
+	{
+		return new TestSuite(EjbTest.class);
+	}
+
+
+        /*
+         * testName: testBasicEjbDeployment
+         * assertion:  verify basic deployment of an EJB JAR.
+         * test Strategy:  Navigate to EJB Applications.
+         *      Add a new resource.  Verify the resource was successfully
+         *      deployed.  Undeploy the archive.
+         *
+         */
+
+	public void testBasicEjbDeployment() throws IOException
+	{
+		// Navigate to EJB Applications
+		HtmlAnchor ejbLink = getNavTreeLink(NAV_EJB);
+		ejbLink.click();
+
+		// click on the "Add new resource" button
+		client.click("actionHeaderForm:addNewContent");  // 404 if setThrowExceptionOnFailingStatusCode(true) above
+
+		// upload ejb 
+		HtmlFileInput fileInput = (HtmlFileInput)client.getElement("createContentForm:file");
+		fileInput.setContentType("application/ejb");
+		fileInput.setValueAttribute(System.getProperty("jsfunit.testdata") + "/ejb/BASIC_JAR");
+		client.click("createContentForm:addButton");
+
+		// assert that the success message appeared on the client side
+		assertTrue(client.getPageAsText().contains("Resource " + BASIC_JAR + " created successfully!"));
+
+		// assert text and severity level for FacesMessage on server side
+		assertTrue(server.getFacesMessages().hasNext());
+		FacesMessage successMessage = server.getFacesMessages().next();
+		assertTrue(FacesMessage.SEVERITY_INFO.equals(successMessage.getSeverity()));
+		assertTrue(successMessage.getDetail().contains("Resource " + BASIC_JAR + " created successfully!"));
+
+		// Use JMX to assert that the EJB components really did deploy successfully
+		assertTrue(isEJBDeployed(BASIC_JAR));
+
+		// Undeploy the EJB JAR 
+		HtmlButtonInput deleteButton = getAppDeleteButton(BASIC_JAR);
+		deleteButton.click();
+
+		assertTrue(client.getPageAsText().contains("Successfully deleted " + NAV_EJB+ " '" + BASIC_JAR +"'."));
+
+		//assertFalse(isEJBDeployed(BASIC_JAR);
+	}
+
+}

Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/WarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/WarTest.java	                        (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/WarTest.java	2009-02-12 17:05:48 UTC (rev 145)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jopr.jsfunit.as5;
+
+import org.jboss.jopr.jsfunit.*;
+import com.gargoylesoftware.htmlunit.html.*;
+import java.io.IOException;
+import java.util.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import java.util.Map;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+import com.gargoylesoftware.htmlunit.WebClient;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import org.jboss.mx.util.MBeanServerLocator;
+
+
+
+/**
+ * This class contains tests for testing the EmbJopr Application
+ * Management Functions for Web Components with JBoss AS 5.
+ * 
+ * @author Shelly McGowan
+ *
+ */
+public class WarTest extends ApplicationTestBaseAS5 {
+
+	/**
+	  * @return the suite of tests being tested
+	*/
+
+	public static Test suite()
+	{
+		return new TestSuite(WarTest.class);
+	}
+
+
+        /*
+         * testName: testBasicWarDeployment
+         * assertion:  verify basic deployment of an EJB JAR.
+         * test Strategy:  Navigate to WAR Applications.
+         *      Add a new resource.  Verify the resource was successfully
+         *      deployed.  Undeploy the archive.
+         *
+         */
+
+
+	public void testBasicWarDeployment() throws IOException
+	{
+		// click the nave tree
+		HtmlAnchor warLink = getNavTreeLink(NAV_WAR);
+		warLink.click();
+
+		// click on the "Add new resource" button
+		client.click("actionHeaderForm:addNewContent");  // 404 if setThrowExceptionOnFailingStatusCode(true) above
+
+		// upload hellothere.war
+		HtmlFileInput fileInput = (HtmlFileInput)client.getElement("createContentForm:file");
+		fileInput.setContentType("application/war");
+		fileInput.setValueAttribute(System.getProperty("jsfunit.testdata") + "/war/hellothere.war");
+		client.click("createContentForm:addButton");
+
+		// assert that the success message appeared on the client side
+		assertTrue(client.getPageAsText().contains("Resource hellothere.war created successfully!"));
+
+		// assert text and sevrity level for FacesMessage on server side
+		assertTrue(server.getFacesMessages().hasNext());
+		FacesMessage successMessage = server.getFacesMessages().next();
+		assertTrue(FacesMessage.SEVERITY_INFO.equals(successMessage.getSeverity()));
+		assertTrue(successMessage.getDetail().contains("Resource hellothere.war created successfully!"));
+
+		// Use JMX to assert that the WAR really did deploy successfully
+		assertTrue(isWarDeployed("hellothere.war"));
+
+		// use HtmlUnit to test the newly deployed war in a new WebClient session
+		// note that I have full access to the FacesContext and the previous request
+		HttpServletRequest request =
+			 (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
+		int port = request.getLocalPort();
+		WebClient webClient = new WebClient();
+		HtmlPage page = (HtmlPage)webClient.getPage("http://localhost:" + port + "/hellothere/hello.jsp");
+		assertTrue(page.asText().contains("HELLO WORLD"));
+
+		// Undeploy the WAR
+		HtmlButtonInput deleteButton = getAppDeleteButton("hellothere.war");
+		deleteButton.click();
+
+		// This assert doesn't work.  jopr does remove the WAR, but for some
+		// reason, JBoss doesn't undeploy the MBeans
+		// JBAS-XXXX
+		//assertFalse(isWarDeployed("hellothere.war"));
+	}
+
+}
+

Added: trunk/jsfunit/testdata/ear/eardeployment.ear
===================================================================
(Binary files differ)


Property changes on: trunk/jsfunit/testdata/ear/eardeployment.ear
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/jsfunit/testdata/ejb/deployment-ejb.jar
===================================================================
(Binary files differ)


Property changes on: trunk/jsfunit/testdata/ejb/deployment-ejb.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream




More information about the embjopr-commits mailing list