public void testNewInstance() { ConstructorAccess<SomeClass> access = ConstructorAccess.get(SomeClass.class); SomeClass someObject = new SomeClass(); assertEquals(someObject, access.newInstance()); assertEquals(someObject, access.newInstance()); assertEquals(someObject, access.newInstance()); }
public void testPackagePrivateNewInstance() { ConstructorAccess<PackagePrivateClass> access = ConstructorAccess.get(PackagePrivateClass.class); PackagePrivateClass someObject = new PackagePrivateClass(); assertEquals(someObject, access.newInstance()); assertEquals(someObject, access.newInstance()); assertEquals(someObject, access.newInstance()); }
public void testHasPublicConstructor() { try { ConstructorAccess<HasPublicConstructor> access = ConstructorAccess.get(HasPublicConstructor.class); HasPublicConstructor newInstance = access.newInstance(); assertEquals("cow", newInstance.getMoo()); } catch (Throwable t) { System.out.println("Unexpected exception happened: " + t); assertTrue(false); } }