Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/langtools/jdk/jshell/BadExecutionControlSpecTest.java
40931 views
1
/*
2
* Copyright (c) 2016, 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.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 8168615
27
* @summary Test bad input to ExecutionControl.generate
28
* @modules jdk.compiler/com.sun.tools.javac.api
29
* jdk.compiler/com.sun.tools.javac.main
30
* jdk.jdeps/com.sun.tools.javap
31
* jdk.jshell/jdk.internal.jshell.tool
32
* @run testng BadExecutionControlSpecTest
33
*/
34
35
import java.io.ByteArrayInputStream;
36
import java.io.ByteArrayOutputStream;
37
import java.io.InputStream;
38
import java.io.PrintStream;
39
import java.util.Collections;
40
import java.util.List;
41
import org.testng.annotations.Test;
42
import jdk.jshell.spi.ExecutionControl;
43
import jdk.jshell.spi.ExecutionEnv;
44
import static org.testng.Assert.fail;
45
46
@Test
47
public class BadExecutionControlSpecTest {
48
private static void assertIllegal(String spec) throws Throwable {
49
try {
50
ExecutionEnv env = new ExecutionEnv() {
51
@Override
52
public InputStream userIn() {
53
return new ByteArrayInputStream(new byte[0]);
54
}
55
56
@Override
57
public PrintStream userOut() {
58
return new PrintStream(new ByteArrayOutputStream());
59
}
60
61
@Override
62
public PrintStream userErr() {
63
return new PrintStream(new ByteArrayOutputStream());
64
}
65
66
@Override
67
public List<String> extraRemoteVMOptions() {
68
return Collections.emptyList();
69
}
70
71
@Override
72
public void closeDown() {
73
}
74
75
};
76
ExecutionControl.generate(env, spec);
77
fail("Expected exception -- " + spec);
78
} catch (IllegalArgumentException ex) {
79
// The expected happened
80
}
81
}
82
83
public void syntaxTest() throws Throwable {
84
assertIllegal(":launch(true)");
85
assertIllegal("jdi:launch(true");
86
assertIllegal("jdi:launch(true)$");
87
assertIllegal("jdi:,");
88
}
89
90
public void notFoundTest() throws Throwable {
91
assertIllegal("fruitbats");
92
assertIllegal("jdi:baz(true)");
93
assertIllegal("random:launch(true)");
94
assertIllegal("jdi:,");
95
}
96
}
97
98