public void testInvalidResp() throws Exception { try { OCSPResp response = new OCSPResp(invalidResp); } catch (CertIOException e) { if (e.getCause() instanceof ASN1Exception) { Throwable c = ((ASN1Exception)e.getCause()).getCause(); if (!c.getMessage().equals("ENUMERATED has zero length")) { fail("parsing failed, but for wrong reason: " + c.getMessage()); } } else { fail("parsing failed, but for wrong reason: " + e.getMessage()); } } }