1 /* |
|
2 * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 * have any questions. |
|
22 */ |
|
23 |
|
24 /* |
|
25 * @test |
|
26 * @bug 6669137 |
|
27 * @summary Test the constructors of InstanceNotFoundExceptionTest. |
|
28 * @author Daniel Fuchs |
|
29 * @compile InstanceNotFoundExceptionTest.java |
|
30 * @run main InstanceNotFoundExceptionTest |
|
31 */ |
|
32 |
|
33 import javax.management.InstanceNotFoundException; |
|
34 import javax.management.ObjectName; |
|
35 |
|
36 public class InstanceNotFoundExceptionTest { |
|
37 public static void main(String[] args) throws Exception { |
|
38 final InstanceNotFoundException x = |
|
39 new InstanceNotFoundException(); |
|
40 System.out.println("InstanceNotFoundException(): "+x.getMessage()); |
|
41 |
|
42 final String msg = "who is toto?"; |
|
43 final InstanceNotFoundException x2 = |
|
44 new InstanceNotFoundException(msg); |
|
45 if (!msg.equals(x2.getMessage())) |
|
46 throw new Exception("Bad message: expected "+msg+ |
|
47 ", got "+x2.getMessage()); |
|
48 System.out.println("InstanceNotFoundException(" + |
|
49 msg+"): "+x2.getMessage()); |
|
50 |
|
51 final InstanceNotFoundException x3 = |
|
52 new InstanceNotFoundException((String)null); |
|
53 if (x3.getMessage() != null) |
|
54 throw new Exception("Bad message: expected "+null+ |
|
55 ", got "+x3.getMessage()); |
|
56 System.out.println("InstanceNotFoundException((String)null): "+ |
|
57 x3.getMessage()); |
|
58 |
|
59 final ObjectName n = new ObjectName("who is toto?:type=msg"); |
|
60 final InstanceNotFoundException x4 = |
|
61 new InstanceNotFoundException(n); |
|
62 if (!String.valueOf(n).equals(x4.getMessage())) |
|
63 throw new Exception("Bad message: expected "+n+ |
|
64 ", got "+x4.getMessage()); |
|
65 System.out.println("InstanceNotFoundException(" + |
|
66 n+"): "+x4.getMessage()); |
|
67 |
|
68 final InstanceNotFoundException x5 = |
|
69 new InstanceNotFoundException((ObjectName)null); |
|
70 if (!String.valueOf((ObjectName)null).equals(x5.getMessage())) |
|
71 throw new Exception("Bad message: expected " + |
|
72 String.valueOf((ObjectName)null)+" got "+x5.getMessage()); |
|
73 System.out.println("InstanceNotFoundException((ObjectName)null): "+ |
|
74 x5.getMessage()); |
|
75 } |
|
76 } |
|