KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > mail > TestData


1 /**
2  *
3  * Copyright 2003-2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * 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
18 package javax.mail;
19 import javax.mail.internet.MimeMessage;
20 public class TestData {
21     public static Store getTestStore() {
22         return new Store(
23             getTestSession(),
24             new URLName("http://alex@test.com")) {
25             public Folder getDefaultFolder() throws MessagingException {
26                 return getTestFolder();
27             }
28             public Folder getFolder(String name) throws MessagingException {
29                 if (name.equals("test")) {
30                     return getTestFolder();
31                 } else {
32                     return null;
33                 }
34             }
35             public Folder getFolder(URLName name) throws MessagingException {
36                 return getTestFolder();
37             }
38         };
39     }
40     public static Session getTestSession() {
41         return Session.getDefaultInstance(System.getProperties());
42     }
43     public static Folder getTestFolder() {
44         return new Folder(getTestStore()) {
45             public void appendMessages(Message[] messages)
46                 throws MessagingException {
47             }
48             public void close(boolean expunge) throws MessagingException {
49             }
50             public boolean create(int type) throws MessagingException {
51                 return false;
52             }
53             public boolean delete(boolean recurse) throws MessagingException {
54                 return false;
55             }
56             public boolean exists() throws MessagingException {
57                 return false;
58             }
59             public Message[] expunge() throws MessagingException {
60                 return null;
61             }
62             public Folder getFolder(String name) throws MessagingException {
63                 return null;
64             }
65             public String getFullName() {
66                 return null;
67             }
68             public Message getMessage(int id) throws MessagingException {
69                 return null;
70             }
71             public int getMessageCount() throws MessagingException {
72                 return 0;
73             }
74             public String getName() {
75                 return null;
76             }
77             public Folder getParent() throws MessagingException {
78                 return null;
79             }
80             public Flags getPermanentFlags() {
81                 return null;
82             }
83             public char getSeparator() throws MessagingException {
84                 return 0;
85             }
86             public int getType() throws MessagingException {
87                 return 0;
88             }
89             public boolean hasNewMessages() throws MessagingException {
90                 return false;
91             }
92             public boolean isOpen() {
93                 return false;
94             }
95             public Folder[] list(String pattern) throws MessagingException {
96                 return null;
97             }
98             public void open(int mode) throws MessagingException {
99             }
100             public boolean renameTo(Folder newName) throws MessagingException {
101                 return false;
102             }
103         };
104     }
105     public static Transport getTestTransport() {
106         return new Transport(
107             getTestSession(),
108             new URLName("http://host.name")) {
109             public void sendMessage(Message message, Address[] addresses)
110                 throws MessagingException {
111                 // TODO Auto-generated method stub
112
}
113         };
114     }
115     public static Message getMessage() {
116         return new MimeMessage(getTestFolder(), 1) {
117         };
118     }
119 }
120
Popular Tags