private static void shouldFail(Object instance, Visibility visibility) { try { new NullPointerTester().testInstanceMethods(instance, visibility); } catch (AssertionFailedError expected) { return; } fail("Should detect problem in " + instance.getClass().getSimpleName()); }
public void testConstructor_ShouldFail() throws Exception { try { new NullPointerTester().testAllPublicConstructors(FailOnOneOfTwoConstructors.class); } catch (AssertionFailedError expected) { return; } fail("Should detect problem in " + FailOnOneOfTwoConstructors.class.getSimpleName()); } }
private static void shouldFail(Class<?> cls, Visibility visibility) { try { new NullPointerTester().testStaticMethods(cls, visibility); } catch (AssertionFailedError expected) { return; } fail("Should detect problem in " + cls.getSimpleName()); }
public void testNonStaticInnerClass() { try { new NullPointerTester().testAllPublicConstructors(Inner.class); fail(); } catch (IllegalArgumentException expected) { assertThat(expected.getMessage()).contains("inner class"); } }
public void testStaticOneArgMethodsThatShouldPass() throws Exception { for (String methodName : STATIC_ONE_ARG_METHODS_SHOULD_PASS) { Method method = OneArg.class.getMethod(methodName, String.class); try { new NullPointerTester().testMethodParameter(new OneArg(), method, 0); } catch (AssertionFailedError unexpected) { fail("Should not have flagged method " + methodName); } } }
public void verifyBarFail(Method method, TwoArg bar) { try { new NullPointerTester().testMethod(bar, method); } catch (AssertionFailedError expected) { return; // good...we wanted a failure } String errorMessage = rootLocaleFormat("Should have flagged method %s for %s", method.getName(), bar); fail(errorMessage); }
public void testNonStaticOneArgMethodsThatShouldPass() throws Exception { OneArg foo = new OneArg(); for (String methodName : NONSTATIC_ONE_ARG_METHODS_SHOULD_PASS) { Method method = OneArg.class.getMethod(methodName, String.class); try { new NullPointerTester().testMethodParameter(foo, method, 0); } catch (AssertionFailedError unexpected) { fail("Should not have flagged method " + methodName); } } }
public void testInterfaceStaticMethod() { NullPointerTester tester = new NullPointerTester(); tester.testAllPublicStaticMethods(InterfaceStaticMethodChecksNull.class); try { tester.testAllPublicStaticMethods(InterfaceStaticMethodFailsToCheckNull.class); } catch (AssertionError expected) { return; } fail(); }
public void testDontAcceptIae() { NullPointerTester tester = new NullPointerTester(); tester.testAllPublicStaticMethods(ThrowsNpe.class); tester.testAllPublicStaticMethods(ThrowsUoe.class); try { tester.testAllPublicStaticMethods(ThrowsIae.class); } catch (AssertionFailedError expected) { return; } fail(); }
public void testInterfaceDefaultMethod() { NullPointerTester tester = new NullPointerTester(); tester.testAllPublicInstanceMethods(InterfaceDefaultMethodChecksNull.create()); try { tester.testAllPublicInstanceMethods(InterfaceDefaultMethodFailsToCheckNull.create()); } catch (AssertionError expected) { return; } fail(); }
private static void shouldFail(Object instance, Visibility visibility) { try { new NullPointerTester().testInstanceMethods(instance, visibility); } catch (AssertionFailedError expected) { return; } fail("Should detect problem in " + instance.getClass().getSimpleName()); }
private static void shouldFail(Class<?> cls, Visibility visibility) { try { new NullPointerTester().testStaticMethods(cls, visibility); } catch (AssertionFailedError expected) { return; } fail("Should detect problem in " + cls.getSimpleName()); }
private static void shouldFail(Class<?> cls, Visibility visibility) { try { new NullPointerTester().testStaticMethods(cls, visibility); } catch (AssertionFailedError expected) { return; } fail("Should detect problem in " + cls.getSimpleName()); }
public void testNonStaticOneArgMethodsThatShouldPass() throws Exception { OneArg foo = new OneArg(); for (String methodName : NONSTATIC_ONE_ARG_METHODS_SHOULD_PASS) { Method method = OneArg.class.getMethod(methodName, String.class); try { new NullPointerTester().testMethodParameter(foo, method, 0); } catch (AssertionFailedError unexpected) { fail("Should not have flagged method " + methodName); } } }
public void verifyBarFail(Method method, TwoArg bar) { try { new NullPointerTester().testMethod(bar, method); } catch (AssertionFailedError expected) { return; // good...we wanted a failure } String errorMessage = rootLocaleFormat("Should have flagged method %s for %s", method.getName(), bar); fail(errorMessage); }
public void testStaticOneArgMethodsThatShouldPass() throws Exception { for (String methodName : STATIC_ONE_ARG_METHODS_SHOULD_PASS) { Method method = OneArg.class.getMethod(methodName, String.class); try { new NullPointerTester().testMethodParameter(new OneArg(), method, 0); } catch (AssertionFailedError unexpected) { fail("Should not have flagged method " + methodName); } } }
public void testNonStaticInnerClass() { try { new NullPointerTester().testAllPublicConstructors(Inner.class); fail(); } catch (IllegalArgumentException expected) { ASSERT.that(expected.getMessage()).contains("inner class"); } } }
public void testInterfaceStaticMethod() { NullPointerTester tester = new NullPointerTester(); tester.testAllPublicStaticMethods(InterfaceStaticMethodChecksNull.class); try { tester.testAllPublicStaticMethods(InterfaceStaticMethodFailsToCheckNull.class); } catch (AssertionError expected) { return; } fail(); }
public void testDontAcceptIae() { NullPointerTester tester = new NullPointerTester(); tester.testAllPublicStaticMethods(ThrowsNpe.class); tester.testAllPublicStaticMethods(ThrowsUoe.class); try { tester.testAllPublicStaticMethods(ThrowsIae.class); } catch (AssertionFailedError expected) { return; } fail(); }
public void testInterfaceDefaultMethod() { NullPointerTester tester = new NullPointerTester(); tester.testAllPublicInstanceMethods(InterfaceDefaultMethodChecksNull.create()); try { tester.testAllPublicInstanceMethods(InterfaceDefaultMethodFailsToCheckNull.create()); } catch (AssertionError expected) { return; } fail(); }