Package com.alibaba.citrus.service.mail.session

Examples of com.alibaba.citrus.service.mail.session.MailTransport


     * ȡ��ָ�����Ƶ�mail transport��
     */
    public MailTransport getMailTransport(String id, Properties overrideProps) throws MailTransportNotFoundException {
        id = assertNotNull(trimToNull(id), "no mailTransport id");

        MailTransport transport = mailTransports.get(id);

        if (transport == null) {
            throw new MailTransportNotFoundException("Could not find mail transport: " + id);
        }

        // ���ظ���
        return new MailTransport(transport, overrideProps);
    }
View Full Code Here


        // set null
        mailService.setMailTransports(null);

        // reset transports
        Map<String, MailTransport> transports = createHashMap();
        transports.put("transport1", new MailTransport());
        transports.put("transport2", new MailTransport());
        mailService.setMailTransports(transports);

        assertNotNull(mailService.getMailTransport("transport1"));
        assertNotNull(mailService.getMailTransport("transport2"));

        transports = createHashMap();
        transports.put("transport3", new MailTransport());
        transports.put("transport4", new MailTransport());
        mailService.setMailTransports(transports);

        try {
            mailService.getMailTransport("transport1");
            fail();
View Full Code Here

    @Test
    public void getTransport() {
        MailServiceImpl mailService = new MailServiceImpl();

        Map<String, MailTransport> transports = createHashMap();
        transports.put("transport1", new MailTransport());
        mailService.setMailTransports(transports);

        // id is null
        try {
            mailService.getMailTransport((String) null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("no mailTransport id"));
        }

        // clone
        MailTransport transport = mailService.getMailTransport("transport1");

        assertNotNull(transport);
        assertNotSame(transport, mailService.getMailTransport("transport1"));
    }
View Full Code Here

    public void getDefaultTransport() {
        MailServiceImpl mailService = new MailServiceImpl();

        // 1 transport
        Map<String, MailTransport> transports = createHashMap();
        transports.put("transport1", new MailTransport());
        mailService.setMailTransports(transports);

        assertNotNull(mailService.getMailTransport()); // the only transport is the default transport

        // 2 transports
        transports.put("transport2", new MailTransport());
        mailService.setMailTransports(transports);

        try {
            mailService.getMailTransport();
            fail();
        } catch (MailTransportNotFoundException e) {
            assertThat(e, exception("Could not find mail transport: _DEFAULT_"));
        }

        // with default transport
        MailTransport transport3 = new MailTransport();
        transport3.setDefault(true);
        transports.put("transport3", transport3);
        mailService.setMailTransports(transports);

        assertNotNull(mailService.getMailTransport());
        assertNotNull(mailService.getMailTransport("transport3"));

        // 2 default transports
        MailTransport transport4 = new MailTransport();
        transport4.setDefault(true);
        transports.put("transport4", transport4);

        try {
            mailService.setMailTransports(transports);
            fail();
View Full Code Here

        // set null
        mailService.setMailTransports(null);

        // reset transports
        Map<String, MailTransport> transports = createHashMap();
        transports.put("transport1", new MailTransport());
        transports.put("transport2", new MailTransport());
        mailService.setMailTransports(transports);

        assertNotNull(mailService.getMailTransport("transport1"));
        assertNotNull(mailService.getMailTransport("transport2"));

        transports = createHashMap();
        transports.put("transport3", new MailTransport());
        transports.put("transport4", new MailTransport());
        mailService.setMailTransports(transports);

        try {
            mailService.getMailTransport("transport1");
            fail();
View Full Code Here

    @Test
    public void getTransport() {
        MailServiceImpl mailService = new MailServiceImpl();

        Map<String, MailTransport> transports = createHashMap();
        transports.put("transport1", new MailTransport());
        mailService.setMailTransports(transports);

        // id is null
        try {
            mailService.getMailTransport((String) null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("no mailTransport id"));
        }

        // clone
        MailTransport transport = mailService.getMailTransport("transport1");

        assertNotNull(transport);
        assertNotSame(transport, mailService.getMailTransport("transport1"));
    }
View Full Code Here

    public void getDefaultTransport() {
        MailServiceImpl mailService = new MailServiceImpl();

        // 1 transport
        Map<String, MailTransport> transports = createHashMap();
        transports.put("transport1", new MailTransport());
        mailService.setMailTransports(transports);

        assertNotNull(mailService.getMailTransport()); // the only transport is the default transport

        // 2 transports
        transports.put("transport2", new MailTransport());
        mailService.setMailTransports(transports);

        try {
            mailService.getMailTransport();
            fail();
        } catch (MailTransportNotFoundException e) {
            assertThat(e, exception("Could not find mail transport: _DEFAULT_"));
        }

        // with default transport
        MailTransport transport3 = new MailTransport();
        transport3.setDefault(true);
        transports.put("transport3", transport3);
        mailService.setMailTransports(transports);

        assertNotNull(mailService.getMailTransport());
        assertNotNull(mailService.getMailTransport("transport3"));

        // 2 default transports
        MailTransport transport4 = new MailTransport();
        transport4.setDefault(true);
        transports.put("transport4", transport4);

        try {
            mailService.setMailTransports(transports);
            fail();
View Full Code Here

    /** 取得指定名称的mail transport。 */
    public MailTransport getMailTransport(String id, Properties overrideProps) throws MailTransportNotFoundException {
        id = assertNotNull(trimToNull(id), "no mailTransport id");

        MailTransport transport = mailTransports.get(id);

        if (transport == null) {
            throw new MailTransportNotFoundException("Could not find mail transport: " + id);
        }

        // 返回复本
        return new MailTransport(transport, overrideProps);
    }
View Full Code Here

     * ȡ��ָ�����Ƶ�mail transport��
     */
    public MailTransport getMailTransport(String id, Properties overrideProps) throws MailTransportNotFoundException {
        id = assertNotNull(trimToNull(id), "no mailTransport id");

        MailTransport transport = mailTransports.get(id);

        if (transport == null) {
            throw new MailTransportNotFoundException("Could not find mail transport: " + id);
        }

        // ���ظ���
        return new MailTransport(transport, overrideProps);
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.mail.session.MailTransport

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.