本文整理汇总了Java中org.springframework.xml.transform.StringSource类的典型用法代码示例。如果您正苦于以下问题:Java StringSource类的具体用法?Java StringSource怎么用?Java StringSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringSource类属于org.springframework.xml.transform包,在下文中一共展示了StringSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testGetOrderHistory
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void testGetOrderHistory() throws IOException {
Source requestPayload = new StringSource(
"<ns1:getOrderHistoryRequest xmlns:ns1=\"http://codenotfound.com/types/orderhistory\">"
+ "<ns1:userId>abc123</ns1:userId>" + "</ns1:getOrderHistoryRequest>");
Source responsePayload = new StringSource(
"<ns1:getOrderHistoryResponse xmlns:ns1=\"http://codenotfound.com/types/orderhistory\">"
+ "<ns1:orderHistory>" + "<ns1:orderList>"
+ "<ns1:order><ns1:orderId>order1</ns1:orderId></ns1:order>"
+ "<ns1:order><ns1:orderId>order2</ns1:orderId></ns1:order>"
+ "<ns1:order><ns1:orderId>order3</ns1:orderId></ns1:order>" + "</ns1:orderList>"
+ "</ns1:orderHistory>" + "</ns1:getOrderHistoryResponse>");
mockWebServiceServer.expect(payload(requestPayload)).andRespond(withPayload(responsePayload));
OrderHistory orderHistory = orderHistoryClient.getOrderHistory("abc123");
assertThat(orderHistory.getOrders().get(2).getOrderId()).isEqualTo("order3");
mockWebServiceServer.verify();
}
开发者ID:code-not-found,项目名称:spring-ws,代码行数:22,代码来源:OrderHistoryClientTest.java
示例2: testGetOrderHistoryOnlyNeededElements
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void testGetOrderHistoryOnlyNeededElements() throws IOException {
Source requestPayload = new StringSource(
"<ns1:getOrderHistoryRequest xmlns:ns1=\"http://codenotfound.com/types/orderhistory\">"
+ "<ns1:userId>def456</ns1:userId>" + "</ns1:getOrderHistoryRequest>");
Source responsePayload = new StringSource(
"<ns1:getOrderHistoryResponse xmlns:ns1=\"http://codenotfound.com/types/orderhistory\">"
+ "<ns1:orderHistory>" + "<ns1:orderList>"
+ "<ns1:order><ns1:orderId>order4</ns1:orderId><ns1:orderName>order-name-1</ns1:orderName></ns1:order>"
+ "<ns1:order><ns1:orderId>order5</ns1:orderId><ns1:orderName>order-name-2</ns1:orderName></ns1:order>"
+ "<ns1:order><ns1:orderId>order6</ns1:orderId><ns1:orderName>order-name-3</ns1:orderName></ns1:order>"
+ "</ns1:orderList>" + "</ns1:orderHistory>" + "</ns1:getOrderHistoryResponse>");
mockWebServiceServer.expect(payload(requestPayload)).andRespond(withPayload(responsePayload));
OrderHistory orderHistory = orderHistoryClient.getOrderHistory("def456");
assertThat(orderHistory.getOrders().get(2).getOrderId()).isEqualTo("order6");
mockWebServiceServer.verify();
}
开发者ID:code-not-found,项目名称:spring-ws,代码行数:22,代码来源:OrderHistoryClientTest.java
示例3: testGetOrderHistoryMinimumAssumptions
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void testGetOrderHistoryMinimumAssumptions() throws IOException {
Source requestPayload = new StringSource(
"<ns1:getOrderHistoryRequest xmlns:ns1=\"http://codenotfound.com/types/orderhistory\">"
+ "<ns1:userId>ghi789</ns1:userId>" + "</ns1:getOrderHistoryRequest>");
Source responsePayload = new StringSource(
"<ns1:getOrderHistoryResponse xmlns:ns1=\"http://codenotfound.com/types/orderhistory\">"
+ "<ns1:newWrapper>" + "<ns1:orderHistory>" + "<ns1:orderList>"
+ "<ns1:order><ns1:orderId>order7</ns1:orderId></ns1:order>"
+ "<ns1:order><ns1:orderId>order8</ns1:orderId></ns1:order>"
+ "<ns1:order><ns1:orderId>order9</ns1:orderId></ns1:order>" + "</ns1:orderList>"
+ "</ns1:orderHistory>" + "</ns1:newWrapper>" + "</ns1:getOrderHistoryResponse>");
mockWebServiceServer.expect(payload(requestPayload)).andRespond(withPayload(responsePayload));
OrderHistory orderHistory = orderHistoryClient.getOrderHistory("ghi789");
assertThat(orderHistory.getOrders().get(2).getOrderId()).isEqualTo("order9");
mockWebServiceServer.verify();
}
开发者ID:code-not-found,项目名称:spring-ws,代码行数:22,代码来源:OrderHistoryClientTest.java
示例4: testGetOrderHistory
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void testGetOrderHistory() {
Source requestPayload = new StringSource(
"<ns1:getOrderHistoryRequest xmlns:ns1=\"http://codenotfound.com/types/orderhistory\">"
+ "<ns1:userId>jkl123</ns1:userId>" + "</ns1:getOrderHistoryRequest>");
Source responsePayload = new StringSource(
"<ns2:getOrderHistoryResponse xmlns:ns2=\"http://codenotfound.com/types/orderhistory\">"
+ "<ns2:orderHistory>" + "<ns2:orderList>"
+ "<ns2:order><ns2:orderId>order0</ns2:orderId></ns2:order>"
+ "<ns2:order><ns2:orderId>order1</ns2:orderId></ns2:order>"
+ "<ns2:order><ns2:orderId>order2</ns2:orderId></ns2:order>" + "</ns2:orderList>"
+ "</ns2:orderHistory>" + "</ns2:getOrderHistoryResponse>");
mockClient.sendRequest(withPayload(requestPayload)).andExpect(payload(responsePayload));
}
开发者ID:code-not-found,项目名称:spring-ws,代码行数:17,代码来源:TicketAgentEndpointTest.java
示例5: testGetOrderHistoryOnlyNeededElements
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void testGetOrderHistoryOnlyNeededElements() {
Source requestPayload = new StringSource(
"<ns1:getOrderHistoryRequest xmlns:ns1=\"http://codenotfound.com/types/orderhistory\">"
+ "<ns1:userId>mno123</ns1:userId>" + "<ns1:userName>user-name</ns1:userName>"
+ "</ns1:getOrderHistoryRequest>");
Source responsePayload = new StringSource(
"<ns2:getOrderHistoryResponse xmlns:ns2=\"http://codenotfound.com/types/orderhistory\">"
+ "<ns2:orderHistory>" + "<ns2:orderList>"
+ "<ns2:order><ns2:orderId>order0</ns2:orderId></ns2:order>"
+ "<ns2:order><ns2:orderId>order1</ns2:orderId></ns2:order>"
+ "<ns2:order><ns2:orderId>order2</ns2:orderId></ns2:order>" + "</ns2:orderList>"
+ "</ns2:orderHistory>" + "</ns2:getOrderHistoryResponse>");
mockClient.sendRequest(withPayload(requestPayload)).andExpect(payload(responsePayload));
}
开发者ID:code-not-found,项目名称:spring-ws,代码行数:18,代码来源:TicketAgentEndpointTest.java
示例6: testGetOrderHistoryMinimumAssumptions
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void testGetOrderHistoryMinimumAssumptions() {
Source requestPayload = new StringSource(
"<ns1:getOrderHistoryRequest xmlns:ns1=\"http://codenotfound.com/types/orderhistory\">"
+ "<ns1:oldWrapper>" + "<ns1:userId>pqr123</ns1:userId>" + "</ns1:oldWrapper>"
+ "</ns1:getOrderHistoryRequest>");
Source responsePayload = new StringSource(
"<ns2:getOrderHistoryResponse xmlns:ns2=\"http://codenotfound.com/types/orderhistory\">"
+ "<ns2:orderHistory>" + "<ns2:orderList>"
+ "<ns2:order><ns2:orderId>order0</ns2:orderId></ns2:order>"
+ "<ns2:order><ns2:orderId>order1</ns2:orderId></ns2:order>"
+ "<ns2:order><ns2:orderId>order2</ns2:orderId></ns2:order>" + "</ns2:orderList>"
+ "</ns2:orderHistory>" + "</ns2:getOrderHistoryResponse>");
mockClient.sendRequest(withPayload(requestPayload)).andExpect(payload(responsePayload));
}
开发者ID:code-not-found,项目名称:spring-ws,代码行数:18,代码来源:TicketAgentEndpointTest.java
示例7: testCreateOrder
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void testCreateOrder() throws XPathExpressionException {
Source requestPayload = new StringSource(
"<ns2:order xmlns:ns2=\"http://codenotfound.com/types/order\">"
+ "<ns2:customer><ns2:firstName>John</ns2:firstName>"
+ "<ns2:lastName>Doe</ns2:lastName>"
+ "</ns2:customer><ns2:lineItems><ns2:lineItem>"
+ "<ns2:product>" + "<ns2:id>2</ns2:id>"
+ "<ns2:name>batman action figure</ns2:name>"
+ "</ns2:product>"
+ "<ns2:quantity>1</ns2:quantity>"
+ "</ns2:lineItem>" + "</ns2:lineItems>"
+ "</ns2:order>");
Map<String, String> namespaces = Collections.singletonMap("ns1",
"http://codenotfound.com/types/order");
mockClient.sendRequest(withPayload(requestPayload))
.andExpect(ResponseMatchers
.xpath("/ns1:orderConfirmation/ns1:confirmationId",
namespaces)
.exists());
}
开发者ID:code-not-found,项目名称:spring-ws,代码行数:24,代码来源:CreateOrderEndpointMockTest.java
示例8: testListFlights
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void testListFlights() {
Source requestPayload =
new StringSource("<ns3:listFlightsRequest xmlns:ns3=\"http://example.org/TicketAgent.xsd\">"
+ "</ns3:listFlightsRequest>");
Source responsePayload =
new StringSource("<v1:listFlightsResponse xmlns:v1=\"http://example.org/TicketAgent.xsd\">"
+ "<flightNumber>101</flightNumber>" + "</v1:listFlightsResponse>");
// check if the SOAP Header is present using the soapHeader matcher
mockWebServiceServer
.expect(
soapHeader(new QName("http://example.org/TicketAgent.xsd", "listFlightsSoapHeaders")))
.andExpect(payload(requestPayload)).andRespond(withPayload(responsePayload));
List<BigInteger> flights = ticketAgentClient.listFlights();
assertThat(flights.get(0)).isEqualTo(BigInteger.valueOf(101));
mockWebServiceServer.verify();
}
开发者ID:code-not-found,项目名称:spring-ws,代码行数:22,代码来源:TicketAgentClientTest.java
示例9: testListFlights
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void testListFlights() {
Source requestEnvelope = new StringSource(
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<SOAP-ENV:Header>"
+ "<ns3:listFlightsSoapHeaders xmlns:ns3=\"http://example.org/TicketAgent.xsd\">"
+ "<isGoldClubMember>true</isGoldClubMember>" + "<clientId>abc123</clientId>"
+ "</ns3:listFlightsSoapHeaders>" + "</SOAP-ENV:Header>" + "<SOAP-ENV:Body>"
+ "<ns3:listFlightsRequest xmlns:ns3=\"http://example.org/TicketAgent.xsd\">"
+ "</ns3:listFlightsRequest>" + "</SOAP-ENV:Body>" + "</SOAP-ENV:Envelope>");
Source responsePayload =
new StringSource("<v1:listFlightsResponse xmlns:v1=\"http://example.org/TicketAgent.xsd\">"
+ "<flightNumber>101</flightNumber>" + "<flightNumber>202</flightNumber>"
+ "</v1:listFlightsResponse>");
mockClient.sendRequest(withSoapEnvelope(requestEnvelope)).andExpect(payload(responsePayload));
}
开发者ID:code-not-found,项目名称:spring-ws,代码行数:19,代码来源:TicketAgentEndpointTest.java
示例10: testListFlights
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void testListFlights() {
Source requestPayload =
new StringSource("<ns3:listFlightsRequest xmlns:ns3=\"http://example.org/TicketAgent.xsd\">"
+ "</ns3:listFlightsRequest>");
Source responsePayload =
new StringSource("<v1:listFlightsResponse xmlns:v1=\"http://example.org/TicketAgent.xsd\">"
+ "<flightNumber>101</flightNumber>" + "</v1:listFlightsResponse>");
// check if the SOAPAction is present using the custom matcher
mockWebServiceServer.expect(new SoapActionMatcher("http://example.com/TicketAgent/listFlights"))
.andExpect(payload(requestPayload)).andRespond(withPayload(responsePayload));
List<BigInteger> flights = ticketAgentClient.listFlights();
assertThat(flights.get(0)).isEqualTo(BigInteger.valueOf(101));
mockWebServiceServer.verify();
}
开发者ID:code-not-found,项目名称:spring-ws,代码行数:20,代码来源:TicketAgentClientTest.java
示例11: formatDate
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
private void formatDate(SaajSoapMessage saajMsg, Date date) throws TransformerException {
if (date == null) {
return;
}
SOAPPart soapPart = saajMsg.getSaajMessage().getSOAPPart();
Source source = new DOMSource(soapPart);
StringResult stringResult = new StringResult();
TransformerFactory.newInstance().newTransformer().transform(source, stringResult);
try {
String from = dateWithTimezone.format(date);
String to = dateWithoutTimezone.format(date);
String content = StringUtils.replace(stringResult.toString(), from, to);
soapPart.setContent(new StringSource(content));
} catch (Exception e) {
throw new TransformerException(e);
}
}
开发者ID:nortal,项目名称:j-road,代码行数:18,代码来源:KirXTeeServiceImpl.java
示例12: substitute
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
/**
* Substitutes all occurences of some given string inside the given {@link WebServiceMessage} with another value.
*
* @param message message to substitute in
* @param from the value to substitute
* @param to the value to substitute with
* @throws TransformerException
*/
public static void substitute(WebServiceMessage message, String from, String to) throws TransformerException {
SaajSoapMessage saajSoapMessage = (SaajSoapMessage) message;
SOAPPart soapPart = saajSoapMessage.getSaajMessage().getSOAPPart();
Source source = new DOMSource(soapPart);
StringResult stringResult = new StringResult();
TransformerFactory.newInstance().newTransformer().transform(source, stringResult);
String content = stringResult.toString().replaceAll(from, to);
try {
soapPart.setContent(new StringSource(content));
} catch (SOAPException e) {
throw new TransformerException(e);
}
}
开发者ID:nortal,项目名称:j-road,代码行数:26,代码来源:SOAPUtil.java
示例13: createSoapMessage
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
/**
* Creates a new SOAP message representation from given payload resource. Constructs a SOAP envelope
* with empty header and payload as body.
*
* @param message
* @return
* @throws IOException
*/
public Message createSoapMessage(Message message) {
try {
String payload = message.getPayload().toString();
LOG.info("Creating SOAP message from payload: " + payload);
WebServiceMessage soapMessage = soapMessageFactory.createWebServiceMessage();
transformerFactory.newTransformer().transform(
new StringSource(payload), soapMessage.getPayloadResult());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
soapMessage.writeTo(bos);
return new SoapMessage(new String(bos.toByteArray()), message.getHeaders());
} catch (Exception e) {
throw new CitrusRuntimeException("Failed to create SOAP message from payload resource", e);
}
}
开发者ID:christophd,项目名称:citrus-simulator,代码行数:27,代码来源:SoapMessageHelper.java
示例14: testSame
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void testSame()
{
Source source = new StringSource(MESSAGE);
MessageMatcher matcher = new MessageMatcher(source);
SoapMessage request = createMock(SoapMessage.class);
SoapEnvelope envelope = createMock(SoapEnvelope.class);
expect(request.getEnvelope()).andReturn(envelope );
expect(envelope.getSource()).andReturn(new StringSource(MESSAGE));
replay(request, envelope);
matcher.matchInternal(null, request);
verify(request, envelope);
}
开发者ID:lukas-krecan,项目名称:smock,代码行数:17,代码来源:MessageMatcherTest.java
示例15: testDifferent
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test(expected=AssertionError.class)
public void testDifferent()
{
Source source = new StringSource(MESSAGE);
MessageMatcher matcher = new MessageMatcher(source);
SoapMessage request = createMock(SoapMessage.class);
SoapEnvelope envelope = createMock(SoapEnvelope.class);
expect(request.getEnvelope()).andReturn(envelope );
expect(envelope.getSource()).andReturn(new StringSource(MESSAGE2));
replay(request, envelope);
matcher.matchInternal(null, request);
verify(request, envelope);
}
开发者ID:lukas-krecan,项目名称:smock,代码行数:17,代码来源:MessageMatcherTest.java
示例16: parseTpicHeaderFromResponseToBackend
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void parseTpicHeaderFromResponseToBackend() throws Exception {
final Map<String, String> context = new HashMap<>();
context.put("our key", "is our value");
final StringResult result = new StringResult();
new SoapHeaderTransport().renderSoapHeader(context, result);
final Source source = new StringSource(result.toString());
final SoapHeader soapHeader = mock(SoapHeader.class);
when(((SoapMessage) messageContext.getResponse()).getSoapHeader()).thenReturn(soapHeader);
final SoapHeaderElement element = mock(SoapHeaderElement.class);
when(element.getSource()).thenReturn(source);
when(soapHeader.examineHeaderElements(eq(SOAP_HEADER_QNAME))).thenReturn(Collections.singletonList(element).iterator());
unit.handleResponse(messageContext);
assertThat(backend.size(), is(1));
assertThat(backend.copyToMap(), hasEntry("our key", "is our value"));
}
开发者ID:tracee,项目名称:tracee,代码行数:19,代码来源:TraceeClientInterceptorTest.java
示例17: parseTpicHeaderFromFaultResponseToBackend
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void parseTpicHeaderFromFaultResponseToBackend() throws Exception {
final Map<String, String> context = new HashMap<>();
context.put("our key", "is our value");
final StringResult result = new StringResult();
new SoapHeaderTransport().renderSoapHeader(context, result);
final Source source = new StringSource(result.toString());
final SoapHeader soapHeader = mock(SoapHeader.class);
when(((SoapMessage) messageContext.getResponse()).getSoapHeader()).thenReturn(soapHeader);
final SoapHeaderElement element = mock(SoapHeaderElement.class);
when(element.getSource()).thenReturn(source);
when(soapHeader.examineHeaderElements(eq(SOAP_HEADER_QNAME))).thenReturn(Collections.singletonList(element).iterator());
unit.handleFault(messageContext);
assertThat(backend.size(), is(1));
assertThat(backend.copyToMap(), hasEntry("our key", "is our value"));
}
开发者ID:tracee,项目名称:tracee,代码行数:19,代码来源:TraceeClientInterceptorTest.java
示例18: parseTpicHeaderFromRequestToTraceeBackend
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void parseTpicHeaderFromRequestToTraceeBackend() throws Exception {
final Map<String, String> context = new HashMap<>();
context.put("our key", "is our value");
final StringResult result = new StringResult();
new SoapHeaderTransport().renderSoapHeader(context, result);
final Source source = new StringSource(result.toString());
final SoapHeader soapHeader = mock(SoapHeader.class);
when(((SoapMessage) messageContext.getRequest()).getSoapHeader()).thenReturn(soapHeader);
final SoapHeaderElement element = mock(SoapHeaderElement.class);
when(element.getSource()).thenReturn(source);
when(soapHeader.examineHeaderElements(eq(SOAP_HEADER_QNAME))).thenReturn(singletonList(element).iterator());
unit.handleRequest(messageContext, new Object());
assertThat(backend.size(), is(2));
assertThat(backend.copyToMap(), hasKey(INVOCATION_ID_KEY));
assertThat(backend.copyToMap(), hasEntry("our key", "is our value"));
}
开发者ID:tracee,项目名称:tracee,代码行数:20,代码来源:TraceeEndpointInterceptorTest.java
示例19: testCall
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void testCall() throws IOException, InterruptedException {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("com.sabre.api.sacs.contract.travelitinerary");
Result marshalledRequest = new StringResult();
marshaller.marshal(getRequestBody("ABCD"), marshalledRequest);
Source requestPayload = new StringSource(marshalledRequest.toString());
Source responsePayload = new StringSource(getResponseBody());
mockServer.expect(payload(requestPayload)).andRespond(withSoapEnvelope(responsePayload));
tir.setRequest(getRequestBody("ABCD"));
tir.setLastInFlow(true);
TravelItineraryReadRS response = tir.executeRequest(context);
Assert.assertEquals(configuration.getSoapProperty("TravelItineraryReadRQVersion"), response.getVersion());
mockServer.verify();
}
开发者ID:SabreDevStudio,项目名称:SACS-Java,代码行数:16,代码来源:TravelItineraryReadTest.java
示例20: testCall
import org.springframework.xml.transform.StringSource; //导入依赖的package包/类
@Test
public void testCall() throws IOException, InterruptedException {
Source responsePayload = new StringSource(getResponseBody());
mockServer.expect(anything()).andRespond(withSoapEnvelope(responsePayload));
pd.setRequest(getRequestBody());
pd.setLastInFlow(true);
PassengerDetailsRS response = pd.executeRequest(context);
Assert.assertEquals("LTUSTX", response.getItineraryRef().getID());
mockServer.verify();
}
开发者ID:SabreDevStudio,项目名称:SACS-Java,代码行数:11,代码来源:PassengerDetailsTest.java
注:本文中的org.springframework.xml.transform.StringSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论