You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by gd...@apache.org on 2007/03/04 19:17:07 UTC
svn commit: r514453 [22/26] - in
/webservices/axis2/trunk/java/modules/kernel: src/org/apache/axis2/
src/org/apache/axis2/addressing/ src/org/apache/axis2/addressing/wsdl/
src/org/apache/axis2/builder/ src/org/apache/axis2/client/
src/org/apache/axis2/...
Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSaveBTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSaveBTest.java?view=diff&rev=514453&r1=514452&r2=514453
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSaveBTest.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/engine/MessageContextSaveBTest.java Sun Mar 4 10:16:54 2007
@@ -21,7 +21,12 @@
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.*;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ContextFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
import org.apache.axis2.description.AxisMessage;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisService;
@@ -30,7 +35,6 @@
import org.apache.axis2.description.InOutAxisOperation;
import org.apache.axis2.description.TransportInDescription;
import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver;
import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
@@ -44,7 +48,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
@@ -52,23 +55,22 @@
import java.util.Iterator;
import java.util.Map;
-public class MessageContextSaveBTest extends TestCase
-{
+public class MessageContextSaveBTest extends TestCase {
private String testArg = null;
//-------------------------------------------------------------------------
// test key-value pairs
//-------------------------------------------------------------------------
private String [] serviceKeys = {
- "serviceKey1",
- "serviceKey2",
- "serviceKey3"
+ "serviceKey1",
+ "serviceKey2",
+ "serviceKey3"
};
private String [] serviceValues = {
- "serviceValue1",
- "serviceValue2",
- "serviceValue3"
+ "serviceValue1",
+ "serviceValue2",
+ "serviceValue3"
};
//-------------------------------------------------------------------------
@@ -78,42 +80,42 @@
// has a full object graph with 3 sets of service groups
// and associated objects
private ConfigurationContext configurationContext = null;
- private AxisConfiguration axisConfiguration = null;
+ private AxisConfiguration axisConfiguration = null;
//------------------------------
// service group ABC
//------------------------------
private String serviceGroupName_ABC = "ABCServiceGroup";
- private String serviceName_A = "ServiceA";
- private String serviceName_B = "ServiceB";
- private String serviceName_C = "ServiceC";
+ private String serviceName_A = "ServiceA";
+ private String serviceName_B = "ServiceB";
+ private String serviceName_C = "ServiceC";
private QName service_QName_A = new QName(serviceName_A);
private QName service_QName_B = new QName(serviceName_B);
private QName service_QName_C = new QName(serviceName_C);
- private String operationName_A1 = "TestOperationA1";
- private String operationName_A2 = "TestOperationA2";
- private QName operation_QName_A1 = new QName(operationName_A1);
- private QName operation_QName_A2 = new QName(operationName_A2);
-
- private ServiceGroupContext srvGrpCtx_ABC = null;
- private AxisServiceGroup axisSrvGrp_ABC = null;
-
- private ServiceContext srvCtx_A = null;
- private ServiceContext srvCtx_B = null;
- private ServiceContext srvCtx_C = null;
- private AxisService axisSrv_A = null;
- private AxisService axisSrv_B = null;
- private AxisService axisSrv_C = null;
-
- private OperationContext opCtx_A1 = null;
- private OperationContext opCtx_A2 = null;
- private AxisOperation axisOp_A1 = null;
- private AxisOperation axisOp_A2 = null;
+ private String operationName_A1 = "TestOperationA1";
+ private String operationName_A2 = "TestOperationA2";
+ private QName operation_QName_A1 = new QName(operationName_A1);
+ private QName operation_QName_A2 = new QName(operationName_A2);
+
+ private ServiceGroupContext srvGrpCtx_ABC = null;
+ private AxisServiceGroup axisSrvGrp_ABC = null;
+
+ private ServiceContext srvCtx_A = null;
+ private ServiceContext srvCtx_B = null;
+ private ServiceContext srvCtx_C = null;
+ private AxisService axisSrv_A = null;
+ private AxisService axisSrv_B = null;
+ private AxisService axisSrv_C = null;
+
+ private OperationContext opCtx_A1 = null;
+ private OperationContext opCtx_A2 = null;
+ private AxisOperation axisOp_A1 = null;
+ private AxisOperation axisOp_A2 = null;
- private MessageContext msgCtx_A1 = null;
- private MessageContext msgCtx_A2 = null;
+ private MessageContext msgCtx_A1 = null;
+ private MessageContext msgCtx_A2 = null;
//private AxisMessage axisMsg_A1 = null;
//private AxisMessage axisMsg_A2 = null;
@@ -122,39 +124,39 @@
//------------------------------
private String serviceGroupName_123 = "123ServiceGroup";
- private String serviceName_1 = "Service1";
- private String serviceName_2 = "Service2";
- private String serviceName_3 = "Service3";
- private String serviceName_4 = "Service4";
+ private String serviceName_1 = "Service1";
+ private String serviceName_2 = "Service2";
+ private String serviceName_3 = "Service3";
+ private String serviceName_4 = "Service4";
private QName service_QName_1 = new QName(serviceName_1);
private QName service_QName_2 = new QName(serviceName_2);
private QName service_QName_3 = new QName(serviceName_3);
private QName service_QName_4 = new QName(serviceName_4);
- private String operationName_1_1 = "TestOperation1_1";
- private String operationName_1_2 = "TestOperation1_2";
- private QName operation_QName_1_1 = new QName(operationName_1_1);
- private QName operation_QName_1_2 = new QName(operationName_1_2);
-
- private ServiceGroupContext srvGrpCtx_123 = null;
- private AxisServiceGroup axisSrvGrp_123 = null;
-
- private ServiceContext srvCtx_1 = null;
- private ServiceContext srvCtx_2 = null;
- private ServiceContext srvCtx_3 = null;
- private ServiceContext srvCtx_4 = null;
- private AxisService axisSrv_1 = null;
- private AxisService axisSrv_2 = null;
- private AxisService axisSrv_3 = null;
- private AxisService axisSrv_4 = null;
-
- private OperationContext opCtx_1_1 = null;
- private OperationContext opCtx_1_2 = null;
- private AxisOperation axisOp_1_1 = null;
- private AxisOperation axisOp_1_2 = null;
+ private String operationName_1_1 = "TestOperation1_1";
+ private String operationName_1_2 = "TestOperation1_2";
+ private QName operation_QName_1_1 = new QName(operationName_1_1);
+ private QName operation_QName_1_2 = new QName(operationName_1_2);
+
+ private ServiceGroupContext srvGrpCtx_123 = null;
+ private AxisServiceGroup axisSrvGrp_123 = null;
+
+ private ServiceContext srvCtx_1 = null;
+ private ServiceContext srvCtx_2 = null;
+ private ServiceContext srvCtx_3 = null;
+ private ServiceContext srvCtx_4 = null;
+ private AxisService axisSrv_1 = null;
+ private AxisService axisSrv_2 = null;
+ private AxisService axisSrv_3 = null;
+ private AxisService axisSrv_4 = null;
+
+ private OperationContext opCtx_1_1 = null;
+ private OperationContext opCtx_1_2 = null;
+ private AxisOperation axisOp_1_1 = null;
+ private AxisOperation axisOp_1_2 = null;
- private MessageContext msgCtx_1_1 = null;
- private MessageContext msgCtx_1_2 = null;
+ private MessageContext msgCtx_1_1 = null;
+ private MessageContext msgCtx_1_2 = null;
//private AxisMessage axisMsg_1_1 = null;
//private AxisMessage axisMsg_1_2 = null;
@@ -164,83 +166,79 @@
//------------------------------
private String serviceGroupName_DAY = "DayServiceGroup";
- private String serviceName_Mon = "MondayService";
- private String serviceName_Tue = "TuesdayService";
- private String serviceName_Wed = "WednesdayService";
- private String serviceName_Thu = "ThursdayService";
- private String serviceName_Fri = "FridayService";
+ private String serviceName_Mon = "MondayService";
+ private String serviceName_Tue = "TuesdayService";
+ private String serviceName_Wed = "WednesdayService";
+ private String serviceName_Thu = "ThursdayService";
+ private String serviceName_Fri = "FridayService";
private QName service_QName_Mon = new QName(serviceName_Mon);
private QName service_QName_Tue = new QName(serviceName_Tue);
private QName service_QName_Wed = new QName(serviceName_Wed);
private QName service_QName_Thu = new QName(serviceName_Thu);
private QName service_QName_Fri = new QName(serviceName_Fri);
- private String operationName_Mon_1 = "TestOperation_Mon_1";
- private String operationName_Mon_2 = "TestOperation_Mon_2";
- private QName operation_QName_Mon_1 = new QName(operationName_Mon_1);
- private QName operation_QName_Mon_2 = new QName(operationName_Mon_2);
-
- private ServiceGroupContext srvGrpCtx_DAY = null;
- private AxisServiceGroup axisSrvGrp_DAY = null;
-
- private ServiceContext srvCtx_Mon = null;
- private ServiceContext srvCtx_Tue = null;
- private ServiceContext srvCtx_Wed = null;
- private ServiceContext srvCtx_Thu = null;
- private ServiceContext srvCtx_Fri = null;
- private AxisService axisSrv_Mon = null;
- private AxisService axisSrv_Tue = null;
- private AxisService axisSrv_Wed = null;
- private AxisService axisSrv_Thu = null;
- private AxisService axisSrv_Fri = null;
-
- private OperationContext opCtx_Mon_1 = null;
- private OperationContext opCtx_Mon_2 = null;
- private AxisOperation axisOp_Mon_1 = null;
- private AxisOperation axisOp_Mon_2 = null;
+ private String operationName_Mon_1 = "TestOperation_Mon_1";
+ private String operationName_Mon_2 = "TestOperation_Mon_2";
+ private QName operation_QName_Mon_1 = new QName(operationName_Mon_1);
+ private QName operation_QName_Mon_2 = new QName(operationName_Mon_2);
+
+ private ServiceGroupContext srvGrpCtx_DAY = null;
+ private AxisServiceGroup axisSrvGrp_DAY = null;
+
+ private ServiceContext srvCtx_Mon = null;
+ private ServiceContext srvCtx_Tue = null;
+ private ServiceContext srvCtx_Wed = null;
+ private ServiceContext srvCtx_Thu = null;
+ private ServiceContext srvCtx_Fri = null;
+ private AxisService axisSrv_Mon = null;
+ private AxisService axisSrv_Tue = null;
+ private AxisService axisSrv_Wed = null;
+ private AxisService axisSrv_Thu = null;
+ private AxisService axisSrv_Fri = null;
+
+ private OperationContext opCtx_Mon_1 = null;
+ private OperationContext opCtx_Mon_2 = null;
+ private AxisOperation axisOp_Mon_1 = null;
+ private AxisOperation axisOp_Mon_2 = null;
- private MessageContext msgCtx_Mon_1 = null;
- private MessageContext msgCtx_Mon_2 = null;
+ private MessageContext msgCtx_Mon_1 = null;
+ private MessageContext msgCtx_Mon_2 = null;
//private AxisMessage axisMsg_Mon_1 = null;
//private AxisMessage axisMsg_Mon_2 = null;
-
-
//-------------------------------------
// objects needed for message context
//------------------------------------
- private TransportOutDescription transportOut = null;
+ private TransportOutDescription transportOut = null;
private TransportOutDescription transportOut2 = null;
private TransportOutDescription transportOut3 = null;
- private TransportInDescription transportIn = null;
- private TransportInDescription transportIn2 = null;
- private TransportInDescription transportIn3 = null;
+ private TransportInDescription transportIn = null;
+ private TransportInDescription transportIn2 = null;
+ private TransportInDescription transportIn3 = null;
- private Phase phase1 = null;
+ private Phase phase1 = null;
private ArrayList executedHandlers = null;
private MessageContext restoredMessageContext = null;
-
//-------------------------------------------------------------------------
// methods
//-------------------------------------------------------------------------
- public MessageContextSaveBTest(String arg0)
- {
+ public MessageContextSaveBTest(String arg0) {
super(arg0);
testArg = new String(arg0);
- try
- {
+ try {
prepare();
}
- catch (Exception e)
- {
- System.out.println("MessageContextSaveBTest:constructor: error in setting up object graph ["+e.getClass().getName()+" : "+e.getMessage()+"]");
+ catch (Exception e) {
+ System.out.println(
+ "MessageContextSaveBTest:constructor: error in setting up object graph [" +
+ e.getClass().getName() + " : " + e.getMessage() + "]");
}
}
@@ -248,8 +246,7 @@
//
// prepare the object hierarchy for testing
//
- private void prepare() throws Exception
- {
+ private void prepare() throws Exception {
//-----------------------------------------------------------------
// setup the top-level objects
//-----------------------------------------------------------------
@@ -258,8 +255,10 @@
configurationContext = new ConfigurationContext(axisConfiguration);
- configurationContext.getAxisConfiguration().addMessageReceiver("http://www.w3.org/2004/08/wsdl/in-only", new RawXMLINOnlyMessageReceiver());
- configurationContext.getAxisConfiguration().addMessageReceiver("http://www.w3.org/2004/08/wsdl/in-out", new RawXMLINOutMessageReceiver());
+ configurationContext.getAxisConfiguration().addMessageReceiver(
+ "http://www.w3.org/2004/08/wsdl/in-only", new RawXMLINOnlyMessageReceiver());
+ configurationContext.getAxisConfiguration().addMessageReceiver(
+ "http://www.w3.org/2004/08/wsdl/in-out", new RawXMLINOutMessageReceiver());
DispatchPhase dispatchPhase = new DispatchPhase();
dispatchPhase.setName("Dispatch");
@@ -290,7 +289,7 @@
//----------------------------
// transport-related objects
//----------------------------
- transportOut = new TransportOutDescription(new QName("null"));
+ transportOut = new TransportOutDescription(new QName("null"));
transportOut2 = new TransportOutDescription(new QName("happy"));
transportOut3 = new TransportOutDescription(new QName("golucky"));
transportOut.setSender(new CommonsHTTPTransportSender());
@@ -316,48 +315,43 @@
// phase-related objects
//----------------------------
phase1 = new Phase("Phase1");
- phase1.addHandler(new TempHandler(1,2));
+ phase1.addHandler(new TempHandler(1, 2));
phase1.addHandler(new HandlerMCS(2, true));
- phase1.addHandler(new TempHandler(3,2));
+ phase1.addHandler(new TempHandler(3, 2));
ArrayList phases = new ArrayList();
phases.add(phase1);
axisConfiguration.setInPhasesUptoAndIncludingPostDispatch(phases);
-
//-----------------------------------------------------------------
// setup the axis side of the hierachy
//-----------------------------------------------------------------
// ABC group
//----------------------------
- axisSrvGrp_ABC = new AxisServiceGroup(axisConfiguration);
+ axisSrvGrp_ABC = new AxisServiceGroup(axisConfiguration);
axisSrvGrp_ABC.setServiceGroupName(serviceGroupName_ABC);
- axisSrv_A = new AxisService(service_QName_A.getLocalPart());
- axisSrv_B = new AxisService(service_QName_B.getLocalPart());
- axisSrv_C = new AxisService(service_QName_C.getLocalPart());
-
- axisSrvGrp_ABC.addService(axisSrv_A);
- axisSrvGrp_ABC.addService(axisSrv_B);
- axisSrvGrp_ABC.addService(axisSrv_C);
-
- axisOp_A1 = new InOutAxisOperation(operation_QName_A1);
- axisOp_A2 = new InOutAxisOperation(operation_QName_A2);
-
- axisOp_A1.setMessageReceiver(new MessageReceiver()
- {
- public void receive(MessageContext messageCtx)
- {
- }
- });
-
- axisOp_A2.setMessageReceiver(new MessageReceiver()
- {
- public void receive(MessageContext messageCtx)
- {
- }
- });
+ axisSrv_A = new AxisService(service_QName_A.getLocalPart());
+ axisSrv_B = new AxisService(service_QName_B.getLocalPart());
+ axisSrv_C = new AxisService(service_QName_C.getLocalPart());
+
+ axisSrvGrp_ABC.addService(axisSrv_A);
+ axisSrvGrp_ABC.addService(axisSrv_B);
+ axisSrvGrp_ABC.addService(axisSrv_C);
+
+ axisOp_A1 = new InOutAxisOperation(operation_QName_A1);
+ axisOp_A2 = new InOutAxisOperation(operation_QName_A2);
+
+ axisOp_A1.setMessageReceiver(new MessageReceiver() {
+ public void receive(MessageContext messageCtx) {
+ }
+ });
+
+ axisOp_A2.setMessageReceiver(new MessageReceiver() {
+ public void receive(MessageContext messageCtx) {
+ }
+ });
axisSrv_A.addOperation(axisOp_A1);
axisSrv_A.mapActionToOperation(operation_QName_A1.getLocalPart(), axisOp_A1);
@@ -373,39 +367,34 @@
axisOp_A1.getRemainingPhasesInFlow().add(phase1);
axisOp_A2.getRemainingPhasesInFlow().add(phase1);
-
//----------------------------
// 123 group
//----------------------------
- axisSrvGrp_123 = new AxisServiceGroup(axisConfiguration);
+ axisSrvGrp_123 = new AxisServiceGroup(axisConfiguration);
axisSrvGrp_123.setServiceGroupName(serviceGroupName_123);
- axisSrv_1 = new AxisService(service_QName_1.getLocalPart());
- axisSrv_2 = new AxisService(service_QName_2.getLocalPart());
- axisSrv_3 = new AxisService(service_QName_3.getLocalPart());
- axisSrv_4 = new AxisService(service_QName_4.getLocalPart());
-
- axisSrvGrp_123.addService(axisSrv_1);
- axisSrvGrp_123.addService(axisSrv_2);
- axisSrvGrp_123.addService(axisSrv_3);
- axisSrvGrp_123.addService(axisSrv_4);
-
- axisOp_1_1 = new InOutAxisOperation(operation_QName_1_1);
- axisOp_1_2 = new InOutAxisOperation(operation_QName_1_2);
-
- axisOp_1_1.setMessageReceiver(new MessageReceiver()
- {
- public void receive(MessageContext messageCtx)
- {
- }
- });
-
- axisOp_1_2.setMessageReceiver(new MessageReceiver()
- {
- public void receive(MessageContext messageCtx)
- {
- }
- });
+ axisSrv_1 = new AxisService(service_QName_1.getLocalPart());
+ axisSrv_2 = new AxisService(service_QName_2.getLocalPart());
+ axisSrv_3 = new AxisService(service_QName_3.getLocalPart());
+ axisSrv_4 = new AxisService(service_QName_4.getLocalPart());
+
+ axisSrvGrp_123.addService(axisSrv_1);
+ axisSrvGrp_123.addService(axisSrv_2);
+ axisSrvGrp_123.addService(axisSrv_3);
+ axisSrvGrp_123.addService(axisSrv_4);
+
+ axisOp_1_1 = new InOutAxisOperation(operation_QName_1_1);
+ axisOp_1_2 = new InOutAxisOperation(operation_QName_1_2);
+
+ axisOp_1_1.setMessageReceiver(new MessageReceiver() {
+ public void receive(MessageContext messageCtx) {
+ }
+ });
+
+ axisOp_1_2.setMessageReceiver(new MessageReceiver() {
+ public void receive(MessageContext messageCtx) {
+ }
+ });
axisSrv_1.addOperation(axisOp_1_1);
axisSrv_1.mapActionToOperation(operation_QName_1_1.getLocalPart(), axisOp_1_1);
@@ -421,42 +410,36 @@
axisOp_1_1.getRemainingPhasesInFlow().add(phase1);
axisOp_1_2.getRemainingPhasesInFlow().add(phase1);
-
-
//----------------------------
// DAY group
//----------------------------
- axisSrvGrp_DAY = new AxisServiceGroup(axisConfiguration);
+ axisSrvGrp_DAY = new AxisServiceGroup(axisConfiguration);
axisSrvGrp_DAY.setServiceGroupName(serviceGroupName_DAY);
- axisSrv_Mon = new AxisService(service_QName_Mon.getLocalPart());
- axisSrv_Tue = new AxisService(service_QName_Tue.getLocalPart());
- axisSrv_Wed = new AxisService(service_QName_Wed.getLocalPart());
- axisSrv_Thu = new AxisService(service_QName_Thu.getLocalPart());
- axisSrv_Fri = new AxisService(service_QName_Fri.getLocalPart());
-
- axisSrvGrp_DAY.addService(axisSrv_Mon);
- axisSrvGrp_DAY.addService(axisSrv_Tue);
- axisSrvGrp_DAY.addService(axisSrv_Wed);
- axisSrvGrp_DAY.addService(axisSrv_Thu);
- axisSrvGrp_DAY.addService(axisSrv_Fri);
-
- axisOp_Mon_1 = new InOutAxisOperation(operation_QName_Mon_1);
- axisOp_Mon_2 = new InOutAxisOperation(operation_QName_Mon_2);
-
- axisOp_Mon_1.setMessageReceiver(new MessageReceiver()
- {
- public void receive(MessageContext messageCtx)
- {
- }
- });
-
- axisOp_Mon_2.setMessageReceiver(new MessageReceiver()
- {
- public void receive(MessageContext messageCtx)
- {
- }
- });
+ axisSrv_Mon = new AxisService(service_QName_Mon.getLocalPart());
+ axisSrv_Tue = new AxisService(service_QName_Tue.getLocalPart());
+ axisSrv_Wed = new AxisService(service_QName_Wed.getLocalPart());
+ axisSrv_Thu = new AxisService(service_QName_Thu.getLocalPart());
+ axisSrv_Fri = new AxisService(service_QName_Fri.getLocalPart());
+
+ axisSrvGrp_DAY.addService(axisSrv_Mon);
+ axisSrvGrp_DAY.addService(axisSrv_Tue);
+ axisSrvGrp_DAY.addService(axisSrv_Wed);
+ axisSrvGrp_DAY.addService(axisSrv_Thu);
+ axisSrvGrp_DAY.addService(axisSrv_Fri);
+
+ axisOp_Mon_1 = new InOutAxisOperation(operation_QName_Mon_1);
+ axisOp_Mon_2 = new InOutAxisOperation(operation_QName_Mon_2);
+
+ axisOp_Mon_1.setMessageReceiver(new MessageReceiver() {
+ public void receive(MessageContext messageCtx) {
+ }
+ });
+
+ axisOp_Mon_2.setMessageReceiver(new MessageReceiver() {
+ public void receive(MessageContext messageCtx) {
+ }
+ });
axisSrv_Mon.addOperation(axisOp_Mon_1);
axisSrv_Mon.mapActionToOperation(operation_QName_Mon_1.getLocalPart(), axisOp_Mon_1);
@@ -473,34 +456,35 @@
axisOp_Mon_1.getRemainingPhasesInFlow().add(phase1);
axisOp_Mon_2.getRemainingPhasesInFlow().add(phase1);
-
//-----------------------------------------------------------------
// setup the context objects
//-----------------------------------------------------------------
- srvGrpCtx_ABC =ContextFactory.createServiceGroupContext(configurationContext,
- axisSrvGrp_ABC);
+ srvGrpCtx_ABC = ContextFactory.createServiceGroupContext(configurationContext,
+ axisSrvGrp_ABC);
srvGrpCtx_ABC.setId(serviceGroupName_ABC);
- srvGrpCtx_123 =ContextFactory.createServiceGroupContext(configurationContext, axisSrvGrp_123);
+ srvGrpCtx_123 =
+ ContextFactory.createServiceGroupContext(configurationContext, axisSrvGrp_123);
srvGrpCtx_123.setId(serviceGroupName_ABC);
- srvGrpCtx_DAY = ContextFactory.createServiceGroupContext(configurationContext, axisSrvGrp_DAY);
+ srvGrpCtx_DAY =
+ ContextFactory.createServiceGroupContext(configurationContext, axisSrvGrp_DAY);
srvGrpCtx_DAY.setId(serviceGroupName_DAY);
- srvCtx_A = ContextFactory.createServiceContext(srvGrpCtx_ABC,axisSrv_A);
- srvCtx_B = ContextFactory.createServiceContext(srvGrpCtx_ABC,axisSrv_B);
- srvCtx_C = ContextFactory.createServiceContext(srvGrpCtx_ABC,axisSrv_C);
-
- srvCtx_1 = ContextFactory.createServiceContext(srvGrpCtx_123,axisSrv_1);
- srvCtx_2 =ContextFactory.createServiceContext(srvGrpCtx_123,axisSrv_2);
- srvCtx_3 =ContextFactory.createServiceContext(srvGrpCtx_123,axisSrv_3);
- srvCtx_4 =ContextFactory.createServiceContext(srvGrpCtx_123,axisSrv_4) ;
-
- srvCtx_Mon = ContextFactory.createServiceContext(srvGrpCtx_DAY,axisSrv_Mon);
- srvCtx_Tue =ContextFactory.createServiceContext(srvGrpCtx_DAY,axisSrv_Tue) ;
- srvCtx_Wed =ContextFactory.createServiceContext(srvGrpCtx_DAY,axisSrv_Wed);
- srvCtx_Thu = ContextFactory.createServiceContext(srvGrpCtx_DAY,axisSrv_Thu) ;
- srvCtx_Fri =ContextFactory.createServiceContext(srvGrpCtx_DAY,axisSrv_Fri);
+ srvCtx_A = ContextFactory.createServiceContext(srvGrpCtx_ABC, axisSrv_A);
+ srvCtx_B = ContextFactory.createServiceContext(srvGrpCtx_ABC, axisSrv_B);
+ srvCtx_C = ContextFactory.createServiceContext(srvGrpCtx_ABC, axisSrv_C);
+
+ srvCtx_1 = ContextFactory.createServiceContext(srvGrpCtx_123, axisSrv_1);
+ srvCtx_2 = ContextFactory.createServiceContext(srvGrpCtx_123, axisSrv_2);
+ srvCtx_3 = ContextFactory.createServiceContext(srvGrpCtx_123, axisSrv_3);
+ srvCtx_4 = ContextFactory.createServiceContext(srvGrpCtx_123, axisSrv_4);
+
+ srvCtx_Mon = ContextFactory.createServiceContext(srvGrpCtx_DAY, axisSrv_Mon);
+ srvCtx_Tue = ContextFactory.createServiceContext(srvGrpCtx_DAY, axisSrv_Tue);
+ srvCtx_Wed = ContextFactory.createServiceContext(srvGrpCtx_DAY, axisSrv_Wed);
+ srvCtx_Thu = ContextFactory.createServiceContext(srvGrpCtx_DAY, axisSrv_Thu);
+ srvCtx_Fri = ContextFactory.createServiceContext(srvGrpCtx_DAY, axisSrv_Fri);
opCtx_A1 = srvCtx_A.createOperationContext(operation_QName_A1);
opCtx_A2 = srvCtx_A.createOperationContext(operation_QName_A2);
@@ -530,8 +514,7 @@
}
- private MessageContext createMessageContext(OperationContext oc) throws Exception
- {
+ private MessageContext createMessageContext(OperationContext oc) throws Exception {
MessageContext mc = ContextFactory.createMessageContext(configurationContext);
mc.setTransportIn(transportIn);
mc.setTransportOut(transportOut);
@@ -549,13 +532,13 @@
mc.setMessageID(UUIDGenerator.getUUID());
- axisOperation.registerOperationContext(mc,oc);
+ axisOperation.registerOperationContext(mc, oc);
mc.setOperationContext(oc);
ServiceContext sc = oc.getServiceContext();
mc.setServiceContext(sc);
- mc.setTo(new EndpointReference("axis2/services/NullService"));
+ mc.setTo(new EndpointReference("axis2/services/NullService"));
mc.setWSAAction("DummyOp");
AxisMessage axisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
@@ -564,13 +547,11 @@
return mc;
}
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
//org.apache.log4j.BasicConfigurator.configure();
}
- public void testServiceProperties() throws Exception
- {
+ public void testServiceProperties() throws Exception {
String title = "MessageContextSaveBTest: testServiceProperties(): ";
AxisEngine engine = new AxisEngine(configurationContext);
@@ -579,13 +560,13 @@
// add some service-level properties
String suffix = "_before";
- addServiceProperties(mc,suffix);
+ addServiceProperties(mc, suffix);
// get the service level properties into a separate table
Map properties_original = new HashMap(getServiceProperties(mc));
showProperties(properties_original, "original properties");
- System.out.println(title+"start - - engine.receive(mc) - - - - - - - - - - - - - - - -");
+ System.out.println(title + "start - - engine.receive(mc) - - - - - - - - - - - - - - - -");
engine.receive(mc);
// get the service level properties into a separate table
@@ -594,10 +575,10 @@
// add some more properties
suffix = "_postReceive";
- addServiceProperties(restoredMessageContext,suffix);
+ addServiceProperties(restoredMessageContext, suffix);
// resume the paused message context
- System.out.println(title+"resume - - engine.resume(mc) - - - - - - - - - - - - - - - -");
+ System.out.println(title + "resume - - engine.resume(mc) - - - - - - - - - - - - - - - -");
engine.resume(restoredMessageContext);
// get the service level properties into a separate table
@@ -616,98 +597,84 @@
}
- private Map getServiceProperties(MessageContext mc)
- {
+ private Map getServiceProperties(MessageContext mc) {
Map properties = null;
// get the service context from the message context
ServiceContext serviceContext = mc.getServiceContext();
- if (serviceContext == null)
- {
+ if (serviceContext == null) {
// get the service context from the operation context
OperationContext operationContext = mc.getOperationContext();
serviceContext = operationContext.getServiceContext();
}
- if (serviceContext != null)
- {
+ if (serviceContext != null) {
properties = serviceContext.getProperties();
}
return properties;
}
- private void addServiceProperties(MessageContext mc, String suffix)
- {
+ private void addServiceProperties(MessageContext mc, String suffix) {
// get the service context from the message context
ServiceContext serviceContext = mc.getServiceContext();
- if (serviceContext == null)
- {
+ if (serviceContext == null) {
// get the service context from the operation context
OperationContext operationContext = mc.getOperationContext();
serviceContext = operationContext.getServiceContext();
}
- if (serviceContext != null)
- {
- for (int k=0; k<serviceKeys.length; k++)
- {
+ if (serviceContext != null) {
+ for (int k = 0; k < serviceKeys.length; k++) {
String key = serviceKeys[k];
String value = serviceValues[k] + suffix;
- serviceContext.setProperty(key,value);
+ serviceContext.setProperty(key, value);
}
}
}
- private void showProperties(Map map, String description)
- {
- System.out.println(description+" ======================================");
- if ((map == null) || (map.isEmpty()))
- {
- System.out.println(description+": No properties");
- System.out.println(description+" ======================================");
+ private void showProperties(Map map, String description) {
+ System.out.println(description + " ======================================");
+ if ((map == null) || (map.isEmpty())) {
+ System.out.println(description + ": No properties");
+ System.out.println(description + " ======================================");
return;
}
Iterator it = map.keySet().iterator();
- while (it.hasNext())
- {
+ while (it.hasNext()) {
String key = (String) it.next();
String value = (String) map.get(key);
- System.out.println(description+": key-value pair ["+key+"]["+value+"]");
+ System.out.println(description + ": key-value pair [" + key + "][" + value + "]");
}
- System.out.println(description+" ======================================");
+ System.out.println(description + " ======================================");
}
/**
* Gets the ID associated with the handler object.
- *
- * @param o The handler object
+ *
+ * @param o The handler object
* @return The ID associated with the handler,
* -1 otherwise
*/
- private int getHandlerID(Object o)
- {
+ private int getHandlerID(Object o) {
int id = -1;
- if (o instanceof TempHandler)
- {
- id = ((TempHandler)o).getHandlerID();
+ if (o instanceof TempHandler) {
+ id = ((TempHandler) o).getHandlerID();
}
return id;
}
-
-
//=========================================================================
// Handler classes
//=========================================================================
@@ -715,15 +682,14 @@
/**
* Performs a save and restore on the message context
*/
- public class HandlerMCS extends AbstractHandler
- {
+ public class HandlerMCS extends AbstractHandler {
private Integer handlerID = null;
- private File theFile = null;
+ private File theFile = null;
private String theFilename = null;
- private boolean pause = false;
- private boolean savedOk = false;
+ private boolean pause = false;
+ private boolean savedOk = false;
private boolean restoredOk = false;
private boolean comparesOk = false;
@@ -731,34 +697,27 @@
// constructors
//-----------------------------------------------------------------
- public HandlerMCS()
- {
+ public HandlerMCS() {
this.handlerID = new Integer(-5);
}
- public HandlerMCS(int index, boolean pause)
- {
+ public HandlerMCS(int index, boolean pause) {
this.handlerID = new Integer(index);
this.pause = pause;
init(new HandlerDescription(new String("handler" + index)));
}
- public HandlerMCS(int index)
- {
+ public HandlerMCS(int index) {
this.handlerID = new Integer(index);
init(new HandlerDescription(new String("handler" + index)));
}
-
-
//-----------------------------------------------------------------
// methods
//-----------------------------------------------------------------
- public int getHandlerID()
- {
- if (handlerID != null)
- {
+ public int getHandlerID() {
+ if (handlerID != null) {
return handlerID.intValue();
}
@@ -766,38 +725,33 @@
}
- public InvocationResponse invoke(MessageContext msgContext) throws AxisFault
- {
- String title = "HandlerMCS["+getHandlerID()+"]:invoke(): ";
- System.out.println(title + "pause = ["+pause+"]");
- savedOk = false;
+ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+ String title = "HandlerMCS[" + getHandlerID() + "]:invoke(): ";
+ System.out.println(title + "pause = [" + pause + "]");
+ savedOk = false;
restoredOk = false;
- if (pause)
- {
+ if (pause) {
System.out.println(title + "msgContext.pause()");
msgContext.pause();
pause = false;
- try
- {
- theFile = File.createTempFile("mcSave",null);
+ try {
+ theFile = File.createTempFile("mcSave", null);
theFilename = theFile.getName();
- System.out.println(title + "temp file = ["+theFilename+"]");
+ System.out.println(title + "temp file = [" + theFilename + "]");
}
- catch (Exception ex)
- {
- System.out.println(title + "error creating temp file = ["+ex.getMessage()+"]");
+ catch (Exception ex) {
+ System.out.println(
+ title + "error creating temp file = [" + ex.getMessage() + "]");
theFile = null;
}
- if (theFile != null)
- {
+ if (theFile != null) {
// ---------------------------------------------------------
// save to the temporary file
// ---------------------------------------------------------
- try
- {
+ try {
// setup an output stream to a physical file
FileOutputStream outStream = new FileOutputStream(theFile);
@@ -820,12 +774,13 @@
System.out.println(title + "....saved message context.....");
long filesize = theFile.length();
- System.out.println(title + "file size after save ["+filesize+"] temp file = ["+theFilename+"]");
+ System.out.println(title + "file size after save [" + filesize +
+ "] temp file = [" + theFilename + "]");
}
- catch (Exception ex2)
- {
- System.out.println(title + "error with saving message context = ["+ex2.getClass().getName()+" : "+ex2.getMessage()+"]");
+ catch (Exception ex2) {
+ System.out.println(title + "error with saving message context = [" +
+ ex2.getClass().getName() + " : " + ex2.getMessage() + "]");
ex2.printStackTrace();
}
@@ -834,8 +789,7 @@
// ---------------------------------------------------------
// restore from the temporary file
// ---------------------------------------------------------
- try
- {
+ try {
// setup an input stream to the file
FileInputStream inStream = new FileInputStream(theFile);
@@ -860,9 +814,9 @@
// variable for the test
restoredMessageContext = msgContext2;
}
- catch (Exception ex2)
- {
- System.out.println(title + "error with restoring message context = ["+ex2.getClass().getName()+" : "+ex2.getMessage()+"]");
+ catch (Exception ex2) {
+ System.out.println(title + "error with restoring message context = [" +
+ ex2.getClass().getName() + " : " + ex2.getMessage() + "]");
ex2.printStackTrace();
restoredMessageContext = null;
}
@@ -872,14 +826,11 @@
// if the save/restore of the message context succeeded,
// then don't keep the temporary file around
boolean removeTmpFile = savedOk && restoredOk;
- if (removeTmpFile)
- {
- try
- {
+ if (removeTmpFile) {
+ try {
theFile.delete();
}
- catch (Exception e)
- {
+ catch (Exception e) {
// just absorb it
}
}
@@ -887,10 +838,8 @@
return InvocationResponse.SUSPEND;
- }
- else
- {
- System.out.println(title + "executedHandlers.add("+handlerID+")");
+ } else {
+ System.out.println(title + "executedHandlers.add(" + handlerID + ")");
executedHandlers.add(handlerID);
}
@@ -899,8 +848,7 @@
}
- public class TempHandler extends AbstractHandler
- {
+ public class TempHandler extends AbstractHandler {
private Integer handlerID = null;
private int count = 0;
private int numberProperties = 3;
@@ -911,19 +859,16 @@
// constructors
//-----------------------------------------------------------------
- public TempHandler()
- {
+ public TempHandler() {
this.handlerID = new Integer(-5);
}
- public TempHandler(int index)
- {
+ public TempHandler(int index) {
this.handlerID = new Integer(index);
init(new HandlerDescription(new String("handler" + index)));
}
- public TempHandler(int index, int number)
- {
+ public TempHandler(int index, int number) {
this.handlerID = new Integer(index);
init(new HandlerDescription(new String("handler" + index)));
numberProperties = number;
@@ -933,10 +878,8 @@
// methods
//-----------------------------------------------------------------
- public int getHandlerID()
- {
- if (handlerID != null)
- {
+ public int getHandlerID() {
+ if (handlerID != null) {
return handlerID.intValue();
}
@@ -944,32 +887,28 @@
}
- public InvocationResponse invoke(MessageContext msgContext) throws AxisFault
- {
- String title = "TempHandler["+getHandlerID()+"]:invoke(): ";
+ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+ String title = "TempHandler[" + getHandlerID() + "]:invoke(): ";
// get the service context from the message context
ServiceContext serviceContext = msgContext.getServiceContext();
- if (serviceContext == null)
- {
+ if (serviceContext == null) {
// get the service context from the operation context
OperationContext operationContext = msgContext.getOperationContext();
serviceContext = operationContext.getServiceContext();
}
- if (serviceContext != null)
- {
- for (int j=0; j<numberProperties; j++)
- {
+ if (serviceContext != null) {
+ for (int j = 0; j < numberProperties; j++) {
count++;
- String key = new String(propertyKey +".ID["+getHandlerID()+"]."+count);
- String value = new String(propertyValue + "["+count+"]");
- serviceContext.setProperty(key,value);
+ String key = new String(propertyKey + ".ID[" + getHandlerID() + "]." + count);
+ String value = new String(propertyValue + "[" + count + "]");
+ serviceContext.setProperty(key, value);
}
}
- System.out.println(title + "executedHandlers.add("+handlerID+")");
+ System.out.println(title + "executedHandlers.add(" + handlerID + ")");
executedHandlers.add(handlerID);
return InvocationResponse.CONTINUE;
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org