You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ha...@apache.org on 2002/08/26 00:43:11 UTC
cvs commit: jakarta-avalon-excalibur/altrmi socketa.xml socketb.xml socketc.xml
hammant 2002/08/25 15:43:11
Modified: altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/stream
CallbackEnabledClientCustomStreamReadWriter.java
Added: altrmi/src/test/org/apache/excalibur/altrmi/test/socket
CallbackEnabledCustomStreamTestCase.java
Removed: altrmi/src/test/org/apache/excalibur/altrmi/test/socket
CustomStreamSocketClientCBTest.java
CustomStreamSocketServerCBTest.java
altrmi socketa.xml socketb.xml socketc.xml
Log:
Call-Back (for speed comparison) now a Unit test.
Revision Changes Path
1.5 +18 -6 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/stream/CallbackEnabledClientCustomStreamReadWriter.java
Index: CallbackEnabledClientCustomStreamReadWriter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/stream/CallbackEnabledClientCustomStreamReadWriter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CallbackEnabledClientCustomStreamReadWriter.java 23 Jun 2002 17:03:53 -0000 1.4
+++ CallbackEnabledClientCustomStreamReadWriter.java 25 Aug 2002 22:43:11 -0000 1.5
@@ -13,6 +13,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.EOFException;
import java.util.HashMap;
import org.apache.excalibur.altrmi.client.impl.stream.ClientStreamReadWriter;
import org.apache.excalibur.altrmi.common.AltrmiCallbackException;
@@ -87,11 +88,15 @@
*/
public void run()
{
+ boolean readingInt = false;
while( !mIsStopped )
{
try
{
+
+ readingInt = true;
int byteArraySize = (int)mDataInputStream.readInt();
+ readingInt = false;
byte[] byteArray = new byte[ byteArraySize ];
mDataInputStream.read( byteArray );
@@ -114,16 +119,23 @@
}
else
{
- //NEVER OCCURS
+ //NEVER OCCURS, or a hack?
}
}
catch( IOException e )
{
- // :-?
- if( e.getClass().getName().equals( "java.net.SocketTimeoutException" ) )
- continue;
- e.printStackTrace();
+ if (e instanceof EOFException && readingInt)
+ {
+ // do nothing, connection closed
+ }
+ else
+ {
+ // :-?
+ if( e.getClass().getName().equals( "java.net.SocketTimeoutException" ) )
+ continue;
+ e.printStackTrace();
+ }
mIsStopped = true;
return;
}
1.1 jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/socket/CallbackEnabledCustomStreamTestCase.java
Index: CallbackEnabledCustomStreamTestCase.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.excalibur.altrmi.test.socket;
import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.callback.socket.CallbackEnabledSocketCustomStreamHostContext;
import org.apache.excalibur.altrmi.client.AltrmiFactory;
import org.apache.excalibur.altrmi.test.TestInterface;
import org.apache.excalibur.altrmi.test.AbstractHelloTestCase;
import org.apache.excalibur.altrmi.test.SimpleHelloTestServerImpl;
import org.apache.excalibur.altrmi.server.impl.callback.socket.CallbackEnabledSocketCustomStreamServer;
/**
* Test Custom Stream over sockets.
* @author Paul Hammant
*/
public class CallbackEnabledCustomStreamTestCase extends AbstractHelloTestCase
{
public CallbackEnabledCustomStreamTestCase(String name)
{
super(name);
}
protected void setUp() throws Exception
{
super.setUp();
// server side setup.
server = new CallbackEnabledSocketCustomStreamServer(10004);
testServer = new SimpleHelloTestServerImpl();
server.publish(testServer, "Hello", TestInterface.class);
server.start();
// Client side setup
AltrmiFactory af = new ClientClassAltrmiFactory(false);
af.setHostContext(new CallbackEnabledSocketCustomStreamHostContext("127.0.0.1", 10004));
testClient = (TestInterface) af.lookup("Hello");
// just a kludge for unit testing given we are intrinsically dealing with
// threads, AltRMI being a client/server thing
Thread.yield();
}
protected void tearDown() throws Exception
{
server.stop();
Thread.yield();
server = null;
testServer = null;
super.tearDown();
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>