Package javax.mail.util

Examples of javax.mail.util.ByteArrayDataSource


//        sb.append( "<BODY>\n" );
//        sb.append( "<H1>" + subject + "</H1>" + "\n" );
        sb.append( body );
//        sb.append( "</BODY>\n" );
//        sb.append( "</HTML>\n" );
        msg.setDataHandler( new DataHandler( new ByteArrayDataSource( sb.toString(), "text/html" ) ) );
    }
View Full Code Here


        XopType xop = new XopType();
        xop.setName("xopName");
        InputStream is =
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/book.xsd");
        byte[] data = IOUtils.readBytesFromStream(is);
        xop.setAttachinfo(new DataHandler(new ByteArrayDataSource(data, "application/octet-stream")));
       
        xop.setAttachinfo2(bookXsd.getBytes());
    
        xop.setImage(ImageIO.read(getClass().getResource(
                "/org/apache/cxf/systest/jaxrs/resources/java.jpg")));
View Full Code Here

        XopType xop = new XopType();
        xop.setName("xopName");
        InputStream is =
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/book.xsd");
        byte[] data = IOUtils.readBytesFromStream(is);
        xop.setAttachinfo(new DataHandler(new ByteArrayDataSource(data, "application/octet-stream")));
       
        String bookXsd = IOUtils.readStringFromStream(getClass().getResourceAsStream(
            "/org/apache/cxf/systest/jaxrs/resources/book.xsd"));
        xop.setAttachinfo2(bookXsd.getBytes());
    
View Full Code Here

          Multipart multipart = new MimeMultipart();
          multipart.addBodyPart(messageBodyPart);
          // Part two is attachment
          messageBodyPart = new MimeBodyPart();
          DataSource source = new ByteArrayDataSource(pdf,
              "application/pdf");
          messageBodyPart.setDataHandler(new DataHandler(source));
          messageBodyPart.setFileName("novedades.pdf");
          messageBodyPart.setDisposition(Part.ATTACHMENT);
          multipart.addBodyPart(messageBodyPart);
View Full Code Here

          Multipart multipart = new MimeMultipart();
          multipart.addBodyPart(messageBodyPart);
          // Part two is attachment
          messageBodyPart = new MimeBodyPart();
          DataSource source = new ByteArrayDataSource(pdf,
              "application/pdf");
          messageBodyPart.setDataHandler(new DataHandler(source));
          messageBodyPart.setFileName("novedades_"+fechadeayer2+".pdf");
          messageBodyPart.setDisposition(Part.ATTACHMENT);
          multipart.addBodyPart(messageBodyPart);
View Full Code Here

        // Byte array
        String response = ws.stringFromBytes(request.getBytes());
        assertEquals(request, response);

        // Data Source
        DataSource source = new ByteArrayDataSource(request.getBytes(), "text/plain; charset=UTF-8");

        // not yet supported !
//        response = ws.stringFromDataSource(source);
//        assertEquals(request, response);
View Full Code Here

  protected Object read(String in)
    throws IOException, JAXBException
  {
    byte[] buffer = Base64.decodeToByteArray(in);

    ByteArrayDataSource bads =
      new ByteArrayDataSource(buffer, DEFAULT_DATA_HANDLER_MIME_TYPE);

    return new DataHandler(bads);
  }
View Full Code Here

        log.finer("No Content-Type specified for DataHandler attachment, " +
                  "assuming " + DEFAULT_DATA_HANDLER_MIME_TYPE);
      }
    }

    ByteArrayDataSource source =
      new ByteArrayDataSource(attachment.getRawContents(), mimeType);

    return new DataHandler(source);
  }
View Full Code Here

    @Test
    public void testBadSOAPEnvelopeNamespace() throws Exception {
        soapMessage = TestUtil.createEmptySoapMessage(Soap12.getInstance(), chain);
        InputStream in = getClass().getResourceAsStream("test-bad-env.xml");
        assertNotNull(in);
        ByteArrayDataSource bads = new ByteArrayDataSource(in, "test/xml");
        soapMessage.setContent(InputStream.class, bads.getInputStream());

        ReadHeadersInterceptor r = new ReadHeadersInterceptor(BusFactory.getDefaultBus());
        try {
            r.handleMessage(soapMessage);
            fail("Did not throw exception");
View Full Code Here

    }

    private void prepareSoapMessage(String message) throws IOException {

        soapMessage = TestUtil.createEmptySoapMessage(Soap12.getInstance(), chain);
        ByteArrayDataSource bads = new ByteArrayDataSource(this.getClass().getResourceAsStream(message),
                                                           "Application/xop+xml");
        String cid = AttachmentUtil.createContentID("http://cxf.apache.org");
        soapMessage.setContent(Attachment.class, new AttachmentImpl(cid, new DataHandler(bads)));
        soapMessage.setContent(InputStream.class, bads.getInputStream());

    }
View Full Code Here

TOP

Related Classes of javax.mail.util.ByteArrayDataSource

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.