Package org.springframework.core.io

Examples of org.springframework.core.io.InputStreamSource


        assertNotNull("Invalid accept header", resultAccept);
    }

    @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");
View Full Code Here


        assertNotNull("Invalid accept header", resultAccept);
    }

    @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");
View Full Code Here

        expect(soapRequest.getSoapBody()).andReturn(soapBody).once();
        expect(soapBody.getPayloadResult()).andReturn(new StringResult()).once();
       
        expect(soapRequest.addAttachment(eq(attachment.getContentId()), (InputStreamSource)anyObject(), eq(attachment.getContentType()))).andAnswer(new IAnswer<Attachment>() {
            public Attachment answer() throws Throwable {
                InputStreamSource contentStream = (InputStreamSource)EasyMock.getCurrentArguments()[1];
                BufferedReader reader = new BufferedReader(new InputStreamReader(contentStream.getInputStream()));
               
                Assert.assertEquals(reader.readLine(), "This is a SOAP attachment");
                Assert.assertEquals(reader.readLine(), "with multi-line");
               
                reader.close();
View Full Code Here

    private Schema createSchemaFromFile(String fileName) {
        return createSchemaFromFile(fileName, fileName);
    }

    private Schema createSchemaFromFile(String name, final String fileName) {
        return SchemaImpl.create(name, null, true, fileName + " desc", new InputStreamSource() {
            public InputStream getInputStream() throws IOException {
                return new FileInputStream(new File(srcdir, fileName));
            }
        });
    }
View Full Code Here

    }

    @Test
    public void getOriginalInputStream_exception() {
        // 情况1. parse时调用
        schema = new SchemaBaseImpl(new InputStreamSource() {
            public InputStream getInputStream() throws IOException {
                throw new IOException("hi");
            }

            @Override
            public String toString() {
                return "mysource";
            }
        });

        schema.transform(transformer);

        try {
            schema.getInputStream();
            fail();
        } catch (ConfigurationPointException e) {
            assertThat(e, exception("Failed to read text of schema file: myschema, source=mysource"));
        }

        // 情况2. getInputStream时调用(无transformer)
        schema = new SchemaBaseImpl(new InputStreamSource() {
            public InputStream getInputStream() throws IOException {
                throw new IOException("hi");
            }

            @Override
View Full Code Here

    private Schema createSchemaFromFile(String fileName) {
        return createSchemaFromFile(fileName, fileName);
    }

    private Schema createSchemaFromFile(String name, final String fileName) {
        return new SchemaImpl(name, null, true, fileName + " desc", new InputStreamSource() {
            public InputStream getInputStream() throws IOException {
                return new FileInputStream(new File(srcdir, fileName));
            }
        });
    }
View Full Code Here

            String priority, boolean isHtml, String encoding) throws MailException, MessagingException {
        List<Pair<String, InputStreamSource>> att = null;
        if (attachments != null) {
            att = Lists.newArrayList();
            for (File file : attachments) {
                InputStreamSource source = new FileSystemResource(file);
                Pair<String, InputStreamSource> pair = Pair.create(file.getName(), source);
                att.add(pair);
            }
        }
        String[] toArr = null;
View Full Code Here

            if (matcher.find()) {
                version = matcher.group(1);
            }

            InputStreamSource source = getResource(classpathLocation, uri);

            if (source != null) {
                nameToSchemaMappings.put(schemaName, new SchemaImpl(schemaName, version, true, desc, source));
                uriToNameMappings.put(uri, schemaName);
            }
View Full Code Here

        return all.toArray(new String[all.size()]);
    }

    private void overrideSchemaForInclude(final Schema schema) {
        InputStreamSource sourceWithoutIncludes = new InputStreamSource() {
            public InputStream getInputStream() throws IOException {
                return new ByteArrayInputStream(SchemaUtil.getSchemaContentWithoutIncludes(schema));
            }
        };
View Full Code Here

        addSchema(new SchemaImpl(schema.getName(), schema.getVersion(), schema.getTargetNamespace(),
                                 schema.getPreferredNsPrefix(), schema.getSourceDescription(), sourceWithoutIncludes));
    }

    private Schema setSchemaWithIncludes(final Schema schema, final Map<String, Schema> allIncludes) {
        InputStreamSource sourceWithModifiedIncludes = new InputStreamSource() {
            public InputStream getInputStream() throws IOException {
                return new ByteArrayInputStream(SchemaUtil.getSchemaContentWithIndirectIncludes(schema, allIncludes));
            }
        };
View Full Code Here

TOP

Related Classes of org.springframework.core.io.InputStreamSource

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.