1   /*
2    * $Id: MailMessageAdapterTestCase.java 10787 2008-02-12 18:51:50Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.email.adapters;
12  
13  import org.mule.api.MessagingException;
14  import org.mule.api.registry.ServiceDescriptorFactory;
15  import org.mule.api.transport.MessageAdapter;
16  import org.mule.transport.AbstractMessageAdapterTestCase;
17  import org.mule.transport.email.MailMessageAdapter;
18  
19  import java.util.Properties;
20  
21  import javax.mail.Message;
22  import javax.mail.Session;
23  import javax.mail.internet.MimeMessage;
24  
25  public class MailMessageAdapterTestCase extends AbstractMessageAdapterTestCase
26  {
27      private Message message;
28  
29      protected void doSetUp() throws Exception
30      {
31          //wee need to load the transport descriptor in order to tes tthe message Adapter
32          muleContext.getRegistry().lookupServiceDescriptor(ServiceDescriptorFactory.PROVIDER_SERVICE_TYPE, "pop3", null);
33      }
34  
35      /*
36       * (non-Javadoc)
37       * 
38       * @see org.mule.tck.providers.AbstractMessageAdapterTestCase#createAdapter()
39       */
40      public MessageAdapter createAdapter(Object payload) throws MessagingException
41      {
42          return new MailMessageAdapter(payload);
43      }
44  
45      /*
46       * (non-Javadoc)
47       * 
48       * @see org.mule.tck.providers.AbstractMessageAdapterTestCase#getValidMessage()
49       */
50      public Object getValidMessage() throws Exception
51      {
52          if (message == null)
53          {
54              message = new MimeMessage(Session.getDefaultInstance(new Properties()));
55              message.setContent("Test Email Message", "text/plain");
56          }
57  
58          return message;
59      }
60  
61  }