1 17 package org.apache.geronimo.mail; 18 19 import java.util.Collections ; 20 import java.util.Properties ; 21 22 import javax.mail.Session ; 23 import javax.mail.Store ; 24 import javax.mail.Transport ; 25 26 import junit.framework.TestCase; 27 28 29 32 public class MailGBeanTest extends TestCase { 33 public void testNotheing() {} 34 35 public void XtestProperties() throws Exception { 36 Properties properties = new Properties (); 37 properties.put("mail.store.protocol", "testStore"); 38 properties.put("mail.transport.protocol", "testTransport"); 39 40 MailGBean mail = new MailGBean("test:name=mail", null, Boolean.TRUE, properties, null, null, null, null, null, null); 41 mail.doStart(); 42 Object proxy = mail.$getResource(); 43 44 assertNotNull(proxy); 45 assertTrue(proxy instanceof Session ); 46 47 Store store = ((Session ) proxy).getStore(); 48 assertNotNull(store); 49 assertTrue(store instanceof TestStore); 50 51 Transport transport = ((Session ) proxy).getTransport(); 52 assertNotNull(transport); 53 assertTrue(transport instanceof TestTransport); 54 55 } 56 57 public void XtestDefaultOverrides() throws Exception { 58 Properties properties = new Properties (); 59 properties.put("mail.store.protocol", "POOKIE"); 60 properties.put("mail.transport.protocol", "BEAR"); 61 62 MailGBean mail = new MailGBean("test:name=mail", null, Boolean.TRUE, properties, null, "test", "test", null, null, null); 63 mail.doStart(); 64 Object proxy = mail.$getResource(); 65 66 assertNotNull(proxy); 67 assertTrue(proxy instanceof Session ); 68 69 Store store = ((Session ) proxy).getStore(); 70 assertNotNull(store); 71 assertTrue(store instanceof TestStore); 72 73 Transport transport = ((Session ) proxy).getTransport(); 74 assertNotNull(transport); 75 assertTrue(transport instanceof TestTransport); 76 77 } 78 79 public void XtestSMTPOverrides() throws Exception { 80 Properties properties = new Properties (); 82 properties.put("mail.store.protocol", "POOKIE"); 83 properties.put("mail.transport.protocol", "BEAR"); 84 properties.put("mail.smtp.ehlo", "false"); 85 86 Properties bundle = new Properties (); 88 bundle.put("mail.smtp.ehlo", "true"); 89 bundle.put("mail.smtp.quitwait", "true"); 90 91 SMTPTransportGBean protocol = new SMTPTransportGBean("test:name=smtp", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); 92 protocol.doStart(); 93 94 MailGBean mail = new MailGBean("test:name=mail", Collections.singleton(protocol), Boolean.TRUE, properties, null, "test", "test", null, null, null); 95 mail.doStart(); 96 Object proxy = mail.$getResource(); 97 98 assertNotNull(proxy); 99 assertTrue(proxy instanceof Session ); 100 101 Store store = ((Session ) proxy).getStore(); 102 assertNotNull(store); 103 assertTrue(store instanceof TestStore); 104 105 Transport transport = ((Session ) proxy).getTransport(); 106 assertNotNull(transport); 107 assertTrue(transport instanceof TestTransport); 108 109 TestTransport testTransport = (TestTransport) transport; 110 assertFalse(testTransport.isEHLO()); 111 112 } 113 114 public void XtestPOP3Overrides() throws Exception { 115 Properties properties = new Properties (); 116 properties.put("mail.store.protocol", "POOKIE"); 117 properties.put("mail.transport.protocol", "BEAR"); 118 properties.put("mail.pop3.ehlo", "true"); 119 120 POP3StoreGBean protocol = new POP3StoreGBean("test:name=pop3", null, null, null, null, null, null, null, null, null, null, null, null, null, null); 121 protocol.doStart(); 122 123 MailGBean mail = new MailGBean("test:name=mail", Collections.singleton(protocol), Boolean.TRUE, properties, null, "test", "test", null, null, null); 124 mail.doStart(); 125 Object proxy = mail.$getResource(); 126 127 assertNotNull(proxy); 128 assertTrue(proxy instanceof Session ); 129 130 Store store = ((Session ) proxy).getStore(); 131 assertNotNull(store); 132 assertTrue(store instanceof TestStore); 133 134 Transport transport = ((Session ) proxy).getTransport(); 135 assertNotNull(transport); 136 assertTrue(transport instanceof TestTransport); 137 138 } 139 140 public void XtestIMAPOverrides() throws Exception { 141 Properties properties = new Properties (); 142 properties.put("mail.store.protocol", "POOKIE"); 143 properties.put("mail.transport.protocol", "BEAR"); 144 properties.put("mail.imap.ehlo", "true"); 145 146 IMAPStoreGBean protocol = new IMAPStoreGBean("test:name=imap", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); 147 protocol.doStart(); 148 149 MailGBean mail = new MailGBean("test:name=mail", Collections.singleton(protocol), Boolean.TRUE, properties, null, "test", "test", null, null, null); 150 mail.doStart(); 151 Object proxy = mail.$getResource(); 152 153 154 assertNotNull(proxy); 155 assertTrue(proxy instanceof Session ); 156 157 Store store = ((Session ) proxy).getStore(); 158 assertNotNull(store); 159 assertTrue(store instanceof TestStore); 160 161 Transport transport = ((Session ) proxy).getTransport(); 162 assertNotNull(transport); 163 assertTrue(transport instanceof TestTransport); 164 165 } 166 167 } 168 | Popular Tags |