Author: mckierna
Date: Tue Nov 11 05:24:37 2008
New Revision: 713031
URL: http://svn.apache.org/viewvc?rev=713031&view=rev
Log:
Concurrent unit test scenario
Added:
webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/scenarios/MultiThreadedTest.java
Modified:
webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/scenarios/RMScenariosTest.java
Added:
webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/scenarios/MultiThreadedTest.java
URL:
http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/scenarios/MultiThreadedTest.java?rev=713031&view=auto
==============================================================================
---
webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/scenarios/MultiThreadedTest.java
(added)
+++
webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/scenarios/MultiThreadedTest.java
Tue Nov 11 05:24:37 2008
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sandesha2.scenarios;
+
+import org.apache.axis2.client.Options;
+
+
+public class MultiThreadedTest extends RMScenariosTest{
+
+
+ public final static int NUMBER_OF_THREADS = 5;
+
+ private int completeTests = 0;
+
+ public void setUp()throws Exception{
+ completeTests = 0;
+ super.setUp();
+ }
+
+
+ public void testPing() throws Exception {
+ final int NUMBER_OF_PING_MSGS_PER_THREAD = 5;
+ //kick of a set of threads to run individual tests
+ for(int i=0; i < NUMBER_OF_THREADS; i++){
+ Thread th = new Thread(){
+ public void run(){
+ try{
+ // Run a ping test with sync
acks
+
MultiThreadedTest.this.runPing(false, false, NUMBER_OF_PING_MSGS_PER_THREAD);
+ // Run a ping test with async
acks
+
MultiThreadedTest.this.runPing(true, true, NUMBER_OF_PING_MSGS_PER_THREAD);
+
MultiThreadedTest.this.completeTests ++ ; //mark another test as complete
+ }
+ catch(Exception e){
+ }
+ }
+ };
+ th.start();
+ }//end for
+
+ int sleepCount = 0;
+ while(completeTests < NUMBER_OF_THREADS){
+ Thread.sleep(1000);
+ sleepCount ++;
+ if(sleepCount>45){
+ fail("waited too long for all threads to
complete");
+ }
+ }
+
+ }
+
+ public void testAsyncEcho() throws Exception {
+
+ //kick of a set of threads to run individual tests
+ for(int i=0; i < NUMBER_OF_THREADS; i++){
+ Thread th = new Thread(){
+ public void run(){
+ try{
+
+ // Test async echo with sync
acks
+ Options clientOptions = new
Options();
+ runEcho(clientOptions, true,
false, false,true,false);
+
+ // Test async echo with async
acks
+ clientOptions = new Options();
+ runEcho(clientOptions, true,
true, false,true,false);
+
MultiThreadedTest.this.completeTests ++ ; //mark another test as complete
+
+ }
+ catch(Exception e){
+ }
+ }
+ };
+ th.start();
+ }//end for
+
+ int sleepCount = 0;
+ while(completeTests < NUMBER_OF_THREADS){
+ Thread.sleep(1000);
+ sleepCount ++;
+ if(sleepCount>45){
+ fail("waited too long for all threads to
complete");
+ }
+ }
+ }
+
+ public void testSyncEcho() throws Exception {
+
+ //kick of a set of threads to run individual tests
+ for(int i=0; i < NUMBER_OF_THREADS; i++){
+ Thread th = new Thread(){
+ public void run(){
+ try{
+ // Test sync echo
+
MultiThreadedTest.super.testSyncEcho();
+
MultiThreadedTest.this.completeTests ++ ; //mark another test as complete
+ }
+ catch(Exception e){
+ }
+ }
+ };
+ th.start();
+ }//end for
+
+ int sleepCount = 0;
+ while(completeTests < NUMBER_OF_THREADS){
+ Thread.sleep(1000);
+ sleepCount ++;
+ if(sleepCount>40){
+ fail("waited too long for all threads to
complete");
+ }
+ }
+ }
+
+ public void testSyncEchoWithOffer() throws Exception {
+
+ //there is an issue with this test in that sequences from other
threads
+ //cause confusion in the error checking.
+// //kick of a set of threads to run individual tests
+// for(int i=0; i < NUMBER_OF_THREADS; i++){
+// Thread th = new Thread(){
+// public void run(){
+// try{
+// // Test sync echo
+//
MultiThreadedTest.super.testSyncEchoWithOffer();
+//
MultiThreadedTest.this.completeTests ++ ; //mark another test as complete
+// }
+// catch(Exception e){
+// }
+// }
+// };
+// th.start();
+// }//end for
+//
+// int sleepCount = 0;
+// while(completeTests < NUMBER_OF_THREADS){
+// Thread.sleep(1000);
+// sleepCount ++;
+// if(sleepCount>45){
+// fail("waited too long for all threads to
complete");
+// }
+// }
+ }
+
+}
Modified:
webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/scenarios/RMScenariosTest.java
URL:
http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/scenarios/RMScenariosTest.java?rev=713031&r1=713030&r2=713031&view=diff
==============================================================================
---
webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/scenarios/RMScenariosTest.java
(original)
+++
webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/scenarios/RMScenariosTest.java
Tue Nov 11 05:24:37 2008
@@ -17,6 +17,7 @@
package org.apache.sandesha2.scenarios;
import java.io.File;
+import java.net.URL;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -122,6 +123,10 @@
}
public void runPing(boolean asyncAcks, boolean stopListener) throws
Exception {
+ runPing(asyncAcks, stopListener, 1);
+ }
+
+ public void runPing(boolean asyncAcks, boolean stopListener, int
msgCount) throws Exception {
Options clientOptions = new Options();
@@ -133,7 +138,6 @@
clientOptions.setAction(pingAction);
clientOptions.setTo(new EndpointReference (to));
clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
- clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE,
"true");
if(asyncAcks) {
String acksTo =
serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
@@ -142,7 +146,13 @@
clientOptions.setUseSeparateListener(true);
}
- serviceClient.fireAndForget(getPingOMBlock("ping1"));
+ for(int i=0; i<msgCount; i++){
+ String text = "ping" + (i+1);
+ if(i == (msgCount-1)){
+
clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ }
+ serviceClient.fireAndForget(getPingOMBlock(text));
//start the pingX text at X=1
+ }
long limit = System.currentTimeMillis() + waitTime;
Error lastError = null;
@@ -152,7 +162,7 @@
try {
SequenceReport sequenceReport =
SandeshaClient.getOutgoingSequenceReport(serviceClient);
System.out.println("Checking Outbound Sequence:
" + sequenceReport.getSequenceID());
- assertTrue("Checking completed messages",
sequenceReport.getCompletedMessages().contains(new Long(1)));
+ assertTrue("Checking completed messages",
sequenceReport.getCompletedMessages().contains(new Long(msgCount)));
assertEquals("Checking sequence terminated",
SequenceReport.SEQUENCE_STATUS_TERMINATED, sequenceReport.getSequenceStatus());
assertEquals("Checking sequence direction",
SequenceReport.SEQUENCE_DIRECTION_OUT, sequenceReport.getSequenceDirection());
@@ -297,6 +307,7 @@
for(Iterator currentSequences = incomingSequences.iterator();
currentSequences.hasNext(); ) {
SequenceReport report = (SequenceReport)
currentSequences.next();
if(!sequenceIds.contains(report.getSequenceID())) {
+
return report;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]