PR target/27599
[official-gcc.git] / libjava / classpath / test / java.io / SequenceInputStreamTest.java
blob7b2c916443e22da383f14069f9521fd3e32df59f
1 /*************************************************************************
2 /* SequenceInputStreamTest.java -- Tests SequenceInputStream's
3 /*
4 /* Copyright (c) 1998 Free Software Foundation, Inc.
5 /* Written by Aaron M. Renn (arenn@urbanophile.com)
6 /*
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 /*************************************************************************/
22 import java.io.*;
24 public class SequenceInputStreamTest
27 public static void
28 main(String argv[])
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");
41 try
43 StringBufferInputStream is1 = new StringBufferInputStream(str1);
44 ByteArrayInputStream is2 = new ByteArrayInputStream(str2.getBytes());
45 SequenceInputStream sis = new SequenceInputStream(is1, is2);
47 int bytes_read;
48 while((bytes_read = sis.read(buf)) != -1)
50 System.out.print(new String(buf,0,bytes_read));
53 sis.close();
54 System.out.println("PASSED: Simple read test");
56 catch(IOException e)
58 System.out.println("FAILED: Simple read test: " + e);
61 System.out.println("Test 2: close() test");
63 try
65 StringBufferInputStream is1 = new StringBufferInputStream(str1);
66 ByteArrayInputStream is2 = new ByteArrayInputStream(str2.getBytes());
67 SequenceInputStream sis = new SequenceInputStream(is1, is2);
69 sis.read(buf);
70 sis.close();
71 if (sis.read() != -1)
72 System.out.println("FAILED: close() test");
73 else
74 System.out.println("PASSED: close() test");
76 catch(IOException e)
78 System.out.println("FAILED: close() test: " + e);
81 System.out.println("Finished test of SequenceInputStream");
84 } // class SequenceInputStream