@Override public void testPreconditions() { Supplier<Void> fn = () -> { super.testPreconditions(); return null; }; AccessibleRunner.run(constructor, fn); } }
@Override public void testValidCombinations() { Supplier<Void> fn = () -> { super.testValidCombinations(); return null; }; AccessibleRunner.run(constructor, fn); }
public void testEquals() { arguments.checkAllArgumentsSet(); AccessibleRunner.run(constructor, () -> { EqualsTester tester = new EqualsTester(); for (List<Argument> args : arguments.getCartesianProduct()) { try { Object[] invokeArgs = args.stream().map(Argument::getValue).toArray(); Object o1 = constructor.newInstance(invokeArgs); Object o2 = constructor.newInstance(invokeArgs); tester.addEqualityGroup(o1, o2); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException e) { throw new ConstructorInvocationException(e); } } tester.testEquals(); return null; }); }
@Test public void run_AccessibleAoGiven_ShouldKeepAoAccessibleBeforeInvocation() throws NoSuchMethodException, SecurityException { Method m = SomeObject.class.getDeclaredMethod("method"); m.setAccessible(true); AccessibleRunner.run(m, () -> { assertTrue(m.isAccessible()); return "whatever"; }); }
@Test public void run_InaccessibleAoGiven_ShouldMakeAoAccessibleBeforeInvocation() throws NoSuchMethodException, SecurityException { Method m = SomeObject.class.getDeclaredMethod("method"); AccessibleRunner.run(m, () -> { assertTrue(m.isAccessible()); return "whatever"; }); }
@Test public void run_AccessibleAoGiven_ShouldKeepAoAccessibleAfterInvocation() throws NoSuchMethodException, SecurityException { Method m = SomeObject.class.getDeclaredMethod("method"); m.setAccessible(true); AccessibleRunner.run(m, () -> { return "whatever"; }); assertTrue(m.isAccessible()); }
@Test public void run_InaccessibleAoGiven_ShouldMakeAoInaccessibleAgainAfterInvocation() throws NoSuchMethodException, SecurityException { Method m = SomeObject.class.getDeclaredMethod("method"); AccessibleRunner.run(m, () -> { return "whatever"; }); assertFalse(m.isAccessible()); }
@Test public void run_InaccessibleAoAndThrowingSupplierGiven_ShouldMakeAoInaccessibleAgainAfterInvocation() throws NoSuchMethodException, SecurityException { Method m = SomeObject.class.getDeclaredMethod("method"); try { AccessibleRunner.run(m, () -> { throw new RuntimeException(); }); fail("expected a RuntimeException"); } catch (RuntimeException re) { assertFalse(m.isAccessible()); } }
@Test public void run_AccessibleAoAndThrowingSupplierGiven_ShouldKeepAoAccessibleAfterInvocation() throws NoSuchMethodException, SecurityException { Method m = SomeObject.class.getDeclaredMethod("method"); m.setAccessible(true); try { AccessibleRunner.run(m, () -> { throw new RuntimeException(); }); fail("expected a RuntimeException"); } catch (RuntimeException re) { assertTrue(m.isAccessible()); } }