EMBJOPR SVN: r154 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: fjuma
Date: 2009-02-17 10:46:54 -0500 (Tue, 17 Feb 2009)
New Revision: 154
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
Log:
Removing testServerSessionCreated() and testClientSessionCreated() from EmbjoprTestCase.java. These tests are no longer needed.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-02-16 20:15:08 UTC (rev 153)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-02-17 15:46:54 UTC (rev 154)
@@ -50,7 +50,7 @@
* @author Ondrej Zizka
* @author Stan Silvert
*/
-public class EmbjoprTestCase extends ServletTestCase {
+public abstract class EmbjoprTestCase extends ServletTestCase {
protected final Logger log = Logger.getLogger(this.getClass().getName());
@@ -368,23 +368,7 @@
nodeArrow.click();
}
-
/**
- * This just checks that the JSFServerSession object was created.
- */
- public void testServerSessionCreated() {
- assertTrue(server != null);
- }
-
-
- /**
- * This just checks that the JSFClientSession object was created.
- */
- public void testClientSessionCreated() {
- assertTrue(client != null);
- }
-
- /**
* Finds a row in the "details table" using the text in the Name column
* and returns the text from the Value column.
* @param name
15 years, 10 months
EMBJOPR SVN: r153 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-02-16 15:15:08 -0500 (Mon, 16 Feb 2009)
New Revision: 153
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java
Log:
EJB test: log messages added to see whether we get HTTP 500; + basic check wheter EJB is listed after deployment.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java 2009-02-13 17:16:43 UTC (rev 152)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EjbTest.java 2009-02-16 20:15:08 UTC (rev 153)
@@ -22,20 +22,14 @@
package org.jboss.jopr.jsfunit.as5;
+import java.util.logging.Level;
+import java.util.logging.Logger;
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;
@@ -82,8 +76,13 @@
fileInput.setValueAttribute(System.getProperty("jsfunit.testdata") + "/ejb/BASIC_JAR");
client.click("createContentForm:addButton");
+ log.info("HTTP status after EJB upload: "+client.getContentPage().getWebResponse().getStatusCode());
+ log.info("renderResponse() called: " + server.getFacesContext().getRenderResponse() );
+ log.info("responseComplete() called: " + server.getFacesContext().getResponseComplete() );
+
+ // FAILS because of NPE and HTTP 500.
// assert that the success message appeared on the client side
- assertTrue(client.getPageAsText().contains("Resource " + BASIC_JAR + " created successfully!"));
+ assertTrue("Success message not found.", client.getPageAsText().contains("Resource " + BASIC_JAR + " created successfully!"));
// assert text and severity level for FacesMessage on server side
assertTrue(server.getFacesMessages().hasNext());
@@ -91,6 +90,11 @@
assertTrue(FacesMessage.SEVERITY_INFO.equals(successMessage.getSeverity()));
assertTrue(successMessage.getDetail().contains("Resource " + BASIC_JAR + " created successfully!"));
+
+ // TODO: Check if listed. See EMBJOPR-74.
+ assertFalse("Page contains 'Total: 0', EJBs probably not listed.", client.getPageAsText().contains("Total: 0"));
+
+
// Use JMX to assert that the EJB components really did deploy successfully
assertTrue(isEJBDeployed(BASIC_JAR));
15 years, 10 months
EMBJOPR SVN: r152 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-02-13 12:16:43 -0500 (Fri, 13 Feb 2009)
New Revision: 152
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS4.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
Log:
We had some of the methods already in EmbjoprTestCase.java, thus removing.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS4.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS4.java 2009-02-13 16:22:02 UTC (rev 151)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS4.java 2009-02-13 17:16:43 UTC (rev 152)
@@ -21,16 +21,8 @@
*/
package org.jboss.jopr.jsfunit;
-import com.gargoylesoftware.htmlunit.html.*;
-import com.gargoylesoftware.htmlunit.BrowserVersion;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
+import com.gargoylesoftware.htmlunit.html.HtmlButtonInput;
-
-import org.jboss.jsfunit.framework.WebClientSpec;
-import org.jboss.jsfunit.jsfsession.JSFSession;
-
/**
* This is the base test class for Embedded Jopr Application tests.
*
@@ -44,68 +36,14 @@
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");
+ return getDeleteButton("resourceSummaryForm", resourceName);
}
- // 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();
+ protected abstract boolean isWarDeployed(String warName) throws RuntimeException;
- if (linkText.contains(linkLabel)) {
- return link;
- }
- }
- throw new IllegalStateException("Nav Tree link for '" +
- linkLabel + "' not found.");
- }
-
}
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java 2009-02-13 16:22:02 UTC (rev 151)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java 2009-02-13 17:16:43 UTC (rev 152)
@@ -22,17 +22,9 @@
package org.jboss.jopr.jsfunit;
import com.gargoylesoftware.htmlunit.html.*;
-import com.gargoylesoftware.htmlunit.BrowserVersion;
-import java.io.IOException;
-import java.util.Iterator;
import java.util.Set;
-import java.util.List;
-
-
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import org.jboss.jsfunit.framework.WebClientSpec;
-import org.jboss.jsfunit.jsfsession.JSFSession;
import org.jboss.mx.util.MBeanServerLocator;
/**
@@ -49,63 +41,18 @@
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();
+ public HtmlButtonInput getAppDeleteButton(String resourceName)
+ {
+ return getDeleteButton("resourceSummaryForm", resourceName);
}
- // 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];
+ public boolean isEJBDeployed(String ejbJarName) throws RuntimeException
+ {
- 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 =
@@ -129,7 +76,8 @@
}
}
- public boolean isWarDeployed(String warName) throws RuntimeException {
+ public boolean isWarDeployed(String warName) throws RuntimeException
+ {
if (warName.endsWith(".war")) {
warName = warName.substring(0, warName.lastIndexOf(".war"));
@@ -160,7 +108,8 @@
}
}
- public boolean isEarDeployed(String earName) throws RuntimeException {
+ public boolean isEarDeployed(String earName) throws RuntimeException
+ {
try {
@@ -186,4 +135,5 @@
throw new RuntimeException(e);
}
}
+
}
15 years, 10 months
EMBJOPR SVN: r151 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-02-13 11:22:02 -0500 (Fri, 13 Feb 2009)
New Revision: 151
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS4.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
Log:
Inconsistent spaces/tab formatting repaired.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS4.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS4.java 2009-02-13 16:11:15 UTC (rev 150)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS4.java 2009-02-13 16:22:02 UTC (rev 151)
@@ -19,42 +19,17 @@
* 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.
@@ -63,77 +38,74 @@
*
*/
public abstract class ApplicationTestBaseAS4 extends EmbjoprTestCase
- implements AppConstants {
+ implements AppConstants {
protected String label = null;
protected final String serviceName = null;
protected final String xmlElementName = null;
protected final String templateHtmlSelectValue = null;
- public boolean isJBoss4;
+ 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.
- */
+ /**
+ * 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();
+ 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);
- }
+ 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 id = link.getIdAttribute();
String[] idElements = id.split(":");
String row = idElements[idElements.length - 2];
- return (HtmlButtonInput)client.getElement(row + ":removeButton");
+ 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);
+ 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();
+ for (Iterator i = links.iterator(); i.hasNext();) {
+ HtmlAnchor link = (HtmlAnchor) i.next();
String linkText = link.getTextContent();
- if (linkText.contains(linkLabel)) return link;
+ if (linkText.contains(linkLabel)) {
+ return link;
+ }
}
-
+
throw new IllegalStateException("Nav Tree link for '" +
- linkLabel + "' not found.");
+ linkLabel + "' not found.");
}
-
+
}
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java 2009-02-13 16:11:15 UTC (rev 150)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java 2009-02-13 16:22:02 UTC (rev 151)
@@ -19,40 +19,19 @@
* 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;
@@ -63,153 +42,148 @@
*
*/
public abstract class ApplicationTestBaseAS5 extends EmbjoprTestCase
- implements AppConstants {
+ 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));
- /**
- * 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();
+ 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 HtmlAnchor getNavTreeLink(String linkLabel) {
- public HtmlButtonInput getAppDeleteButton(String resourceName)
- {
+ 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 id = link.getIdAttribute();
String[] idElements = id.split(":");
String row = idElements[idElements.length - 2];
- return (HtmlButtonInput)client.getElement(row + ":removeButton");
+ 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);
+ 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();
+ for (Iterator i = links.iterator(); i.hasNext();) {
+ HtmlAnchor link = (HtmlAnchor) i.next();
String linkText = link.getTextContent();
- if (linkText.contains(linkLabel)) return link;
+ if (linkText.contains(linkLabel)) {
+ return link;
+ }
}
-
+
throw new IllegalStateException("Nav Tree link for '" +
- linkLabel + "' not found.");
+ linkLabel + "' not found.");
}
-
- public boolean isEJBDeployed(String ejbJarName) throws RuntimeException
- {
+ 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);
+ 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;
+ if (mBeans.size() != 1) {
+ return false;
+ }
- ObjectName deploymentMBean = (ObjectName)mBeans.iterator().next();
+ ObjectName deploymentMBean = (ObjectName) mBeans.iterator().next();
- // returns org.jboss.deployers.spi.DeploymentState
- Object state = jmxServer.getAttribute(deploymentMBean, "StateString");
+ // returns org.jboss.deployers.spi.DeploymentState
+ Object state = jmxServer.getAttribute(deploymentMBean, "StateString");
- return "Started".equals(state.toString());
+ return "Started".equals(state.toString());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ public boolean isWarDeployed(String warName) throws RuntimeException {
- 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"));
+ }
- 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);
- 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;
+ }
- if (mBeans.size() != 1) return false;
+ ObjectName deploymentMBean = (ObjectName) mBeans.iterator().next();
- ObjectName deploymentMBean = (ObjectName)mBeans.iterator().next();
+ // returns org.jboss.deployers.spi.DeploymentState
+ Object state = jmxServer.getAttribute(deploymentMBean, "State");
- // returns org.jboss.deployers.spi.DeploymentState
- Object state = jmxServer.getAttribute(deploymentMBean, "State");
+ return "DEPLOYED".equals(state.toString());
- return "DEPLOYED".equals(state.toString());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public boolean isEarDeployed(String earName) throws RuntimeException
- {
+ public boolean isEarDeployed(String earName) throws RuntimeException {
- try {
+ try {
- MBeanServer jmxServer = MBeanServerLocator.locateJBoss();
- ObjectName objName =
- new ObjectName("jboss.deployment:id=\"vfszip:" +
- System.getProperty("jsfunit.deploy.dir") + "/" + earName + "\",*");
+ MBeanServer jmxServer = MBeanServerLocator.locateJBoss();
+ ObjectName objName =
+ new ObjectName("jboss.deployment:id=\"vfszip:" +
+ System.getProperty("jsfunit.deploy.dir") + "/" + earName + "\",*");
- Set mBeans = jmxServer.queryNames(objName, null);
+ Set mBeans = jmxServer.queryNames(objName, null);
- if (mBeans.size() != 1) return false;
+ if (mBeans.size() != 1) {
+ return false;
+ }
- ObjectName deploymentMBean = (ObjectName)mBeans.iterator().next();
+ ObjectName deploymentMBean = (ObjectName) mBeans.iterator().next();
- // returns org.jboss.deployers.spi.DeploymentState
- Object state = jmxServer.getAttribute(deploymentMBean, "State");
+ // returns org.jboss.deployers.spi.DeploymentState
+ Object state = jmxServer.getAttribute(deploymentMBean, "State");
- return "DEPLOYED".equals(state.toString());
+ return "DEPLOYED".equals(state.toString());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
}
15 years, 10 months
EMBJOPR SVN: r150 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-02-13 11:11:15 -0500 (Fri, 13 Feb 2009)
New Revision: 150
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/JoprLoginStrategy.java
Log:
Login credentials moved to constants.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/JoprLoginStrategy.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/JoprLoginStrategy.java 2009-02-13 15:55:16 UTC (rev 149)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/JoprLoginStrategy.java 2009-02-13 16:11:15 UTC (rev 150)
@@ -37,7 +37,7 @@
*/
public JoprLoginStrategy()
{
- this("admin", "admin");
+ this( EmbjoprTestCase.LOGIN_USERNAME, EmbjoprTestCase.LOGIN_PASSWORD);
}
/**
15 years, 10 months
EMBJOPR SVN: r149 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-02-13 10:55:16 -0500 (Fri, 13 Feb 2009)
New Revision: 149
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
Log:
Login credentials moved to constants.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-02-13 15:54:11 UTC (rev 148)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-02-13 15:55:16 UTC (rev 149)
@@ -59,7 +59,10 @@
protected JSFClientSession client;
protected JSFServerSession server;
+ public static final String LOGIN_USERNAME = "admin";
+ public static final String LOGIN_PASSWORD = "admin";
+
/**
* 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
15 years, 10 months
EMBJOPR SVN: r148 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-02-13 10:54:11 -0500 (Fri, 13 Feb 2009)
New Revision: 148
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/LoginTest.java
Log:
Login test
Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/LoginTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/LoginTest.java (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/LoginTest.java 2009-02-13 15:54:11 UTC (rev 148)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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 java.io.IOException;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Login test. Makes use of default login in EmbjoprTestCase::setUp()
+ *
+ * @author Stan Silvert
+ */
+public class LoginTest extends EmbjoprTestCase
+{
+
+ /**
+ * @return the suite of tests being tested
+ */
+ public static Test suite() {
+ return new TestSuite( LoginTest.class );
+ }
+
+
+
+ public void testLoggedIn() throws IOException
+ {
+
+ // TODO: Move user name to a constant.
+ assertTrue( client.getPageAsText().contains(LOGIN_USERNAME) );
+ assertTrue( client.getPageAsText().contains("Logout") );
+
+ assertEquals("admin", server.getManagedBeanValue("#{identity.username}") );
+
+ }
+
+
+}
\ No newline at end of file
15 years, 10 months
EMBJOPR SVN: r147 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-02-13 07:29:58 -0500 (Fri, 13 Feb 2009)
New Revision: 147
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ServerNodeSummaryTest.java
Log:
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ServerNodeSummaryTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ServerNodeSummaryTest.java 2009-02-13 12:29:16 UTC (rev 146)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ServerNodeSummaryTest.java 2009-02-13 12:29:58 UTC (rev 147)
@@ -1,5 +1,8 @@
package org.jboss.jopr.jsfunit.as5;
+import java.io.FileNotFoundException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException;
import org.jboss.jopr.jsfunit.exceptions.ActionOutOfSyncException;
import com.gargoylesoftware.htmlunit.html.*;
@@ -10,6 +13,7 @@
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
+import org.jboss.jopr.jsfunit.DebugUtils;
import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
import org.jboss.jopr.jsfunit.EmbjoprTestCase;
@@ -37,9 +41,11 @@
//HtmlElement box = tabMenu.getTabContentBox().getElement();
helpers.checkSummaryValue( "Name", helpers.getLocalHostName() );
- helpers.checkSummaryValue( "OS Name", System.getProperty("os.name") );
+ // System.getProperty("os.name") // Gives the computer name.
+ //helpers.checkSummaryValue( "OS Name", System.getProperty("os.name") );
+ helpers.checkSummaryValue( "OS Name", executeProcessAndGetOutput("uname") );
helpers.checkSummaryValue( "OS Version", System.getProperty("os.version") );
- helpers.checkSummaryValue( "OS Architecture", System.getProperty("os.arch") );
+ helpers.checkSummaryValue( "Architecture", System.getProperty("os.arch") );
// $ cat /proc/version
@@ -48,7 +54,10 @@
// $ cat /etc/redhat-release
// Red Hat Enterprise Linux Server release 5.2 (Tikanga)
- try{
+
+ // Commented out - this would only work on Red Hat.
+ // TODO: How to get these values universally?
+ /*try{
String rhRelease = executeProcessAndGetOutput("cat /etc/redhat-release");
String distName = helpers.getSummaryValue("Distribution Name").trim();
String distVersion = helpers.getSummaryValue("Distribution Version").trim();
@@ -57,8 +66,9 @@
catch( IOException ex ){
// cat not found or similar.
// When file not found, just returns emty string.
- }
+ }*/
+
}
catch( IOException ex ){
throw new EmbJoprTestException(ex);
@@ -89,7 +99,7 @@
tabMenu.clickTab("Control");
TabContentBox box = tabMenu.getTabContentBox();
- HtmlButton button = box.getButtonByLabel("Manual Autodiscovery");
+ HtmlButtonInput button = box.getButtonByLabel("Manual Autodiscovery");
button.click();
// TODO: check the result.
@@ -115,7 +125,7 @@
tabMenu.clickTab("Control");
TabContentBox box = tabMenu.getTabContentBox();
- HtmlButton button = box.getButtonByLabel("View Process List");
+ HtmlButtonInput button = box.getButtonByLabel("View Process List");
button.click();
// TODO: check the result.
@@ -150,20 +160,31 @@
* @throws org.jboss.jopr.jsfunit.AssertException
*/
private String getSummaryValue(String name) throws EmbJoprTestException{
+
+ try {
+ DebugUtils.writeFile("Summary.html", client.getPageAsText());
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(ServerNodeSummaryTest.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(ServerNodeSummaryTest.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
HtmlElement box = tabMenu.getTabContentBox().getElement();
- String xPath = "//td/span/strong[contains(string(), '"+name+":')]/ancestor::td[1]";
+ String xPath = "//td//strong[contains(string(), '"+name+":')]/ancestor::td[1]";
HtmlElement tableCell = (HtmlElement) box.getFirstByXPath(xPath);
if( null == tableCell )
throw new EmbJoprTestException("Value for '"+name+"' not found using XPath: "+xPath);
- String actualValue = tableCell.getTextContent();
+ String actualValue = tableCell.getLastChild().getTextContent().trim();
return actualValue;
}
private void checkSummaryValue(String name, String expectedValue ) throws EmbJoprTestException {
String actualValue = getSummaryValue(name);
- assertTrue( actualValue.trim().endsWith(expectedValue) );
+ assertTrue( "Doesn't fit - expected: '"+expectedValue+"';" +
+ " actual: '"+actualValue+"'",
+ actualValue.trim().endsWith(expectedValue) );
}
@@ -217,9 +238,26 @@
*/
class NavTree {
- private void clickRootNode() throws IOException {
+ private void clickRootNode() throws IOException, EmbJoprTestException {
DomElement element = (DomElement)client.getElement("navTreeForm");
- HtmlAnchor rootNodeLink = element.getFirstByXPath("//a[@id='navTreeForm:navTree:2::homeLink']");
+ if( null == element )
+ throw new HtmlElementNotFoundException("Can't find #navTreeForm.");
+
+ // ID changes upon core build?
+ //HtmlAnchor rootNodeLink = element.getFirstByXPath("//a[@id='navTreeForm:navTree:2::homeLink']");
+
+ // javax.xml.transform.TransformerException: Can't find function: matches
+ //HtmlAnchor rootNodeLink = element.getFirstByXPath(
+ // "//a[matches(@id,'^navTreeForm:navTree:.+::homeLink$')]");
+
+
+ String xPath = "//a[ starts-with( @id, 'navTreeForm:navTree:' ) " +
+ " and contains( @id, '::homeLink' ) ]"; // XPath 2.0: ends-with( @id, '::homeLink' )
+ HtmlAnchor rootNodeLink = element.getFirstByXPath(xPath);
+
+ if( null == rootNodeLink )
+ throw new HtmlElementNotFoundException("Root node not found using XPath: "+xPath);
+
rootNodeLink.click();
}
@@ -239,7 +277,7 @@
public TabContentBox getTabContentBox() throws EmbJoprTestException {
HtmlElement contentElement = (HtmlElement) client.getElement("content");
- HtmlElement tabContentBox = (HtmlElement) contentElement.getByXPath("div[@class='tabmenubox']");
+ HtmlElement tabContentBox = (HtmlElement) contentElement.getFirstByXPath("div[@class='tabmenubox']");
if( null == tabContentBox )
throw new EmbJoprTestException("Tab content box not found using div[@class='tabmenubox'] XPath");
@@ -249,11 +287,11 @@
public StyledElement getTab( String label ) throws EmbJoprTestException {
DomElement element = (DomElement)client.getElement("tabmenu");
- StyledElement tabContent = element.getFirstByXPath(
- "ul/li/span[string()='"+label+"'] | ul/li/a[string()='"+label+"']");
+ String xPath = "ul/li/span[normalize-space(string())='"+label+"'] | ul/li/a[normalize-space(string())='"+label+"']";
+ StyledElement tabContent = element.getFirstByXPath(xPath);
if( null == tabContent )
- throw new EmbJoprTestException("No such tab: "+label);
+ throw new EmbJoprTestException("Tab '"+label+" not found using XPath '"+xPath+"'");
return tabContent;
@@ -326,12 +364,12 @@
}
}
- public HtmlButton getButtonByLabel( String label )
+ public HtmlButtonInput getButtonByLabel( String label )
throws HtmlElementNotFoundException, ActionOutOfSyncException {
checkIfStillValid();
- HtmlButton button = this.box.getFirstByXPath("//input[@value='"+label+"']");
+ HtmlButtonInput button = this.box.getFirstByXPath("//input[@value='"+label+"']");
if( null == button )
throw new HtmlElementNotFoundException("Button labelled '"+label+"' not found.");
15 years, 10 months
EMBJOPR SVN: r146 - trunk/core/src/main/webapp/secure.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-02-13 07:29:16 -0500 (Fri, 13 Feb 2009)
New Revision: 146
Modified:
trunk/core/src/main/webapp/secure/resourceInstanceSummary.xhtml
Log:
Changing <b> to <strong>, see https://jira.jboss.org/jira/browse/EMBJOPR-72
Modified: trunk/core/src/main/webapp/secure/resourceInstanceSummary.xhtml
===================================================================
--- trunk/core/src/main/webapp/secure/resourceInstanceSummary.xhtml 2009-02-12 17:05:48 UTC (rev 145)
+++ trunk/core/src/main/webapp/secure/resourceInstanceSummary.xhtml 2009-02-13 12:29:16 UTC (rev 146)
@@ -69,7 +69,7 @@
var="trait"
columnClasses="standard-traitscolumn">
<h:column>
- <b>#{ summaryMeasurementDefinitionMap[trait.measurementData.name].displayName}:</b>
+ <strong>#{ summaryMeasurementDefinitionMap[trait.measurementData.name].displayName}:</strong>
#{ trait.measurementValueAndUnits}
</h:column>
</h:dataTable>
15 years, 10 months
EMBJOPR SVN: r145 - in trunk/jsfunit: src/test/java/org/jboss/jopr/jsfunit/as4 and 4 other directories.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)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
15 years, 10 months