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