You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2018/01/05 10:58:07 UTC

[2/2] commons-compress git commit: fix indentation

fix indentation


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/334f1de9
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/334f1de9
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/334f1de9

Branch: refs/heads/COMPRESS-380
Commit: 334f1de9a3efa31303c2788c209d249d7b33d3aa
Parents: f4b7501
Author: Stefan Bodewig <bo...@apache.org>
Authored: Fri Jan 5 11:57:51 2018 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Fri Jan 5 11:57:51 2018 +0100

----------------------------------------------------------------------
 .../Deflate64CompressorInputStreamTest.java     | 246 +++++++++----------
 1 file changed, 117 insertions(+), 129 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/334f1de9/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64CompressorInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64CompressorInputStreamTest.java b/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64CompressorInputStreamTest.java
index b7b3cd9..3526224 100644
--- a/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64CompressorInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/compressors/deflate64/Deflate64CompressorInputStreamTest.java
@@ -34,134 +34,122 @@ import static org.mockito.Mockito.times;
 
 @RunWith(MockitoJUnitRunner.class)
 public class Deflate64CompressorInputStreamTest {
-   private final HuffmanDecoder nullDecoder = null;
-
-   @Mock
-   private HuffmanDecoder decoder;
-
-   @Test
-   public void readWhenClosed() throws Exception
-   {
-      Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(nullDecoder);
-      assertEquals(-1, input.read());
-      assertEquals(-1, input.read(new byte[1]));
-      assertEquals(-1, input.read(new byte[1], 0, 1));
-   }
-
-   @Test
-   public void properSizeWhenClosed() throws Exception
-   {
-      Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(nullDecoder);
-      assertEquals(0, input.available());
-   }
-
-   @Test
-   public void delegatesAvailable() throws Exception
-   {
-      Mockito.when(decoder.available()).thenReturn(1024);
-
-      Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(decoder);
-      assertEquals(1024, input.available());
-   }
-
-   @Test
-   public void closeCallsDecoder() throws Exception
-   {
-
-      Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(decoder);
-      input.close();
-
-      Mockito.verify(decoder, times(1)).close();
-   }
-
-   @Test
-   public void closeIsDelegatedJustOnce() throws Exception
-   {
-
-      Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(decoder);
-
-      input.close();
-      input.close();
-
-      Mockito.verify(decoder, times(1)).close();
-   }
-
-   @Test
-   public void uncompressedBlock() throws Exception
-   {
-      byte[] data = {
-         1, 11, 0, -12, -1,
-         'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'
-      };
-
-      try (Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(new ByteArrayInputStream(data));
-           BufferedReader br = new BufferedReader(new InputStreamReader(input)))
-      {
-         assertEquals("Hello World", br.readLine());
-         assertEquals(null, br.readLine());
-      }
-   }
-
-   @Test
-   public void uncompressedBlockViaFactory() throws Exception
-   {
-      byte[] data = {
-         1, 11, 0, -12, -1,
-         'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'
-      };
-
-      try (InputStream input = new CompressorStreamFactory()
-           .createCompressorInputStream(CompressorStreamFactory.DEFLATE64, new ByteArrayInputStream(data));
-           BufferedReader br = new BufferedReader(new InputStreamReader(input)))
-      {
-         assertEquals("Hello World", br.readLine());
-         assertEquals(null, br.readLine());
-      }
-   }
-
-   @Test
-   public void uncompressedBlockAvailable() throws Exception
-   {
-      byte[] data = {
-         1, 11, 0, -12, -1,
-         'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'
-      };
-
-      try (Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(new ByteArrayInputStream(data))) {
-          assertEquals('H', input.read());
-          assertEquals(10, input.available());
-      }
-   }
-
-   @Test
-   public void streamIgnoresExtraBytesAfterDeflatedInput() throws Exception
-   {
-      byte[] data = {
-         1, 11, 0, -12, -1,
-         'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', 'X'
-      };
-
-      try (Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(new ByteArrayInputStream(data));
-           BufferedReader br = new BufferedReader(new InputStreamReader(input)))
-      {
-         assertEquals("Hello World", br.readLine());
-         assertEquals(null, br.readLine());
-      }
-   }
-
-   @Test(expected = java.io.EOFException.class)
-   public void throwsEOFExceptionOnTruncatedStreams() throws Exception
-   {
-      byte[] data = {
-         1, 11, 0, -12, -1,
-         'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l',
-      };
-
-      try (Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(new ByteArrayInputStream(data));
-           BufferedReader br = new BufferedReader(new InputStreamReader(input)))
-      {
-         assertEquals("Hello World", br.readLine());
-      }
-   }
+    private final HuffmanDecoder nullDecoder = null;
+
+    @Mock
+    private HuffmanDecoder decoder;
+
+    @Test
+    public void readWhenClosed() throws Exception {
+        Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(nullDecoder);
+        assertEquals(-1, input.read());
+        assertEquals(-1, input.read(new byte[1]));
+        assertEquals(-1, input.read(new byte[1], 0, 1));
+    }
+
+    @Test
+    public void properSizeWhenClosed() throws Exception {
+        Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(nullDecoder);
+        assertEquals(0, input.available());
+    }
+
+    @Test
+    public void delegatesAvailable() throws Exception {
+        Mockito.when(decoder.available()).thenReturn(1024);
+
+        Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(decoder);
+        assertEquals(1024, input.available());
+    }
+
+    @Test
+    public void closeCallsDecoder() throws Exception {
+
+        Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(decoder);
+        input.close();
+
+        Mockito.verify(decoder, times(1)).close();
+    }
+
+    @Test
+    public void closeIsDelegatedJustOnce() throws Exception {
+
+        Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(decoder);
+
+        input.close();
+        input.close();
+
+        Mockito.verify(decoder, times(1)).close();
+    }
+
+    @Test
+    public void uncompressedBlock() throws Exception {
+        byte[] data = {
+            1, 11, 0, -12, -1,
+            'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'
+        };
+
+        try (Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(new ByteArrayInputStream(data));
+             BufferedReader br = new BufferedReader(new InputStreamReader(input))) {
+            assertEquals("Hello World", br.readLine());
+            assertEquals(null, br.readLine());
+        }
+    }
+
+    @Test
+    public void uncompressedBlockViaFactory() throws Exception {
+        byte[] data = {
+            1, 11, 0, -12, -1,
+            'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'
+        };
+
+        try (InputStream input = new CompressorStreamFactory()
+             .createCompressorInputStream(CompressorStreamFactory.DEFLATE64, new ByteArrayInputStream(data));
+             BufferedReader br = new BufferedReader(new InputStreamReader(input))) {
+            assertEquals("Hello World", br.readLine());
+            assertEquals(null, br.readLine());
+        }
+    }
+
+    @Test
+    public void uncompressedBlockAvailable() throws Exception {
+        byte[] data = {
+            1, 11, 0, -12, -1,
+            'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'
+        };
+
+        try (Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(new ByteArrayInputStream(data))) {
+            assertEquals('H', input.read());
+            assertEquals(10, input.available());
+        }
+    }
+
+    @Test
+    public void streamIgnoresExtraBytesAfterDeflatedInput() throws Exception
+    {
+        byte[] data = {
+            1, 11, 0, -12, -1,
+            'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', 'X'
+        };
+
+        try (Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(new ByteArrayInputStream(data));
+             BufferedReader br = new BufferedReader(new InputStreamReader(input))) {
+            assertEquals("Hello World", br.readLine());
+            assertEquals(null, br.readLine());
+        }
+    }
+
+    @Test(expected = java.io.EOFException.class)
+    public void throwsEOFExceptionOnTruncatedStreams() throws Exception
+    {
+        byte[] data = {
+            1, 11, 0, -12, -1,
+            'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l',
+        };
+
+        try (Deflate64CompressorInputStream input = new Deflate64CompressorInputStream(new ByteArrayInputStream(data));
+             BufferedReader br = new BufferedReader(new InputStreamReader(input))) {
+            assertEquals("Hello World", br.readLine());
+        }
+    }
 
 }