OutOfMemoryErrorTest.java revision cc05ad238516f1303687aba4a978e24e57c0c07a
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 dalvik.annotation.TestTargets;
21import dalvik.annotation.TestLevel;
22import dalvik.annotation.TestTargetNew;
23import dalvik.annotation.TestTargetClass;
24
25@TestTargetClass(OutOfMemoryError.class)
26public class OutOfMemoryErrorTest extends junit.framework.TestCase {
27
28    /**
29     * @tests java.lang.OutOfMemoryError#OutOfMemoryError()
30     */
31    @TestTargetNew(
32        level = TestLevel.COMPLETE,
33        notes = "",
34        method = "OutOfMemoryError",
35        args = {}
36    )
37    public void test_Constructor() {
38        // Test for method java.lang.OutOfMemoryError()
39        Error e = new OutOfMemoryError();
40        assertNull(e.getCause());
41        assertNull(e.getMessage());
42    }
43
44    /**
45     * @tests java.lang.OutOfMemoryError#OutOfMemoryError(java.lang.String)
46     */
47    @TestTargetNew(
48        level = TestLevel.COMPLETE,
49        notes = "",
50        method = "OutOfMemoryError",
51        args = {java.lang.String.class}
52    )
53    public void test_ConstructorLjava_lang_String() {
54        // Test for method java.lang.OutOfMemoryError(java.lang.String)
55        Error e = new OutOfMemoryError(null);
56        assertNull(e.getMessage());
57        assertNull(e.getCause());
58
59        e= new OutOfMemoryError("msg");
60        assertEquals("msg", e.getMessage());
61        assertNull(e.getCause());
62    }
63
64}
65