@Test public void testDoCryptStuffThrowsNullPointerException() throws Throwable { byte[] data = new byte[4]; try { jCEHandler.doCryptStuff(data, null, 100); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
@Test public void testDoCryptStuffThrowsJCEHandlerException1() throws Throwable { byte[] clearKeyBytes = new byte[1]; Key key = jCEHandler.formDESKey((short) 192, clearKeyBytes); JCEHandler jCEHandler2 = new JCEHandler((Provider) null); byte[] data = new byte[3]; try { jCEHandler2.doCryptStuff(data, key, 100); fail("Expected JCEHandlerException to be thrown"); } catch (JCEHandlerException ex) { assertEquals("ex.getMessage()", "java.lang.NullPointerException", ex.getMessage()); assertNull("ex.getNested().getMessage()", ex.getNested().getMessage()); assertEquals( "(SecretKeySpec) key.getAlgorithm()", "DESede", ((SecretKeySpec) key).getAlgorithm()); } }
@Test public void testDoCryptStuffThrowsJCEHandlerException() throws Throwable { jCEHandler = new JCEHandler((Provider) null); byte[] bytes = new byte[1]; Key key = new SecretKeySpec(bytes, "testJCEHandlerParam2"); byte[] data = new byte[3]; try { jCEHandler.doCryptStuff(data, key, 100); fail("Expected JCEHandlerException to be thrown"); } catch (JCEHandlerException ex) { assertEquals("ex.getMessage()", "java.lang.NullPointerException", ex.getMessage()); assertNull("ex.getNested().getMessage()", ex.getNested().getMessage()); assertEquals( "(SecretKeySpec) key.getAlgorithm()", "testJCEHandlerParam2", ((SecretKeySpec) key).getAlgorithm()); } }