Hi!Here i wrote the code for
test to Jump from
Tomcat to
Jboss on load. Can u pls modify it on
JSP and send me. Early response will appriciate.
*********************
package test.com.gt247.load.session;
/**
* <p>Title : TestTomJbossSession</p>
* <p>Description: Test class to verify that the session value being passed from tomcat does not get corrupt</p>
* <p>Copyright : Copyright (c) 2003</p>
* <p>Company : Dariel Solutions (Pty) Ltd</p>
*
* <p>History : Version : Date : Auth : Description</p>
* <p> : 1.0 : Nov 27, 2003 : RB : Initial Creation of class</p>
* <p> : 1.1 : Dec 4, 2003 : RB : Added multithreading to simulate multiple users</p>
*
* @author Chandram.S for Dariel Solutions (Pty) Ltd
* @dated Nov 27, 2003
* @version 1.1
*/
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.PostMethodWebRequest;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
public class TestTomJboss extends TestCase {
private static final int PASSES = 5000;
private static final int USERS = 40;
private static final
String SERVER_PATH = "http://dariel-03:";
private static final int TOMCAT_PORT = 8080;
private static final int JNP_PORT = 1099;
private static final String CONTEXT = "/loadTest/";
private static final String JNP_URL = SERVER_PATH + JNP_PORT + CONTEXT;
private static final String TOMCAT_URL = SERVER_PATH + TOMCAT_PORT + CONTEXT;
public static void main(String args[]) {
for (int i = 0; i < USERS; i++) {
new
Thread() {
public void run() {
junit.textui.TestRunner.run(suite());
};
}
.start();
}
}
public static Test suite() {
return new TestSuite(TestTomJboss.class);
}
public TestTomJboss(String name) {
super(name);
}
/**
* Connect to the tomcat web server and make multiple page requests,
* checking the session id of each page
* @throws Exception
*/
public void testTomcatSessionID() throws Exception {
try {
System.out.println(
Thread.currentThread().getName()
+ ":"
+ "Testing tomcat session");
WebConversation conversation = new WebConversation();
WebRequest request = new GetMethodWebRequest(TOMCAT_URL + "1.jsp");
WebResponse response = conversation.getResponse(request);
String title1 = response.getTitle();
for (int i = 0; i < PASSES; i++) {
request = new PostMethodWebRequest(TOMCAT_URL + "2.jsp");
response = conversation.getResponse(request);
String title2 = response.getTitle();
assertTrue(title1.equals(title2));
request = new PostMethodWebRequest(TOMCAT_URL + "3.jsp");
response = conversation.getResponse(request);
String title3 = response.getTitle();
assertTrue(title2.equals(title3));
if (i % 100 == 0) {
System.out.println(
"Test 1: "
+ Thread.currentThread().getName()
+ ":"
+ i);
}
}
} catch (Exception e) {
e.printStackTrace();
assertTrue(false);
}
}
/**
* Connect to the JBOSS web server and make multiple page requests,
* checking the session id of each page
* @throws Exception
*/
public void testJNPSessionID() throws Exception {
System.out.println(
Thread.currentThread().getName() + ":" + "Testing JBOSS session ");
try {
WebConversation conversation = new WebConversation();
WebRequest request = new GetMethodWebRequest(JNP_URL + "1.jsp");
WebResponse response = conversation.getResponse(request);
String title1 = response.getTitle();
for (int i = 0; i < PASSES; i++) {
request = new PostMethodWebRequest(JNP_URL + "2.jsp");
response = conversation.getResponse(request);
String title2 = response.getTitle();
assertTrue(title1.equals(title2));
request = new PostMethodWebRequest(JNP_URL + "3.jsp");
response = conversation.getResponse(request);
String title3 = response.getTitle();
assertTrue(title2.equals(title3));
if (i % 100 == 0) {
System.out.println(
"Test 2:" + Thread.currentThread().getName() + ":" + i);
}
}
} catch (Exception e) {
e.printStackTrace();
assertTrue(false);
}
}
}
***************************