1 // Tags: JDK1.4 |
|
2 |
|
3 // Copyright (C) 2004 Sascha Brawer <brawer@dandelis.ch> |
|
4 |
|
5 // This file is part of Mauve. |
|
6 |
|
7 // Mauve is free software; you can redistribute it and/or modify |
|
8 // it under the terms of the GNU General Public License as published by |
|
9 // the Free Software Foundation; either version 2, or (at your option) |
|
10 // any later version. |
|
11 |
|
12 // Mauve is distributed in the hope that it will be useful, |
|
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 // GNU General Public License for more details. |
|
16 |
|
17 // You should have received a copy of the GNU General Public License |
|
18 // along with Mauve; see the file COPYING. If not, write to |
|
19 // the Free Software Foundation, 59 Temple Place - Suite 330, |
|
20 // Boston, MA 02111-1307, USA. |
|
21 |
|
22 package gnu.testlet.javax.imageio.spi.ServiceRegistry; |
|
23 |
|
24 import gnu.testlet.Testlet; |
|
25 import gnu.testlet.TestHarness; |
|
26 |
|
27 import java.util.*; |
|
28 |
|
29 import javax.imageio.spi.RegisterableService; |
|
30 import javax.imageio.spi.ServiceRegistry; |
|
31 |
|
32 /** |
|
33 * Checks #3, #4, #7, and #9 are known to fail on JDK 1.4.1_01. |
|
34 * The author believes that these checks should succeed, so that |
|
35 * this shows a bug in the reference implementation of the JDK. |
|
36 * |
|
37 * @author <a href="mailto:brawer@dandelis.ch">Sascha Brawer</a> |
|
38 */ |
|
39 public class setOrdering |
|
40 implements Testlet |
|
41 { |
|
42 public void test(TestHarness h) |
|
43 { |
|
44 Throwable caught; |
|
45 ServiceRegistry registry; |
|
46 List categories; |
|
47 |
|
48 // Set-up. |
|
49 categories = new LinkedList(); |
|
50 categories.add(String.class); |
|
51 categories.add(RegisterableService.class); |
|
52 registry = new ServiceRegistry(categories.iterator()); |
|
53 registry.registerServiceProvider("sheep", String.class); |
|
54 registry.registerServiceProvider("goat", String.class); |
|
55 registry.registerServiceProvider("cow", String.class); |
|
56 |
|
57 // Check #1: Unknown category --> IllegalArgumentException. |
|
58 caught = null; |
|
59 try |
|
60 { |
|
61 registry.setOrdering(String.class, "foo", null); |
|
62 } |
|
63 catch (Exception ex) |
|
64 { |
|
65 caught = ex; |
|
66 } |
|
67 h.check(caught instanceof IllegalArgumentException); |
|
68 |
|
69 // Check #2: Twice the same object --> IllegalArgumentException. |
|
70 caught = null; |
|
71 try |
|
72 { |
|
73 registry.setOrdering(String.class, "sheep", "sheep"); |
|
74 } |
|
75 catch (Exception ex) |
|
76 { |
|
77 caught = ex; |
|
78 } |
|
79 h.check(caught instanceof IllegalArgumentException); |
|
80 |
|
81 // Check #3. Fails on JDK 1.4.1_01. |
|
82 h.check(registry.setOrdering(String.class, "cow", "sheep")); |
|
83 |
|
84 // Check #4. Fails on JDK 1.4.1_01. |
|
85 h.check(registry.setOrdering(String.class, "sheep", "goat")); |
|
86 |
|
87 // Check #5. |
|
88 h.check(!registry.setOrdering(String.class, "sheep", "goat")); |
|
89 |
|
90 // Check #6. |
|
91 h.check(!registry.setOrdering(String.class, "cow", "sheep")); |
|
92 |
|
93 // Check #7. Fails on JDK 1.4.1_01. |
|
94 h.check(registry.unsetOrdering(String.class, "cow", "sheep")); |
|
95 |
|
96 // Check #8. |
|
97 h.check(!registry.unsetOrdering(String.class, "cow", "sheep")); |
|
98 |
|
99 // Check #9. Fails on JDK 1.4.1_01. |
|
100 h.check(registry.setOrdering(String.class, "cow", "sheep")); |
|
101 } |
|
102 } |
|