question: public void testIsWeak ( ) { try { DESKeySpec . isWeak ( null , 1 ) ; fail ( "Should raise an InvalidKeyException " + "in case of null byte array." ) ; } catch ( NullPointerException e ) { fail ( "Unexpected NullPointerException was thrown." ) ; } catch ( InvalidKeyException e ) { } byte [ ] key = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } ; try { DESKeySpec . isWeak ( key , 1 ) ; fail ( "Should raise an InvalidKeyException " + "in case of short byte array." ) ; } catch ( NullPointerException e ) { fail ( "Unexpected NullPointerException was thrown." ) ; } catch ( InvalidKeyException e ) { } for ( int i = 0 ; i < semiweaks . length ; i ++ ) { try { assertTrue ( "Method returns false when true is expected" , DESKeySpec . isWeak ( semiweaks [ i ] , 0 ) ) ; } catch ( InvalidKeyException e ) { fail ( "Unexpected InvalidKeyException was thrown." ) ; } } for ( int i = 0 ; i < notsemiweaks . length ; i ++ ) { try { assertFalse ( "Method returns true when false is expected" , DESKeySpec . isWeak ( notsemiweaks [ i ] , 0 ) ) ; } catch ( InvalidKeyException e ) { fail ( "Unexpected InvalidKeyException was thrown." ) ; } } }
target:  isWeak(byte[] key, int offset) method testing. Tests if the method throws appropriate exceptions on incorrect byte array, if it returns true on weak or semi-weak keys, and if it returns false on other keys.