Package org.springframework.ws.transport

Examples of org.springframework.ws.transport.MockTransportOutputStream


        SoapBody body = soapMessage.getSoapBody();
        String payload = "<payload xmlns='http://www.springframework.org' />";
        transformer.transform(new StringSource(payload), body.getPayloadResult());

        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
        MockTransportOutputStream tos = new MockTransportOutputStream(bos);
        String soapAction = "http://springframework.org/spring-ws/Action";
        soapMessage.setSoapAction(soapAction);
        soapMessage.writeTo(tos);
        String result = bos.toString("UTF-8");
        assertXMLEqual(
                "<Envelope xmlns='http://www.w3.org/2003/05/soap-envelope'><Body><payload xmlns='http://www.springframework.org' /></Body></Envelope>",
                result);
        String contentType = tos.getHeaders().get(TransportConstants.HEADER_CONTENT_TYPE);
        assertTrue("Invalid Content-Type set",
            contentType.contains(SoapVersion.SOAP_12.getContentType()));
        assertNull(TransportConstants.HEADER_SOAP_ACTION + " header must not be found",
                tos.getHeaders().get(TransportConstants.HEADER_SOAP_ACTION));
        assertTrue("Invalid Content-Type set", contentType.contains(soapAction));
        String resultAccept = tos.getHeaders().get("Accept");
        assertNotNull("Invalid accept header", resultAccept);
    }
View Full Code Here


    @Override
    public void testWriteToTransportResponseAttachment() throws Exception {
        InputStreamSource inputStreamSource = new ByteArrayResource("contents".getBytes("UTF-8"));
        soapMessage.addAttachment("contentId", inputStreamSource, "text/plain");
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        MockTransportOutputStream tos = new MockTransportOutputStream(bos);
        soapMessage.writeTo(tos);
        String contentType = tos.getHeaders().get("Content-Type");
        assertTrue("Content-Type for attachment message does not contains multipart/related",
            contentType.contains("multipart/related"));
        assertTrue("Content-Type for attachment message does not contains type=\"application/soap+xml\"",
            contentType.contains("type=\"application/soap+xml\""));
    }
View Full Code Here

        assertEquals("Invalid SOAP Action", "\"SoapAction\"", soapMessage.getSoapAction());
    }

    @Test
    public void testCharsetAttribute() throws Exception {
        MockTransportOutputStream outputStream = new MockTransportOutputStream(new ByteArrayOutputStream());
        soapMessage.writeTo(outputStream);
        Map<String, String> headers = outputStream.getHeaders();
        String contentType = headers.get(TransportConstants.HEADER_CONTENT_TYPE);
        if (contentType != null) {
            Pattern charsetPattern = Pattern.compile("charset\\s*=\\s*([^;]+)");
            Matcher matcher = charsetPattern.matcher(contentType);
            if (matcher.find() && matcher.groupCount() == 1) {
View Full Code Here

        SoapBody body = soapMessage.getSoapBody();
        String payload = "<payload xmlns='http://www.springframework.org' />";
        transformer.transform(new StringSource(payload), body.getPayloadResult());

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        MockTransportOutputStream tos = new MockTransportOutputStream(bos);
        String soapAction = "http://springframework.org/spring-ws/Action";
        soapMessage.setSoapAction(soapAction);
        soapMessage.writeTo(tos);
        String result = bos.toString("UTF-8");
        assertXMLEqual(
                "<Envelope xmlns='http://schemas.xmlsoap.org/soap/envelope/'><Body><payload xmlns='http://www.springframework.org' /></Body></Envelope>",
                result);
        String contentType = tos.getHeaders().get("Content-Type");
        assertTrue("Invalid Content-Type set", contentType.indexOf(SoapVersion.SOAP_11.getContentType()) != -1);
        String resultSoapAction = tos.getHeaders().get("SOAPAction");
        assertEquals("Invalid soap action", "\"" + soapAction + "\"", resultSoapAction);
        String resultAccept = tos.getHeaders().get("Accept");
        assertNotNull("Invalid accept header", resultAccept);
    }
View Full Code Here

    @Override
    public void testWriteToTransportResponseAttachment() throws Exception {
        InputStreamSource inputStreamSource = new ByteArrayResource("contents".getBytes("UTF-8"));
        soapMessage.addAttachment("contentId", inputStreamSource, "text/plain");
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        MockTransportOutputStream tos = new MockTransportOutputStream(bos);
        soapMessage.writeTo(tos);
        String contentType = tos.getHeaders().get("Content-Type");
        assertTrue("Content-Type for attachment message does not contains multipart/related",
                contentType.indexOf("multipart/related") != -1);
        assertTrue("Content-Type for attachment message does not contains type=\"text/xml\"",
                contentType.indexOf("type=\"text/xml\"") != -1);
    }
View Full Code Here

TOP

Related Classes of org.springframework.ws.transport.MockTransportOutputStream

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.