1
package org.jboss.test.remoting.transport.socket.raw;
3
import junit.framework.TestCase;
5
import java.io.BufferedInputStream;
6
import java.io.BufferedOutputStream;
7
import java.io.IOException;
8
import java.io.InputStream;
9
import java.io.ObjectInputStream;
10
import java.io.ObjectOutputStream;
11
import java.io.OutputStream;
12
import java.net.Socket;
14
import org.jboss.remoting.Version;
17
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
19
public class RawTestClient extends TestCase
21
protected String address = "localhost";
22
protected int port = 6700;
24
public boolean enableTcpNoDelay = false;
25
public int timeout = 60000;
27
private Socket socket = null;
29
private OutputStream out;
30
private InputStream in;
31
private ObjectOutputStream oos;
32
private ObjectInputStream objInputStream;
34
public void testRawInvocation()
40
public void makeRawInvocation()
42
// In response to JBREM-692 (Let marshallers/unmarshallers construct
43
// their preferred streams.), some changes are necessary to make this
44
// test work. SerializableMarshaller and SerializableUnMarshaller now
45
// implement the method getMarshallingStream(), which allows
46
// ClientSocketWrapper and ServerSocketWrapper to get object streams
47
// when they are created and cache them for future use, instead of
48
// recreating them with each invocation.
56
oos.write(Version.getDefaultVersion());
60
// oos = new ObjectOutputStream(out);
62
oos.writeObject("This is the request");
66
// objInputStream = new ObjectInputStream(in);
67
Object obj = objInputStream.readObject();
68
System.out.println("response: " + obj);
69
assertEquals(RawTestServer.RESPONSE, obj);
70
System.out.println("PASSED");
77
catch(ClassNotFoundException e)
85
public void getSocket() throws IOException
91
socket = new Socket(address, port);
92
socket.setTcpNoDelay(enableTcpNoDelay);
93
// socket.setSoTimeout(timeout);
95
out = new BufferedOutputStream(socket.getOutputStream());
96
in = new BufferedInputStream(socket.getInputStream());
97
oos = new ObjectOutputStream(out);
98
objInputStream = new ObjectInputStream(in);
111
// objInputStream.readByte();
112
// objInputStream.reset();
116
public static void main(String[] args)
118
RawTestClient client = new RawTestClient();
119
client.testRawInvocation();