You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2001/09/02 15:34:08 UTC
cvs commit: xml-axis/java/test/functional TestTransportSample.java
gdaniels 01/09/02 06:34:08
Modified: java/samples/transport FileReader.java FileSender.java
java/test/functional TestTransportSample.java
Log:
Fix file transport sample, and reintroduce doTestIBM functional test.
Revision Changes Path
1.15 +6 -3 xml-axis/java/samples/transport/FileReader.java
Index: FileReader.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/transport/FileReader.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- FileReader.java 2001/08/29 14:17:14 1.14
+++ FileReader.java 2001/09/02 13:34:08 1.15
@@ -91,9 +91,15 @@
Thread.sleep( 100 ); // let the other side finish writing
FileInputStream fis = new FileInputStream( file );
+
int thisNum = nextNum++; // increment early to avoid infinite loops
Message msg = new Message( fis );
+ msg.getAsBytes();
+
+ fis.close();
+ file.delete();
+
MessageContext msgContext = new MessageContext(server);
msgContext.setRequestMessage( msg );
@@ -112,9 +118,6 @@
FileOutputStream fos = new FileOutputStream( "xml" + thisNum + ".res" );
fos.write( buf );
fos.close();
-
- fis.close();
- file.delete();
}
catch( Exception e ) {
if ( !(e instanceof FileNotFoundException) )
1.7 +9 -9 xml-axis/java/samples/transport/FileSender.java
Index: FileSender.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/transport/FileSender.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FileSender.java 2001/09/02 05:39:08 1.6
+++ FileSender.java 2001/09/02 13:34:08 1.7
@@ -81,6 +81,7 @@
public void invoke(MessageContext msgContext) throws AxisFault {
Message msg = msgContext.getRequestMessage();
byte[] buf = (byte[]) msg.getAsBytes();
+ boolean timedOut = false;
try {
FileOutputStream fos = new FileOutputStream( "xml" + nextNum + ".req" );
@@ -90,18 +91,18 @@
catch( Exception e ) {
e.printStackTrace();
}
-
+
long timeout = Long.MAX_VALUE;
- if (msgContext.getTimeout()!=0)
+ if (msgContext.getTimeout()!=0)
timeout=(new Date()).getTime()+msgContext.getTimeout();
- for (;;) {
+ for (; timedOut == false;) {
try {
Thread.sleep( 100 );
File file = new File( "xml" + nextNum + ".res" );
if ((new Date().getTime())>=timeout)
- throw new AxisFault("timeout");
+ timedOut = true;
if ( !file.exists() ) continue ;
Thread.sleep( 100 ); // let the other side finish writing
@@ -109,20 +110,19 @@
msg = new Message( fis );
msg.getAsBytes(); // just flush the buffer
fis.close();
- Thread.sleep( 100 );
+ Thread.sleep( 100 );
(new File("xml" + nextNum + ".res")).delete();
msgContext.setResponseMessage( msg );
break ;
}
catch( Exception e ) {
- if ((new Date().getTime())>=timeout)
- throw new AxisFault("timeout");
-
// File not there - just loop
}
-
}
nextNum++ ;
+ if (timedOut)
+ throw new AxisFault("timeout");
+
}
public void undo(MessageContext msgContext) {
1.10 +0 -7 xml-axis/java/test/functional/TestTransportSample.java
Index: TestTransportSample.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/functional/TestTransportSample.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TestTransportSample.java 2001/09/02 04:04:22 1.9
+++ TestTransportSample.java 2001/09/02 13:34:08 1.10
@@ -124,15 +124,8 @@
doTestClientDeploy();
System.out.println("Testing deployment...");
doTestDeploy();
-/* Removing this for now. xmltoday is down at present, and my build was
- therefore hanging. If you add it back in, PLEASE make sure that timeouts
- on the Document.parse() from the xmltoday URL in StockQuoteSample are
- handled somehow, and that a timeout does not indicate a failed test
- with this example. --Glen
-
System.out.println("Testing service with symbol IBM...");
doTestIBM();
-*/
System.out.println("Testing service with symbol XXX...");
doTestXXX();
System.out.println("Test complete.");