author | mchung |
Thu, 28 May 2015 10:54:48 -0700 | |
changeset 30820 | 0d4717a011d3 |
parent 14778 | 5947768d173d |
child 37681 | b1a0f119f766 |
permissions | -rw-r--r-- |
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
1 |
/* |
13256 | 2 |
* Copyright (c) 1999, 2012, 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 |
/* @test |
|
25 |
* |
|
26 |
* @summary HttpSocket functionality test |
|
27 |
* @author Dana Burns |
|
28 |
* |
|
29 |
* @library ../../testlibrary |
|
30820 | 30 |
* @modules java.rmi/sun.rmi.registry |
31 |
* java.rmi/sun.rmi.server |
|
32 |
* java.rmi/sun.rmi.transport |
|
33 |
* java.rmi/sun.rmi.transport.proxy |
|
34 |
* java.rmi/sun.rmi.transport.tcp |
|
14778 | 35 |
* @build TestLibrary HttpSocketTest HttpSocketTest_Stub |
2 | 36 |
* @run main/othervm/policy=security.policy HttpSocketTest |
37 |
*/ |
|
38 |
||
39 |
/* |
|
40 |
* This test assures remote methods can be carried out over RMI. |
|
41 |
* After setting the RMI runtime socket factory to the http proxy version, |
|
42 |
* a registry is created, a remote object (an instance of this class) is |
|
43 |
* registered with it, and then it is exercised. |
|
44 |
*/ |
|
45 |
||
46 |
import java.rmi.Remote; |
|
47 |
import java.rmi.RemoteException; |
|
48 |
import java.rmi.Naming; |
|
49 |
import java.rmi.RMISecurityManager; |
|
50 |
import java.rmi.registry.LocateRegistry; |
|
51 |
import java.rmi.registry.Registry; |
|
52 |
import java.rmi.server.RMISocketFactory; |
|
53 |
import java.rmi.server.UnicastRemoteObject; |
|
54 |
import sun.rmi.transport.proxy.RMIHttpToPortSocketFactory; |
|
55 |
||
56 |
interface MyRemoteInterface extends Remote { |
|
57 |
void setRemoteObject( Remote r ) throws RemoteException; |
|
58 |
Remote getRemoteObject() throws RemoteException; |
|
59 |
} |
|
60 |
||
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
61 |
public class HttpSocketTest extends UnicastRemoteObject |
2 | 62 |
implements MyRemoteInterface |
63 |
{ |
|
64 |
private static final String NAME = "HttpSocketTest"; |
|
65 |
||
66 |
public HttpSocketTest() throws RemoteException{} |
|
67 |
||
68 |
private Remote ro; |
|
69 |
||
70 |
public static void main(String[] args) |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
71 |
throws Exception |
2 | 72 |
{ |
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
73 |
|
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
74 |
Registry registry = null; |
2 | 75 |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
76 |
TestLibrary.suggestSecurityManager(null); |
2 | 77 |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
78 |
// Set the socket factory. |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
79 |
System.err.println("installing socket factory"); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
80 |
RMISocketFactory.setSocketFactory(new RMIHttpToPortSocketFactory()); |
13256 | 81 |
int registryPort = -1; |
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
82 |
|
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
83 |
try { |
2 | 84 |
System.err.println("Starting registry"); |
13256 | 85 |
registry = TestLibrary.createRegistryOnUnusedPort(); |
86 |
registryPort = TestLibrary.getRegistryPort(registry); |
|
2 | 87 |
} catch (Exception e) { |
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
88 |
TestLibrary.bomb(e); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
89 |
} |
2 | 90 |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
91 |
try { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
92 |
registry.rebind( NAME, new HttpSocketTest() ); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
93 |
MyRemoteInterface httpTest = |
13256 | 94 |
(MyRemoteInterface)Naming.lookup("//:" + registryPort + "/" + NAME); |
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
95 |
httpTest.setRemoteObject( new HttpSocketTest() ); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
96 |
Remote r = httpTest.getRemoteObject(); |
2 | 97 |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
98 |
} catch (Exception e) { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
99 |
TestLibrary.bomb(e); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
100 |
} |
2 | 101 |
|
102 |
||
103 |
} |
|
104 |
||
105 |
public void setRemoteObject( Remote ro ) throws RemoteException { |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
106 |
this.ro = ro; |
2 | 107 |
} |
108 |
||
109 |
public Remote getRemoteObject() throws RemoteException { |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
110 |
return( this.ro ); |
2 | 111 |
} |
112 |
||
113 |
} |