1 package org.apache.commons.jcs3.auxiliary.remote.server;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.IOException;
23 import java.io.Serializable;
24 import java.net.InetSocketAddress;
25 import java.net.ServerSocket;
26 import java.net.Socket;
27 import java.rmi.server.RMISocketFactory;
28
29
30 public class MockRMISocketFactory
31 extends RMISocketFactory
32 implements Serializable
33 {
34
35 private static final long serialVersionUID = 1056199478581218676L;
36
37
38 private String testStringProperty;
39
40
41
42
43
44
45
46 @Override
47 public Socket createSocket( final String host, final int port )
48 throws IOException
49 {
50
51
52 final Socket socket = new Socket();
53 socket.setSoTimeout( 1000 );
54 socket.setSoLinger( false, 0 );
55 socket.connect( new InetSocketAddress( host, port ), 1000 );
56 return socket;
57 }
58
59
60
61
62
63
64 @Override
65 public ServerSocket createServerSocket( final int port )
66 throws IOException
67 {
68
69
70 return new ServerSocket( port );
71 }
72
73
74
75
76 public void setTestStringProperty( final String testStringProperty )
77 {
78 this.testStringProperty = testStringProperty;
79 }
80
81
82
83
84 public String getTestStringProperty()
85 {
86 return testStringProperty;
87 }
88 }