Package org.springframework.oxm

Examples of org.springframework.oxm.Unmarshaller


        verify(unmarshallerMock, messageMock);
    }

    @Test
    public void testUnmarshalNoPayload() throws Exception {
        Unmarshaller unmarshallerMock = createMock(Unmarshaller.class);
        MimeMessage messageMock = createMock(MimeMessage.class);

        expect(messageMock.getPayloadSource()).andReturn(null);

        replay(unmarshallerMock, messageMock);
View Full Code Here


*/
public class MarshallingHttpMessageConverterTests {

  @Test
  public void canRead() throws Exception {
    Unmarshaller unmarshaller = mock(Unmarshaller.class);

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

    MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter();
    converter.setUnmarshaller(unmarshaller);

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

  @Test
  public void read() throws Exception {
    String body = "<root>Hello World</root>";
    MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes("UTF-8"));

    Unmarshaller unmarshaller = mock(Unmarshaller.class);
    given(unmarshaller.unmarshal(isA(StreamSource.class))).willReturn(body);

    MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter();
    converter.setUnmarshaller(unmarshaller);

    String result = (String) converter.read(Object.class, inputMessage);
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 readWithMarshallingFailureException() throws Exception {
    MockHttpInputMessage inputMessage = new MockHttpInputMessage(new byte[0]);
    UnmarshallingFailureException ex = new UnmarshallingFailureException("forced");

    Unmarshaller unmarshaller = mock(Unmarshaller.class);
    given(unmarshaller.unmarshal(isA(StreamSource.class))).willThrow(ex);

    MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter();
    converter.setUnmarshaller(unmarshaller);

    try {
View Full Code Here

        assertNull(externalUser.getLastPasswordChange());
    }
   
    @Test
    public void testImportJarArchive() throws Exception {
        final Unmarshaller unmarshaller = mock(Unmarshaller.class);
       
        final List<IDataImporter<? extends Object>> importers = setupAllImporters(new MockDataImporterSetup() {
            @Override
            public void setup(IPortalDataType dataType, IDataImporter<? extends Object> dataImporter) {
                when(dataImporter.getUnmarshaller()).thenReturn(unmarshaller);
View Full Code Here

        verify(unmarshaller, times(16)).unmarshal(any(Source.class));
    }
   
    @Test
    public void testImportZipArchive() throws Exception {
        final Unmarshaller unmarshaller = mock(Unmarshaller.class);
       
        final List<IDataImporter<? extends Object>> importers = setupAllImporters(new MockDataImporterSetup() {
            @Override
            public void setup(IPortalDataType dataType, IDataImporter<? extends Object> dataImporter) {
                when(dataImporter.getUnmarshaller()).thenReturn(unmarshaller);
View Full Code Here

        verify(unmarshaller, times(16)).unmarshal(any(Source.class));
    }
   
    @Test
    public void testImportTarGzipArchive() throws Exception {
        final Unmarshaller unmarshaller = mock(Unmarshaller.class);
       
        final List<IDataImporter<? extends Object>> importers = setupAllImporters(new MockDataImporterSetup() {
            @Override
            public void setup(IPortalDataType dataType, IDataImporter<? extends Object> dataImporter) {
                when(dataImporter.getUnmarshaller()).thenReturn(unmarshaller);
View Full Code Here

        verify(unmarshaller, times(16)).unmarshal(any(Source.class));
    }
   
    @Test
    public void testImportTGZArchive() throws Exception {
        final Unmarshaller unmarshaller = mock(Unmarshaller.class);
       
        final List<IDataImporter<? extends Object>> importers = setupAllImporters(new MockDataImporterSetup() {
            @Override
            public void setup(IPortalDataType dataType, IDataImporter<? extends Object> dataImporter) {
                when(dataImporter.getUnmarshaller()).thenReturn(unmarshaller);
View Full Code Here

       
      final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory();
      final XMLEventReader xmlEventReader = xmlInputFactory.createXMLEventReader(new StringReader(importData));
       
        //Unmarshall from XML
        final Unmarshaller unmarshaller = dataImporter.getUnmarshaller();
        final StAXSource source = new StAXSource(xmlEventReader);
    @SuppressWarnings("unchecked")
        final T dataImport = (T)unmarshaller.unmarshal(source);
       
        //Make sure the data was unmarshalled
        assertNotNull("Unmarshalled import data was null", dataImport);
       
        //Import the data
View Full Code Here

TOP

Related Classes of org.springframework.oxm.Unmarshaller

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.