Beispiel #1
0
 // Classtoken version:
 public static <T> void fill(Addable<T> addable, Class<? extends T> classToken, int size) {
   for (int i = 0; i < size; i++)
     try {
       addable.add(classToken.newInstance());
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
 }
Beispiel #2
0
 private static Object createTestObject(Method creator) {
   if (creator != null) {
     try {
       return creator.invoke(testClass);
     } catch (Exception e) {
       throw new RuntimeException("Couldn't run " + "@TestObject (creator) method.");
     }
   } else { // Use the default constructor:
     try {
       return testClass.newInstance();
     } catch (Exception e) {
       throw new RuntimeException(
           "Couldn't create a " + "test object. Try using a @TestObject method.");
     }
   }
 }