1/* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. 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 17package org.apache.harmony.tests.java.util; 18 19import java.io.Serializable; 20import java.util.DuplicateFormatFlagsException; 21 22import junit.framework.TestCase; 23 24import org.apache.harmony.testframework.serialization.SerializationTest; 25import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert; 26 27public class DuplicateFormatFlagsExceptionTest extends TestCase { 28 29 /** 30 * java.util.DuplicateFormatFlagsException#DuplicateFormatFlagsException(String) 31 */ 32 public void test_duplicateFormatFlagsException() { 33 try { 34 new DuplicateFormatFlagsException(null); 35 fail("should throw NullPointerException."); 36 } catch (NullPointerException e) { 37 // desired 38 } 39 } 40 41 /** 42 * java.util.DuplicateFormatFlagsException#getFlags() 43 */ 44 public void test_getFlags() { 45 String strFlags = "MYTESTFLAGS"; 46 DuplicateFormatFlagsException duplicateFormatException = new DuplicateFormatFlagsException( 47 strFlags); 48 assertEquals(strFlags, duplicateFormatException.getFlags()); 49 } 50 51 /** 52 * java.util.DuplicateFormatFlagsException#getMessage() 53 */ 54 public void test_getMessage() { 55 String strFlags = "MYTESTFLAGS"; 56 DuplicateFormatFlagsException duplicateFormatException = new DuplicateFormatFlagsException( 57 strFlags); 58 assertTrue(null != duplicateFormatException.getFlags()); 59 60 } 61 62 // comparator for DuplicateFormatFlagsException objects 63 private static final SerializableAssert exComparator = new SerializableAssert() { 64 public void assertDeserialized(Serializable initial, 65 Serializable deserialized) { 66 67 SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial, 68 deserialized); 69 70 DuplicateFormatFlagsException initEx = (DuplicateFormatFlagsException) initial; 71 DuplicateFormatFlagsException desrEx = (DuplicateFormatFlagsException) deserialized; 72 73 assertEquals("Flags", initEx.getFlags(), desrEx.getFlags()); 74 } 75 }; 76 77 /** 78 * serialization/deserialization. 79 */ 80 public void testSerializationSelf() throws Exception { 81 82 SerializationTest.verifySelf(new DuplicateFormatFlagsException( 83 "TESTDESC"), exComparator); 84 } 85 86 /** 87 * serialization/deserialization compatibility with RI. 88 */ 89 public void testSerializationCompatibility() throws Exception { 90 91 SerializationTest.verifyGolden(this, new DuplicateFormatFlagsException( 92 "TESTDESC"), exComparator); 93 } 94} 95