KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > mail > MailGBeanTest


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.mail;
18
19 import java.util.Collections JavaDoc;
20 import java.util.Properties JavaDoc;
21
22 import javax.mail.Session JavaDoc;
23 import javax.mail.Store JavaDoc;
24 import javax.mail.Transport JavaDoc;
25
26 import junit.framework.TestCase;
27
28
29 /**
30  * @version $Rev: 484867 $ $Date: 2006-12-08 19:52:56 -0500 (Fri, 08 Dec 2006) $
31  */

32 public class MailGBeanTest extends TestCase {
33     public void testNotheing() {}
34
35     public void XtestProperties() throws Exception JavaDoc {
36         Properties JavaDoc properties = new Properties JavaDoc();
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 JavaDoc proxy = mail.$getResource();
43
44         assertNotNull(proxy);
45         assertTrue(proxy instanceof Session JavaDoc);
46
47         Store JavaDoc store = ((Session JavaDoc) proxy).getStore();
48         assertNotNull(store);
49         assertTrue(store instanceof TestStore);
50
51         Transport JavaDoc transport = ((Session JavaDoc) proxy).getTransport();
52         assertNotNull(transport);
53         assertTrue(transport instanceof TestTransport);
54
55     }
56
57     public void XtestDefaultOverrides() throws Exception JavaDoc {
58         Properties JavaDoc properties = new Properties JavaDoc();
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 JavaDoc proxy = mail.$getResource();
65
66         assertNotNull(proxy);
67         assertTrue(proxy instanceof Session JavaDoc);
68
69         Store JavaDoc store = ((Session JavaDoc) proxy).getStore();
70         assertNotNull(store);
71         assertTrue(store instanceof TestStore);
72
73         Transport JavaDoc transport = ((Session JavaDoc) proxy).getTransport();
74         assertNotNull(transport);
75         assertTrue(transport instanceof TestTransport);
76
77     }
78
79     public void XtestSMTPOverrides() throws Exception JavaDoc {
80         // these are defaults, all to be overridden
81
Properties JavaDoc properties = new Properties JavaDoc();
82         properties.put("mail.store.protocol", "POOKIE");
83         properties.put("mail.transport.protocol", "BEAR");
84         properties.put("mail.smtp.ehlo", "false");
85
86         // this is done in the property bundle for the transport.
87
Properties JavaDoc bundle = new Properties JavaDoc();
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 JavaDoc proxy = mail.$getResource();
97
98         assertNotNull(proxy);
99         assertTrue(proxy instanceof Session JavaDoc);
100
101         Store JavaDoc store = ((Session JavaDoc) proxy).getStore();
102         assertNotNull(store);
103         assertTrue(store instanceof TestStore);
104
105         Transport JavaDoc transport = ((Session JavaDoc) 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 JavaDoc {
115         Properties JavaDoc properties = new Properties JavaDoc();
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 JavaDoc proxy = mail.$getResource();
126
127         assertNotNull(proxy);
128         assertTrue(proxy instanceof Session JavaDoc);
129
130         Store JavaDoc store = ((Session JavaDoc) proxy).getStore();
131         assertNotNull(store);
132         assertTrue(store instanceof TestStore);
133
134         Transport JavaDoc transport = ((Session JavaDoc) proxy).getTransport();
135         assertNotNull(transport);
136         assertTrue(transport instanceof TestTransport);
137
138     }
139
140     public void XtestIMAPOverrides() throws Exception JavaDoc {
141         Properties JavaDoc properties = new Properties JavaDoc();
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 JavaDoc proxy = mail.$getResource();
152
153
154         assertNotNull(proxy);
155         assertTrue(proxy instanceof Session JavaDoc);
156
157         Store JavaDoc store = ((Session JavaDoc) proxy).getStore();
158         assertNotNull(store);
159         assertTrue(store instanceof TestStore);
160
161         Transport JavaDoc transport = ((Session JavaDoc) proxy).getTransport();
162         assertNotNull(transport);
163         assertTrue(transport instanceof TestTransport);
164
165     }
166
167 }
168
Popular Tags