Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/sound/midi/spi/MidiFileReader/ExpectedNPEOnNull.java
41154 views
1
/*
2
* Copyright (c) 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.
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.io.File;
25
import java.io.InputStream;
26
import java.net.URL;
27
28
import javax.sound.midi.MidiSystem;
29
import javax.sound.midi.spi.MidiFileReader;
30
31
import static java.util.ServiceLoader.load;
32
33
/**
34
* @test
35
* @bug 8143909
36
* @author Sergey Bylokhov
37
*/
38
public final class ExpectedNPEOnNull {
39
40
public static void main(final String[] args) throws Exception {
41
testMS();
42
for (final MidiFileReader mfr : load(MidiFileReader.class)) {
43
testMFR(mfr);
44
}
45
}
46
47
/**
48
* Tests the part of MidiSystem API, which implemented via MidiFileReader.
49
*/
50
private static void testMS() throws Exception {
51
// MidiSystem#getMidiFileFormat(InputStream)
52
try {
53
MidiSystem.getMidiFileFormat((InputStream) null);
54
throw new RuntimeException("NPE is expected");
55
} catch (final NullPointerException ignored) {
56
}
57
// MidiSystem#getMidiFileFormat(URL)
58
try {
59
MidiSystem.getMidiFileFormat((URL) null);
60
throw new RuntimeException("NPE is expected");
61
} catch (final NullPointerException ignored) {
62
}
63
// MidiSystem#getMidiFileFormat(File)
64
try {
65
MidiSystem.getMidiFileFormat((File) null);
66
throw new RuntimeException("NPE is expected");
67
} catch (final NullPointerException ignored) {
68
}
69
// MidiSystem#getSequence(InputStream)
70
try {
71
MidiSystem.getSequence((InputStream) null);
72
throw new RuntimeException("NPE is expected");
73
} catch (final NullPointerException ignored) {
74
}
75
// MidiSystem#getSequence(URL)
76
try {
77
MidiSystem.getSequence((URL) null);
78
throw new RuntimeException("NPE is expected");
79
} catch (final NullPointerException ignored) {
80
}
81
// MidiSystem#getSequence(File)
82
try {
83
MidiSystem.getSequence((File) null);
84
throw new RuntimeException("NPE is expected");
85
} catch (final NullPointerException ignored) {
86
}
87
}
88
89
/**
90
* Tests the MidiFileReader API directly.
91
*/
92
private static void testMFR(final MidiFileReader mfr) throws Exception {
93
// MidiFileReader#getMidiFileFormat(InputStream)
94
try {
95
mfr.getMidiFileFormat((InputStream) null);
96
throw new RuntimeException("NPE is expected");
97
} catch (final NullPointerException ignored) {
98
}
99
// MidiFileReader#getMidiFileFormat(URL)
100
try {
101
mfr.getMidiFileFormat((URL) null);
102
throw new RuntimeException("NPE is expected");
103
} catch (final NullPointerException ignored) {
104
}
105
// MidiFileReader#getMidiFileFormat(File)
106
try {
107
mfr.getMidiFileFormat((File) null);
108
throw new RuntimeException("NPE is expected");
109
} catch (final NullPointerException ignored) {
110
}
111
// MidiFileReader#getSequence(InputStream)
112
try {
113
mfr.getSequence((InputStream) null);
114
throw new RuntimeException("NPE is expected");
115
} catch (final NullPointerException ignored) {
116
}
117
// MidiFileReader#getSequence(URL)
118
try {
119
mfr.getSequence((URL) null);
120
throw new RuntimeException("NPE is expected");
121
} catch (final NullPointerException ignored) {
122
}
123
// MidiFileReader#getSequence(File)
124
try {
125
mfr.getSequence((File) null);
126
throw new RuntimeException("NPE is expected");
127
} catch (final NullPointerException ignored) {
128
}
129
}
130
}
131
132