IllegalArgumentExceptionTest.java revision 2ad60cfc28e14ee8f0bb038720836a4696c478ad
1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17
18package org.apache.harmony.luni.tests.java.lang;
19
20import junit.framework.TestCase;
21
22import org.apache.harmony.testframework.serialization.SerializationTest;
23
24public class IllegalArgumentExceptionTest extends TestCase {
25
26    /**
27     * @tests java.lang.IllegalArgumentException#IllegalArgumentException()
28     */
29    public void test_Constructor() {
30        IllegalArgumentException e = new IllegalArgumentException();
31        assertNull(e.getMessage());
32        assertNull(e.getLocalizedMessage());
33        assertNull(e.getCause());
34    }
35
36    /**
37     * @tests java.lang.IllegalArgumentException#IllegalArgumentException(java.lang.String)
38     */
39    public void test_ConstructorLjava_lang_String() {
40        IllegalArgumentException e = new IllegalArgumentException("fixture");
41        assertEquals("fixture", e.getMessage());
42        assertNull(e.getCause());
43    }
44
45    /**
46     * @tests java.lang.IllegalArgumentException#IllegalArgumentException(String,Throwable)
47     */
48    @SuppressWarnings("nls")
49    public void test_ConstructorLjava_lang_StringLjava_lang_Throwable() {
50        NullPointerException npe = new NullPointerException();
51        IllegalArgumentException e = new IllegalArgumentException("fixture",
52                npe);
53        assertSame("fixture", e.getMessage());
54        assertSame(npe, e.getCause());
55    }
56
57    /**
58     * @tests serialization/deserialization.
59     */
60    public void testSerializationSelf() throws Exception {
61        SerializationTest.verifySelf(new IllegalArgumentException());
62    }
63
64    /**
65     * @tests serialization/deserialization compatibility with RI.
66     */
67    public void testSerializationCompatibility() throws Exception {
68        SerializationTest.verifyGolden(this, new IllegalArgumentException());
69    }
70}
71