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

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Thu Jun 11 11:53:00 EDT 2009


Author: ozizka at redhat.com
Date: 2009-06-11 11:53:00 -0400 (Thu, 11 Jun 2009)
New Revision: 517

Modified:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ApplicationsPageTest.java
Log:
Pagination test updated not to leave deployed apps upon failure.

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ApplicationsPageTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ApplicationsPageTest.java	2009-06-10 16:34:04 UTC (rev 516)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ApplicationsPageTest.java	2009-06-11 15:53:00 UTC (rev 517)
@@ -77,80 +77,100 @@
 	/**
 	 * Test pagination in Applications page.
 	 * 
-	 * FAILS because of EMBJOPR-61.
+	 * Was failing because of EMBJOPR-61.
 	 * Bad number of listed rows at page 2. expected:<5> but was:<0>
 	 */
 	public void testAppsPagination() throws EmbJoprTestException, IOException {
 
-		// Deploy enough apps.
-		// TODO: Create test which would only deploy many apps at once (hotdeploy/embjopr/both?).
-		// TODO: Undeploy.
-		String fileSrcPath = ejtt.getTestDataDir() +"/war/"+ BASIC_WAR;
-		
-		String destDir = ejtt.getTempDir() + "/appPagination";
-		new File(destDir).mkdirs();
-		if( ! new File(destDir).isDirectory() )
-			throw new EmbJoprTestException("Coundn't create directory: "+destDir);
+		final int DEPLOYED_WARS_COUNT = 8;
+		int succesfullyDeployed = 0;
 
-		// Deploy the same APP multiple times.
-		for (int i = 0; i < 8; i++) {
-			String fileDestPath = destDir+"/appPagination"+i+".war";
-			FileUtils.copyFile( new File(fileSrcPath), new File(fileDestPath) );
-			ejtt.deployment.deployViaEmbJoprRepeatedly( DeployableTypes.WAR, fileDestPath );
-		}
-		
+		try {
+			// Deploy enough apps.
+			// TODO: Create test which would only deploy many apps at once (hotdeploy/embjopr/both?).
+			// TODO: Undeploy.
+			String fileSrcPath = ejtt.getTestDataDir() +"/war/"+ BASIC_WAR;
 
-		// Navigate to apps summary tab
-		NavTreeNode appsNode = ejtt.navTree.getNodeByLabel(NAV_APPLICATIONS);
-		assertNotNull(appsNode);
-		appsNode.click();
-		ejtt.tabMenu.clickTab("Summary");
+			String destDir = ejtt.getTempDir() + "/appPagination";
+			new File(destDir).mkdirs();
+			if( ! new File(destDir).isDirectory() )
+				throw new EmbJoprTestException("Couldn't create directory: "+destDir);
 
-		ejtt.sleep(1000);
+			// Deploy the same APP multiple times.
+			for (int i = 0; i < DEPLOYED_WARS_COUNT; i++) {
+				String fileDestPath = destDir+"/appPagination"+i+".war";
+				FileUtils.copyFile( new File(fileSrcPath), new File(fileDestPath) );
+				ejtt.deployment.deployViaEmbJoprRepeatedly( DeployableTypes.WAR, fileDestPath );
+				succesfullyDeployed = i+1;
+			}
+			
 
-		// Get and check total items count.
-		int itemsCount = ejtt.tabMenu.getTabContentBox().getPagination().getTotalItemsCount();
 
-		// Returns null, skipping.
-		//Number serverCount = (Number) server.getManagedBeanValue("#{paginationDataModel.size}");
-		//assertEquals("Items count reported in page differs from server's.", serverCount, itemsCount);
+			// Navigate to apps summary tab
+			NavTreeNode appsNode = ejtt.navTree.getNodeByLabel(NAV_APPLICATIONS);
+			assertNotNull(appsNode);
+			appsNode.click();
+			ejtt.tabMenu.clickTab("Summary");
 
-		// Check whether trinomial equation fits
-		int itemsPerPage = ejtt.tabMenu.getTabContentBox().getPagination().getItemsPerPage();
-		int expectedPages = itemsCount / itemsPerPage;
-		if( itemsCount % itemsPerPage > 0 )
-			expectedPages++;
-		int pageCount = ejtt.tabMenu.getTabContentBox().getPagination().getPageCount();
-		assertEquals("Expected number of pages: "+itemsCount+" / "+itemsPerPage, expectedPages, pageCount);
-		
-		// ------- FAILS HERE because of EMBJOPR-61. --------- //
-		int page = 0;
-		while( ejtt.tabMenu.getTabContentBox().getPagination().goNext() ){
+			ejtt.sleep(1000);
 
-			page++;
-			if( page > expectedPages )
-				throw new EmbJoprTestException("Got too far when clicking Next" +
-								" - to "+page+"th page, expected only "+expectedPages+".");
+			// Get and check total items count.
+			int itemsCount = ejtt.tabMenu.getTabContentBox().getPagination().getTotalItemsCount();
 
-			// Get rows.
-			ContentTable table = ejtt.tabMenu.getTabContentBox().getFirstTable();
-			List<ContentTableRow> rows = table.getRows();
+			// Returns null, skipping.
+			//Number serverCount = (Number) server.getManagedBeanValue("#{paginationDataModel.size}");
+			//assertEquals("Items count reported in page differs from server's.", serverCount, itemsCount);
 
-			// Check the number of rows listed against what set in combo.
-			if( page < expectedPages )
-				assertEquals("Bad number of listed rows at page "+page+".", itemsPerPage, rows.size() );
-			else
-				assertEquals("Bad number of listed rows at last page.", itemsCount % itemsPerPage, rows.size() );
+			// Check whether trinomial equation fits
+			int itemsPerPage = ejtt.tabMenu.getTabContentBox().getPagination().getItemsPerPage();
+			int expectedPages = itemsCount / itemsPerPage;
+			if( itemsCount % itemsPerPage > 0 )
+				expectedPages++;
+			int pageCount = ejtt.tabMenu.getTabContentBox().getPagination().getPageCount();
+			assertEquals("Expected number of pages: "+itemsCount+" / "+itemsPerPage, expectedPages, pageCount);
 
-		}// while (next page)
 
+			int page = 0;
+			while( ejtt.tabMenu.getTabContentBox().getPagination().goNext() ){
 
-		// TODO: And back
+				page++;
+				if( page > expectedPages )
+					throw new EmbJoprTestException("Got too far when clicking Next" +
+									" - to "+page+"th page, expected only "+expectedPages+".");
 
-		// TODO: Go to specified page
+				// Get rows.
+				ContentTable table = ejtt.tabMenu.getTabContentBox().getFirstTable();
+				List<ContentTableRow> rows = table.getRows();
 
-		// TODO: Check that more pages do not list same app.
+				// Check the number of rows listed against what set in combo.
+				if( page < expectedPages )
+					assertEquals("Bad number of listed rows at page "+page+".", itemsPerPage, rows.size() );
+				else
+					assertEquals("Bad number of listed rows at last page.", itemsCount % itemsPerPage, rows.size() );
 
+			}// while (next page)
+
+
+			// TODO: And back
+
+			// TODO: Go to specified page
+
+			// TODO: Check that more pages do not list same app.
+
+		}
+		finally {
+			// Undeploy the apps.
+			for (int i = 0; i < succesfullyDeployed; i++) {
+				String deployableName = "appPagination"+i+".war";
+				try {
+					ejtt.deployment.undeployViaEmbJopr( DeployableTypes.WAR, deployableName );
+				}
+				catch( EmbJoprTestException ex ){
+					log.error("Exception during undeployment of '"+deployableName+"': "+ex);
+				}
+			}
+		}
+
 	}// testAppsPagination()
 
 
@@ -231,6 +251,8 @@
 	
 
 
+
+	
 	/**
 	 * Determines the type of the deployable based on the value
 	 * in the Type column in EmbJopr.




More information about the embjopr-commits mailing list