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 tests.api.java.io;
19
20import java.io.InvalidObjectException;
21
22import dalvik.annotation.TestLevel;
23import dalvik.annotation.TestTargetClass;
24import dalvik.annotation.TestTargetNew;
25
26@TestTargetClass(java.io.InvalidObjectException.class)
27public class InvalidObjectExceptionTest extends junit.framework.TestCase {
28
29    /**
30     * @tests java.io.InvalidObjectException#InvalidObjectException(java.lang.String)
31     */
32    @TestTargetNew(
33        level = TestLevel.COMPLETE,
34        notes = "Verifies the InvalidObjectException(java.lang.String) constructor.",
35        method = "InvalidObjectException",
36        args = {java.lang.String.class}
37    )
38    public void test_ConstructorLjava_lang_String() {
39        // Test for method java.io.InvalidObjectException(java.lang.String)
40        try {
41            if (true) throw new InvalidObjectException("This object is not valid.");
42            fail("Exception not thrown.");
43        } catch (InvalidObjectException e) {
44            assertEquals("The exception message is not equal to the one " +
45                         "passed to the constructor.",
46                         "This object is not valid.", e.getMessage());
47        }
48    }
49}
50