[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [stellation-res] SvcConnectTest: assertion of 'true' and 'true\n'!
|
Hello Florin,
--- Florin Iucha <florin@xxxxxxxxx> wrote:
> The StringTokenizer created at line 61 eats that newline. That
> StringTokenizer breaks the program output in lines.
I found the problem. The newline character ('\n') is defined as a
Line-Feed charachter (ASCII character 10). I suspect that everyone in
the Stellation team except me runs on Unix systems where semantically,
a newline is just an LF, while on Windows it's the combination of CR +
LF (ASCII 13 + ASCII 10). As a result, the StringTokenizer eats the LF
but not the CR. In the attached patch, I replaced the use of
StringTokenizer with a BufferedReader using a StringReader. The
readLine method of BufferedReader is exactly what I needed to get rid
of the CR too.
http://java.sun.com/j2se/1.3/docs/api/java/io/BufferedReader.html#readLine()
The test now works for me on Windows. Can you check if the patch also
runs on Unix systems? Your CVS commit access will probably be activated
by tomorrow, so I'll let you commit it to the CVS.
Cheers,
Ringo
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
Index: IORedirector.java
===================================================================
RCS file: /home/technology/org.eclipse.stellation/plugins/org.eclipse.stellation.unittest/src/org/eclipse/stellation/unittest/IORedirector.java,v
retrieving revision 1.1
diff -u -r1.1 IORedirector.java
--- IORedirector.java 30 Jul 2002 15:34:41 -0000 1.1
+++ IORedirector.java 1 Aug 2002 19:17:27 -0000
@@ -11,19 +11,16 @@
package org.eclipse.stellation.unittest;
+import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
-import java.text.SimpleDateFormat;
-import java.util.Collection;
-import java.util.Date;
-import java.util.StringTokenizer;
+import java.io.StringReader;
import junit.framework.Assert;
-import org.eclipse.stellation.workspace.Svc;
-
public class IORedirector
{
public void setUp() throws Exception
@@ -55,33 +52,39 @@
return programResult_.toString();
}
- public StringTokenizer getProgramOutput()
+ public BufferedReader getProgramOutput()
{
String resultString = getRawProgramOutput();
- StringTokenizer tokenizer = new StringTokenizer(resultString, "\n");
+ BufferedReader tokenizer = new BufferedReader(new StringReader(resultString));
return tokenizer;
}
public void verifyOutput(String[] lines)
{
- StringTokenizer tokenizer = getProgramOutput();
+ try {
+ BufferedReader tokenizer = getProgramOutput();
+ String message = null;
if (lines.length > 0)
{
+ message = tokenizer.readLine();
Assert.assertEquals("There is output",
true,
- tokenizer.hasMoreElements());
+ message != null);
for (int i = 0; i < lines.length; i ++)
{
- String message = (String) tokenizer.nextElement();
Assert.assertEquals("Line " + i + ": ",
lines[i],
message);
+ message = tokenizer.readLine();
}
}
Assert.assertEquals("There is no more output",
- false,
- tokenizer.hasMoreElements());
+ true,
+ message == null);
+ } catch(IOException ioe) {
+ Assert.fail("IOException when parsing output of svc!");
+ }
}
private PrintStream defaultOutputStream_ = null;