2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package tests.api.javax.xml.parsers;
18 import javax.xml.parsers.FactoryConfigurationError;
20 import junit.framework.TestCase;
21 import dalvik.annotation.TestLevel;
22 import dalvik.annotation.TestTargetClass;
23 import dalvik.annotation.TestTargetNew;
25 @TestTargetClass(FactoryConfigurationError.class)
26 public class FactoryConfigurationErrorTest extends TestCase {
29 level = TestLevel.COMPLETE,
31 method = "FactoryConfigurationError",
34 public void test_Constructor() {
35 FactoryConfigurationError fce = new FactoryConfigurationError();
36 assertNull(fce.getMessage());
37 assertNull(fce.getLocalizedMessage());
38 assertNull(fce.getCause());
42 level = TestLevel.COMPLETE,
44 method = "FactoryConfigurationError",
45 args = {java.lang.Exception.class}
47 public void test_ConstructorLjava_lang_Exception() {
48 Exception e = new Exception();
49 // case 1: Try to create FactoryConfigurationError
50 // which is based on Exception without parameters.
51 FactoryConfigurationError fce = new FactoryConfigurationError(e);
52 assertNotNull(fce.getMessage());
53 assertNotNull(fce.getLocalizedMessage());
54 assertEquals(e.getCause(), fce.getCause());
56 // case 2: Try to create FactoryConfigurationError
57 // which is based on Exception with String parameter.
58 e = new Exception("test message");
59 fce = new FactoryConfigurationError(e);
60 assertEquals(e.toString(), fce.getMessage());
61 assertEquals(e.toString(), fce.getLocalizedMessage());
62 assertEquals(e.getCause(), fce.getCause());
66 level = TestLevel.COMPLETE,
68 method = "FactoryConfigurationError",
69 args = {java.lang.Exception.class, java.lang.String.class}
71 public void test_ConstructorLjava_lang_ExceptionLjava_lang_String() {
72 Exception e = new Exception();
73 // case 1: Try to create FactoryConfigurationError
74 // which is based on Exception without parameters.
75 FactoryConfigurationError fce = new FactoryConfigurationError(e, "msg");
76 assertNotNull(fce.getMessage());
77 assertNotNull(fce.getLocalizedMessage());
78 assertEquals(e.getCause(), fce.getCause());
80 // case 2: Try to create FactoryConfigurationError
81 // which is based on Exception with String parameter.
82 e = new Exception("test message");
83 fce = new FactoryConfigurationError(e, "msg");
84 assertEquals("msg", fce.getMessage());
85 assertEquals("msg", fce.getLocalizedMessage());
86 assertEquals(e.getCause(), fce.getCause());
90 level = TestLevel.COMPLETE,
92 method = "FactoryConfigurationError",
93 args = {java.lang.String.class}
95 public void test_ConstructorLjava_lang_String() {
96 FactoryConfigurationError fce = new FactoryConfigurationError("Oops!");
97 assertEquals("Oops!", fce.getMessage());
98 assertEquals("Oops!", fce.getLocalizedMessage());
99 assertNull(fce.getCause());
103 level = TestLevel.COMPLETE,
105 method = "getException",
108 public void test_getException() {
109 FactoryConfigurationError fce = new FactoryConfigurationError();
110 assertNull(fce.getException());
111 fce = new FactoryConfigurationError("test");
112 assertNull(fce.getException());
113 Exception e = new Exception("msg");
114 fce = new FactoryConfigurationError(e);
115 assertEquals(e, fce.getException());
116 NullPointerException npe = new NullPointerException();
117 fce = new FactoryConfigurationError(npe);
118 assertEquals(npe, fce.getException());
122 level = TestLevel.COMPLETE,
124 method = "getMessage",
127 public void test_getMessage() {
128 assertNull(new FactoryConfigurationError().getMessage());
130 new FactoryConfigurationError("msg1").getMessage());
131 assertEquals(new Exception("msg2").toString(),
132 new FactoryConfigurationError(
133 new Exception("msg2")).getMessage());
134 assertEquals(new NullPointerException().toString(),
135 new FactoryConfigurationError(
136 new NullPointerException()).getMessage());