CompilerTest.java revision 89c1feb0a69a7707b271086e749975b3f7acacf7
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.TestInfo;
21import dalvik.annotation.TestLevel;
22import dalvik.annotation.TestTarget;
23import dalvik.annotation.TestTargetClass;
24
25import junit.framework.TestCase;
26
27@TestTargetClass(Compiler.class)
28public class CompilerTest extends TestCase {
29
30    /**
31     * @tests java.lang.Compiler#command(java.lang.Object)
32     */
33    @TestInfo(
34      level = TestLevel.PARTIAL,
35      purpose = "NullPointerException is not verified.",
36      targets = {
37        @TestTarget(
38          methodName = "command",
39          methodArgs = {java.lang.Object.class}
40        )
41    })
42    public void test_commandLjava_lang_Object() {
43        try {
44            assertNull("Incorrect behavior.", Compiler.command(new Object()));
45        } catch (Exception e) {
46            fail("Exception during test : " + e.getMessage());
47        }
48    }
49
50    /**
51     * @tests java.lang.Compiler#compileClass(java.lang.Class)
52     */
53    @TestInfo(
54      level = TestLevel.PARTIAL,
55      purpose = "NullPointerException is not verified.",
56      targets = {
57        @TestTarget(
58          methodName = "compileClass",
59          methodArgs = {java.lang.Class.class}
60        )
61    })
62    public void test_compileClassLjava_lang_Class() {
63        try {
64            // Do not test return value, may return true or false depending on
65            // if the jit is enabled. Make the call to ensure it doesn't crash.
66            Compiler.compileClass(Compiler.class);
67        } catch (Exception e) {
68            fail("Exception during test.");
69        }
70    }
71
72    /**
73     * @tests java.lang.Compiler#compileClasses(java.lang.String)
74     */
75    @TestInfo(
76      level = TestLevel.PARTIAL,
77      purpose = "NullPointerException is not verified.",
78      targets = {
79        @TestTarget(
80          methodName = "compileClasses",
81          methodArgs = {java.lang.String.class}
82        )
83    })
84    public void test_compileClassesLjava_lang_String() {
85        try {
86            // Do not test return value, may return true or false depending on
87            // if the jit is enabled. Make the call to ensure it doesn't crash.
88            Compiler.compileClasses("Compiler");
89        } catch (Exception e) {
90            fail("Exception during test.");
91        }
92    }
93
94    /**
95     * @tests java.lang.Compiler#disable()
96     */
97    @TestInfo(
98      level = TestLevel.TODO,
99      purpose = "Doesn't verify that disable() method causes the Compiler " +
100            "to cease operation.",
101      targets = {
102        @TestTarget(
103          methodName = "disable",
104          methodArgs = {}
105        )
106    })
107    public void test_disable() {
108        try {
109            Compiler.disable();
110            Compiler.compileClass(Compiler.class);
111        } catch (Exception e) {
112            fail("Exception during test : " + e.getMessage());
113        }
114    }
115
116    /**
117     * @tests java.lang.Compiler#enable()
118     */
119    @TestInfo(
120      level = TestLevel.TODO,
121      purpose = "Doesn't verify that enable() method causes the Compiler " +
122            "to resume operation.",
123      targets = {
124        @TestTarget(
125          methodName = "enable",
126          methodArgs = {}
127        )
128    })
129    public void test_enable() {
130        try {
131            Compiler.disable();
132            Compiler.enable();
133            Compiler.compileClass(Compiler.class);
134        } catch (Exception e) {
135            fail("Exception during test : " + e.getMessage());
136        }
137    }
138}
139