2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0.
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package gov.nasa.jpf.test.java.io;
20 import gov.nasa.jpf.util.test.TestJPF;
22 import java.io.BufferedInputStream;
24 import java.io.FileInputStream;
25 import java.io.FileOutputStream;
27 import org.junit.After;
28 import org.junit.Before;
29 import org.junit.Test;
32 * raw test for java.io.BufferedInputStream
34 public class BufferedInputStreamTest extends TestJPF {
38 System.out.println("setUp() creating test file");
43 public void tearDown() {
44 System.out.println("setUp() deleting test file");
48 public static void createTestFile() {
50 FileOutputStream fo = new FileOutputStream(testFile);
53 } catch (Throwable t) {
54 throw new RuntimeException("failed to create test file", t);
58 public static void deleteTestFile() {
59 if (testFile.exists()) {
65 static File testFile = new File("__test__");
66 static final byte[] TEST_DATA = {42, 42, 42};
69 public void testSimpleRead() {
70 if (verifyNoPropertyViolation()) {
72 FileInputStream fis = new FileInputStream(testFile);
73 BufferedInputStream bis = new BufferedInputStream(fis);
74 int n = bis.available();
76 assert n == TEST_DATA.length : "wrong available count: " + n;
78 for (int i = 0; i < n; i++) {
81 System.out.print(',');
82 assert d == TEST_DATA[i] : "wrong read data";
88 } catch (Throwable t) {
89 assert false : "BufferedInputStream test failed: " + t;