/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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 5085148 4143651
* @summary Test if Reader methods will check if the stream
* has been closed.
*/
public enum OpsAfterClose {
try {
r.read();
} catch (IOException io) {
return true;
}
return false;
} },
try {
char buf[] = new char[2];
int len = 1;
} catch (IOException io) {
return true;
}
return false;
} },
try {
r.ready();
} catch (IOException io) {
return true;
}
return false;
} },
try {
r.mark(1);
} catch (IOException io) {
return true;
}
return false;
} },
try {
r.skip(1);
} catch (IOException io) {
return true;
}
return false;
} },
try {
r.reset();
} catch (IOException io) {
return true;
}
return false;
} },
try {
r.close();
} catch (IOException io) {
return false;
}
return true;
} };
boolean failed = false;
new StringReader("abc def ghi"));
if (testReader(br)) {
failed = true;
}
if (testReader(car)) {
failed = true;
}
new CharArrayReader(new char[2]));
if (testReader(pbr)) {
failed = true;
}
if (testPushbackReader(pbr)) {
failed = true;
}
if (testReader(sr)) {
failed = true;
}
if (testReader(isr)) {
failed = true;
}
new StringReader("abc def ghi"));
if (testReader(lnr)) {
failed = true;
}
"NewFile");
f.createNewFile();
f.deleteOnExit();
if (testReader(fr)) {
failed = true;
}
if (testReader(pr)) {
failed = true;
}
if (failed) {
throw new Exception("Test failed for some of the operation{s}" +
" on some of the reader{s}, check the messages");
}
}
r.close();
boolean failed = false;
boolean result;
if (!result) {
failed = true;
}
}
if (failed) {
" above for the Reader:" + r);
}
return failed;
}
throws Exception {
boolean failed = false;
try {
failed = true;
} catch (IOException io) {
}
char buf[] = new char[2];
try {
pr);
failed = true;
} catch (IOException io) {
}
try {
failed = true;
} catch (IOException io) {
}
return failed;
}
}