ArgCheck { static public long requireStrictlyPostive(long l) throws IllegalArgumentException { return requireStrictlyPostive(l, "long value must be strictly positive"); } private  ArgCheck(); static T requireNonNull(T obj); static T requireNonNull(T obj, String errMsg); static long requirePostive(long l); static long requirePostive(long l, String msg); static long requireStrictlyPostive(long l); static long requireStrictlyPostive(long l, String msg); static int requirePostive(int i); static int requirePostive(int i, String msg); static int requireStrictlyPostive(int i); static int requireStrictlyPostive(int i, String msg); static Set<T> setWithoutNull(Set<T> set); static Set<T> setWithoutNull(Set<T> set, String msg);  }
@Test public void testRequireStrictlyPositiveLong() { ArgCheck.requireStrictlyPostive(1L); try { ArgCheck.requireStrictlyPostive(0L); Assert.fail("Should have thrown an NPE"); } catch (IllegalArgumentException e) { } try { ArgCheck.requireStrictlyPostive(-1L); Assert.fail("Should have thrown an NPE"); } catch (IllegalArgumentException e) { } String msg = "msg"; ArgCheck.requireStrictlyPostive(1L, msg); try { ArgCheck.requireStrictlyPostive(0L, msg); Assert.fail("Should have thrown an NPE"); } catch (IllegalArgumentException e) { Assert.assertEquals(msg, e.getMessage()); } try { ArgCheck.requireStrictlyPostive(-1L, msg); Assert.fail("Should have thrown an NPE"); } catch (IllegalArgumentException e) { Assert.assertEquals(msg, e.getMessage()); } }
@Test public void testRequireStrictlyPositiveInteger() { ArgCheck.requireStrictlyPostive(1); try { ArgCheck.requireStrictlyPostive(0); Assert.fail("Should have thrown an NPE"); } catch (IllegalArgumentException e) { } try { ArgCheck.requireStrictlyPostive(-1); Assert.fail("Should have thrown an NPE"); } catch (IllegalArgumentException e) { } String msg = "msg"; ArgCheck.requireStrictlyPostive(1, msg); try { ArgCheck.requireStrictlyPostive(0, msg); Assert.fail("Should have thrown an NPE"); } catch (IllegalArgumentException e) { Assert.assertEquals(msg, e.getMessage()); } try { ArgCheck.requireStrictlyPostive(-1, msg); Assert.fail("Should have thrown an NPE"); } catch (IllegalArgumentException e) { Assert.assertEquals(msg, e.getMessage()); } }