コード例 #1
0
 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());
 }
コード例 #2
0
 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());
 }
コード例 #3
0
 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);
   }
 }