Package org.springframework.oxm

Examples of org.springframework.oxm.Marshaller


    protected boolean onUnmarshalRequest(MessageContext messageContext, Object requestObject) throws Exception {
        return true;
    }

    private void marshalResponse(Object responseObject, WebServiceMessage response) throws IOException {
        Marshaller marshaller = getMarshaller();
        Assert.notNull(marshaller, "No marshaller registered. Check configuration of endpoint.");
        if (logger.isDebugEnabled()) {
            logger.debug("Marshalling [" + responseObject + "] to response payload");
        }
        MarshallingUtils.marshal(marshaller, responseObject, response);
View Full Code Here


                                        final WebServiceMessageCallback requestCallback) {
        return sendAndReceive(uri, new WebServiceMessageCallback() {

            public void doWithMessage(WebServiceMessage request) throws IOException, TransformerException {
                if (requestPayload != null) {
                    Marshaller marshaller = getMarshaller();
                    if (marshaller == null) {
                        throw new IllegalStateException(
                                "No marshaller registered. Check configuration of WebServiceTemplate.");
                    }
                    MarshallingUtils.marshal(marshaller, requestPayload, request);
View Full Code Here

        verify(unmarshallerMock, messageMock);
    }

    @Test
    public void testMarshal() throws Exception {
        Marshaller marshallerMock = createMock(Marshaller.class);
        WebServiceMessage messageMock = createMock(WebServiceMessage.class);

        Result result = new StringResult();
        Object marshalled = new Object();
        expect(messageMock.getPayloadResult()).andReturn(result);
        marshallerMock.marshal(marshalled, result);

        replay(marshallerMock, messageMock);

        MarshallingUtils.marshal(marshallerMock, marshalled, messageMock);
View Full Code Here

    assertTrue(converter.canRead(String.class, MediaType.TEXT_XML));
  }

  @Test
  public void canWrite() throws Exception {
    Marshaller marshaller = mock(Marshaller.class);

    given(marshaller.supports(Integer.class)).willReturn(false);
    given(marshaller.supports(String.class)).willReturn(true);

    MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter();
    converter.setMarshaller(marshaller);

    assertFalse(converter.canWrite(Boolean.class, MediaType.TEXT_PLAIN));
View Full Code Here

  @Test(expected = TypeMismatchException.class)
  public void readWithTypeMismatchException() throws Exception {
    MockHttpInputMessage inputMessage = new MockHttpInputMessage(new byte[0]);

    Marshaller marshaller = mock(Marshaller.class);
    Unmarshaller unmarshaller = mock(Unmarshaller.class);
    given(unmarshaller.unmarshal(isA(StreamSource.class))).willReturn(Integer.valueOf(3));

    MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter(marshaller, unmarshaller);
    converter.read(String.class, inputMessage);
View Full Code Here

  @Test
  public void write() throws Exception {
    String body = "<root>Hello World</root>";
    MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();

    Marshaller marshaller = mock(Marshaller.class);
    willDoNothing().given(marshaller).marshal(eq(body), isA(Result.class));

    MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter(marshaller);
    converter.write(body, null, outputMessage);
View Full Code Here

  public void writeWithMarshallingFailureException() throws Exception {
    String body = "<root>Hello World</root>";
    MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
    MarshallingFailureException ex = new MarshallingFailureException("forced");

    Marshaller marshaller = mock(Marshaller.class);
    willThrow(ex).given(marshaller).marshal(eq(body), isA(Result.class));

    try {
      MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter(marshaller);
      converter.write(body, null, outputMessage);
View Full Code Here

       
        //Make sure the data was exported
        assertNotNull("Exported data was null", dataExport);
       
        //Marshall to XML
        final Marshaller marshaller = dataExporter.getMarshaller();
       
        final StringWriter result = new StringWriter();
        marshaller.marshal(dataExport, new StreamResult(result));
       
        //Compare the exported XML data with the imported XML data, they should match
        final String resultString = result.toString();
        try {
          XMLUnit.setIgnoreWhitespace(true);
View Full Code Here

        final Object data = portalDataExporter.exportData(dataId);
        if (data == null) {
            return null;
        }
       
        final Marshaller marshaller = portalDataExporter.getMarshaller();
        try {
            marshaller.marshal(data, result);
            return portalDataExporter.getFileName(data);
        }
        catch (XmlMappingException e) {
            throw new RuntimeException("Failed to map provided portal data to XML", e);
        }
View Full Code Here

   */
  private StaxEventItemWriter<Object> createItemWriter() throws Exception {
    StaxEventItemWriter<Object> source = new StaxEventItemWriter<Object>();
    source.setResource(resource);

    Marshaller marshaller = new SimpleMarshaller();
    source.setMarshaller(marshaller);

    source.setEncoding("UTF-8");
    source.setRootTagName("root");
    source.setVersion("1.0");
View Full Code Here

TOP

Related Classes of org.springframework.oxm.Marshaller

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.