Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/sound/midi/MidiSystem/DefaultProperties/DefaultPropertiesNegative.java
41161 views
1
/*
2
* Copyright (c) 2018, 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
import java.nio.file.Paths;
25
26
import com.sun.media.sound.JDK13Services;
27
28
/**
29
* @test
30
* @bug 8201279
31
* @summary this test checks that "javax.sound.config.file" will be ignored if
32
* the user has no access to the properties file
33
* @run main/othervm/policy=negative.policy DefaultPropertiesNegative
34
* @modules java.desktop/com.sun.media.sound
35
*/
36
public class DefaultPropertiesNegative {
37
38
private static final Class[] lineTypeClasses = {
39
javax.sound.midi.Receiver.class,
40
javax.sound.midi.Transmitter.class,
41
javax.sound.midi.Sequencer.class,
42
javax.sound.midi.Synthesizer.class,
43
};
44
45
public static void main(String[] args) throws Exception {
46
boolean allOk = true;
47
String path = Paths.get(System.getProperty("test.src", "."),
48
"testdata", "conf", "sound.properties")
49
.toAbsolutePath().normalize().toString();
50
System.setProperty("javax.sound.config.file", path);
51
52
for (int i = 0; i < lineTypeClasses.length; i++) {
53
Class cls = lineTypeClasses[i];
54
// properties file, both provider class name and instance name
55
String result = JDK13Services.getDefaultProviderClassName(cls);
56
if (result != null) {
57
out("type " + cls + " failed: provider class should be 'null' "
58
+ "but is '" + result + "'!");
59
allOk = false;
60
}
61
result = JDK13Services.getDefaultInstanceName(cls);
62
if (result != null) {
63
out("type " + cls + " failed: instance name should be 'null' "
64
+ "but is '" + result + "'!");
65
allOk = false;
66
}
67
}
68
if (! allOk) {
69
throw new Exception("Test failed");
70
} else {
71
out("Test passed");
72
}
73
}
74
75
private static void out(String message) {
76
System.out.println(message);
77
}
78
}
79
80
81