本文整理汇总了Java中org.apache.axis.MessageContext.setRequestMessage方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.setRequestMessage方法的具体用法?Java MessageContext.setRequestMessage怎么用?Java MessageContext.setRequestMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis.MessageContext
的用法示例。
在下文中一共展示了MessageContext.setRequestMessage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInvokeReturnsValidXml
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/**
* Tests that a valid XML response results in a successful invocation of the handler that produces
* a valid SOAP envelope.
*/
@Test
public void testInvokeReturnsValidXml() throws IOException {
// Unlike the failure tests below, create the MessageContext here with an actual AxisClient,
// not a mock AxisEngine. Otherwise, the call to getSOAPEnvelope below will fail.
MessageContext messageContext = new MessageContext(new AxisClient());
messageContext.setRequestMessage(requestMessage);
messageContext.setProperty(MessageContext.TRANS_URL, mockHttpServer.getServerUrl());
SoapResponseXmlProvider.getTestSoapResponse(API_VERSION);
mockHttpServer.setMockResponse(
new MockResponse(SoapResponseXmlProvider.getTestSoapResponse(API_VERSION)));
httpHandler.invoke(messageContext);
assertNotNull(
"SOAP envelope of response is null", messageContext.getResponseMessage().getSOAPEnvelope());
}
示例2: testInvokeReturnsInvalidXml
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/** Tests that a poorly formed XML response will result in an AxisFault. */
@Test
public void testInvokeReturnsInvalidXml() throws AxisFault {
MessageContext messageContext = new MessageContext(axisEngine);
messageContext.setRequestMessage(requestMessage);
messageContext.setProperty(MessageContext.TRANS_URL, mockHttpServer.getServerUrl());
messageContext.setProperty(HTTPConstants.MC_GZIP_REQUEST, true);
mockHttpServer.setMockResponse(
new MockResponse(
"<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
+ "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
+ "foo..."));
httpHandler.invoke(messageContext);
// Expect parsing to fail. Tear down will verify the stream was closed.
thrown.expect(AxisFault.class);
messageContext.getResponseMessage().getSOAPEnvelope();
}
示例3: testInvokeReturnsNonXmlResponse
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/**
* Tests that a failed, non-XML response results in an AxisFault containing the HTTP status and
* message.
*/
@Test
public void testInvokeReturnsNonXmlResponse() throws AxisFault {
MessageContext messageContext = new MessageContext(axisEngine);
messageContext.setRequestMessage(requestMessage);
messageContext.setProperty(MessageContext.TRANS_URL, mockHttpServer.getServerUrl());
messageContext.setProperty(HTTPConstants.MC_GZIP_REQUEST, true);
MockResponse mockResponse = new MockResponse("Something went wrong", 500);
mockResponse.setContentType("text/html");
mockHttpServer.setMockResponse(mockResponse);
// Expect an AxisFault based on the status code and content type.
thrown.expect(AxisFault.class);
httpHandler.invoke(messageContext);
}
示例4: testInvokeWithoutContentType
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/** Tests that a request with null content type will fail as expected. */
@Test
public void testInvokeWithoutContentType() throws AxisFault {
MessageContext messageContext = new MessageContext(axisEngine);
messageContext.setRequestMessage(requestMessage);
messageContext.setProperty(MessageContext.TRANS_URL, mockHttpServer.getServerUrl());
messageContext.setProperty(HTTPConstants.MC_GZIP_REQUEST, true);
MockResponse mockResponse = new MockResponse("Something went wrong", 500);
mockResponse.setContentType(null);
mockHttpServer.setMockResponse(mockResponse);
// Expect an AxisFault based on the status code and content type.
thrown.expect(AxisFault.class);
httpHandler.invoke(messageContext);
}
示例5: testInvokeWithoutRequestUrl
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/** Tests that a request with null request URL will fail as expected. */
@Test
public void testInvokeWithoutRequestUrl() throws AxisFault {
MessageContext messageContext = new MessageContext(axisEngine);
messageContext.setRequestMessage(requestMessage);
thrown.expect(AxisFault.class);
thrown.expectCause(Matchers.<Exception>instanceOf(IllegalArgumentException.class));
thrown.expectMessage("URL");
httpHandler.invoke(messageContext);
}
示例6: testInvokeSetsTimeout
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/** Tests that the timeout set on the message context is passed to the underlying request. */
@Test
public void testInvokeSetsTimeout() {
MessageContext messageContext = new MessageContext(axisEngine);
messageContext.setRequestMessage(requestMessage);
messageContext.setProperty(MessageContext.TRANS_URL, "https://www.example.com");
// Do not care about XML parsing for this test, so set the response's status code to 302
// to trigger an AxisFault.
MockLowLevelHttpResponse lowLevelHttpResponse = new MockLowLevelHttpResponse();
lowLevelHttpResponse.setContent("Intentional failure");
lowLevelHttpResponse.setStatusCode(302);
/*
* Set timeout on the message context, then create a custom mock transport that will capture
* invocations of LowLevelHttpRequest.setTimeout(int, int) and record the arguments passed.
*/
int timeout = 1234567;
messageContext.setTimeout(timeout);
final int[] actualTimeouts = new int[] {Integer.MIN_VALUE, Integer.MIN_VALUE};
MockLowLevelHttpRequest lowLevelHttpRequest =
new MockLowLevelHttpRequest() {
@Override
public void setTimeout(int connectTimeout, int readTimeout) throws IOException {
actualTimeouts[0] = connectTimeout;
actualTimeouts[1] = readTimeout;
super.setTimeout(connectTimeout, readTimeout);
}
};
lowLevelHttpRequest.setResponse(lowLevelHttpResponse);
MockHttpTransport mockTransport =
new MockHttpTransport.Builder().setLowLevelHttpRequest(lowLevelHttpRequest).build();
httpHandler = new HttpHandler(mockTransport, streamListener);
try {
httpHandler.invoke(messageContext);
fail("Expected an AxisFault");
} catch (AxisFault e) {
assertThat(e.getFaultString(), Matchers.containsString("302"));
}
assertArrayEquals(
"Timeouts not set to expected values", new int[] {timeout, timeout}, actualTimeouts);
}