[embjopr-commits] EMBJOPR SVN: r152 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
embjopr-commits at lists.jboss.org
embjopr-commits at lists.jboss.org
Fri Feb 13 12:16:44 EST 2009
Author: ozizka at 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);
}
}
+
}
More information about the embjopr-commits
mailing list