2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
|
2
|
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 |
*
|
5506
|
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.
|
2
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
* @test
|
|
26 |
* @bug 5046815
|
|
27 |
* @summary Test that RMIServer.getVersion() reflects the JDK version when
|
|
28 |
* JMX is bundled into the Java platform and the application is run with a
|
|
29 |
* security manager and the test codebase has the java permission to read
|
|
30 |
* the "java.runtime.version" system property.
|
|
31 |
* @author Luis-Miguel Alventosa, Joel Feraud
|
|
32 |
* @run clean ImplVersionTest ImplVersionCommand
|
|
33 |
* @run build ImplVersionTest ImplVersionCommand ImplVersionReader
|
|
34 |
* @run main ImplVersionTest
|
|
35 |
*/
|
|
36 |
|
|
37 |
import java.io.File;
|
|
38 |
import java.security.CodeSource;
|
|
39 |
import javax.management.MBeanServer;
|
|
40 |
|
|
41 |
public class ImplVersionTest {
|
|
42 |
|
|
43 |
public static void main(String[] args) {
|
|
44 |
try {
|
|
45 |
// Get OS name
|
|
46 |
//
|
|
47 |
String osName = System.getProperty("os.name");
|
|
48 |
System.out.println("osName = " + osName);
|
|
49 |
if ("Windows 98".equals(osName)) {
|
|
50 |
// Disable this test on Win98 due to parsing
|
|
51 |
// errors (bad handling of white spaces) when
|
|
52 |
// J2SE is installed under "Program Files".
|
|
53 |
//
|
|
54 |
System.out.println("This test is disabled on Windows 98.");
|
|
55 |
System.out.println("Bye! Bye!");
|
|
56 |
return;
|
|
57 |
}
|
|
58 |
|
|
59 |
// Get Java Home
|
|
60 |
String javaHome = System.getProperty("java.home");
|
|
61 |
|
|
62 |
// Get test src
|
|
63 |
//
|
|
64 |
String testSrc = System.getProperty("test.src");
|
|
65 |
|
|
66 |
// Get test classes
|
|
67 |
String testClasses = System.getProperty("test.classes");
|
|
68 |
|
|
69 |
// Get boot class path
|
|
70 |
String bootClassPath = System.getProperty("sun.boot.class.path");
|
|
71 |
|
|
72 |
// Build command string
|
|
73 |
String command =
|
|
74 |
javaHome + File.separator + "bin" + File.separator + "java " +
|
|
75 |
" -Xbootclasspath/p:" + bootClassPath +
|
|
76 |
" -classpath " + testClasses +
|
|
77 |
" -Djava.security.manager -Djava.security.policy==" + testSrc +
|
|
78 |
File.separator + "policy -Dtest.classes=" + testClasses +
|
|
79 |
" ImplVersionCommand " + System.getProperty("java.runtime.version");
|
|
80 |
System.out.println("ImplVersionCommand Exec Command = " + command);
|
|
81 |
|
|
82 |
// Exec command
|
|
83 |
Process proc = Runtime.getRuntime().exec(command);
|
|
84 |
new ImplVersionReader(proc, proc.getInputStream()).start();
|
|
85 |
new ImplVersionReader(proc, proc.getErrorStream()).start();
|
|
86 |
int exitValue = proc.waitFor();
|
|
87 |
|
|
88 |
System.out.println("ImplVersionCommand Exit Value = " +
|
|
89 |
exitValue);
|
|
90 |
if (exitValue != 0) {
|
|
91 |
System.out.println("TEST FAILED: Incorrect exit value " +
|
|
92 |
"from ImplVersionCommand");
|
|
93 |
System.exit(exitValue);
|
|
94 |
}
|
|
95 |
// Test OK!
|
|
96 |
System.out.println("Bye! Bye!");
|
|
97 |
} catch (Exception e) {
|
|
98 |
System.out.println("Unexpected exception caught = " + e);
|
|
99 |
e.printStackTrace();
|
|
100 |
System.exit(1);
|
|
101 |
}
|
|
102 |
}
|
|
103 |
}
|