File: PipedTestWriter.java

package info (click to toggle)
mauve 20080616-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 26,856 kB
  • ctags: 21,952
  • sloc: java: 234,107; sh: 2,834; xml: 208; makefile: 59
file content (71 lines) | stat: -rw-r--r-- 1,412 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Tags: not-a-test

package gnu.testlet.java.io.PipedReaderWriter;
import gnu.testlet.TestHarness;
import java.io.*;

class PipedTestWriter implements Runnable
{

String str;
StringReader sbr;
PipedWriter out;
TestHarness harness;

public
PipedTestWriter(TestHarness harness)
{
  this.harness = harness;

  str = "In college, there was a tradition going for a while that people\n" +
    "would get together and hang out at Showalter Fountain - in the center\n" +
    "of Indiana University's campus - around midnight.  It was mostly folks\n" +
    "from the computer lab and just people who liked to use the Forum\n" +
    "bbs system on the VAX.  IU pulled the plug on the Forum after I left\n" +
    "despite its huge popularity.  Now they claim they are just giving\n" +
    "students what they want by cutting deals to make the campus all\n" +
    "Microsoft.\n";

  sbr = new StringReader(str);

  out = new PipedWriter();
}

public PipedWriter
getWriter()
{
  return(out);
}

public String
getStr()
{
  return(str);
}

public void
run() 
{
  char[] buf = new char[32];

  int chars_read;

  try
    {
      int b = sbr.read();
      out.write(b);

      while ((chars_read = sbr.read(buf)) != -1)
        out.write(buf, 0, chars_read);
	  out.flush();
      out.close();
    }
  catch(IOException e)
    {
      harness.debug("In Writer: " + e);
      harness.check(false);
    }
}

} // PipedTestWriter