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.email.mail.internet;
     18 
     19 import android.test.suitebuilder.annotation.SmallTest;
     20 
     21 import junit.framework.TestCase;
     22 
     23 /**
     24  * This is a series of unit tests for the MimeHeader class.  These tests must be locally
     25  * complete - no server(s) required.
     26  */
     27 @SmallTest
     28 public class MimeHeaderUnitTests extends TestCase {
     29 
     30     // TODO more test
     31 
     32     /**
     33      * Test for writeToString()
     34      */
     35     public void testWriteToString() throws Exception {
     36         MimeHeader header = new MimeHeader();
     37 
     38         // empty header
     39         String actual1 = header.writeToString();
     40         assertEquals("empty header", actual1, null);
     41 
     42         // single header
     43         header.setHeader("Header1", "value1");
     44         String actual2 = header.writeToString();
     45         assertEquals("single header", actual2, "Header1: value1\r\n");
     46 
     47         // multiple headers
     48         header.setHeader("Header2", "value2");
     49         String actual3 = header.writeToString();
     50         assertEquals("multiple headers", actual3,
     51                 "Header1: value1\r\n"
     52                 + "Header2: value2\r\n");
     53 
     54         // omit header
     55         header.setHeader(MimeHeader.HEADER_ANDROID_ATTACHMENT_STORE_DATA, "value3");
     56         String actual4 = header.writeToString();
     57         assertEquals("multiple headers", actual4,
     58                 "Header1: value1\r\n"
     59                 + "Header2: value2\r\n");
     60     }
     61 }
     62