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

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Wed Jun 10 12:34:04 EDT 2009


Author: ozizka at redhat.com
Date: 2009-06-10 12:34:04 -0400 (Wed, 10 Jun 2009)
New Revision: 516

Added:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarStressTest.java
Modified:
   trunk/jsfunit/pom.xml
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java
Log:
Ear deployment stress test separated.

Modified: trunk/jsfunit/pom.xml
===================================================================
--- trunk/jsfunit/pom.xml	2009-06-10 15:22:21 UTC (rev 515)
+++ trunk/jsfunit/pom.xml	2009-06-10 16:34:04 UTC (rev 516)
@@ -462,6 +462,7 @@
                            </includes>
                            <excludes>
                              <exclude>**/as4/**</exclude>
+                             <exclude>**/*EarStressTest.java</exclude>
                              <!--
                               -->
                            </excludes>

Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarStressTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarStressTest.java	                        (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarStressTest.java	2009-06-10 16:34:04 UTC (rev 516)
@@ -0,0 +1,163 @@
+/*
+ * 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.ear;
+
+import org.jboss.jopr.jsfunit.*;
+import com.gargoylesoftware.htmlunit.html.*;
+import java.io.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.commons.lang.math.RandomUtils;
+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 Application archives with JBoss AS 5.
+ * 
+ * @author Ondra Zizka
+ *
+ */
+public class EarStressTest extends ApplicationTestBaseAS5 {
+
+	public static final DeployableTypes APP_TYPE = DeployableTypes.EAR;
+
+
+	
+	/**
+	  * @return the suite of tests being tested
+	*/
+	public static Test suite(){
+		return new TestSuite(EarStressTest.class);
+	}
+
+	public EarStressTest() {
+	}
+	private EarStressTest(String testToRun) {
+		super(testToRun);
+	}
+
+
+
+
+/**
+	 * Test aimed to reveal potential memory leak.
+	 * Can take very long.
+	 */
+	public void testEarDeploymentRepeated() throws IOException, EmbJoprTestException
+	{
+		final String DEPLOYABLE_NAME = BASIC_EAR;
+		int TURNS = 100;
+
+		try {
+			for (int i = TURNS; i > 0; i--) {
+				log.info("Remaining EAR deploys: "+i);
+				// Deploy the EAR.
+				String earFilePath = ejtt.getTestDataDir() + "/ear/"+DEPLOYABLE_NAME;
+				//deployEar( earFilePath );
+				ejtt.deployment.deployViaEmbJopr(APP_TYPE, earFilePath);
+				String expectedMessage = DEPLOYABLE_NAME + " created successfully";
+				checkClientAndServerMessages(expectedMessage, expectedMessage, false);
+				// Undeploy the EAR.
+				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
+			}
+		}
+		catch( EmbJoprTestException ex ){
+			log.error(ex.toString());
+			throw ex;
+		}
+		finally {
+			try {
+				// Undeploy the EAR.
+				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
+			}catch( EmbJoprTestException ex ){
+				// Expected to fail - EAR should be undeployed if everything goes well.
+				log.debug("Expected exception - "+ex.getMessage());
+			}
+		}
+
+	}
+
+
+
+
+	
+
+
+	private void deployEar( String earFilePath ) throws IOException, HtmlElementNotFoundException
+	{
+		if( !(new File(earFilePath)).exists())
+			throw new FileNotFoundException(earFilePath);
+
+		log.info("Deploying: "+earFilePath);
+
+		// Navigate to Enterprise Archives
+		ejtt.getNavTree().getNodeLink(NAV_EAR).click();
+
+		// click on the "Add new resource" button
+		client.click("actionHeaderForm:addNewContent");  // 404 if setThrowExceptionOnFailingStatusCode(true) above
+
+		// Upload the file
+		HtmlFileInput fileInput = (HtmlFileInput)client.getElement("createContentForm:file");
+		fileInput.setContentType("application/ear");
+		fileInput.setValueAttribute(earFilePath);
+		client.click("createContentForm:addButton");
+		ejtt.sleep( 2000 );
+
+		// Log the message
+		ejtt.logServerMessage("Something went wrong with deploy: ");
+	}
+
+	private void undeployEar( String earFileName ) throws IOException, HtmlElementNotFoundException, ActionNotAvailableException
+	{
+
+		// Navigate to Enterprise Archives
+		ejtt.getNavTree().getNodeLink(NAV_EAR).click();
+
+		ejtt.getTabMenu().clickSummaryTab();
+
+		/// Debug log - we're getting HTTP 500 here :/
+		String dumpFile = "target/"+this.getName()+"-undeployEar-"+(1000+RandomUtils.nextInt(1000))+".html";
+		log.debug("Dumping page to "+dumpFile);
+		DebugUtils.writeFile( dumpFile, client.getPageAsText());
+		int httpStatusCode = client.getContentPage().getWebResponse().getStatusCode();
+		if( 200 != httpStatusCode )
+			log.warn("Status code before undeployment is: "+httpStatusCode);
+
+		HtmlButtonInput deleteButton = getAppDeleteButton( earFileName );
+		deleteButton.click();
+
+		// Log the message (with prefix of potential warning)
+		ejtt.logServerMessage("Something went wrong with undeploy: ");
+
+		// Sleep for 3 sec.  TODO: write some waitForUndeployed()
+		ejtt.sleep( 3000 );
+
+	}
+
+
+
+}// class EarTest

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java	2009-06-10 15:22:21 UTC (rev 515)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java	2009-06-10 16:34:04 UTC (rev 516)
@@ -134,46 +134,10 @@
 
 
 
-	/**
-	 * Test aimed to reveal potential memory leak.
-	 * Can take very long.
-	 */
-	public void testEarDeploymentRepeated() throws IOException, EmbJoprTestException
-	{
-		final String DEPLOYABLE_NAME = BASIC_EAR;
-		int TURNS = 100;
 
-		try {
-			for (int i = TURNS; i > 0; i--) {
-				log.info("Remaining EAR deploys: "+i);
-				// Deploy the EAR.
-				String earFilePath = ejtt.getTestDataDir() + "/ear/"+DEPLOYABLE_NAME;
-				deployEar( earFilePath );
-				String expectedMessage = DEPLOYABLE_NAME + " created successfully";
-				checkClientAndServerMessages(expectedMessage, expectedMessage, false);
-				// Undeploy the EAR.
-				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
-			}
-		}
-		catch( EmbJoprTestException ex ){
-			log.error(ex.toString());
-			throw ex;
-		}
-		finally {
-			try {
-				// Undeploy the EAR.
-				ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
-			}catch( EmbJoprTestException ex ){
-				// Expected to fail - EAR should be undeployed if everything goes well.
-				log.debug("Expected exception - "+ex.getMessage());
-			}
-		}
 
-	}
 
 
-
-
 	
 	/**
 	 *	assertion:




More information about the embjopr-commits mailing list