Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java
38838 views
1
/*
2
* Copyright (c) 2015, Oracle and/or its affiliates. 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 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.
22
*/
23
24
/*
25
* @test
26
* @bug 8068721
27
* @summary test RMI-IIOP call with ConcurrentHashMap as an argument
28
* @library /lib/testlibrary
29
* @build jdk.testlibrary.*
30
* @build Test HelloInterface HelloServer HelloClient HelloImpl _HelloImpl_Tie _HelloInterface_Stub ConcurrentHashMapTest
31
* @run main/othervm -Djava.naming.provider.url=iiop://localhost:1050
32
* -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory ConcurrentHashMapTest
33
* @run main/othervm/secure=java.lang.SecurityManager/policy=jtreg.test.policy
34
* -Djava.naming.provider.url=iiop://localhost:1050
35
* -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory ConcurrentHashMapTest
36
*/
37
38
39
import java.io.DataInputStream;
40
import java.io.File;
41
import java.util.ArrayList;
42
import java.util.Arrays;
43
import java.util.List;
44
import java.util.concurrent.TimeUnit;
45
import java.util.concurrent.CountDownLatch;
46
import jdk.testlibrary.JDKToolFinder;
47
import jdk.testlibrary.JDKToolLauncher;
48
49
public class ConcurrentHashMapTest {
50
51
static final String ORBD = JDKToolFinder.getTestJDKTool("orbd");
52
static final String JAVA = JDKToolFinder.getTestJDKTool("java");
53
static final JDKToolLauncher orbdLauncher = JDKToolLauncher.createUsingTestJDK("orbd");
54
static final String CLASSPATH = System.getProperty("java.class.path");
55
static final int FIVE_SECONDS = 5000;
56
57
private static Exception clientException;
58
private static boolean exceptionInClient;
59
private static Process orbdProcess;
60
private static Process rmiServerProcess;
61
62
public static void main(String[] args) throws Exception {
63
startTestComponents();
64
stopTestComponents();
65
System.err.println("Test completed OK ");
66
}
67
68
static void startTestComponents () throws Exception {
69
startOrbd();
70
Thread.sleep(FIVE_SECONDS);
71
startRmiIiopServer();
72
Thread.sleep(FIVE_SECONDS);
73
executeRmiIiopClient();
74
}
75
76
private static void stopTestComponents() throws Exception {
77
stopRmiIiopServer();
78
stopOrbd();
79
if (exceptionInClient) {
80
throw new RuntimeException(clientException);
81
} else if (!isResponseReceived()) {
82
throw new RuntimeException("Expected Response not received");
83
}
84
}
85
86
static void startOrbd() throws Exception {
87
System.out.println("\nStarting orbd on port 1050 ");
88
89
//orbd -ORBInitialHost localhost -ORBInitialPort 1050
90
orbdLauncher.addToolArg("-ORBInitialHost").addToolArg("localhost")
91
.addToolArg("-ORBInitialPort").addToolArg("1050");
92
93
System.out.println("ConcurrentHashMapTest: Executing: " + Arrays.asList(orbdLauncher.getCommand()));
94
ProcessBuilder pb = new ProcessBuilder(orbdLauncher.getCommand());
95
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
96
orbdProcess = pb.start();
97
}
98
99
100
static void startRmiIiopServer() throws Exception {
101
System.out.println("\nStarting RmiServer");
102
// java -cp .
103
// -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
104
// -Djava.naming.provider.url=iiop://localhost:1050 HelloServer
105
List<String> commands = new ArrayList<>();
106
commands.add(ConcurrentHashMapTest.JAVA);
107
commands.add("-Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory");
108
commands.add("-Djava.naming.provider.url=iiop://localhost:1050");
109
commands.add("-cp");
110
commands.add(ConcurrentHashMapTest.CLASSPATH);
111
commands.add("HelloServer");
112
113
System.out.println("ConcurrentHashMapTest: Executing: " + commands);
114
ProcessBuilder pb = new ProcessBuilder(commands);
115
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
116
rmiServerProcess = pb.start();
117
}
118
119
static boolean isResponseReceived() {
120
return HelloClient.isResponseReceived();
121
}
122
123
static void stopRmiIiopServer() throws Exception {
124
rmiServerProcess.destroy();
125
rmiServerProcess.waitFor();
126
//rmiServerProcess.waitFor(30, TimeUnit.SECONDS);
127
System.out.println("serverProcess exitCode:"
128
+ rmiServerProcess.exitValue());
129
}
130
131
static void stopOrbd() throws Exception {
132
orbdProcess.destroy();
133
orbdProcess.waitFor();
134
//orbdProcess.waitFor(30, TimeUnit.SECONDS);
135
System.out.println("orbd exitCode:"
136
+ orbdProcess.exitValue());
137
}
138
139
static void executeRmiIiopClient() throws Exception {
140
try {
141
HelloClient.executeRmiClientCall();
142
} catch (Exception ex) {
143
clientException = ex;
144
exceptionInClient = true;
145
}
146
}
147
}
148
149