Examples of ByteArrayDataSource


Examples of javax.mail.util.ByteArrayDataSource

         
      URL url = new URL(attachmentURL);
      URLConnection connection = url.openConnection();
      connection.setRequestProperty( "User-Agent","OpenForum");
         
          ByteArrayDataSource ds = new ByteArrayDataSource(connection.getInputStream(), attachmentMimeType);
          filePart.setDataHandler(new DataHandler(ds));
          multipart.addBodyPart(filePart);
        }
       
        MimeBodyPart textPart = new MimeBodyPart();
View Full Code Here

Examples of javax.mail.util.ByteArrayDataSource

            out.write(footer);
        }
    }

    protected String getEncoding(final byte[] rawBytes, final String contentType) {
        final DataSource dataSource = new ByteArrayDataSource(rawBytes, contentType);
        return MimeUtility.getEncoding(dataSource);
    }
View Full Code Here

Examples of javax.mail.util.ByteArrayDataSource

                elements.add(new DOMSource(StaxUtils.read(new StringReader(MtomTestHelper.REQ_MESSAGE)).getDocumentElement()));
                CxfPayload<SoapHeader> body = new CxfPayload<SoapHeader>(new ArrayList<SoapHeader>(),
                    elements, null);
                exchange.getIn().setBody(body);
                exchange.getIn().addAttachment(MtomTestHelper.REQ_PHOTO_CID,
                    new DataHandler(new ByteArrayDataSource(MtomTestHelper.REQ_PHOTO_DATA, "application/octet-stream")));

                exchange.getIn().addAttachment(MtomTestHelper.REQ_IMAGE_CID,
                    new DataHandler(new ByteArrayDataSource(MtomTestHelper.requestJpeg, "image/jpeg")));

            }
           
        });
       
View Full Code Here

Examples of org.apache.axiom.attachments.ByteArrayDataSource

                    entry.addAttribute(TYPE, BYTE, attrNS);
                    entry.setText(o.toString());
                } else if (o instanceof byte[]) {
                    entry.addAttribute(TYPE, BYTEARRAY, attrNS);
                    OMText text = fac.createOMText(new DataHandler(
                            new ByteArrayDataSource((byte[]) o)), true);
                    entry.addChild(text);
                } else if (o instanceof Float) {
                    entry.addAttribute(TYPE, FLOAT, attrNS);
                    entry.setText(o.toString());
                } else if (o instanceof Double) {
View Full Code Here

Examples of org.apache.axiom.attachments.ByteArrayDataSource

    content.setSrc("foo");
    assertNotNull(content);
    assertEquals(content.getMimeType().toString(), "text/foo");
    assertEquals(content.getSrc().toString(), "foo");
    content = factory.newContent(new MimeType("text/foo"));
    content.setDataHandler(new DataHandler(new ByteArrayDataSource("foo".getBytes())));
    assertEquals(content.getValue(), "Zm9v");
    assertEquals(content.getContentType(), Content.Type.MEDIA);
    el = factory.newName();
    assertNotNull(el);
    el = factory.newName();
View Full Code Here

Examples of org.apache.axiom.attachments.ByteArrayDataSource

        OMAttribute cType1 = fac.createOMAttribute("contentType", mime,
                                                 "text/plain");
        text.addAttribute(cType1);
        byte[] byteArray = new byte[] { 13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
                98 };
        dataHandler = new DataHandler(new ByteArrayDataSource(byteArray));
        OMText textData = fac.createOMText(dataHandler, false);

        envelope.addChild(body);
        body.addChild(data);
        data.addChild(text);
View Full Code Here

Examples of org.apache.axiom.attachments.ByteArrayDataSource

    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMDataSource ds = new WrappedTextNodeOMDataSourceFromDataSource(new QName("wrapper"),
                new ByteArrayDataSource("test".getBytes("utf-8")), Charset.forName("utf-8"));
        OMSourcedElement element = factory.createOMElement(ds);
        OMCloneOptions options = new OMCloneOptions();
        options.setCopyOMDataSources(copyOMDataSources);
        OMElement clone = (OMElement)element.clone(options);
        if (copyOMDataSources) {
View Full Code Here

Examples of org.apache.axiom.attachments.ByteArrayDataSource

    private void performTestNewDataHandler(StandardTypesServiceClient serviceClient) throws IOException {
        DataHandler[] dha = new DataHandler[3];
        dha[0] = new DataHandler("Some data", "text/plain");
        dha[1] = new DataHandler(new URL("http://tuscany.apache.org/home.html"));
        dha[2] = new DataHandler(new ByteArrayDataSource("Some data2".getBytes()));

        for (int i = 0; i < dha.length; ++i) {
            DataHandler actual = serviceClient.getNewDataHandlerForward(dha[i]);
            // Note: The DataHandler returned may use a different type of DataSource.
            // Compare the data content instead of using equals().
View Full Code Here

Examples of org.apache.axiom.attachments.ByteArrayDataSource

    private void performTestNewDataHandlerArray(StandardTypesServiceClient serviceClient) throws IOException {
        DataHandler[] dha = new DataHandler[3];
        dha[0] = new DataHandler("Some data", "text/plain");
        dha[1] = new DataHandler(new URL("http://tuscany.apache.org/home.html"));
        dha[2] = new DataHandler(new ByteArrayDataSource("Some data2".getBytes()));

        DataHandler[] actual = serviceClient.getNewDataHandlerArrayForward(dha);
        Assert.assertEquals(dha.length, actual.length);
        for (int i = 0; i < dha.length; ++i) {
            // Note: The DataHandler returned may use a different type of DataSource.
View Full Code Here

Examples of org.apache.axiom.attachments.ByteArrayDataSource

    private void performTestNewDataHandler(StandardTypesServiceClient serviceClient) throws IOException {
        DataHandler[] dha = new DataHandler[3];
        dha[0] = new DataHandler("Some data", "text/plain");
        dha[1] = new DataHandler(new URL("http://tuscany.apache.org/home.html"));
        dha[2] = new DataHandler(new ByteArrayDataSource("Some data2".getBytes()));

        for (int i = 0; i < dha.length; ++i) {
            DataHandler actual = serviceClient.getNewDataHandlerForward(dha[i]);
            // Note: The DataHandler returned may use a different type of DataSource.
            // Compare the data content instead of using equals().
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.