author | dfuchs |
Wed, 10 Sep 2008 16:27:13 +0200 | |
changeset 1227 | 4546977d0d66 |
permissions | -rw-r--r-- |
1227
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
1 |
/* |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
2 |
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
4 |
* |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
8 |
* |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
13 |
* accompanied this code). |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
14 |
* |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
18 |
* |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
21 |
* have any questions. |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
22 |
*/ |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
23 |
|
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
24 |
/* |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
25 |
* @test |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
26 |
* @bug 6669137 |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
27 |
* @summary Test the constructors of InstanceNotFoundExceptionTest. |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
28 |
* @author Daniel Fuchs |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
29 |
* @compile InstanceNotFoundExceptionTest.java |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
30 |
* @run main InstanceNotFoundExceptionTest |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
31 |
*/ |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
32 |
|
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
33 |
import javax.management.InstanceNotFoundException; |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
34 |
import javax.management.ObjectName; |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
35 |
|
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
36 |
public class InstanceNotFoundExceptionTest { |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
37 |
public static void main(String[] args) throws Exception { |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
38 |
final InstanceNotFoundException x = |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
39 |
new InstanceNotFoundException(); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
40 |
System.out.println("InstanceNotFoundException(): "+x.getMessage()); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
41 |
|
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
42 |
final String msg = "who is toto?"; |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
43 |
final InstanceNotFoundException x2 = |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
44 |
new InstanceNotFoundException(msg); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
45 |
if (!msg.equals(x2.getMessage())) |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
46 |
throw new Exception("Bad message: expected "+msg+ |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
47 |
", got "+x2.getMessage()); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
48 |
System.out.println("InstanceNotFoundException(" + |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
49 |
msg+"): "+x2.getMessage()); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
50 |
|
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
51 |
final InstanceNotFoundException x3 = |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
52 |
new InstanceNotFoundException((String)null); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
53 |
if (x3.getMessage() != null) |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
54 |
throw new Exception("Bad message: expected "+null+ |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
55 |
", got "+x3.getMessage()); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
56 |
System.out.println("InstanceNotFoundException((String)null): "+ |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
57 |
x3.getMessage()); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
58 |
|
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
59 |
final ObjectName n = new ObjectName("who is toto?:type=msg"); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
60 |
final InstanceNotFoundException x4 = |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
61 |
new InstanceNotFoundException(n); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
62 |
if (!String.valueOf(n).equals(x4.getMessage())) |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
63 |
throw new Exception("Bad message: expected "+n+ |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
64 |
", got "+x4.getMessage()); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
65 |
System.out.println("InstanceNotFoundException(" + |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
66 |
n+"): "+x4.getMessage()); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
67 |
|
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
68 |
final InstanceNotFoundException x5 = |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
69 |
new InstanceNotFoundException((ObjectName)null); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
70 |
if (!String.valueOf((ObjectName)null).equals(x5.getMessage())) |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
71 |
throw new Exception("Bad message: expected " + |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
72 |
String.valueOf((ObjectName)null)+" got "+x5.getMessage()); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
73 |
System.out.println("InstanceNotFoundException((ObjectName)null): "+ |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
74 |
x5.getMessage()); |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
75 |
} |
4546977d0d66
6746754: jmx namespace: test for leading separator missing
dfuchs
parents:
diff
changeset
|
76 |
} |