Home | History | Annotate | Download | only in internet
      1 /*
      2  * Copyright (C) 2009 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.emailcommon.internet;
     18 
     19 import com.android.emailcommon.internet.MimeBodyPart;
     20 import com.android.emailcommon.internet.MimeHeader;
     21 import com.android.emailcommon.mail.MessagingException;
     22 
     23 import junit.framework.TestCase;
     24 
     25 import android.test.suitebuilder.annotation.SmallTest;
     26 
     27 /**
     28  * This is a series of unit tests for the MimeBodyPart class.  These tests must be locally
     29  * complete - no server(s) required.
     30  */
     31 @SmallTest
     32 public class MimeBodyPartTest extends TestCase {
     33 
     34     // TODO: more tests.
     35 
     36     /*
     37      * Confirm getContentID() correctly works.
     38      */
     39     public void testGetContentId() throws MessagingException {
     40         MimeBodyPart bp = new MimeBodyPart();
     41 
     42         // no content-id
     43         assertNull(bp.getContentId());
     44 
     45         // normal case
     46         final String cid1 = "cid.1 (at) android.com";
     47         bp.setHeader(MimeHeader.HEADER_CONTENT_ID, cid1);
     48         assertEquals(cid1, bp.getContentId());
     49 
     50         // surrounded by optional bracket
     51         bp.setHeader(MimeHeader.HEADER_CONTENT_ID, "<" + cid1 + ">");
     52         assertEquals(cid1, bp.getContentId());
     53     }
     54 }
     55