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