author | psomashe |
Fri, 09 Feb 2018 09:56:05 -0800 | |
changeset 48952 | e999964446d7 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
43706
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
1 |
/* |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
4 |
* |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
8 |
* |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
13 |
* accompanied this code). |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
14 |
* |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
18 |
* |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
21 |
* questions. |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
22 |
*/ |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
23 |
|
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
24 |
import java.io.BufferedWriter; |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
25 |
import java.io.FileWriter; |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
26 |
import java.io.IOException; |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
27 |
import java.io.PrintWriter; |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
28 |
|
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
29 |
import org.omg.CORBA.ORB; |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
30 |
|
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
31 |
/* |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
32 |
* @test |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
33 |
* @bug 8049375 |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
34 |
* @summary Extend how the org.omg.CORBA.ORB handles the search for orb.properties |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
35 |
* @library /lib/testlibrary |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
36 |
* @build jdk.testlibrary.* |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
37 |
* @modules java.corba |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
38 |
* @compile OrbPropertiesTest.java TestOrbImpl.java TestSingletonOrbImpl.java |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
39 |
* @run main/othervm |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
40 |
* -Djava.naming.provider.url=iiop://localhost:1050 |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
41 |
* -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
42 |
* OrbPropertiesTest -port 1049 |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
43 |
* @run main/othervm/secure=java.lang.SecurityManager/policy=jtreg.test.policy |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
44 |
* -Djava.naming.provider.url=iiop://localhost:3050 |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
45 |
* -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
46 |
* OrbPropertiesTest -port 3049 |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
47 |
*/ |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
48 |
public class OrbPropertiesTest { |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
49 |
|
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
50 |
public static void main(String[] args) throws Exception { |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
51 |
updateOrbPropertiesFile(); |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
52 |
// create and initialize the ORB |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
53 |
ORB orb = ORB.init(args, null); |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
54 |
if (!(orb instanceof TestOrbImpl)) { |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
55 |
throw new RuntimeException("org.omg.CORBA.ORBClass property not set as expected"); |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
56 |
} |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
57 |
ORB singletonOrb = ORB.init(); |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
58 |
System.out.println("singletonOrb class == " + singletonOrb.getClass().getName()); |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
59 |
if (!(singletonOrb instanceof TestSingletonOrbImpl)) { |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
60 |
throw new RuntimeException("org.omg.CORBA.ORBSingletonClass property not set as expected"); |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
61 |
} |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
62 |
|
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
63 |
} |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
64 |
|
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
65 |
private static void updateOrbPropertiesFile() throws Exception { |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
66 |
String orbPropertiesFile = System.getProperty("java.home", ".") + "/conf/orb.properties"; |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
67 |
String orbClassMapping = "org.omg.CORBA.ORBClass TestOrbImpl"; |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
68 |
String orbSingletonClassMapping = "org.omg.CORBA.ORBSingletonClass TestSingletonOrbImpl"; |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
69 |
String orbPropertiesMappings = orbClassMapping + "\n" + orbSingletonClassMapping +"\n"; |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
70 |
try (PrintWriter hfPWriter = new PrintWriter(new BufferedWriter( |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
71 |
new FileWriter(orbPropertiesFile, false)))) { |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
72 |
hfPWriter.println(orbPropertiesMappings); |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
73 |
} catch (IOException ioEx) { |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
74 |
ioEx.printStackTrace(); |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
75 |
throw ioEx; |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
76 |
} |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
77 |
} |
cc2552ae2866
8049375: Extend how the org.omg.CORBA.ORB handles the search for orb.properties
msheppar
parents:
diff
changeset
|
78 |
} |