@Test public void testCreatedMessage() throws Exception{ SOAPMessage soapMessage = null; MimeMessage mimeMsg = null; MimeHeaders mimeHeaders = new MimeHeaders(); InputStream contentStream = FIXTURE_LOADER.getResourceAsStream("mime_message_content.dat"); mimeHeaders.setHeader("Content-Type", "text/xml; charset=utf-8"); try { soapMessage = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL).createMessage(mimeHeaders,contentStream); } catch (IOException e) { e.printStackTrace(); Assert.fail("Failed on loading the content inputstream\n"+e.getMessage()); } catch (SOAPException e) { e.printStackTrace(); Assert.fail("Create SOAP Message Failed\n"+e.getMessage()); } if(soapMessage == null) Assert.fail("Create SOAP Message Failed\n Message Should not be Null."); System.out.println("SoapMessage Created."); try { mimeMsg = mailSender.createMessage(MAIL_FROM, MAIL_TO, "", "SOAPMailSenderTest.testCreatedMessageLineMaxLimit", soapMessage); } catch (ConnectionException e) { e.printStackTrace(); Assert.fail("Create MimeMessage Failed\n"+e.getMessage()); } if(mimeMsg == null) Assert.fail("Create MimeMessage Failed\n Message Should not be Null."); System.out.println("MimeMessage Created."); InputStream data = FIXTURE_LOADER.getResourceAsStream("mime_message_content.dat"); mimeHeaders.setHeader("Content-Type", "text/xml; charset=utf-8"); soapMessage = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL).createMessage(mimeHeaders,data); ByteArrayOutputStream sampleContentStream = new ByteArrayOutputStream(); OutputStream os = MimeUtility.encode(sampleContentStream, "base64"); soapMessage.writeTo(os); ByteArrayOutputStream actualContentStream = new ByteArrayOutputStream(); mimeMsg.writeTo(actualContentStream); BufferedReader sampleDataReader = new BufferedReader(new StringReader(sampleContentStream.toString())); BufferedReader actualDataReader = new BufferedReader(new StringReader(actualContentStream.toString())); for(int i =0; i < 8; i++){ actualDataReader.readLine(); } boolean endOfString = false; do{ String sample = sampleDataReader.readLine(); String actual = actualDataReader.readLine(); if(sample == null){ endOfString = true; continue; } Assert.assertTrue(sample+"\n"+actual, sample.equals(actual)); }while (!endOfString); }
public MimeMessage createMessage(String from, String to, String cc, String subject, SOAPMessage soapMessage) throws ConnectionException { return createMessage(from, to, cc, subject, soapMessage, createSession()); }
SOAPMailSender extends MailSender { public MimeMessage createMessage(String from, String to, String cc, String subject, SOAPMessage soapMessage) throws ConnectionException { return createMessage(from, to, cc, subject, soapMessage, createSession()); } }
SOAPMailSender extends MailSender { public MimeMessage createMessage(String from, String to, String cc, String subject, SOAPMessage soapMessage) throws ConnectionException { return createMessage(from, to, cc, subject, soapMessage, createSession()); } SOAPMailSender(String host);  SOAPMailSender(String protocol, String host);  SOAPMailSender(String host, String username, String password);  SOAPMailSender(String protocol, String host, String username,
            String password); }
SOAPMailSender extends MailSender { public MimeMessage createMessage(String from, String to, String cc, String subject, SOAPMessage soapMessage) throws ConnectionException { return createMessage(from, to, cc, subject, soapMessage, createSession()); } SOAPMailSender(String host);  SOAPMailSender(String protocol, String host);  SOAPMailSender(String host, String username, String password);  SOAPMailSender(String protocol, String host, String username,
            String password); MimeMessage createMessage(String from, String to, String cc,
            String subject, SOAPMessage soapMessage); MimeMessage createMessage(String from, String to, String cc,
            String subject, SOAPMessage soapMessage, Session session); void send(String from, String to, String cc, String subject,
            SOAPMessage soapMessage); }
SOAPMailSender extends MailSender { public MimeMessage createMessage(String from, String to, String cc, String subject, SOAPMessage soapMessage) throws ConnectionException { return createMessage(from, to, cc, subject, soapMessage, createSession()); } SOAPMailSender(String host);  SOAPMailSender(String protocol, String host);  SOAPMailSender(String host, String username, String password);  SOAPMailSender(String protocol, String host, String username,
            String password); MimeMessage createMessage(String from, String to, String cc,
            String subject, SOAPMessage soapMessage); MimeMessage createMessage(String from, String to, String cc,
            String subject, SOAPMessage soapMessage, Session session); void send(String from, String to, String cc, String subject,
            SOAPMessage soapMessage);  }