Author: ozizka(a)redhat.com
Date: 2009-04-27 20:48:27 -0400 (Mon, 27 Apr 2009)
New Revision: 361
Added:
trunk/jsfunit/testdata/war/hellothere-multi-hotdeploy.war
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ApplicationsPageTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
Added WarTest#testWarHotDeployManyWarsAtOnce()
Updated pagination, AS node, WAR and EAR tests
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-04-27
21:14:35 UTC (rev 360)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-04-28
00:48:27 UTC (rev 361)
@@ -176,7 +176,7 @@
if (linkText.contains(linkLabel)) return link;
}
- throw new IllegalStateException("Link for '"+ linkLabel
+"' not found.");
+ throw new IllegalStateException("Link for '"+ linkLabel
+"' not found in form #"+formId);
}
/**
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-04-27
21:14:35 UTC (rev 360)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/ApplicationsPageTest.java 2009-04-28
00:48:27 UTC (rev 361)
@@ -86,9 +86,14 @@
// TODO: Create test which would only deploy many apps at once
(hotdeploy/embjopr/both?).
// TODO: Undeploy.
String fileSrcPath = ejtt.getTestDataDir() +"/ear/"+ BASIC_EAR;
+
+ String destDir = ejtt.getTempDir() + "/appPagination";
+ if( ! new File(destDir).mkdirs() )
+ throw new EmbJoprTestException("Coundn't create directory: "+destDir);
+
+ // Deploy the same APP multiple times.
for (int i = 0; i < 8; i++) {
- // Deploy the same APP multiple times.
- String fileDestPath = ejtt.getTempDir() +
"/appPagination/appPagination"+i+".ear";
+ String fileDestPath = destDir+"/appPagination"+i+".ear";
FileUtils.copyFile( new File(fileSrcPath), new File(fileDestPath) );
ejtt.deployment.deployViaEmbJoprRepeatedly( DeployableTypes.EAR, fileDestPath );
}
@@ -164,10 +169,16 @@
// Deploy enough apps.
// TODO: Create test which would only deploy many apps at once
(hotdeploy/embjopr/both?).
// TODO: Undeploy.
+
+ String fileSrcPath = ejtt.getTestDataDir() +"/ear/"+ BASIC_EAR;
+
+ String destDir = ejtt.getTempDir() + "/appPagination";
+ if( ! new File(destDir).mkdirs() )
+ throw new EmbJoprTestException("Coundn't create directory: "+destDir);
+
+ // Deploy the same APP multiple times.
for (int i = 0; i < 8; i++) {
- // Deploy the same APP multiple times.
- String fileSrcPath = ejtt.getTestDataDir() +"/ear/"+ BASIC_EAR;
- String fileDestPath = ejtt.getTempDir() +
"/appPagination/testAppsListing"+i+".ear";
+ String fileDestPath = destDir+"/testAppsListing"+i+".ear";
FileUtils.copyFile( new File(fileSrcPath), new File(fileDestPath) );
ejtt.deployment.deployViaEmbJoprRepeatedly( DeployableTypes.EAR, fileDestPath );
}
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java 2009-04-27
21:14:35 UTC (rev 360)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java 2009-04-28
00:48:27 UTC (rev 361)
@@ -57,10 +57,13 @@
*/
public class EarTest extends ApplicationTestBaseAS5 {
+ public static final DeployableTypes APP_TYPE = DeployableTypes.EAR;
+
+
+
/**
* @return the suite of tests being tested
*/
-
public static Test suite()
{
String testToRun = System.getProperty("jsfunit.test.single");
@@ -118,10 +121,12 @@
}
finally {
// Undeploy the EAR.
- undeployEar( DEPLOYABLE_NAME );
+ /*undeployEar( DEPLOYABLE_NAME );
String expectedMessage = "Successfully deleted Enterprise Application (EAR)
'"+DEPLOYABLE_NAME+"'.";
assertTrue(client.getPageAsText().contains( expectedMessage ));
+ /**/
+ ejtt.deployment.undeployViaEmbJopr(APP_TYPE, DEPLOYABLE_NAME);
}
// This assert doesn't work. The JXM view is not consistent with the mananaged
view.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java 2009-04-27
21:14:35 UTC (rev 360)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/JBossASNodeTest.java 2009-04-28
00:48:27 UTC (rev 361)
@@ -103,6 +103,8 @@
Active Thread Count 7.0 The current number of active threads for this app server
instance
JVM Free Memory 183.6MB The amount of free memory for the JVM this app server
instance is running on
JVM Total Memory 218.7MB The amount of total memory for the JVM this app server
instance is running on
+
+ TODO: Split - grab some resources and do a page refresh for every part?
*/
headerText = "Metrics Summary";
assertTrue("Page doesn't contain the header: "+headerText,
pageText.contains(headerText));
@@ -113,31 +115,45 @@
Properties metricsProps = table.getProperties("Name", "Value");
log.info( headerText +" 1st: "+ metricsProps.toString() );
- // Active Thread Count
+ // Parse the values.
int threads1 = (int)NumberUtils.toDouble(metricsProps.getProperty("Active Thread
Count").replace(',', '.'));
double memFree1 = NumberUtils.toDouble(metricsProps.getProperty("JVM Free
Memory").replace(',', '.').replace("MB", ""));
double memTotal1 = NumberUtils.toDouble(metricsProps.getProperty("JVM Total
Memory").replace(',', '.').replace("MB", ""));
+
// Do some requests to add threads.
-
+ // Bad way - thread pool can cause thread number not to change.
+ /*
// Create HTMLUnit WebClient.
WebClient wc = new WebClient(BrowserVersion.FIREFOX_3);
wc.setCssEnabled(false);
wc.setJavaScriptEnabled(false);
// Get some page.
wc.getPage("http://localhost:8080/");
+ */
+ // Launch as much threads as the current number to get higher number.
+ ThreadGroup threadGroup = new ThreadGroup("Dummy threads");
+ for( int i = 0; i < threads1; i++ ) {
+ Thread thread = new Thread(threadGroup, new MyRunnable(), "Dummy thread
"+i);
+ thread.run();
+ }
+
+
+
// Allocate some memory to decrease free mem.
- byte tmp[] = new byte[5 * 1024 * 1024]; // Few MB.
+ byte tmp[] = new byte[100 * 1024 * 1024]; // Few MB.
// Refresh the page
- // TODO: Do it several times avoid accidentally same value.
-
((HtmlPage)client.getContentPage()).refresh();
+ // Stop the threads.
+ threadGroup.interrupt();
+
+
// Read new values.
headerText = "Metrics Summary";
assertTrue("Page doesn't contain the header: "+headerText,
pageText.contains(headerText));
@@ -148,11 +164,9 @@
metricsProps = table.getProperties("Name", "Value");
log.info( headerText +" 2nd: "+ metricsProps.toString() );
- // Active Thread Count
+ // Parse the values.
int threads2 = (int)NumberUtils.toDouble( metricsProps.getProperty("Active Thread
Count").replace(',', '.') );
- //log.info( "DEBUG - memFree2: "+ metricsProps.getProperty("JVM Free
Memory").replace(',', '.') );///
double memFree2 = NumberUtils.toDouble(metricsProps.getProperty("JVM Free
Memory").replace(',', '.').replace("MB", "") );
- //log.info( "DEBUG - memFree2: "+ metricsProps.getProperty("JVM Total
Memory").replace(',', '.') );///
double memTotal2 = NumberUtils.toDouble(metricsProps.getProperty("JVM Total
Memory").replace(',', '.').replace("MB", "") );
log.info( "Value | old | new ");
@@ -160,13 +174,23 @@
log.info( String.format("Mem free: %f, %f", memFree1, memFree2) );
log.info( String.format("Mem total: %f, %f", memTotal1, memTotal2) );
- assertTrue("New thread count should be >= old. Is: "+threads1 +"
-> "+ threads2, threads1 != threads2);
- assertTrue("New free mem should be <= old. Is: "+memFree1 +" ->
"+ memFree2, memFree1 != memFree2);
- //assertTrue("New total mem should be = old. Is: "+memTotal1 +","+
memTotal2, memTotal1 == memTotal2);
+ assertTrue("New thread count should be > old. Is: "+threads1 +" ->
"+ threads2, threads1 < threads2);
+ assertTrue("New free mem should be != old. Is: "+memFree1 +" ->
"+ memFree2, memFree1 != memFree2);
+ //assertTrue("New total mem should be ?? old. Is: "+memTotal1 +","+
memTotal2, memTotal1 == memTotal2);
}
+
+ /** Runnable for creating threads to increase JVM thread count. */
+ class MyRunnable implements Runnable {
+ public void run() {
+ ejtt.sleep(20000); // Ends on InterruptedException.
+ }
+ }
+
+
+
}// class
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-04-27
21:14:35 UTC (rev 360)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-04-28
00:48:27 UTC (rev 361)
@@ -916,7 +916,7 @@
throws HtmlElementNotFoundException
{
if( 0 == element.getRowCount() )
- throw new HtmlElementNotFoundException("Table has no rows.");
+ throw new HtmlElementNotFoundException("Table has no rows.", currentTest);
String xPath =
".//tr[.//a[normalize-space()='"+linkLabel+"']]";
HtmlTableRow elm = (HtmlTableRow) element.getFirstByXPath(xPath);
Added: trunk/jsfunit/testdata/war/hellothere-multi-hotdeploy.war
===================================================================
(Binary files differ)
Property changes on: trunk/jsfunit/testdata/war/hellothere-multi-hotdeploy.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream