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