SecurityExceptionTest.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 SecurityExceptionTest extends TestCase {
25
26    /**
27     * @tests java.lang.SecurityException#SecurityException()
28     */
29    public void test_Constructor() {
30        SecurityException e = new SecurityException();
31        assertNull(e.getMessage());
32        assertNull(e.getLocalizedMessage());
33        assertNull(e.getCause());
34    }
35
36    /**
37     * @tests java.lang.SecurityException#SecurityException(java.lang.String)
38     */
39    public void test_ConstructorLjava_lang_String() {
40        SecurityException e = new SecurityException("fixture");
41        assertEquals("fixture", e.getMessage());
42        assertNull(e.getCause());
43    }
44
45    /**
46     * @tests java.lang.SecurityException#SecurityException(String, Throwable)
47     */
48    @SuppressWarnings("nls")
49    public void test_ConstructorLjava_lang_StringLjava_lang_Throwable() {
50        NullPointerException npe = new NullPointerException();
51        SecurityException e = new SecurityException("fixture", npe);
52        assertSame("fixture", e.getMessage());
53        assertSame(npe, e.getCause());
54    }
55
56    /**
57     * @tests java.lang.SecurityException#SecurityException(Throwable)
58     */
59    @SuppressWarnings("nls")
60    public void test_ConstructorLjava_lang_Throwable() {
61        NullPointerException npe = new NullPointerException();
62        SecurityException e = new SecurityException(npe);
63        assertSame(npe, e.getCause());
64    }
65
66    /**
67     * @tests serialization/deserialization.
68     */
69    public void testSerializationSelf() throws Exception {
70
71        SerializationTest.verifySelf(new SecurityException());
72    }
73
74    /**
75     * @tests serialization/deserialization compatibility with RI.
76     */
77    public void testSerializationCompatibility() throws Exception {
78
79        SerializationTest.verifyGolden(this, new SecurityException());
80    }
81}
82