[embjopr-commits] EMBJOPR SVN: r505 - in trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit: as5/app/ejb and 1 other directory.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Fri Jun 5 12:43:21 EDT 2009


Author: ozizka at redhat.com
Date: 2009-06-05 12:43:20 -0400 (Fri, 05 Jun 2009)
New Revision: 505

Added:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/Ejb30Test.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java
Modified:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/Ejb20Test.java
Log:
EJB tests updated.

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java	2009-06-05 13:55:21 UTC (rev 504)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java	2009-06-05 16:43:20 UTC (rev 505)
@@ -41,22 +41,25 @@
 		 */
 		public enum DeployableTypes {
 
-			// Nav tree link label, testdata/$dir, extension, suffix, mime type.
-			EAR(AppConstants.NAV_EAR,   "ear",   ".ear", null,  "application/ear"),
-			WAR(AppConstants.NAV_WAR,   "war",   ".war", null,  "application/war"),
-			EJB2(AppConstants.NAV_EJB2, "ejb2",  ".jar", null,  "application/java-archive"),
-			EJB3(AppConstants.NAV_EJB3, "ejb3",  ".jar", null,  "application/java-archive"),
-			SAR(AppConstants.NAV_SAR,   "sar",   ".sar", "-service.xml", "application/sar"),
-			RAR(AppConstants.NAV_RAR,   "rar",   ".rar", null,   "application/rar"),
-			EMB_RAR(AppConstants.NAV_EMB_RAR,"", ".rar", null, "application/rar"),
-			MC_BEAN(AppConstants.NAV_MC, "mc",   "",     null,   "application/java-archive"),
-			EMB_WAR(AppConstants.NAV_EMB_WAR,"",".war", null, "application/war");
+			// Nav tree link label, EmbJopr display name, testdata/$dir, extension, suffix, mime type.
+			EAR(AppConstants.NAV_EAR,        "EAR",           "ear",   ".ear", null,  "application/ear"),
+			WAR(AppConstants.NAV_WAR,        "WAR",           "war",   ".war", null,  "application/war"),
+			EJB2(AppConstants.NAV_EJB2,      "EJB2 JAR",      "ejb2",  ".jar", null,  "application/java-archive"),
+			EJB3(AppConstants.NAV_EJB3,      "EJB3 JAR",      "ejb3",  ".jar", null,  "application/java-archive"),
+			SAR(AppConstants.NAV_SAR,        "SAR",           "sar",   ".sar", "-service.xml", "application/sar"),
+			RAR(AppConstants.NAV_RAR,        "RAR",           "rar",   ".rar", null,   "application/rar"),
+			EMB_RAR(AppConstants.NAV_EMB_RAR,"Embedded RAR",  "",      ".rar", null, "application/rar"),
+			MC_BEAN(AppConstants.NAV_MC,     "?",             "mc",    "",     null,   "application/java-archive"),
+			EMB_WAR(AppConstants.NAV_EMB_WAR,"Embbedded WAR", "",      ".war", null, "application/war");
 
 			// -- Fields --
 
 			protected final String navTreeLabel;
 			public String getNavTreeLabel() {			return navTreeLabel;		}
 
+			protected final String displayName;
+			public String getDisplayName() {			return displayName;		}
+
 			protected final String dataDir;
 			public String getDataDir() {			return dataDir;		}
 
@@ -76,11 +79,13 @@
 
 			private DeployableTypes(
 							String navTreeLabel,
+							String displayName,
 							String dataDir,
 							String extension,
 							String suffix, String mimeType)
 			{
 				this.navTreeLabel = navTreeLabel;
+				this.displayName = displayName;
 				this.dataDir = dataDir;
 				this.extension = extension;
 				this.suffix = suffix;
@@ -131,14 +136,17 @@
 
 
 		// EJB 2.x
+    public static final String BASIC_EJB2 = "deployment-ejb.jar";
     public static final String BAD_EJB2_JAR = "ejbredeploy-bad.jar";
     public static final String GOOD_EJB2_JAR = "ejbredeploy-good.jar";
     public static final String REDEPLOY_EJB2_JAR = "ejbredeploy.jar";
 
 
 		// EJB 3.0
-    public static final String BASIC_EJB2 = "deployment-ejb.jar";
     public static final String BASIC_EJB3 = "BasicEJB3.jar";
+    public static final String BAD_EJB3_JAR = "BasicEJB3-bad.jar";
+    public static final String GOOD_EJB3_JAR = "BasicEJB3-good.jar";
+    public static final String REDEPLOY_EJB3_JAR = "BasicEJB3.jar";
 
 
 		// EAR
@@ -208,8 +216,10 @@
 			"sqlexception-service.xml", "transaction-service.xml", "uuid-key-generator.sar"
 		};
 		
-   // Status Messages
-    public static final String EJB2_DEL_MSG = "Successfully deleted EJB2 JAR";
-    public static final String EJB3_DEL_MSG = "Successfully deleted EJB3 JAR";
+		// Status Messages
+		//public static final String EJB2_DEL_MSG = "Successfully deleted EJB2 JAR";
+		//public static final String EJB3_DEL_MSG = "Successfully deleted EJB3 JAR";
+		public static final String EJB_DEL_MSG_FORMAT = "Successfully deleted %s JAR '%s'.";
+		public static final String DELETE_MSG_FORMAT = "Successfully deleted %s '%s'.";
 
 }

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/Ejb20Test.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/Ejb20Test.java	2009-06-05 13:55:21 UTC (rev 504)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/Ejb20Test.java	2009-06-05 16:43:20 UTC (rev 505)
@@ -23,21 +23,7 @@
 
 import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;
 
