1 /*************************************************************************
2 /* SequenceInputStreamTest.java -- Tests SequenceInputStream's
4 /* Copyright (c) 1998 Free Software Foundation, Inc.
5 /* Written by Aaron M. Renn (arenn@urbanophile.com)
7 /* This program is free software; you can redistribute it and/or modify
8 /* it under the terms of the GNU General Public License as published
9 /* by the Free Software Foundation, either version 2 of the License, or
10 /* (at your option) any later version.
12 /* This program is distributed in the hope that it will be useful, but
13 /* WITHOUT ANY WARRANTY; without even the implied warranty of
14 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 /* GNU General Public License for more details.
17 /* You should have received a copy of the GNU General Public License
18 /* along with this program; if not, write to the Free Software Foundation
19 /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 /*************************************************************************/
24 public class SequenceInputStreamTest
30 System
.out
.println("Started test of SequenceInputStream");
32 String str1
= "I don't believe in going to chain restaurants. I think\n" +
33 "they are evil. I can't believe all the suburban folks who go to \n";
35 String str2
= "places like the Olive Garden. Not only does the food make\n" +
36 "me want to puke, non of these chains has the slightest bit of character.\n";
38 byte[] buf
= new byte[10];
40 System
.out
.println("Test 1: Simple read test");
43 StringBufferInputStream is1
= new StringBufferInputStream(str1
);
44 ByteArrayInputStream is2
= new ByteArrayInputStream(str2
.getBytes());
45 SequenceInputStream sis
= new SequenceInputStream(is1
, is2
);
48 while((bytes_read
= sis
.read(buf
)) != -1)
50 System
.out
.print(new String(buf
,0,bytes_read
));
54 System
.out
.println("PASSED: Simple read test");
58 System
.out
.println("FAILED: Simple read test: " + e
);
61 System
.out
.println("Test 2: close() test");
65 StringBufferInputStream is1
= new StringBufferInputStream(str1
);
66 ByteArrayInputStream is2
= new ByteArrayInputStream(str2
.getBytes());
67 SequenceInputStream sis
= new SequenceInputStream(is1
, is2
);
72 System
.out
.println("FAILED: close() test");
74 System
.out
.println("PASSED: close() test");
78 System
.out
.println("FAILED: close() test: " + e
);
81 System
.out
.println("Finished test of SequenceInputStream");
84 } // class SequenceInputStream