[6785] | 1 | /**************************************************************** |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one * |
---|
| 3 | * or more contributor license agreements. See the NOTICE file * |
---|
| 4 | * distributed with this work for additional information * |
---|
| 5 | * regarding copyright ownership. The ASF licenses this file * |
---|
| 6 | * to you under the Apache License, Version 2.0 (the * |
---|
| 7 | * "License"); you may not use this file except in compliance * |
---|
| 8 | * with the License. You may obtain a copy of the License at * |
---|
| 9 | * * |
---|
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 * |
---|
| 11 | * * |
---|
| 12 | * Unless required by applicable law or agreed to in writing, * |
---|
| 13 | * software distributed under the License is distributed on an * |
---|
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * |
---|
| 15 | * KIND, either express or implied. See the License for the * |
---|
| 16 | * specific language governing permissions and limitations * |
---|
| 17 | * under the License. * |
---|
| 18 | ****************************************************************/ |
---|
| 19 | |
---|
| 20 | package org.apache.james.mime4j.field; |
---|
| 21 | |
---|
| 22 | import org.apache.james.mime4j.dom.field.ContentTransferEncodingField; |
---|
| 23 | import org.apache.james.mime4j.field.ContentTransferEncodingFieldImpl; |
---|
| 24 | import org.apache.james.mime4j.field.DefaultFieldParser; |
---|
| 25 | |
---|
| 26 | import junit.framework.TestCase; |
---|
| 27 | |
---|
| 28 | public class ContentTransferEncodingFieldTest extends TestCase { |
---|
| 29 | |
---|
| 30 | public void testGetEncoding() throws Exception { |
---|
| 31 | ContentTransferEncodingField f = null; |
---|
| 32 | |
---|
| 33 | f = (ContentTransferEncodingField) |
---|
| 34 | DefaultFieldParser.parse("Content-Transfer-Encoding: 8bit"); |
---|
| 35 | assertEquals("8bit", f.getEncoding()); |
---|
| 36 | |
---|
| 37 | f = (ContentTransferEncodingField) |
---|
| 38 | DefaultFieldParser.parse("Content-Transfer-Encoding: BaSE64 "); |
---|
| 39 | assertEquals("base64", f.getEncoding()); |
---|
| 40 | |
---|
| 41 | f = (ContentTransferEncodingField) |
---|
| 42 | DefaultFieldParser.parse("Content-Transfer-Encoding: "); |
---|
| 43 | assertEquals("", f.getEncoding()); |
---|
| 44 | |
---|
| 45 | f = (ContentTransferEncodingField) |
---|
| 46 | DefaultFieldParser.parse("Content-Transfer-Encoding:"); |
---|
| 47 | assertEquals("", f.getEncoding()); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | public void testGetEncodingStatic() throws Exception { |
---|
| 51 | ContentTransferEncodingField f = null; |
---|
| 52 | |
---|
| 53 | f = (ContentTransferEncodingField) |
---|
| 54 | DefaultFieldParser.parse("Content-Transfer-Encoding: 8bit"); |
---|
| 55 | assertEquals("8bit", ContentTransferEncodingFieldImpl.getEncoding(f)); |
---|
| 56 | |
---|
| 57 | f = null; |
---|
| 58 | assertEquals("7bit", ContentTransferEncodingFieldImpl.getEncoding(f)); |
---|
| 59 | |
---|
| 60 | f = (ContentTransferEncodingField) |
---|
| 61 | DefaultFieldParser.parse("Content-Transfer-Encoding: "); |
---|
| 62 | assertEquals("7bit", ContentTransferEncodingFieldImpl.getEncoding(f)); |
---|
| 63 | |
---|
| 64 | f = (ContentTransferEncodingField) |
---|
| 65 | DefaultFieldParser.parse("Content-Transfer-Encoding:"); |
---|
| 66 | assertEquals("7bit", ContentTransferEncodingFieldImpl.getEncoding(f)); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | } |
---|