comparison truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/TruffleToolTest.java @ 21951:9c8c0937da41

Moving all sources into truffle subdirectory
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 17 Jun 2015 10:58:08 +0200
parents graal/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/TruffleToolTest.java@3b8bbf51d320
children dc83cc1f94f2 3aad794eec0e
comparison
equal deleted inserted replaced
21950:2a5011c7e641 21951:9c8c0937da41
1 /*
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package com.oracle.truffle.tools.test;
26
27 import static org.junit.Assert.*;
28
29 import org.junit.*;
30
31 import com.oracle.truffle.api.instrument.*;
32
33 /**
34 * Test the basic life cycle properties shared by all instances of {@link InstrumentationTool}.
35 */
36 public class TruffleToolTest {
37
38 @Test
39 public void testEmptyLifeCycle() {
40 final DummyTruffleTool tool = new DummyTruffleTool();
41 assertFalse(tool.isEnabled());
42 tool.install();
43 assertTrue(tool.isEnabled());
44 tool.reset();
45 assertTrue(tool.isEnabled());
46 tool.setEnabled(false);
47 assertFalse(tool.isEnabled());
48 tool.reset();
49 assertFalse(tool.isEnabled());
50 tool.setEnabled(true);
51 assertTrue(tool.isEnabled());
52 tool.reset();
53 assertTrue(tool.isEnabled());
54 tool.dispose();
55 assertFalse(tool.isEnabled());
56 }
57
58 @Test(expected = IllegalStateException.class)
59 public void testNotYetInstalled1() {
60 final DummyTruffleTool tool = new DummyTruffleTool();
61 tool.reset();
62 }
63
64 @Test(expected = IllegalStateException.class)
65 public void testNotYetInstalled2() {
66 final DummyTruffleTool tool = new DummyTruffleTool();
67 tool.setEnabled(true);
68 }
69
70 @Test(expected = IllegalStateException.class)
71 public void testNotYetInstalled3() {
72 final DummyTruffleTool tool = new DummyTruffleTool();
73 tool.dispose();
74 }
75
76 @Test(expected = IllegalStateException.class)
77 public void testAlreadyInstalled() {
78 final DummyTruffleTool tool = new DummyTruffleTool();
79 tool.install();
80 tool.install();
81 }
82
83 @Test(expected = IllegalStateException.class)
84 public void testAlreadyDisposed1() {
85 final DummyTruffleTool tool = new DummyTruffleTool();
86 tool.install();
87 tool.dispose();
88 tool.install();
89 }
90
91 @Test(expected = IllegalStateException.class)
92 public void testAlreadyDisposed2() {
93 final DummyTruffleTool tool = new DummyTruffleTool();
94 tool.install();
95 tool.dispose();
96 tool.reset();
97 }
98
99 @Test(expected = IllegalStateException.class)
100 public void testAlreadyDisposed3() {
101 final DummyTruffleTool tool = new DummyTruffleTool();
102 tool.install();
103 tool.dispose();
104 tool.setEnabled(true);
105 }
106
107 @Test(expected = IllegalStateException.class)
108 public void testAlreadyDisposed4() {
109 final DummyTruffleTool tool = new DummyTruffleTool();
110 tool.install();
111 tool.dispose();
112 tool.dispose();
113 }
114
115 private static final class DummyTruffleTool extends InstrumentationTool {
116
117 @Override
118 protected boolean internalInstall() {
119 return true;
120 }
121
122 @Override
123 protected void internalReset() {
124 }
125
126 @Override
127 protected void internalDispose() {
128 }
129
130 }
131 }