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 */ 16package org.apache.harmony.luni.tests.java.util; 17 18import java.io.Serializable; 19import java.util.IllegalFormatWidthException; 20 21import junit.framework.TestCase; 22 23import org.apache.harmony.testframework.serialization.SerializationTest; 24import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert; 25 26public class IllegalFormatWidthExceptionTest extends TestCase { 27 28 /** 29 * @tests java.util.IllegalFormatWidthException#IllegalFormatWidthException(int) 30 */ 31 public void test_illegalFormatWidthException() { 32 int width = Integer.MAX_VALUE; 33 IllegalFormatWidthException illegalFormatWidthException = new IllegalFormatWidthException( 34 width); 35 assertEquals(width, illegalFormatWidthException.getWidth()); 36 37 } 38 39 /** 40 * @tests java.util.IllegalFormatWidthException#getWidth() 41 */ 42 public void test_getWidth() { 43 int width = 12345; 44 IllegalFormatWidthException illegalFormatWidthException = new IllegalFormatWidthException( 45 width); 46 assertEquals(width, illegalFormatWidthException.getWidth()); 47 48 } 49 50 /** 51 * @tests java.util.IllegalFormatWidthException#getMessage() 52 */ 53 public void test_getMessage() { 54 int width = 12345; 55 IllegalFormatWidthException illegalFormatWidthException = new IllegalFormatWidthException( 56 width); 57 assertTrue(null != illegalFormatWidthException.getMessage()); 58 59 } 60 61 // comparator for IllegalFormatWidthException objects 62 private static final SerializableAssert exComparator = new SerializableAssert() { 63 public void assertDeserialized(Serializable initial, 64 Serializable deserialized) { 65 66 SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial, 67 deserialized); 68 69 IllegalFormatWidthException initEx = (IllegalFormatWidthException) initial; 70 IllegalFormatWidthException desrEx = (IllegalFormatWidthException) deserialized; 71 72 assertEquals("Width", initEx.getWidth(), desrEx.getWidth()); 73 } 74 }; 75 76 /** 77 * @tests serialization/deserialization. 78 */ 79 public void testSerializationSelf() throws Exception { 80 81 SerializationTest.verifySelf(new IllegalFormatWidthException(12345), 82 exComparator); 83 } 84 85 /** 86 * @tests serialization/deserialization compatibility with RI. 87 */ 88 public void testSerializationCompatibility() throws Exception { 89 90 SerializationTest.verifyGolden(this, new IllegalFormatWidthException( 91 12345), exComparator); 92 } 93} 94