author | lana |
Thu, 04 Nov 2010 15:39:43 -0700 | |
changeset 7205 | e6560614a608 |
parent 6506 | 36a2d4253a54 |
child 21596 | 0e3a39f29dbc |
permissions | -rw-r--r-- |
6506
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
1 |
/* |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
4 |
* |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
10 |
* |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
15 |
* accompanied this code). |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
16 |
* |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
20 |
* |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
23 |
* questions. |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
24 |
*/ |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
25 |
|
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
26 |
/** |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
27 |
* @test |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
28 |
* @bug 4937708 |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
29 |
* @summary Tests that AudioFormat.matches handle NOT_SPECIFIED value in all fields |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
30 |
* @run main Matches_NOT_SPECIFIED |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
31 |
* @author Alex Menkov |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
32 |
* |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
33 |
*/ |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
34 |
|
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
35 |
import javax.sound.sampled.AudioFormat; |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
36 |
import javax.sound.sampled.AudioFormat.Encoding; |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
37 |
import javax.sound.sampled.AudioSystem; |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
38 |
|
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
39 |
|
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
40 |
public class Matches_NOT_SPECIFIED { |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
41 |
|
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
42 |
static boolean success = true; |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
43 |
static AudioFormat f1; |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
44 |
static AudioFormat f2; |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
45 |
|
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
46 |
public static void main(String[] args) throws Exception { |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
47 |
AudioFormat f3; |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
48 |
f1 = new AudioFormat(44100, 16, 2, true, false); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
49 |
f2 = new AudioFormat(Encoding.PCM_SIGNED, |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
50 |
AudioSystem.NOT_SPECIFIED, |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
51 |
AudioSystem.NOT_SPECIFIED, |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
52 |
AudioSystem.NOT_SPECIFIED, |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
53 |
AudioSystem.NOT_SPECIFIED, |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
54 |
AudioSystem.NOT_SPECIFIED, false); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
55 |
test(true); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
56 |
|
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
57 |
// f1 = new AudioFormat(44100, 8, 16, true, false); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
58 |
f2 = new AudioFormat(Encoding.PCM_SIGNED, |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
59 |
AudioSystem.NOT_SPECIFIED, |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
60 |
AudioSystem.NOT_SPECIFIED, |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
61 |
AudioSystem.NOT_SPECIFIED, |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
62 |
AudioSystem.NOT_SPECIFIED, |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
63 |
AudioSystem.NOT_SPECIFIED, true); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
64 |
test(false); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
65 |
|
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
66 |
f1 = new AudioFormat(44100, 8, 8, true, false); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
67 |
test(true); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
68 |
|
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
69 |
if (success) { |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
70 |
out("The test PASSED."); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
71 |
} else { |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
72 |
out("The test FAILED."); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
73 |
throw new Exception("The test FAILED"); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
74 |
} |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
75 |
} |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
76 |
|
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
77 |
static void test(boolean shouldMatch) { |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
78 |
out("testing:"); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
79 |
out(" - " + f1.toString()); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
80 |
out(" - " + f2.toString()); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
81 |
if (f1.matches(f2)) { |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
82 |
if (shouldMatch) { |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
83 |
out(" (OK) MATCHES"); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
84 |
} else { |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
85 |
out(" (ERROR) MATCHES"); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
86 |
success = false; |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
87 |
} |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
88 |
} else { |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
89 |
if (shouldMatch) { |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
90 |
out(" (ERROR) DOESNT MATCH!"); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
91 |
success = false; |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
92 |
} else { |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
93 |
out(" (OK) DOESNT MATCH!"); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
94 |
} |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
95 |
} |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
96 |
} |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
97 |
|
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
98 |
static void out(String s) { |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
99 |
System.out.println(s); |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
100 |
} |
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
101 |
|
36a2d4253a54
4937708: AudioFormat.matches should allow NOT_SPECIFY in all fields
amenkov
parents:
diff
changeset
|
102 |
} |