Code example for Inflater

Methods: needsInput, reset, setInput

0
    /** 
     * @tests java.util.zip.Inflater#needsDictionary() 
     */ 
    @TestTargetNew( 
        level = TestLevel.COMPLETE, 
        notes = "", 
        method = "needsDictionary", 
        args = {} 
    ) 
    public void test_needsDictionary() { 
        // test method of java.util.zip.inflater.needsDictionary() 
        // note: this flag is set after inflate is called 
        byte outPutInf[] = new byte[500];
 
        // testing with dictionary set. 
        Inflater inflateDiction = new Inflater();
        if (inflateDiction.needsInput()) {
            inflateDiction.setInput(outPutDiction);
        } 
        try { 
            assertEquals("should return 0 because needs dictionary", 0,
                    inflateDiction.inflate(outPutInf));
        } catch (DataFormatException e) {
            fail("Should not cause exception");
        } 
        assertTrue(
                "method needsDictionary returned false when dictionary was used in deflater",