User: d_jencks
Date: 01/09/14 18:07:11
Modified: src/main/org/jboss/test/hello/test
HelloTimingStressTestCase.java
Log:
Converted to JBossTestCase and logging, made work (dbtest still breaks with
Hypersonic 1.4)
Revision Changes Path
1.3 +47 -59
jbosstest/src/main/org/jboss/test/hello/test/HelloTimingStressTestCase.java
Index: HelloTimingStressTestCase.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/hello/test/HelloTimingStressTestCase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HelloTimingStressTestCase.java 2001/09/12 20:43:01 1.2
+++ HelloTimingStressTestCase.java 2001/09/15 01:07:11 1.3
@@ -1,34 +1,38 @@
/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+/*
* Copyright 1999 by dreamBean Software,
* All rights reserved.
*/
package org.jboss.test.hello.test;
-//import javax.swing.*;
import javax.ejb.*;
import javax.naming.*;
-import org.jboss.jmx.service.Deployer;
import org.jboss.test.hello.interfaces.*;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.jboss.test.JBossTestCase;
-import org.jboss.test.util.Deploy;
/**
*
* @see <related>
- * @author $Author: schaefera $
- * @version $Revision: 1.2 $
+ * @author Author: schaefera
+ * @version $Revision: 1.3 $
*/
public class HelloTimingStressTestCase
- extends TestCase
+ extends JBossTestCase
{
// Constants -----------------------------------------------------
-
+ private static final int ITERATIONS = 500;
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
@@ -50,9 +54,9 @@
public void testHello()
throws Exception
{
- HelloHome home = (HelloHome)new InitialContext().lookup(HelloHome.JNDI_NAME);
+ HelloHome home = (HelloHome)getInitialContext().lookup(HelloHome.JNDI_NAME);
Hello hello = home.create();
- System.out.println(hello.hello("World"));
+ getLog().debug(hello.hello("World"));
hello.remove();
}
@@ -64,11 +68,11 @@
public void testData()
throws Exception
{
- HelloHome home = (HelloHome)new InitialContext().lookup(HelloHome.JNDI_NAME);
+ HelloHome home = (HelloHome)getInitialContext().lookup(HelloHome.JNDI_NAME);
Hello hello = home.create();
HelloData name = new HelloData();
name.setName("World");
- System.out.println(hello.howdy(name));
+ getLog().debug(hello.howdy(name));
hello.remove();
}
@@ -80,25 +84,24 @@
public void testSpeed()
throws Exception
{
- int iter = 500;
long start = System.currentTimeMillis();
long start2 = start;
- HelloHome home = (HelloHome)new InitialContext().lookup(HelloHome.JNDI_NAME);
+ HelloHome home = (HelloHome)getInitialContext().lookup(HelloHome.JNDI_NAME);
Hello hello = home.create();
- for (int i = 0 ; i < iter; i++)
+ for (int i = 0 ; i < ITERATIONS; i++)
{
hello.hello("Rickard");
if (i % 100 == 0 && i != 0)
{
long end = System.currentTimeMillis();
-
System.out.println("Time/call(ms):"+((end-start2)/100));
+ getLog().debug("Time/call(ms):"+((end-start2)/100));
start2 = end;
}
}
long end = System.currentTimeMillis();
- System.out.println("Avg. time/call(ms):"+((end-start)/iter));
+ getLog().debug("Avg. time/call(ms):"+((end-start)/ITERATIONS));
}
/**
@@ -109,24 +112,23 @@
public void testSpeed2()
throws Exception
{
- int iter = 500;
long start = System.currentTimeMillis();
long start2 = start;
- HelloHome home = (HelloHome)new InitialContext().lookup(HelloHome.JNDI_NAME);
+ HelloHome home = (HelloHome)getInitialContext().lookup(HelloHome.JNDI_NAME);
Hello hello = home.create();
- for (int i = 0 ; i < iter; i++)
+ for (int i = 0 ; i < ITERATIONS; i++)
{
hello.helloHello(hello);
if (i % 100 == 0 && i != 0)
{
long end = System.currentTimeMillis();
- System.out.println("Time/call(ms):"+((end-start2)/100));
+ getLog().debug("Time/call(ms):"+((end-start2)/100));
start2 = end;
}
}
long end = System.currentTimeMillis();
- System.out.println("Avg. time/call(ms):"+((end-start)/iter));
+ getLog().debug("Avg. time/call(ms):"+((end-start)/ITERATIONS));
}
/**
@@ -137,14 +139,13 @@
/* public void testInternalSpeed()
throws Exception
{
- HelloHome home = (HelloHome)new InitialContext().lookup(HelloHome.JNDI_NAME);
+ HelloHome home = (HelloHome)getInitialContext().lookup(HelloHome.JNDI_NAME);
Hello hello = home.create();
- int iter = 10000;
long start = System.currentTimeMillis();
- hello.testSpeed("Rickard", iter);
+ hello.testSpeed("Rickard", ITERATIONS);
long end = System.currentTimeMillis();
- System.out.println("Avg. time/call(ms):"+((end-start)/iter));
+ getLog().debug("Avg. time/call(ms):"+((end-start)/ITERATIONS));
}
*/
/**
@@ -155,16 +156,15 @@
public void testContextSpeed()
throws Exception
{
- int iter = 500;
long start = System.currentTimeMillis();
- System.out.println("Starting context lookup speed test");
- for (int i = 0; i < iter; i++)
+ getLog().debug("Starting context lookup speed test");
+ for (int i = 0; i < ITERATIONS; i++)
{
- HelloHome home = (HelloHome)new
InitialContext().lookup(HelloHome.JNDI_NAME);
+ HelloHome home = (HelloHome)getInitialContext().lookup(HelloHome.JNDI_NAME);
}
long end = System.currentTimeMillis();
- System.out.println("Avg. time/call(ms):"+((end-start)/iter));
+ getLog().debug("Avg. time/call(ms):"+((end-start)/ITERATIONS));
}
/**
@@ -175,45 +175,33 @@
public void testReusedContextSpeed()
throws Exception
{
- Context ctx = new InitialContext();
- int iter = 500;
+ Context ctx = getInitialContext();
long start = System.currentTimeMillis();
- System.out.println("Starting context lookup speed test");
- for (int i = 0; i < iter; i++)
+ getLog().debug("Starting context lookup speed test");
+ for (int i = 0; i < ITERATIONS; i++)
{
HelloHome home = (HelloHome)ctx.lookup(HelloHome.JNDI_NAME);
}
long end = System.currentTimeMillis();
- System.out.println("Avg. time/call(ms):"+((end-start)/iter));
+ getLog().debug("Avg. time/call(ms):"+((end-start)/ITERATIONS));
}
- protected void setUp()
- throws Exception
- {
- /*
- if (deployed) return;
- System.out.println("Deploying");
- new org.jboss.jmx.client.Deployer().deploy("../deploy/hello.jar");
- deployed = true;
- */
- }
- /**
- * Setup the test suite.
+ /**
+ * The JUnit setup method
+ *
+ * @exception Exception Description of Exception
*/
- public static Test suite() {
- TestSuite suite = new TestSuite();
-
- // add a test case to deploy our support applications
- String filename = "hello.jar";
- suite.addTest(new Deploy.Deployer( filename ));
-
- suite.addTest(new TestSuite(HelloTimingStressTestCase.class));
-
- // add a test case to undeploy our support applications
- suite.addTest(new Deploy.Undeployer(filename));
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ deployJ2ee("hello.jar");
+ }
- return suite;
+ protected void tearDown() throws Exception
+ {
+ undeployJ2ee("hello.jar");
+ super.tearDown();
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development