[embjopr-commits] EMBJOPR SVN: r151 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Fri Feb 13 11:22:02 EST 2009


Author: ozizka at 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);
+		}
+	}
 }




More information about the embjopr-commits mailing list