本文整理汇总了Java中org.apache.axis2.context.MessageContext.setFLOW方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.setFLOW方法的具体用法?Java MessageContext.setFLOW怎么用?Java MessageContext.setFLOW使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.setFLOW方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDoProcessingForInitiator
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessingForInitiator() throws Exception {
System.out.println("[testDoProcessingForInitiator]");
MessageContext mc = new MessageContext();
mc.setFLOW(MessageContext.OUT_FLOW);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertNotNull(invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
Options options = mc.getOptions();
assertNotNull(options.getProperty(HTTPConstants.USER_AGENT));
}
示例2: createMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private MessageContext createMessageContext(OperationContext oc, ConfigurationContext cc,
int flowType) throws Exception {
MessageContext mc = cc.createMessageContext();
mc.setFLOW(flowType);
mc.setTransportIn(transportIn);
mc.setTransportOut(transportOut);
mc.setServerSide(true);
// mc.setProperty(MessageContext.TRANSPORT_OUT, System.out);
SOAPFactory omFac = OMAbstractFactory.getSOAP11Factory();
mc.setEnvelope(omFac.getDefaultEnvelope());
AxisOperation axisOperation = oc.getAxisOperation();
String action = axisOperation.getName().getLocalPart();
mc.setSoapAction(action);
// System.out.flush();
mc.setMessageID(UUIDGenerator.getUUID());
axisOperation.registerOperationContext(mc, oc);
mc.setOperationContext(oc);
ServiceContext sc = oc.getServiceContext();
mc.setServiceContext(sc);
mc.setTo(new EndpointReference("axis2/services/NullService"));
mc.setWSAAction("DummyOp");
AxisMessage axisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
mc.setAxisMessage(axisMessage);
return mc;
}
示例3: testInFlows
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testInFlows() throws Exception {
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
MessageContext mc = new MessageContext();
mc.setFLOW(MessageContext.IN_FLOW);
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
PullRequest pullRequest = new PullRequest();
pullRequest.setMessageId("some_pull_request_id_01");
PullRequestElement.createElement(headerBlock, pullRequest);
assertNull(mc.getProperty(MessageContextProperties.IN_PULL_REQUEST));
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
assertNotNull(mc.getProperty(MessageContextProperties.IN_PULL_REQUEST));
}
示例4: testDoProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
MessageMetaData mmd = TestUtils.getMMD("security/handlers/full_mmd.xml", this);
// Creating SOAP envelope
SOAPEnvelope env =
SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding UserMessage from mmd
OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);
MessageContext mc = new MessageContext();
System.out.println("mc: " + mc);
mc.setFLOW(MessageContext.IN_FLOW);
mc.setProperty(SecurityConstants.ADD_SECURITY_HEADERS, Boolean.TRUE);
UserMessage userMessage = UserMessageElement.readElement(umElement);
OperationContext operationContext = mock(OperationContext.class);
when(operationContext
.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE))
.thenReturn(mc);
mc.setOperationContext(operationContext);
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
StorageManager storageManager = core.getStorageManager();
// Setting input message property
IUserMessageEntity userMessageEntity =
storageManager.storeIncomingMessageUnit(userMessage);
mc.setProperty(MessageContextProperties.IN_USER_MESSAGE,
userMessageEntity);
SecurityConstants.WSS_FAILURES part =
SecurityConstants.WSS_FAILURES.DECRYPTION;
String errorMessage = "some error message";
mc.setProperty(SecurityConstants.INVALID_DEFAULT_HEADER,
new KeyValuePair<>(part, errorMessage));
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
assertEquals(ProcessingState.FAILURE,
userMessageEntity.getCurrentProcessingState().getState());
}
示例5: testDoProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding UserMessage from mmd
OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);
MessageContext mc = new MessageContext();
mc.setFLOW(MessageContext.OUT_FLOW);
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
PMode pmode = new PMode();
Leg leg = new Leg();
// Setting all protocol configurations checked by the tested handler
Protocol protocolConfig = new Protocol();
protocolConfig.setAddress("address");
protocolConfig.setHTTPCompression(true);
protocolConfig.setChunking(true);
leg.setProtocol(protocolConfig);
pmode.addLeg(leg);
UserMessage userMessage = UserMessageElement.readElement(umElement);
// Setting attachments
Attachments attachments = new Attachments();
Payload payload = new Payload();
payload.setContainment(IPayload.Containment.ATTACHMENT);
String payloadPath = "file://./flower.jpg";
payload.setPayloadURI(payloadPath);
payload.setContentLocation(baseDir + "/flower.jpg");
userMessage.addPayload(payload);
attachments.addDataHandler(payloadPath,
new DataHandler(new URL(payload.getPayloadURI())));
mc.setAttachmentMap(attachments);
String pmodeId =
userMessage.getCollaborationInfo().getAgreement().getPModeId();
userMessage.setPModeId(pmodeId);
pmode.setId(pmodeId);
core.getPModeSet().add(pmode);
// Setting input message property
IUserMessageEntity userMessageEntity =
core.getStorageManager().storeIncomingMessageUnit(userMessage);
mc.setProperty(MessageContextProperties.OUT_USER_MESSAGE,
userMessageEntity);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
verify(mockAppender, atLeastOnce())
.doAppend(captorLoggingEvent.capture());
List<LoggingEvent> events = captorLoggingEvent.getAllValues();
String msg = "HTTP configuration done";
assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
示例6: testDoProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
MessageMetaData mmd = TestUtils.getMMD("compression/full_mmd.xml", this);
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding UserMessage from mmd
OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);
MessageContext mc = new MessageContext();
mc.setFLOW(MessageContext.IN_FLOW);
PMode pmode = new PMode();
Leg leg = new Leg();
UserMessageFlow umFlow = new UserMessageFlow();
PayloadProfile plProfile = new PayloadProfile();
plProfile.setCompressionType(CompressionFeature.COMPRESSED_CONTENT_TYPE);
umFlow.setPayloadProfile(plProfile);
leg.setUserMessageFlow(umFlow);
pmode.addLeg(leg);
UserMessage userMessage = UserMessageElement.readElement(umElement);
// We need to add payload with containment type "attachment" to user message,
// because PartInfoElement does not read the "containment" attribute
// value of the PartInfo tag from file now (23-Feb-2017 T.S.)
Payload payload = new Payload();
payload.setContainment(IPayload.Containment.ATTACHMENT);
ArrayList<IProperty> props = new ArrayList<>();
Property p = new Property();
p.setName(CompressionFeature.FEATURE_PROPERTY_NAME);
p.setValue(CompressionFeature.COMPRESSED_CONTENT_TYPE);
props.add(p);
p = new Property();
p.setName(CompressionFeature.MIME_TYPE_PROPERTY_NAME);
p.setValue("jpeg");
props.add(p);
payload.setProperties(props);
String payloadPath = "file://./uncompressed.jpg";
payload.setPayloadURI(payloadPath);
userMessage.addPayload(payload);
Attachments attachments = new Attachments();
attachments.addDataHandler(payloadPath,
new DataHandler(new URL(payload.getPayloadURI())));
mc.setAttachmentMap(attachments);
String pmodeId =
userMessage.getCollaborationInfo().getAgreement().getPModeId();
// Copy pmodeId of the agreement to the user message
userMessage.setPModeId(pmodeId);
pmode.setId(pmodeId);
core.getPModeSet().add(pmode);
// Setting input message property
IUserMessageEntity userMessageEntity =
core.getStorageManager().storeIncomingMessageUnit(userMessage);
mc.setProperty(MessageContextProperties.IN_USER_MESSAGE,
userMessageEntity);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
verify(mockAppender, atLeastOnce())
.doAppend(captorLoggingEvent.capture());
List<LoggingEvent> events = captorLoggingEvent.getAllValues();
String expLogMsg = "Replaced DataHandler to enable decompression";
assertTrue(eventContainsMsg(events, Level.DEBUG, expLogMsg));
}
示例7: testDoProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
// Creating SOAP envelope
SOAPEnvelope env =
SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding UserMessage from mmd
OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);
MessageContext mc = new MessageContext();
mc.setFLOW(MessageContext.OUT_FLOW);
UserMessage userMessage = UserMessageElement.readElement(umElement);
OperationContext operationContext = mock(OperationContext.class);
when(operationContext
.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE))
.thenReturn(mc);
mc.setOperationContext(operationContext);
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
StorageManager storageManager = core.getStorageManager();
// Setting input message property
IUserMessageEntity userMessageEntity =
storageManager.storeIncomingMessageUnit(userMessage);
mc.setProperty(MessageContextProperties.OUT_USER_MESSAGE,
userMessageEntity);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
assertEquals(ProcessingState.SENDING,
userMessageEntity.getCurrentProcessingState().getState());
}
示例8: send
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* This methods represents the outflow of the Axis, this could be either at the server side or the client side.
* Here the <code>ExecutionChain</code> is created using the Phases. The Handlers at the each Phases is ordered in
* deployment time by the deployment module
*
* @param msgContext
* @throws AxisFault
* @see MessageContext
* @see Phase
* @see Handler
*/
public static void send(MessageContext msgContext) throws AxisFault {
if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
log.trace(msgContext.getLogIDString() + " send:" + msgContext.getMessageID());
}
// find and invoke the Phases
OperationContext operationContext = msgContext.getOperationContext();
ArrayList executionChain = operationContext.getAxisOperation().getPhasesOutFlow();
//rather than having two steps added both oparation and global chain together
ArrayList outPhases = new ArrayList();
outPhases.addAll(executionChain);
outPhases.addAll(msgContext.getConfigurationContext().getAxisConfiguration().getOutFlowPhases());
msgContext.setExecutionChain(outPhases);
msgContext.setFLOW(MessageContext.OUT_FLOW);
try {
InvocationResponse pi = invoke(msgContext, NOT_RESUMING_EXECUTION);
if (pi.equals(InvocationResponse.CONTINUE)) {
// write the Message to the Wire
TransportOutDescription transportOut = msgContext.getTransportOut();
if (transportOut == null) {
throw new AxisFault("Transport out has not been set");
}
TransportSender sender = transportOut.getSender();
// This boolean property only used in client side fireAndForget invocation
//It will set a property into message context and if some one has set the
//property then transport sender will invoke in a diffrent thread
if (Utils.isClientThreadNonBlockingPropertySet(msgContext)) {
msgContext.getConfigurationContext().getThreadPool().execute(
new TransportNonBlockingInvocationWorker(msgContext, sender));
} else {
sender.invoke(msgContext);
}
//REVIEW: In the case of the TransportNonBlockingInvocationWorker, does this need to wait until that finishes?
flowComplete(msgContext);
} else if (pi.equals(InvocationResponse.SUSPEND)) {
} else if (pi.equals(InvocationResponse.ABORT)) {
flowComplete(msgContext);
} else {
String errorMsg =
"Unrecognized InvocationResponse encountered in AxisEngine.send()";
log.error(msgContext.getLogIDString() + " " + errorMsg);
throw new AxisFault(errorMsg);
}
} catch (AxisFault e) {
msgContext.setFailureReason(e);
flowComplete(msgContext);
throw e;
}
}
示例9: testDoProcessingOfTheResponseReceipt
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessingOfTheResponseReceipt() throws Exception {
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
MessageContext mc = new MessageContext();
mc.setServerSide(true);
mc.setFLOW(MessageContext.OUT_FLOW);
Receipt receipt = new Receipt();
OMElement receiptChildElement =
env.getOMFactory().createOMElement(RECEIPT_CHILD_ELEMENT_NAME);
ArrayList<OMElement> content = new ArrayList<>();
content.add(receiptChildElement);
receipt.setContent(content);
ReceiptElement.createElement(headerBlock, receipt);
StorageManager updateManager = core.getStorageManager();
IReceiptEntity receiptEntity =
updateManager.storeIncomingMessageUnit(receipt);
mc.setProperty(MessageContextProperties.RESPONSE_RECEIPT, receiptEntity);
// Mocking the Axis2 Operation Context
OperationContext operationContext = mock(OperationContext.class);
when(operationContext
.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE))
.thenReturn(mc);
mc.setOperationContext(operationContext);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertNotNull(invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
verify(mockAppender, atLeastOnce())
.doAppend(captorLoggingEvent.capture());
List<LoggingEvent> events = captorLoggingEvent.getAllValues();
String msg = "Response contains a receipt signal";
assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
示例10: testDoProcessingOfTheErrors
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessingOfTheErrors() throws Exception {
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
MessageContext mc = new MessageContext();
mc.setServerSide(true);
mc.setFLOW(MessageContext.OUT_FLOW);
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
ErrorMessage errorMessage = new ErrorMessage();
ArrayList<IEbmsError> errors = new ArrayList<>();
EbmsError ebmsError = new EbmsError();
ebmsError.setSeverity(IEbmsError.Severity.FAILURE);
ebmsError.setErrorCode("some_error_code");
errors.add(ebmsError);
errorMessage.setErrors(errors);
// todo We also need to test multiple errors handling
// todo I'm going to implement this test later (TS)
ErrorSignalElement.createElement(headerBlock, errorMessage);
StorageManager updateManager = core.getStorageManager();
IErrorMessageEntity errorMessageEntity =
updateManager.storeIncomingMessageUnit(errorMessage);
ArrayList<IErrorMessageEntity> errorMessageEntities = new ArrayList<>();
errorMessageEntities.add(errorMessageEntity);
mc.setProperty(MessageContextProperties.OUT_ERRORS,
errorMessageEntities);
// Mocking the Axis2 Operation Context
OperationContext operationContext = mock(OperationContext.class);
when(operationContext
.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE))
.thenReturn(mc);
mc.setOperationContext(operationContext);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertNotNull(invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
verify(mockAppender, atLeastOnce())
.doAppend(captorLoggingEvent.capture());
List<LoggingEvent> events = captorLoggingEvent.getAllValues();
String msg = "Response does contain one error signal";
assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
示例11: testDoProcessingOfUserMessage
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessingOfUserMessage() throws Exception {
// todo Can we remove dependency from the xml data?
MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding UserMessage from mmd
OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);
MessageContext mc = new MessageContext();
mc.setFLOW(MessageContext.IN_FLOW);
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
UserMessage userMessage
= UserMessageElement.readElement(umElement);
// Setting input message property
StorageManager updateManager = core.getStorageManager();
IUserMessageEntity userMessageEntity =
updateManager.storeIncomingMessageUnit(userMessage);
mc.setProperty(MessageContextProperties.IN_USER_MESSAGE,
userMessageEntity);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertNotNull(invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
// Checking log messages to make sure handler validated
// the user message successfully
verify(mockAppender, atLeastOnce())
.doAppend(captorLoggingEvent.capture());
List<LoggingEvent> events = captorLoggingEvent.getAllValues();
String msg = "Received User Message satisfies basic validations";
assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
示例12: testProcessingOfTheUserMessage
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testProcessingOfTheUserMessage() throws Exception {
MessageMetaData mmd = TestUtils.getMMD("multihop/icloud/full_mmd.xml", this);
// Creating SOAP envelope
SOAPEnvelope env =
SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding UserMessage from mmd
OMElement userMessage = UserMessageElement.createElement(headerBlock, mmd);
IUserMessageEntity userMessageEntity =
HolodeckB2BCore.getStorageManager().storeIncomingMessageUnit(
UserMessageElement.readElement(userMessage));
OMElement ciElement = CollaborationInfoElement.getElement(userMessage);
OMElement arElement = AgreementRefElement.getElement(ciElement);
AgreementReference ar = AgreementRefElement.readElement(arElement);
assertNotNull(ar.getPModeId());
MessageContext mc = new MessageContext();
mc.setFLOW(MessageContext.OUT_FLOW);
PMode pmode = new PMode();
pmode.setMep(EbMSConstants.ONE_WAY_MEP);
pmode.setMepBinding(EbMSConstants.ONE_WAY_PUSH);
Leg leg = new Leg();
Protocol protocolConfig = new Protocol();
protocolConfig.setAddress("address");
protocolConfig.setAddActorOrRoleAttribute(true);
leg.setProtocol(protocolConfig);
pmode.addLeg(leg);
Agreement agreement = new Agreement();
pmode.setAgreement(agreement);
pmode.setId(ar.getPModeId());
//Adding PMode to the managed PMode set.
core.getPModeSet().add(pmode);
HolodeckB2BCore.getStorageManager().setPModeId(userMessageEntity, ar.getPModeId());
// Setting out message property
mc.setProperty(MessageContextProperties.OUT_USER_MESSAGE, userMessageEntity);
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
SOAPHeaderBlock messaging = Messaging.getElement(mc.getEnvelope());
// Setting Role, as stated in paragraph 4.3 of AS4 profile
messaging.setRole(MultiHopConstants.NEXT_MSH_TARGET);
assertNotNull(MessageContextUtils.getReceivedMessageUnits(mc));
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals("InvocationResponse.CONTINUE", invokeResp.toString());
} catch (Exception e) {
fail(e.getMessage());
}
}
示例13: testDoProcessingOfReciepts
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessingOfReciepts() throws Exception {
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding Receipts
Receipt receipt = new Receipt();
receipt.setMessageId("some_message_id");
receipt.setRefToMessageId("some_ref_to_message_id");
receipt.setTimestamp(new Date());
ArrayList<OMElement> receiptContent = new ArrayList<>();
OMElement receiptChildElement =
headerBlock.getOMFactory().createOMElement(RECEIPT_CHILD_ELEMENT_NAME);
receiptChildElement.setText("eb3:UserMessage");
System.out.println("receiptChildElement: " + receiptChildElement);
receiptContent.add(receiptChildElement);
receipt.setContent(receiptContent);
MessageContext mc = new MessageContext();
mc.setFLOW(MessageContext.IN_FLOW);
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
// Setting input Receipt property
StorageManager updateManager = core.getStorageManager();
IReceiptEntity receiptEntity =
updateManager.storeIncomingMessageUnit(receipt);
ArrayList<IReceiptEntity> receiptEntities = new ArrayList<>();
receiptEntities.add(receiptEntity);
mc.setProperty(MessageContextProperties.IN_RECEIPTS,
receiptEntities);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertNotNull(invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
// Checking log messages to make sure handler validated
// the pull request successfully
verify(mockAppender, atLeastOnce())
.doAppend(captorLoggingEvent.capture());
List<LoggingEvent> events = captorLoggingEvent.getAllValues();
String msg = "Received Receipt satisfies basic validations";
assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
示例14: testDoProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
MessageContext mc = new MessageContext();
mc.setFLOW(MessageContext.IN_FLOW);
PMode pmode = new PMode();
pmode.setMep(EbMSConstants.ONE_WAY_MEP);
pmode.setMepBinding(EbMSConstants.ONE_WAY_PULL);
// Setting token configuration
UsernameTokenConfig tokenConfig = new UsernameTokenConfig();
tokenConfig.setUsername("username");
tokenConfig.setPassword("secret");
PartnerConfig initiator = new PartnerConfig();
SecurityConfig secConfig = new SecurityConfig();
X509Certificate sigConfig = new X509Certificate(null);
EncryptionConfig encConfig = new EncryptionConfig();
encConfig.setKeystoreAlias("exampleca");
secConfig.setEncryptionConfiguration(encConfig);
secConfig.setUsernameTokenConfiguration(
ISecurityConfiguration.WSSHeaderTarget.EBMS, tokenConfig);
initiator.setSecurityConfiguration(secConfig);
pmode.setInitiator(initiator);
Leg leg = new Leg();
PullRequestFlow prFlow = new PullRequestFlow();
prFlow.setSecurityConfiguration(secConfig);
leg.addPullRequestFlow(prFlow);
pmode.addLeg(leg);
final Map<String, IAuthenticationInfo> authInfo = new HashMap<>();
authInfo.put(SecurityConstants.EBMS_USERNAMETOKEN, tokenConfig);
authInfo.put(SecurityConstants.SIGNATURE, sigConfig);
mc.setProperty(SecurityConstants.MC_AUTHENTICATION_INFO, authInfo);
PullRequest pullRequest = new PullRequest();
pullRequest.setMessageId("some_msg_id");
core.getPModeSet().add(pmode);
// Setting input message property
StorageManager storageManager = core.getStorageManager();
System.out.println("um: " + storageManager.getClass());
IPullRequestEntity pullRequestEntity =
storageManager.storeIncomingMessageUnit(pullRequest);
mc.setProperty(MessageContextProperties.IN_PULL_REQUEST,
pullRequestEntity);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
// Checking log messages to make sure handler found pmode
verify(mockAppender, atLeastOnce())
.doAppend(captorLoggingEvent.capture());
List<LoggingEvent> events = captorLoggingEvent.getAllValues();
String msg = "Store the list of " + 1
+ " authorized PModes so next handler can retrieve message unit to return";
assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
示例15: testDoProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding UserMessage from mmd
UserMessageElement.createElement(headerBlock, mmd);
String msgId = "some_msg_id";
MessageContext mc = new MessageContext();
mc.setServerSide(true);
mc.setFLOW(MessageContext.IN_FLOW);
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
String errorId = "error_id";
ErrorMessage errorMessage = new ErrorMessage();
ArrayList<IEbmsError> errors = new ArrayList<>();
EbmsError ebmsError = new EbmsError();
ebmsError.setSeverity(IEbmsError.Severity.FAILURE);
ebmsError.setErrorCode("some_error_code");
ebmsError.setRefToMessageInError(msgId);
ebmsError.setMessage("some error message");
errors.add(ebmsError);
errorMessage.setErrors(errors);
errorMessage.setRefToMessageId(msgId);
errorMessage.setMessageId(errorId);
ErrorSignalElement.createElement(headerBlock, errorMessage);
assertNull(mc.getProperty(MessageContextProperties.IN_ERRORS));
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
assertNotNull(mc.getProperty(MessageContextProperties.IN_ERRORS));
}