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

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Sun May 17 22:52:44 EDT 2009


Author: smcgowan at redhat.com
Date: 2009-05-17 22:52:43 -0400 (Sun, 17 May 2009)
New Revision: 431

Added:
   trunk/jsfunit/testdata/ejb2/ejbredeploy-bad.jar
Modified:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
   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/ejb/Ejb20Test.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/rar/RarTest.java
Log:
exclude testRarConfigurationTab test, add testRarInEar test and ejb redeploy

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java	2009-05-15 21:00:10 UTC (rev 430)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java	2009-05-18 02:52:43 UTC (rev 431)
@@ -112,12 +112,20 @@
     public static final String NAV_RAR = "Resource Adaptor (RAR)s";
     public static final String NAV_WAR = "Web Application (WAR)s";
     public static final String NAV_EMB_WAR = "Embedded Web Application (WAR)s";
+    public static final String NAV_EMB_RAR = "Embedded Resource Adaptor (RAR)s";
 
 		public static final String EAR_MALFORMED_APP_FILENAME = "malformed-application-xml.ear";
 		public static final String WAR_FILENAME_MALFORMED_APP = "malformed-web-xml.war";
 
     // Test Archives
 
+
+		// EJB 2.x
+    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 = "basic-ejb3.jar";
@@ -131,6 +139,7 @@
 		public static final String EAR_WITH_WAR_COUNTER = "EarWithWar-Counter.ear";
 		public static final String EAR_WITH_WAR_COUNTER_20 = "EarWithWar-Counter-20.ear";
 		public static final String EAR_EXT_DEPENDENCIES = "EarExtDependencies.ear";
+		public static final String EAR_WITH_RAR = "testscopedrar.ear";
 
 		// WAR
     public static final String BASIC_WAR = "hellothere.war";

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-05-15 21:00:10 UTC (rev 430)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/EarTest.java	2009-05-18 02:52:43 UTC (rev 431)
@@ -853,7 +853,7 @@
 
 
 			// Assert that the app is stopped.
-      page = (HtmlPage)webClient.getPage(testPageUrl);
+      			page = (HtmlPage)webClient.getPage(testPageUrl);
 			assertTrue( 200 != page.getWebResponse().getStatusCode() );
 
 
@@ -1147,21 +1147,52 @@
 
 
 
+	/*
+	 * testName: testRarInEarDeployment
+         * assertion:  verify the deployment of Enterprise Archive which contains a resource adapter jar
+	 * 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 testRarInEarDeployment() throws IOException, EmbJoprTestException
+	{
 
+		final String DEPLOYABLE_NAME =  EAR_WITH_RAR;
+		String query = "jboss.deployment:id=\"vfszip:" +
+                                                System.getProperty("jsfunit.deploy.dir") + "/" + EAR_WITH_RAR +
+						"/" + BASIC_RAR + "/\",*";
+		// Deploy the EAR.
+		String earFilePath = ejtt.getTestDataDir() + "/ear/"+DEPLOYABLE_NAME;
+		deployEar( earFilePath );
 
+		String expectedMessage = DEPLOYABLE_NAME + " created successfully";
+		checkClientAndServerMessages(expectedMessage, expectedMessage, false);
 
+		try {
+			assertTrue("JMX doesn't report EAR as deployed: testscopedrar.ear", isEarDeployed(DEPLOYABLE_NAME));
+			assertTrue("JMX doesn't report RAR as deployed. jbosstestadapter.rar", isMBeanStateDeployedByQuery(query));
+		}
+		catch (Exception e) {
+                        throw new RuntimeException(e);
+                }
 
+		finally {
+			try {
+			// Undeploy the EAR.
 
+			ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
+			assertFalse(isEarDeployed(DEPLOYABLE_NAME));
+			assertFalse(isMBeanStateDeployedByQuery(query));
+		 	} catch (Exception e) {
+                        	throw new RuntimeException(e);
+                	}
 
+		}
 
+	}
 
 
-
-
-
-
-
-
 	/**
 	 * Waits for the deployable to be in the UP State.
 	 *

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-05-15 21:00:10 UTC (rev 430)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/Ejb20Test.java	2009-05-18 02:52:43 UTC (rev 431)
@@ -30,7 +30,10 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import javax.faces.application.FacesMessage;
-import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+import org.apache.commons.io.FileUtils;
+import org.jboss.jopr.jsfunit.exceptions.*;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit;
+import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;
 
 
 
@@ -127,8 +130,117 @@
 		
 	}// 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);
+			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);
+
+			// 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));
+
+			// Undeploy the EJB JAR 
+			HtmlButtonInput deleteButton = getAppDeleteButton(REDEPLOY_EJB2_JAR);
+			deleteButton.click();
+
+			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 {
+                        undeployEJB(REDEPLOY_EJB2_JAR);
+                }
+        }
 	
 
+	// Helpers
+
+ 	private void undeployEJB( String ejbFileName )
+                                        throws IOException, HtmlElementNotFoundException, ActionNotAvailableException
+        {
+
+                // Navigate to Embedded EJB 2.x Applications
+                ejtt.getNavTree().getNodeLink(NAV_EJB2).click();
+
+                ejtt.getTabMenu().clickSummaryTab();
+
+                // Find the row containing the deployable. Use the pagination if needed.
+                ContentTableRow appRow = ejtt.getTabMenu().getTabContentBox().
+                                                findLinkRowInDataTableUsingPagination(ejbFileName);
+
+                if( null == appRow ){
+                        log.warn("Can't find row with Ejb 2.x to undeploy: "+ejbFileName);
+                        return;
+                }
+
+                appRow.getButtonByLabel("Delete").click();
+
+                // Log the message (with prefix of potential warning)
+                ejtt.logServerMessage("Something went wrong with undeploy: ");
+
+                // Sleep for 3 sec. TODO: write some waitForUndeployed(), as negation of opposite.
+                ejtt.sleep( 2000 );
+
+        }
+
+      private void deployEJB( String ejbFilePath )
+                                        throws IOException, HtmlElementNotFoundException
+        {
+                if( !(new File(ejbFilePath)).exists())
+                        throw new FileNotFoundException(ejbFilePath);
+
+                log.info("Deploying: "+ejbFilePath);
+
+                // Navigate to Embedded EJB 2 Applications
+                ejtt.getNavTree().getNodeLink(AppConstants.DeployableTypes.EJB2.getNavTreeLabel()).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/war");
+                fileInput.setValueAttribute(ejbFilePath);
+                client.click("createContentForm:addButton");
+
+                // Log server message.
+                ejtt.logServerMessage();
+
+                // Todo: Write some waitUntilDeployed().
+                ejtt.sleep( 2000 );
+
+        }
+
+
 }// class
 
 

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/rar/RarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/rar/RarTest.java	2009-05-15 21:00:10 UTC (rev 430)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/rar/RarTest.java	2009-05-18 02:52:43 UTC (rev 431)
@@ -332,8 +332,9 @@
 	/**
 	 * Changes RAR configuration, and checks whether the changes were saved.
 	 *
+	 * JOPR-147
 	 */
-	public void testRarConfigurationTab() throws IOException, EmbJoprTestException {
+	public void DISABLEDtestRarConfigurationTab() throws IOException, EmbJoprTestException {
 
 		// Deploy the RAR.
 		String rarFilePath = ejtt.getTestDataDir() +"/rar/"+ BASIC_RAR;

Added: trunk/jsfunit/testdata/ejb2/ejbredeploy-bad.jar
===================================================================
(Binary files differ)


Property changes on: trunk/jsfunit/testdata/ejb2/ejbredeploy-bad.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream




More information about the embjopr-commits mailing list