test/java/util/zip/ConstructDeflaterInput.java

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @bug 4679743
  27  * @summary Test parts of DeflaterInputStream code that don't really do I/O.
  28  */
  29 
  30 import java.io.*;
  31 import java.util.zip.*;
  32 
  33 public class ConstructDeflaterInput {
  34 
  35     static class MyDeflater extends Deflater {
  36         private boolean ended = false;
  37         boolean getEnded() { return ended; }
  38         public void end() {
  39             fail("MyDeflater had end() called");
  40             super.end();
  41         }
  42     }
  43 

  44     public static void realMain(String[] args) throws Throwable {
  45         ByteArrayInputStream bais = new ByteArrayInputStream(
  46             "hello, world".getBytes());
  47         MyDeflater def = new MyDeflater();
  48         DeflaterInputStream dis = null;
  49         byte[] b = new byte[512];
  50 
  51         // Check construction
  52         //
  53         try {
  54             dis = new DeflaterInputStream(null);
  55             fail();
  56         } catch (NullPointerException ex) {
  57             pass();
  58         }
  59 
  60         try {
  61             dis = new DeflaterInputStream(bais, null);
  62             fail();
  63         } catch (NullPointerException ex) {
  64             pass();
  65         }
  66 
  67         try {




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @bug 4679743 8148624
  27  * @summary Test parts of DeflaterInputStream code that don't really do I/O.
  28  */
  29 
  30 import java.io.*;
  31 import java.util.zip.*;
  32 
  33 public class ConstructDeflaterInput {
  34 
  35     static class MyDeflater extends Deflater {
  36         private boolean ended = false;
  37         boolean getEnded() { return ended; }
  38         public void end() {
  39             fail("MyDeflater had end() called");
  40             super.end();
  41         }
  42     }
  43 
  44     private static MyDeflater def = new MyDeflater();
  45     public static void realMain(String[] args) throws Throwable {
  46         ByteArrayInputStream bais = new ByteArrayInputStream(
  47             "hello, world".getBytes());

  48         DeflaterInputStream dis = null;
  49         byte[] b = new byte[512];
  50 
  51         // Check construction
  52         //
  53         try {
  54             dis = new DeflaterInputStream(null);
  55             fail();
  56         } catch (NullPointerException ex) {
  57             pass();
  58         }
  59 
  60         try {
  61             dis = new DeflaterInputStream(bais, null);
  62             fail();
  63         } catch (NullPointerException ex) {
  64             pass();
  65         }
  66 
  67         try {