Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/sound/midi/SysexMessage/Basic.java
41153 views
1
/*
2
* Copyright (c) 2019, 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.util.Arrays;
25
26
import javax.sound.midi.SysexMessage;
27
28
import static javax.sound.midi.SysexMessage.SPECIAL_SYSTEM_EXCLUSIVE;
29
import static javax.sound.midi.SysexMessage.SYSTEM_EXCLUSIVE;
30
31
/**
32
* @test
33
* @bug 8221445
34
* @summary Checks basic functionality of javax.sound.midi.SysexMessage class
35
*/
36
public class Basic {
37
38
public static void main(final String[] args) throws Exception {
39
byte[] dataExclusive = {(byte) (SYSTEM_EXCLUSIVE)};
40
byte[] dataSpecialExclusive = {(byte) (SPECIAL_SYSTEM_EXCLUSIVE)};
41
byte[] empty = {};
42
43
////////////////////////////
44
// Constructors
45
////////////////////////////
46
SysexMessage msg = new SysexMessage(dataExclusive, 1);
47
test(msg, SYSTEM_EXCLUSIVE, empty, 1);
48
msg = new SysexMessage(dataSpecialExclusive, 1);
49
test(msg, SPECIAL_SYSTEM_EXCLUSIVE, empty, 1);
50
msg = new SysexMessage(SYSTEM_EXCLUSIVE, empty, 0);
51
test(msg, SYSTEM_EXCLUSIVE, empty, 1);
52
msg = new SysexMessage(SPECIAL_SYSTEM_EXCLUSIVE, empty, 0);
53
test(msg, SPECIAL_SYSTEM_EXCLUSIVE, empty, 1);
54
msg = new SysexMessage(SYSTEM_EXCLUSIVE, dataSpecialExclusive, 1);
55
test(msg, SYSTEM_EXCLUSIVE, dataSpecialExclusive, 2);
56
msg = new SysexMessage(SPECIAL_SYSTEM_EXCLUSIVE, dataExclusive, 1);
57
test(msg, SPECIAL_SYSTEM_EXCLUSIVE, dataExclusive, 2);
58
59
////////////////////////////
60
// SysexMessage.setMessage()
61
////////////////////////////
62
msg = new SysexMessage();
63
msg.setMessage(dataExclusive, 1);
64
test(msg, SYSTEM_EXCLUSIVE, empty, 1);
65
msg = new SysexMessage();
66
msg.setMessage(dataSpecialExclusive, 1);
67
test(msg, SPECIAL_SYSTEM_EXCLUSIVE, empty, 1);
68
msg = new SysexMessage();
69
msg.setMessage(SYSTEM_EXCLUSIVE, empty, 0);
70
test(msg, SYSTEM_EXCLUSIVE, empty, 1);
71
msg = new SysexMessage();
72
msg.setMessage(SPECIAL_SYSTEM_EXCLUSIVE, empty, 0);
73
test(msg, SPECIAL_SYSTEM_EXCLUSIVE, empty, 1);
74
msg = new SysexMessage();
75
msg.setMessage(SYSTEM_EXCLUSIVE, dataSpecialExclusive, 1);
76
test(msg, SYSTEM_EXCLUSIVE, dataSpecialExclusive, 2);
77
msg = new SysexMessage();
78
msg.setMessage(SPECIAL_SYSTEM_EXCLUSIVE, dataExclusive, 1);
79
test(msg, SPECIAL_SYSTEM_EXCLUSIVE, dataExclusive, 2);
80
}
81
82
static void test(SysexMessage msg, int status, byte[] data, int length) {
83
if (msg.getStatus() != status) {
84
System.err.println("Expected status: " + status);
85
System.err.println("Actual status: " + msg.getStatus());
86
throw new RuntimeException();
87
}
88
if (msg.getLength() != length) {
89
System.err.println("Expected length: " + length);
90
System.err.println("Actual length: " + msg.getLength());
91
throw new RuntimeException();
92
}
93
if (!Arrays.equals(msg.getData(), data)) {
94
System.err.println("Expected data: " + Arrays.toString(data));
95
System.err.println("Actual data: " + Arrays.toString(msg.getData()));
96
throw new RuntimeException();
97
}
98
}
99
}
100
101