messagecontextsavebtest.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 918 行 · 第 1/3 页
JAVA
918 行
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.axis2.engine;
import junit.framework.TestCase;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.util.UUIDGenerator;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.ConfigurationContext;
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;
import org.apache.axis2.description.AxisServiceGroup;
import org.apache.axis2.description.HandlerDescription;
import org.apache.axis2.description.InOutAxisOperation;
import org.apache.axis2.description.TransportInDescription;
import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.dispatchers.AddressingBasedDispatcher;
import org.apache.axis2.dispatchers.RequestURIBasedDispatcher;
import org.apache.axis2.dispatchers.SOAPActionBasedDispatcher;
import org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher;
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver;
import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
import org.apache.axis2.transport.http.CommonsHTTPTransportSender;
import org.apache.axis2.transport.http.SimpleHTTPServer;
import org.apache.axis2.util.ObjectStateUtils;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.xml.namespace.QName;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class MessageContextSaveBTest extends TestCase {
protected static final Log log = LogFactory.getLog(MessageContextSaveBTest.class);
//-------------------------------------------------------------------------
// test key-value pairs
//-------------------------------------------------------------------------
private String [] serviceKeys = {
"serviceKey1",
"serviceKey2",
"serviceKey3"
};
private String [] serviceValues = {
"serviceValue1",
"serviceValue2",
"serviceValue3"
};
//-------------------------------------------------------------------------
// variables for the object graph
//-------------------------------------------------------------------------
// used on a save/restore of the message context
// has a full object graph with 3 sets of service groups
// and associated objects
private ConfigurationContext configurationContext = 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 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 MessageContext msgCtx_A1 = null;
private MessageContext msgCtx_A2 = null;
//private AxisMessage axisMsg_A1 = null;
//private AxisMessage axisMsg_A2 = null;
//------------------------------
// service group 123
//------------------------------
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 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 MessageContext msgCtx_1_1 = null;
private MessageContext msgCtx_1_2 = null;
//private AxisMessage axisMsg_1_1 = null;
//private AxisMessage axisMsg_1_2 = null;
//------------------------------
// service group DAY
//------------------------------
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 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 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 transportOut2 = null;
private TransportOutDescription transportOut3 = null;
private TransportInDescription transportIn = null;
private TransportInDescription transportIn2 = null;
private TransportInDescription transportIn3 = null;
private Phase phase1 = null;
private ArrayList executedHandlers = null;
private MessageContext restoredMessageContext = null;
//-------------------------------------------------------------------------
// methods
//-------------------------------------------------------------------------
public MessageContextSaveBTest(String arg0) {
super(arg0);
try {
prepare();
}
catch (Exception e) {
log.debug("MessageContextSaveBTest:constructor: error in setting up object graph [" +
e.getClass().getName() + " : " + e.getMessage() + "]");
}
}
//
// prepare the object hierarchy for testing
//
private void prepare() throws Exception {
//-----------------------------------------------------------------
// setup the top-level objects
//-----------------------------------------------------------------
axisConfiguration = new AxisConfiguration();
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());
DispatchPhase dispatchPhase = new DispatchPhase();
dispatchPhase.setName("Dispatch");
AddressingBasedDispatcher abd = new AddressingBasedDispatcher();
abd.initDispatcher();
RequestURIBasedDispatcher rud = new RequestURIBasedDispatcher();
rud.initDispatcher();
SOAPActionBasedDispatcher sabd = new SOAPActionBasedDispatcher();
sabd.initDispatcher();
SOAPMessageBodyBasedDispatcher smbd = new SOAPMessageBodyBasedDispatcher();
smbd.initDispatcher();
dispatchPhase.addHandler(abd);
dispatchPhase.addHandler(rud);
dispatchPhase.addHandler(sabd);
dispatchPhase.addHandler(smbd);
configurationContext.getAxisConfiguration().getInFlowPhases().add(dispatchPhase);
//----------------------------
// transport-related objects
//----------------------------
transportOut = new TransportOutDescription("null");
transportOut2 = new TransportOutDescription("happy");
transportOut3 = new TransportOutDescription("golucky");
transportOut.setSender(new CommonsHTTPTransportSender());
transportOut2.setSender(new CommonsHTTPTransportSender());
transportOut3.setSender(new CommonsHTTPTransportSender());
axisConfiguration.addTransportOut(transportOut3);
axisConfiguration.addTransportOut(transportOut2);
axisConfiguration.addTransportOut(transportOut);
transportIn = new TransportInDescription("null");
transportIn2 = new TransportInDescription("always");
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?