/* * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* * @test * @bug 4008296 4008293 4190090 4193729 4358774 * @summary Check for correct handling of parameters to * XXXXInputStream.read(b, off, len). *
*/
/* check for correct handling of null b */ publicstaticvoid doTest1(InputStream in) throws Exception { byte b[] = null; try {
in.read(b, 0, 32);
} catch (NullPointerException npe) {
System.err.println("SuccessFully completed null b test on " + in); return;
} thrownew RuntimeException(in + " Failed null b test");
}
publicstaticvoid main(String args[]) throws Exception{ /* initialise stuff */
File fn = new File("x.ReadBounds");
FileOutputStream fout = new FileOutputStream(fn); for (int i = 0; i < 32; i++) {
fout.write(i);
}
fout.close();
byte b[] = newbyte[64]; for(int i = 0; i < 64; i++) {
b[i] = 1;
}
/* test all input streams */
FileInputStream fis = new FileInputStream(fn);
doTest(fis);
doTest1(fis);
fis.close();
BufferedInputStream bis = new BufferedInputStream(new MyInputStream(1024));
doTest(bis);
doTest1(bis);
bis.close();
ByteArrayInputStream bais = new ByteArrayInputStream(b);
doTest(bais);
doTest1(bais);
bais.close();
FileOutputStream fos = new FileOutputStream(fn);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeInt(12345);
oos.writeObject("Today");
oos.writeObject(new Integer(32));
oos.close();
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fn));
doTest(ois);
doTest1(ois);
ois.close();
DataInputStream dis = new DataInputStream(new MyInputStream(1024));
doTest(dis);
doTest1(dis);
dis.close();
LineNumberInputStream lis = new LineNumberInputStream(new MyInputStream(1024));
doTest(lis);
doTest1(lis);
lis.close();
PipedOutputStream pos = new PipedOutputStream();
PipedInputStream pis = new PipedInputStream();
pos.connect(pis);
pos.write(b, 0, 64);
doTest(pis);
doTest1(pis);
pis.close();
PushbackInputStream pbis = new PushbackInputStream(new MyInputStream(1024));
doTest(pbis);
doTest1(pbis);
pbis.close();
StringBufferInputStream sbis = new StringBufferInputStream(new String(b));
doTest(sbis);
doTest1(sbis);
sbis.close();
SequenceInputStream sis = new SequenceInputStream(new MyInputStream(1024), new MyInputStream(1024));
doTest(sis);
doTest1(sis);
sis.close();
ZipInputStream zis = new ZipInputStream(new FileInputStream(fn));
doTest(zis);
doTest1(zis);
zis.close();
byte[] data = newbyte[256];
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DeflaterOutputStream dos = new DeflaterOutputStream(bos);
dos.write(data, 0, data.length);
dos.close();
InflaterInputStream ifs = new InflaterInputStream
(new ByteArrayInputStream(bos.toByteArray()));
doTest(ifs);
doTest1(ifs);
ifs.close();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.