User: d_jencks
Date: 01/09/11 21:55:38
Added: src/main/org/jboss/test/hello/test
HelloTimingStressTestCase.java
Removed: src/main/org/jboss/test/hello/test Main.java
Log:
Changed naming scheme of tests to *UnitTestCase.java for short running tests and
*StressTestCase.java for lengthy tests. Made tests-unit and tests-stress targets in
build.xml
Revision Changes Path
1.1
jbosstest/src/main/org/jboss/test/hello/test/HelloTimingStressTestCase.java
Index: HelloTimingStressTestCase.java
===================================================================
/*
* 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.client.Deployer;
import org.jboss.test.hello.interfaces.*;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.jboss.test.util.Deploy;
/**
*
* @see <related>
* @author $Author: d_jencks $
* @version $Revision: 1.1 $
*/
public class HelloTimingStressTestCase
extends TestCase
{
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
static boolean deployed = false;
// Constructors --------------------------------------------------
public HelloTimingStressTestCase(String name)
{
super(name);
}
// Public --------------------------------------------------------
/**
* Lookup the bean, call it, remove it.
*
* @exception Exception
*/
public void testHello()
throws Exception
{
HelloHome home = (HelloHome)new InitialContext().lookup(HelloHome.JNDI_NAME);
Hello hello = home.create();
System.out.println(hello.hello("World"));
hello.remove();
}
/**
* Test marshalling of custom data-holders.
*
* @exception Exception
*/
public void testData()
throws Exception
{
HelloHome home = (HelloHome)new InitialContext().lookup(HelloHome.JNDI_NAME);
Hello hello = home.create();
HelloData name = new HelloData();
name.setName("World");
System.out.println(hello.howdy(name));
hello.remove();
}
/**
* This tests the speed of invocations
*
* @exception Exception
*/
public void testSpeed()
throws Exception
{
int iter = 500;
long start = System.currentTimeMillis();
long start2 = start;
HelloHome home = (HelloHome)new InitialContext().lookup(HelloHome.JNDI_NAME);
Hello hello = home.create();
for (int i = 0 ; i < iter; i++)
{
hello.hello("Rickard");
if (i % 100 == 0 && i != 0)
{
long end = System.currentTimeMillis();
System.out.println("Time/call(ms):"+((end-start2)/100));
start2 = end;
}
}
long end = System.currentTimeMillis();
System.out.println("Avg. time/call(ms):"+((end-start)/iter));
}
/**
* This tests the speed of invocations
*
* @exception Exception
*/
public void testSpeed2()
throws Exception
{
int iter = 500;
long start = System.currentTimeMillis();
long start2 = start;
HelloHome home = (HelloHome)new InitialContext().lookup(HelloHome.JNDI_NAME);
Hello hello = home.create();
for (int i = 0 ; i < iter; i++)
{
hello.helloHello(hello);
if (i % 100 == 0 && i != 0)
{
long end = System.currentTimeMillis();
System.out.println("Time/call(ms):"+((end-start2)/100));
start2 = end;
}
}
long end = System.currentTimeMillis();
System.out.println("Avg. time/call(ms):"+((end-start)/iter));
}
/**
* This tests the speed of server-internal invocations
*
* @exception Exception
*/
/* public void testInternalSpeed()
throws Exception
{
HelloHome home = (HelloHome)new InitialContext().lookup(HelloHome.JNDI_NAME);
Hello hello = home.create();
int iter = 10000;
long start = System.currentTimeMillis();
hello.testSpeed("Rickard", iter);
long end = System.currentTimeMillis();
System.out.println("Avg. time/call(ms):"+((end-start)/iter));
}
*/
/**
* This tests the speed of InitialContext lookups
*
* @exception Exception
*/
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++)
{
HelloHome home = (HelloHome)new
InitialContext().lookup(HelloHome.JNDI_NAME);
}
long end = System.currentTimeMillis();
System.out.println("Avg. time/call(ms):"+((end-start)/iter));
}
/**
* This tests the speed of JNDI lookups
*
* @exception Exception
*/
public void testReusedContextSpeed()
throws Exception
{
Context ctx = new InitialContext();
int iter = 500;
long start = System.currentTimeMillis();
System.out.println("Starting context lookup speed test");
for (int i = 0; i < iter; i++)
{
HelloHome home = (HelloHome)ctx.lookup(HelloHome.JNDI_NAME);
}
long end = System.currentTimeMillis();
System.out.println("Avg. time/call(ms):"+((end-start)/iter));
}
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.
*/
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));
return suite;
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development