|
1 | 1 | /** |
2 | | - * Copyright 2016 EMC Corporation. All Rights Reserved. |
| 2 | + * Copyright 2016-2017 EMC Corporation. All Rights Reserved. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"). |
5 | 5 | * You may not use this file except in compliance with the License. |
@@ -47,19 +47,27 @@ public void testReadingAndWriting() throws Exception { |
47 | 47 | assertTrue(test.exists()); |
48 | 48 | assertTrue(test.canModify()); |
49 | 49 | assertTrue(test.canRead()); |
50 | | - byte[] expectedData = "some data".getBytes(RpcRequest.CHARSET); |
| 50 | + byte[] expectedData = new byte[] { 1, 2, 3, 127, -1, -128, 0, 1, 32 }; |
51 | 51 | outputStream.write(expectedData); |
52 | 52 | outputStream.close(); |
53 | 53 |
|
54 | 54 | NfsFileInputStream inputStream = new NfsFileInputStream(test); |
55 | | - byte[] buffer = new byte[1000]; |
56 | 55 | assertEquals(expectedData.length, inputStream.available()); |
57 | 56 | int bytesRead = (int) inputStream.skip(expectedData.length); |
58 | 57 | assertEquals(0, inputStream.available()); |
59 | 58 | inputStream.close(); |
60 | 59 |
|
61 | 60 | inputStream = new NfsFileInputStream(test); |
62 | | - buffer = new byte[1000]; |
| 61 | + for (int i = 0; i < expectedData.length; ++i) { |
| 62 | + int nextByte = inputStream.read(); |
| 63 | + assertNotEquals(NfsFileInputStream.EOF, nextByte); |
| 64 | + assertEquals(expectedData[i], (byte) nextByte); |
| 65 | + } |
| 66 | + assertEquals(NfsFileInputStream.EOF, inputStream.read()); |
| 67 | + inputStream.close(); |
| 68 | + |
| 69 | + inputStream = new NfsFileInputStream(test); |
| 70 | + byte[] buffer = new byte[1000]; |
63 | 71 | assertEquals(expectedData.length, inputStream.available()); |
64 | 72 | bytesRead = inputStream.read(buffer); |
65 | 73 | assertEquals(0, inputStream.available()); |
@@ -119,9 +127,8 @@ public void testClosing() throws Exception { |
119 | 127 |
|
120 | 128 | try { |
121 | 129 | outputStream.close(); |
122 | | - fail("This should throw an IOException"); |
123 | 130 | } catch (IOException e) { |
124 | | - // Do nothing, this was expected. |
| 131 | + fail("This should not throw an IOException"); |
125 | 132 | } |
126 | 133 |
|
127 | 134 | try { |
@@ -164,9 +171,8 @@ public void testClosing() throws Exception { |
164 | 171 |
|
165 | 172 | try { |
166 | 173 | inputStream.close(); |
167 | | - fail("This should throw an IOException"); |
168 | 174 | } catch (IOException e) { |
169 | | - // Do nothing, this was expected. |
| 175 | + fail("This should not throw an IOException"); |
170 | 176 | } |
171 | 177 |
|
172 | 178 | try { |
|
0 commit comments