RdRandUtil { public static void nextBytes(byte[] bytes) { if (!LOADED) { throw new RdRandException(RdRandStatus.NOT_LOADED); } int result = nextBytesNative(bytes, bytes.length); RdRandStatus status = RdRandStatus.getStatusByCode(result); if (status != RdRandStatus.SUCCESS) { throw new RdRandException(status); } } private  RdRandUtil(); static RdRandStatus verify(); static void nextBytes(byte[] bytes); static int next(int bits); static final String LIB_NAME; }
@Test public final void testNextBytes() { final String methodName = "testNextBytes : "; RdRandStatus status = RdRandUtil.verify(); byte[] bytes = new byte[32]; if (status == RdRandStatus.SUCCESS) { LOGGER.debug("{} Native Shared Library loaded successfully, running success branch tests.", methodName); RdRandUtil.nextBytes(bytes); byte[] emptyBytes = new byte[32]; assertFalse(Arrays.equals(bytes, emptyBytes)); } else { LOGGER.debug("{} Native Shared Library load failed with {}, running failure branch tests.", methodName, status); RdRandException error = null; try { RdRandUtil.nextBytes(bytes); } catch (RdRandException e) { error = e; } assertNotNull(error); assertEquals("Different status returned by nextBytes vs verify..", status, error.getStatus()); } }