本文整理汇总了Java中org.apache.axis2.engine.Handler.InvocationResponse方法的典型用法代码示例。如果您正苦于以下问题:Java Handler.InvocationResponse方法的具体用法?Java Handler.InvocationResponse怎么用?Java Handler.InvocationResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.engine.Handler
的用法示例。
在下文中一共展示了Handler.InvocationResponse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDoProcessingForResponder
import org.apache.axis2.engine.Handler; //导入方法依赖的package包/类
@Test
public void testDoProcessingForResponder() throws Exception {
System.out.println("[testDoProcessingForResponder]");
MessageContext mc = new MessageContext();
mc.setFLOW(MessageContext.OUT_FLOW);
mc.setServerSide(true);
AxisHttpResponse response = mock(AxisHttpResponse.class);
mc.setProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO, response);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertNotNull(invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
verify(response).setHeader("Server", HTTP_HDR_VALUE);
}
示例2: testDoProcessingOfErrors
import org.apache.axis2.engine.Handler; //导入方法依赖的package包/类
@Test
public void testDoProcessingOfErrors() throws Exception {
// Initialising Errors
ErrorMessage error = new ErrorMessage();
error.setMessageId("some_message_id");
error.setTimestamp(new Date());
ArrayList<IEbmsError> errors = new ArrayList<>();
errors.add(new EbmsError());
error.setErrors(errors);
MessageContext mc = new MessageContext();
// Setting input Receipt property
StorageManager updateManager = core.getStorageManager();
IErrorMessageEntity errorMessageEntity =
updateManager.storeIncomingMessageUnit(error);
System.out.println("errors: " + errorMessageEntity.getErrors());
ArrayList<IErrorMessageEntity> errorMessageEntities = new ArrayList<>();
errorMessageEntities.add(errorMessageEntity);
mc.setProperty(MessageContextProperties.IN_ERRORS,
errorMessageEntities);
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 validated
// the pull request successfully
verify(mockAppender, atLeastOnce())
.doAppend(captorLoggingEvent.capture());
List<LoggingEvent> events = captorLoggingEvent.getAllValues();
String msg = "Received Error satisfies basic validations";
assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
示例3: testDoProcessingForInitiator
import org.apache.axis2.engine.Handler; //导入方法依赖的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));
}
示例4: testDoProcessing
import org.apache.axis2.engine.Handler; //导入方法依赖的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();
UserMessage userMessage
= UserMessageElement.readElement(umElement);
String msgId = userMessage.getMessageId();
StorageManager updateManager = core.getStorageManager();
IUserMessageEntity userMessageEntity =
updateManager.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());
LoggingEvent loggingEvent = captorLoggingEvent.getValue();
//Check log level
assertThat(loggingEvent.getLevel(), is(Level.WARN));
//Check the message being logged
assertThat(loggingEvent.getRenderedMessage(),
is("User message [msgId= " + msgId + "] is ready for processing"));
}
示例5: testProcessing
import org.apache.axis2.engine.Handler; //导入方法依赖的package包/类
/**
* Test construction of the user message to be successfully consumed by
* {@link org.holodeckb2b.ebms3.handlers.inflow.ReadUserMessage ReadUserMessage} handler
*/
@Test
public void testProcessing() {
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);
MessageContext mc = new MessageContext();
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
assertNull(mc.getProperty(MessageContextProperties.IN_USER_MESSAGE));
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
assertNotNull(mc.getProperty(MessageContextProperties.IN_USER_MESSAGE));
}
示例6: testDoProcessing
import org.apache.axis2.engine.Handler; //导入方法依赖的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());
}
示例7: testDoProcessing
import org.apache.axis2.engine.Handler; //导入方法依赖的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));
}
示例8: testDoProcessingIfInitiator
import org.apache.axis2.engine.Handler; //导入方法依赖的package包/类
@Test
public void testDoProcessingIfInitiator() 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);
PMode pmode = new PMode();
Leg leg = new Leg();
pmode.addLeg(leg);
UserMessage userMessage = UserMessageElement.readElement(umElement);
String pmodeId =
userMessage.getCollaborationInfo().getAgreement().getPModeId();
// todo the pmodeId should be set to userMessage in the UserMessageElement.readElement() method
userMessage.setPModeId(pmodeId);
// System.out.println("userMessage pmode id: " + userMessage.getPModeId());
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 = "Added SOAP envelope to message context";
assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
示例9: testDoProcessing
import org.apache.axis2.engine.Handler; //导入方法依赖的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());
}
示例10: testDoProcessing
import org.apache.axis2.engine.Handler; //导入方法依赖的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));
}
示例11: testDoProcessingOfTheResponseReceipt
import org.apache.axis2.engine.Handler; //导入方法依赖的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));
}
示例12: testDoProcessingOfTheErrors
import org.apache.axis2.engine.Handler; //导入方法依赖的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));
}
示例13: testDoProcessingOfUserMessage
import org.apache.axis2.engine.Handler; //导入方法依赖的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));
}
示例14: testProcessingOfTheUserMessage
import org.apache.axis2.engine.Handler; //导入方法依赖的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());
}
}
示例15: testDoProcessingOfReciepts
import org.apache.axis2.engine.Handler; //导入方法依赖的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));
}