-import com.gargoylesoftware.htmlunit.WebClient;
-import org.jboss.jopr.jsfunit.*;
-import com.gargoylesoftware.htmlunit.html.*;
-import java.io.*;
-import java.util.*;
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
-import javax.servlet.http.HttpServletRequest;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.math.NumberUtils;
 import org.jboss.jopr.jsfunit.AppConstants.DeployableTypes;
-import org.jboss.jopr.jsfunit.exceptions.*;
 import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;
 
 /**
@@ -47,387 +33,36 @@
  * @author Shelly McGowan
  *
  */
-public class Ejb20Test extends ApplicationTestBaseAS5 {
+public class Ejb20Test extends EjbTestBase {
 
-	public static final DeployableTypes APP_TYPE = DeployableTypes.EJB2;
-
-	/**
-	 * @return the suite of tests being tested
-	 */
-	public static Test suite() {
-		return new TestSuite(Ejb20Test.class);
+	public DeployableTypes getAppType() {
+		return DeployableTypes.EJB2;
 	}
 
-
-
-
-
-	/*
-	 * 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, EmbJoprTestException {
-
-		final String DEPLOYABLE_NAME = BASIC_EJB2;
-
-		try {
-			// Navigate to EJB Applications
-			HtmlAnchor ejbLink = getNavTreeLink(APP_TYPE.getNavTreeLabel());
-			ejbLink.click();
-
-			// click on the "Add new resource" button
-			client.click("actionHeaderForm:addNewContent");  // 404 if setThrowExceptionOnFailingStatusCode(true) above
-
-			// TODO: "/ejb/BASIC_JAR" causes exceptions in seam:
-			// http://wwwapps.rdu.redhat.com/w3xpastebin/pastebin.php?show=9842
-
-			String filePath = ejtt.getTestDataDir() + "/" + APP_TYPE.getDataDir() + "/" + DEPLOYABLE_NAME;
-			log.info("Uploading EJB2 archive: " + filePath);
-			File uploadFile = new File(filePath);
-			if (!uploadFile.exists()) {
-				throw new EmbJoprTestException("Can't find EJB2 file to upload: '" + filePath + "'");
-			}
-
-			// upload ejb
-			HtmlFileInput fileInput = (HtmlFileInput) client.getElement("createContentForm:file");
-			fileInput.setContentType("application/ejb");
-			fileInput.setValueAttribute(filePath);
-			client.click("createContentForm:addButton");
-
-			log.info("HTTP status after EJB2 upload: " + client.getContentPage().getWebResponse().getStatusCode());
-			log.info("renderResponse() called: " + server.getFacesContext().getRenderResponse());
-			log.info("responseComplete() called: " + server.getFacesContext().getResponseComplete());
-
-			String errorMessage =
-							(server.getFacesMessages().hasNext() && server.getFacesMessages().next().getSeverity() != FacesMessage.SEVERITY_INFO) ? " Faces message: " + server.getFacesMessages().next()
-							: ""; // Awful code
-
-			// FAILS because of NPE and HTTP 500.
-			// assert that the success message appeared on the client side
-			assertTrue("Success message not found." + errorMessage, client.getPageAsText().contains("Resource " + DEPLOYABLE_NAME + " 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 " + DEPLOYABLE_NAME + " created successfully!"));
-
-			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(DEPLOYABLE_NAME));
-
-			// Undeploy the EJB JAR
-			HtmlButtonInput deleteButton = getAppDeleteButton(DEPLOYABLE_NAME);
-			deleteButton.click();
-
-			assertTrue("Page doesn't contain success message.", client.getPageAsText().contains(EJB2_DEL_MSG + " '" + DEPLOYABLE_NAME + "'."));
-
-			assertFalse("Deployable seems not to be deployed: " + DEPLOYABLE_NAME, isEJBDeployed(DEPLOYABLE_NAME));
-		} finally {
-			// Undeploy the EJB JAR
-			try {
-				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, REDEPLOY_EJB2_JAR);
-			} catch (EmbJoprTestException ex) {
-				log.debug("Exception during undeployment - " + ex.getMessage());
-			}
-		}
-
-	}// testBasicEjbDeployment()
-
-
-
-
-
-
-	
-	/**
-	test Strategy:
-
-	Deploy an ejb-jar that is known to have a bad deployment
-	descriptor.  Verify the console shows deployment failed.
-	Upload the fixed the achive, redeploy and
-	verify the archive has been successfully deployed.
-	 */
-	public void testBadEjbRedeploy() throws IOException, HtmlElementNotFoundException, ActionNotAvailableException {
-
-		try {
-			String badFileSrcPath = ejtt.getTestDataDir() + "/" + APP_TYPE.getDataDir() + "/" + BAD_EJB2_JAR;
-			String goodFileSrcPath = ejtt.getTestDataDir() + "/" + APP_TYPE.getDataDir() + "/" + GOOD_EJB2_JAR;
-			String ejbFilePath = ejtt.getTestDataDir() + "/" + APP_TYPE.getDataDir() + "/" + REDEPLOY_EJB2_JAR;
-
-			FileUtils.copyFile(new File(badFileSrcPath), new File(ejbFilePath));
-			//deployEJB(ejbFilePath);
-			ejtt.deployment.deployViaEmbJopr(APP_TYPE, ejbFilePath);
-			assertFalse("JMX doesn't report " + REDEPLOY_EJB2_JAR + " as deployed.", isEJBDeployed(REDEPLOY_EJB2_JAR));
-
-			// Copy fixed archive to same name, and deploy
-			FileUtils.copyFile(new File(goodFileSrcPath), new File(ejbFilePath));
-
-			//deployEJB(ejbFilePath);
-			ejtt.deployment.deployViaEmbJopr(APP_TYPE, ejbFilePath);
-
-			// 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 " + REDEPLOY_EJB2_JAR + " created successfully!"));
-
-			// Use JMX to assert that the EJB components really did deploy successfully
-			assertTrue(isEJBDeployed(REDEPLOY_EJB2_JAR));
-
-			assertTrue("Page doesn't contain success message.", client.getPageAsText().contains(EJB2_DEL_MSG + " '" + REDEPLOY_EJB2_JAR + "'."));
-			assertFalse("Deployable seems not to be deployed: " + REDEPLOY_EJB2_JAR, isEJBDeployed(REDEPLOY_EJB2_JAR));
-		} finally {
-			// Undeploy the EJB JAR
-			try {
-				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, REDEPLOY_EJB2_JAR);
-			} catch (EmbJoprTestException ex) {
-				log.debug("Exception during undeployment - " + ex.getMessage());
-			}
-		}
+	@Override
+	public String getArchiveNameBasic() {
+		return BASIC_EJB2;
 	}
 
-
-
-
-	/**
-	 *
-	 */
-	public void testEjb20SummaryTab() throws EmbJoprTestException, IOException {
-
-		final String DEPLOYABLE_NAME = BASIC_EJB2;
-
-		try {
-
-			// Deploy the APP
-			String appFilePath = ejtt.getTestDataDir() + "/"+APP_TYPE.getDataDir()+"/" + DEPLOYABLE_NAME;
-			ejtt.deployment.deployViaEmbJopr(APP_TYPE, appFilePath);
-
-			// Click on the app link.
-			ContentTableRow appRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
-			appRow.getLinkByLabel(DEPLOYABLE_NAME).click();
-
-
-			// Check the values in info table(s)
-
-			// General Properties
-			HtmlTable genpropTable = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("General Properties").getElement();
-			ContentInfoTable infoTable = ejtt.getContentInfoTable(genpropTable);
-			Properties props = infoTable.getProperties();
-
-			// Name
-			assertEquals(DEPLOYABLE_NAME, props.getProperty("Name").trim());
-			// Version: "--"
-			// Description: "a standalone EJB 2.x application"
-
-
-			// Traits
-			infoTable = ejtt.getContentInfoTable(
-							ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Traits").getElement());
-			props = infoTable.getProperties();
-
-			// Path
-			String path = ejtt.getDeployDir() + "/" + DEPLOYABLE_NAME;
-			assertEquals(path, props.getProperty("Path").trim());
-
-			// Exploded
-			assertEquals("no", props.getProperty("Exploded?").trim());
-
-			/* Currently hidden.
-			// Metrics Summary
-			HtmlTable summaryTable = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Numeric Metrics").getElement();
-			infoTable = ejtt.getContentInfoTable(summaryTable);
-			/**/
-
-		} finally {
-			try {
-				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
-			} catch (Exception ex) {
-				log.error("Caught exception when undeploying: " + ex, ex);
-			}
-		}
-
+	@Override
+	public String getArchiveNameGood() {
+		return GOOD_EJB2_JAR;
 	}
 
-	/**
-	 *
-	 */
-	public void testEjb20MetricsTab() throws EmbJoprTestException, IOException {
-
-		final String DEPLOYABLE_NAME = BASIC_EJB2;
-
-		try {
-
-			// Deploy the APP
-			String appFilePath = ejtt.getTestDataDir() + "/"+APP_TYPE.getDataDir()+"/" + DEPLOYABLE_NAME;
-			ejtt.deployment.deployViaEmbJopr(APP_TYPE, appFilePath);
-
-			// Click on the app link.
-			ContentTableRow appRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
-			appRow.getLinkByLabel(DEPLOYABLE_NAME).click();
-
-			// Switch to the Metrics tab.
-			ejtt.tabMenu.getTabByID(METRICS_TAB).click();
-
-
-			// Check the values in info table(s)
-
-			// General Properties
-			HtmlTable genpropTable = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("General Properties").getElement();
-			ContentInfoTable infoTable = ejtt.getContentInfoTable(genpropTable);
-			Properties props = infoTable.getProperties();
-
-			// Traits
-			infoTable = ejtt.getContentInfoTable(
-							ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Traits").getElement());
-			props = infoTable.getProperties();
-
-			// Path
-			String path = ejtt.getDeployDir() + "/" + DEPLOYABLE_NAME;
-			assertEquals(path, props.getProperty("Path").trim());
-
-
-			/* Currently no num metrics..
-			// Metrics Summary
-			HtmlTable summaryTable = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Numeric Metrics").getElement();
-			infoTable = ejtt.getContentInfoTable(summaryTable);
-			/**/
-
-
-			// Finally, click the Refresh button.
-			String xPath = ".//input[normalize-space(value)='Refresh']";
-			HtmlInput button = ejtt.tabMenu.getTabContentBox().getElement().getFirstByXPath(xPath);
-			if( null == button )
-				throw new HtmlElementNotFoundException("Refresh button not found using XPath: "+xPath);
-
-			button.click();
-
-			// Check that we are still on Metrics tab.
-			assertTrue( ejtt.tabMenu.isTabActiveByID(METRICS_TAB) );
-
-
-		} finally {
-			try {
-				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
-			} catch (Exception ex) {
-				log.error("Caught exception when undeploying: " + ex, ex);
-			}
-		}
-
+	@Override
+	public String getArchiveNameBad() {
+		return BAD_EJB2_JAR;
 	}
 
-
-
-
-
-
-
-
-
-	/**
-	 * Stops and Starts an EJB.
-	 *
-	 * Was failing because of EMBJOPR-133.
-	 * Now FAILS because of EMBJOPR-172.
-	 */
-	public void testEjbStopAndStart() throws IOException, EmbJoprTestException
-	{
-		final String DEPLOYABLE_NAME = BASIC_EJB2;
-
-
-		// Deploy the APP.
-		String appfilePath = ejtt.getTestDataDir() + "/"+APP_TYPE.getDataDir()+"/"+DEPLOYABLE_NAME;
-		ejtt.deployment.deployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
-
-
-		try {
-
-			// Wait until app is UP
-			ejtt.getNavTree().getNodeByLabel(APP_TYPE.getNavTreeLabel()).click();
-			ejtt.deployment.waitActivelyForDeployment(APP_TYPE, DEPLOYABLE_NAME,
-							3000, 15, this);
-
-			// Navigate to the web app, then to it's Control tab.
-			ContentTableRow row = ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
-			row.getLinkByLabel(DEPLOYABLE_NAME).click();
-			ejtt.getTabMenu().clickControlTab();
-
-			// Click the Stop button.
-			ejtt.tabMenu.getTabContentBox().getButtonByLabel("Stop").click();
-
-			// Wait for the op to finish and check the final status.
-			ejtt.operations.waitActivelyForOperationToFinish("Stop", 1500, 5);
-			assertTrue( ejtt.getTabMenu().getTabContentBox().getOperationsHistoryTable().wasLastOperationSuccesful() );
-
-
-
-			// Click the Start button.
-			ejtt.tabMenu.getTabContentBox().getButtonByLabel("Start").click();
-			ejtt.operations.waitActivelyForOperationToFinish("Start", 1500, 5);
-
-		}
-		finally {
-			try {
-				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
-			}catch( Exception ex ){
-				log.error("Caught exception when undeploying: "+ex, ex);
-			}
-		}
+	@Override
+	public String getArchiveNameRedeploy() {
+		return REDEPLOY_EJB2_JAR;
 	}
 
 
-	/**
-	 * Restarts the EJB in Control tab.
-	 */
-	public void testEjbRestart() throws IOException, EmbJoprTestException
-	{
-		final String DEPLOYABLE_NAME = BASIC_EJB2;
 
 
-		// Deploy the app.
-		String appFilePath = ejtt.getTestDataDir() + "/"+APP_TYPE.getDataDir()+"/"+DEPLOYABLE_NAME;
-		ejtt.deployment.deployViaEmbJopr(APP_TYPE, appFilePath);
 
-		try {
-
-			// Wait until app is UP
-			ejtt.getNavTree().getNodeByLabel(APP_TYPE.getNavTreeLabel()).click();
-			ejtt.deployment.waitActivelyForDeployment(APP_TYPE, DEPLOYABLE_NAME,
-							3000, 15, this);
-
-
-			// Navigate to the app, then to it's Control tab.
-			ContentTableRow row = ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
-			row.getLinkByLabel(DEPLOYABLE_NAME).click();
-			ejtt.getTabMenu().clickControlTab();
-
-			// Click the Restart button.
-			ejtt.tabMenu.getTabContentBox().getButtonByLabel("Restart").click();
-
-			// Wait for the op to finish and check the final status.
-			ejtt.operations.waitActivelyForOperationToFinish("Restart", 1500, 5);
-			assertTrue( ejtt.getTabMenu().getTabContentBox().getOperationsHistoryTable().wasLastOperationSuccesful() );
-
-		}
-		finally {
-			try {
-				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
-			}catch( Exception ex ){
-				log.error("Caught exception when undeploying: "+ex, ex);
-			}
-		}
-	}
-
-
-
-
-
 }// class
 
 

Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/Ejb30Test.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/Ejb30Test.java	                        (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/Ejb30Test.java	2009-06-05 16:43:20 UTC (rev 505)
@@ -0,0 +1,69 @@
+/*
+ * 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.app.ejb;
+
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;
+
+import org.jboss.jopr.jsfunit.AppConstants.DeployableTypes;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;
+
+/**
+ * This class contains tests for testing the EmbJopr Application
+ * Management Functions for Enterprise JavaBean archives with JBoss AS 5.
+ * 
+ * @author Shelly McGowan
+ *
+ */
+public class Ejb30Test extends EjbTestBase {
+
+	public DeployableTypes getAppType() {
+		return DeployableTypes.EJB3;
+	}
+
+	@Override
+	public String getArchiveNameBasic() {
+		return BASIC_EJB3;
+	}
+
+	@Override
+	public String getArchiveNameGood() {
+		return GOOD_EJB3_JAR;
+	}
+
+	@Override
+	public String getArchiveNameBad() {
+		return BAD_EJB3_JAR;
+	}
+
+	@Override
+	public String getArchiveNameRedeploy() {
+		return REDEPLOY_EJB3_JAR;
+	}
+
+
+
+
+
+}// class
+
+
+

Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java	                        (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java	2009-06-05 16:43:20 UTC (rev 505)
@@ -0,0 +1,441 @@
+/*
+ * 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.app.ejb;
+
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;
+
+import org.jboss.jopr.jsfunit.*;
+import com.gargoylesoftware.htmlunit.html.*;
+import java.io.*;
+import java.util.*;
+import javax.faces.application.FacesMessage;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.commons.io.FileUtils;
+import org.jboss.jopr.jsfunit.AppConstants.DeployableTypes;
+import org.jboss.jopr.jsfunit.exceptions.*;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;
+
+/**
+ * This class contains tests for testing the EmbJopr Application
+ * Management Functions for Enterprise JavaBean archives with JBoss AS 5.
+ * 
+ * @author Ondrej Zizka
+ *
+ */
+public abstract class EjbTestBase extends ApplicationTestBaseAS5 {
+
+	public abstract DeployableTypes getAppType();
+	public abstract String getArchiveNameBasic();
+	public abstract String getArchiveNameGood();
+	public abstract String getArchiveNameBad();
+	public abstract String getArchiveNameRedeploy();
+
+
+	public final DeployableTypes APP_TYPE = this.getAppType();
+
+	/**
+	 * @return the suite of tests being tested
+	 */
+	public static Test suite() {
+		return new TestSuite(EjbTestBase.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 testEjbBasicDeployment() throws IOException, EmbJoprTestException {
+
+		final String DEPLOYABLE_NAME = getArchiveNameBasic();
+
+		try {
+			// Navigate to EJB Applications
+			HtmlAnchor ejbLink = getNavTreeLink(APP_TYPE.getNavTreeLabel());
+			ejbLink.click();
+
+			// click on the "Add new resource" button
+			client.click("actionHeaderForm:addNewContent");  // 404 if setThrowExceptionOnFailingStatusCode(true) above
+
+			// TODO: "/ejb/BASIC_JAR" causes exceptions in seam:
+			// http://wwwapps.rdu.redhat.com/w3xpastebin/pastebin.php?show=9842
+
+			String filePath = ejtt.getTestDataDir() + "/" + APP_TYPE.getDataDir() + "/" + DEPLOYABLE_NAME;
+			log.info("Uploading EJB archive: " + filePath);
+			File uploadFile = new File(filePath);
+			if (!uploadFile.exists()) {
+				throw new EmbJoprTestException("Can't find EJB file to upload: '" + filePath + "'");
+			}
+
+			// upload ejb
+			HtmlFileInput fileInput = (HtmlFileInput) client.getElement("createContentForm:file");
+			fileInput.setContentType("application/ejb");
+			fileInput.setValueAttribute(filePath);
+			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());
+
+			String errorMessage =
+							(server.getFacesMessages().hasNext() && server.getFacesMessages().next().getSeverity() != FacesMessage.SEVERITY_INFO)
+							? " Faces message: " + server.getFacesMessages().next()
+							: ""; // Awful code
+
+			// FAILS because of NPE and HTTP 500.
+			// assert that the success message appeared on the client side
+			assertTrue("Success message not found." + errorMessage, client.getPageAsText().contains("Resource " + DEPLOYABLE_NAME + " 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 " + DEPLOYABLE_NAME + " created successfully!"));
+
+			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(DEPLOYABLE_NAME));
+
+			// Undeploy the EJB JAR
+			HtmlButtonInput deleteButton = getAppDeleteButton(DEPLOYABLE_NAME);
+			deleteButton.click();
+
+			String expectedMessage = String.format(EJB_DEL_MSG_FORMAT, APP_TYPE, DEPLOYABLE_NAME);
+			assertTrue("Page doesn't contain success message.", client.getPageAsText().contains(expectedMessage));
+			assertFalse("Deployable should be undeployed: " + DEPLOYABLE_NAME, isEJBDeployed(DEPLOYABLE_NAME));
+		}
+		finally {
+			// Undeploy the EJB JAR
+			try {
+				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
+			} catch (EmbJoprTestException ex) {
+				log.debug("Expected exception during undeployment - " + ex.getMessage());
+			}
+		}
+
+	}//
+
+
+
+
+
+
+	
+	/**
+		test Strategy:
+
+		Deploy an ejb-jar that is known to have a bad deployment
+		descriptor.  Verify the console shows deployment failed.
+		Upload the fixed the achive, redeploy and
+		verify the archive has been successfully deployed.
+	 */
+	public void testEjbDeployBadAndRedeploy() throws IOException, HtmlElementNotFoundException, ActionNotAvailableException {
+
+		final String REDEPLOY_JAR_NAME = getArchiveNameRedeploy();
+
+		try {
+			String badFileSrcPath = ejtt.getTestDataDir() + "/" + APP_TYPE.getDataDir() + "/" + getArchiveNameBad();
+			String goodFileSrcPath = ejtt.getTestDataDir() + "/" + APP_TYPE.getDataDir() + "/" + getArchiveNameGood();
+			String ejbFilePath = ejtt.getTestDataDir() + "/" + APP_TYPE.getDataDir() + "/" + REDEPLOY_JAR_NAME;
+
+			// Copy bad file under good file's name (we need to keep the filename the same for redeployment).
+			FileUtils.copyFile(new File(badFileSrcPath), new File(ejbFilePath));
+			ejtt.deployment.deployViaEmbJopr(APP_TYPE, ejbFilePath);
+			assertFalse("JMX shouldn't report " + REDEPLOY_JAR_NAME + " as deployed - it's renamed malformed jar '"+getArchiveNameBad()+"'.", isEJBDeployed(REDEPLOY_JAR_NAME));
+
+			// Copy fixed archive to same name, and deploy.
+			FileUtils.copyFile(new File(goodFileSrcPath), new File(ejbFilePath));
+			ejtt.deployment.deployViaEmbJopr(APP_TYPE, ejbFilePath);
+
+			// 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 " + REDEPLOY_JAR_NAME + " created successfully!"));
+
+			// Use JMX to assert that the EJB components really did deploy successfully.
+			assertTrue("JMX shouldn't report " + REDEPLOY_JAR_NAME + " as deployed.", isEJBDeployed(REDEPLOY_JAR_NAME));
+
+			String expectedMessage = String.format( DELETE_MSG_FORMAT, APP_TYPE.getDisplayName(), REDEPLOY_JAR_NAME);
+			assertTrue("Page doesn't contain success message.", client.getPageAsText().contains(expectedMessage));
+			assertFalse("Deployable seems not to be deployed: " + REDEPLOY_JAR_NAME, isEJBDeployed(REDEPLOY_JAR_NAME));
+		}
+		finally {
+			// Undeploy the EJB JAR
+			try {
+				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, REDEPLOY_JAR_NAME);
+			} catch (EmbJoprTestException ex) {
+				log.debug("Exception during undeployment - " + ex.getMessage());
+			}
+		}
+	}
+
+
+
+
+	/**
+	 *
+	 */
+	public void testEjbSummaryTab() throws EmbJoprTestException, IOException {
+
+		final String DEPLOYABLE_NAME = getArchiveNameBasic();
+
+		try {
+
+			// Deploy the APP
+			String appFilePath = ejtt.getTestDataDir() + "/"+APP_TYPE.getDataDir()+"/" + DEPLOYABLE_NAME;
+			ejtt.deployment.deployViaEmbJopr(APP_TYPE, appFilePath);
+
+			// Click on the app link.
+			ContentTableRow appRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
+			appRow.getLinkByLabel(DEPLOYABLE_NAME).click();
+
+
+			// Check the values in info table(s)
+
+			// General Properties
+			HtmlTable genpropTable = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("General Properties").getElement();
+			ContentInfoTable infoTable = ejtt.getContentInfoTable(genpropTable);
+			Properties props = infoTable.getProperties();
+
+			// Name
+			assertEquals(DEPLOYABLE_NAME, props.getProperty("Name").trim());
+			// Version: "--"
+			// Description: "a standalone EJB 2.x application"
+
+
+			// Traits
+			infoTable = ejtt.getContentInfoTable(
+							ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Traits").getElement());
+			props = infoTable.getProperties();
+
+			// Path
+			String path = ejtt.getDeployDir() + "/" + DEPLOYABLE_NAME;
+			assertEquals(path, props.getProperty("Path").trim());
+
+			// Exploded
+			assertEquals("no", props.getProperty("Exploded?").trim());
+
+			/* Currently hidden.
+			// Metrics Summary
+			HtmlTable summaryTable = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Numeric Metrics").getElement();
+			infoTable = ejtt.getContentInfoTable(summaryTable);
+			/**/
+
+		} finally {
+			try {
+				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
+			} catch (Exception ex) {
+				log.error("Caught exception when undeploying: " + ex, ex);
+			}
+		}
+
+	}
+
+
+
+	
+	/**
+	 *
+	 */
+	public void testEjbMetricsTab() throws EmbJoprTestException, IOException {
+
+		final String DEPLOYABLE_NAME = getArchiveNameBasic();
+
+		try {
+
+			// Deploy the APP
+			String appFilePath = ejtt.getTestDataDir() + "/"+APP_TYPE.getDataDir()+"/" + DEPLOYABLE_NAME;
+			ejtt.deployment.deployViaEmbJopr(APP_TYPE, appFilePath);
+
+			// Click on the app link.
+			ContentTableRow appRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
+			appRow.getLinkByLabel(DEPLOYABLE_NAME).click();
+
+			// Switch to the Metrics tab.
+			ejtt.tabMenu.getTabByID(METRICS_TAB).click();
+
+
+			// Check the values in info table(s)
+
+			// General Properties
+			HtmlTable genpropTable = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("General Properties").getElement();
+			ContentInfoTable infoTable = ejtt.getContentInfoTable(genpropTable);
+			Properties props = infoTable.getProperties();
+
+			// Traits
+			infoTable = ejtt.getContentInfoTable(
+							ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Traits").getElement());
+			props = infoTable.getProperties();
+
+			// Path
+			String path = ejtt.getDeployDir() + "/" + DEPLOYABLE_NAME;
+			assertEquals(path, props.getProperty("Path").trim());
+
+
+			/* Currently no num metrics..
+			// Metrics Summary
+			HtmlTable summaryTable = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader("Numeric Metrics").getElement();
+			infoTable = ejtt.getContentInfoTable(summaryTable);
+			/**/
+
+
+			// Finally, click the Refresh button.
+			String xPath = ".//input[normalize-space(value)='Refresh']";
+			HtmlInput button = ejtt.tabMenu.getTabContentBox().getElement().getFirstByXPath(xPath);
+			if( null == button )
+				throw new HtmlElementNotFoundException("Refresh button not found using XPath: "+xPath);
+
+			button.click();
+
+			// Check that we are still on Metrics tab.
+			assertTrue( ejtt.tabMenu.isTabActiveByID(METRICS_TAB) );
+
+
+		} finally {
+			try {
+				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
+			} catch (Exception ex) {
+				log.error("Caught exception when undeploying: " + ex, ex);
+			}
+		}
+
+	}
+
+
+
+
+
+	/**
+	 * Stops and Starts an EJB.
+	 *
+	 * Was failing because of EMBJOPR-133.
+	 * Now FAILS because of EMBJOPR-172.
+	 */
+	public void testEjbStopAndStart() throws IOException, EmbJoprTestException
+	{
+		final String DEPLOYABLE_NAME = getArchiveNameBasic();
+
+
+		// Deploy the APP.
+		String appfilePath = ejtt.getTestDataDir() + "/"+APP_TYPE.getDataDir()+"/"+DEPLOYABLE_NAME;
+		ejtt.deployment.deployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
+
+
+		try {
+
+			// Wait until app is UP
+			ejtt.getNavTree().getNodeByLabel(APP_TYPE.getNavTreeLabel()).click();
+			ejtt.deployment.waitActivelyForDeployment(APP_TYPE, DEPLOYABLE_NAME,
+							3000, 15, this);
+
+			// Navigate to the web app, then to it's Control tab.
+			ContentTableRow row = ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
+			row.getLinkByLabel(DEPLOYABLE_NAME).click();
+			ejtt.getTabMenu().clickControlTab();
+
+			// Click the Stop button.
+			ejtt.tabMenu.getTabContentBox().getButtonByLabel("Stop").click();
+
+			// Wait for the op to finish and check the final status.
+			ejtt.operations.waitActivelyForOperationToFinish("Stop", 1500, 5);
+			assertTrue( ejtt.getTabMenu().getTabContentBox().getOperationsHistoryTable().wasLastOperationSuccesful() );
+
+
+
+			// Click the Start button.
+			ejtt.tabMenu.getTabContentBox().getButtonByLabel("Start").click();
+			ejtt.operations.waitActivelyForOperationToFinish("Start", 1500, 5);
+
+		}
+		finally {
+			try {
+				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
+			}catch( Exception ex ){
+				log.error("Caught exception when undeploying: "+ex, ex);
+			}
+		}
+	}
+
+
+
+	
+	/**
+	 * Restarts the EJB in Control tab.
+	 */
+	public void testEjbRestart() throws IOException, EmbJoprTestException
+	{
+		final String DEPLOYABLE_NAME = getArchiveNameBasic();
+
+
+		// Deploy the app.
+		String appFilePath = ejtt.getTestDataDir() + "/"+APP_TYPE.getDataDir()+"/"+DEPLOYABLE_NAME;
+		ejtt.deployment.deployViaEmbJopr(APP_TYPE, appFilePath);
+
+		try {
+
+			// Wait until app is UP
+			ejtt.getNavTree().getNodeByLabel(APP_TYPE.getNavTreeLabel()).click();
+			ejtt.deployment.waitActivelyForDeployment(APP_TYPE, DEPLOYABLE_NAME,
+							3000, 15, this);
+
+
+			// Navigate to the app, then to it's Control tab.
+			ContentTableRow row = ejtt.getDefaultContentTable().getFirstRowContainingLink(DEPLOYABLE_NAME);
+			row.getLinkByLabel(DEPLOYABLE_NAME).click();
+			ejtt.getTabMenu().clickControlTab();
+
+			// Click the Restart button.
+			ejtt.tabMenu.getTabContentBox().getButtonByLabel("Restart").click();
+
+			// Wait for the op to finish and check the final status.
+			ejtt.operations.waitActivelyForOperationToFinish("Restart", 1500, 5);
+			assertTrue( ejtt.getTabMenu().getTabContentBox().getOperationsHistoryTable().wasLastOperationSuccesful() );
+
+		}
+		finally {
+			try {
+				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
+			}catch( Exception ex ){
+				log.error("Caught exception when undeploying: "+ex, ex);
+			}
+		}
+	}
+
+
+
+
+
+}// class
+
+
+




More information about the embjopr-commits mailing list