Skip to content

Commit

Permalink
Formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-philippe-martin committed May 8, 2017
1 parent c62ddf1 commit ad3cbe5
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class CloudStorageReadTest {
+ "The Heart-ache, and the thousand Natural shocks\n"
+ "That Flesh is heir to? 'Tis a consummation\n";

// large enough value that we write more than one "chunk", for interesting behavior.
// Large enough value that we write more than one "chunk", for interesting behavior.
private static final int repeat = 10000;

@Rule
Expand All @@ -74,17 +74,18 @@ public void testInputStreamReads() throws IOException, InterruptedException {

try (InputStream is = Files.newInputStream(p)) {
byte[] buf = new byte[bytes.length];
for (int i=0; i < repeat; i++) {
for (int i = 0; i < repeat; i++) {
Arrays.fill(buf, (byte) 0);
for (int off=0; off < bytes.length;) {
for (int off = 0; off < bytes.length;) {
int delta = is.read(buf, off, bytes.length - off);
if (delta < 0) {
// EOF
break;
}
off += delta;
}
assertWithMessage("Wrong bytes from input stream at repeat " + i).that(new String(buf, UTF_8)).isEqualTo(ALONE);
assertWithMessage("Wrong bytes from input stream at repeat " + i)
.that(new String(buf, UTF_8)).isEqualTo(ALONE);
}
// reading past the end
int eof = is.read(buf, 0, 1);
Expand All @@ -102,7 +103,7 @@ public void testChannelReads() throws IOException, InterruptedException {

try (SeekableByteChannel chan = Files.newByteChannel(p, StandardOpenOption.READ)) {
ByteBuffer buf = ByteBuffer.allocate(bytes.length);
for (int i=0; i < repeat; i++) {
for (int i = 0; i < repeat; i++) {
buf.clear();
for (int off = 0; off < bytes.length;) {
int read = chan.read(buf);
Expand All @@ -112,7 +113,8 @@ public void testChannelReads() throws IOException, InterruptedException {
}
off += read;
}
assertWithMessage("Wrong bytes from channel at repeat " + i).that(new String(buf.array(), UTF_8)).isEqualTo(ALONE);
assertWithMessage("Wrong bytes from channel at repeat " + i)
.that(new String(buf.array(), UTF_8)).isEqualTo(ALONE);
}
// reading past the end
buf.clear();
Expand All @@ -125,7 +127,7 @@ public void testChannelReads() throws IOException, InterruptedException {
private Path fillFile(FileSystem fs, byte[] bytes, int repeat) throws IOException {
Path p = fs.getPath("/alone");
try (OutputStream os = Files.newOutputStream(p)) {
for (int i=0; i<repeat; i++) {
for (int i = 0; i < repeat; i++) {
os.write(bytes);
}
}
Expand Down

0 comments on commit ad3cbe5

Please sign in to comment.