[testedby-commit] [testedby] r186 committed - better exception message

0 views
Skip to first unread message

test...@googlecode.com

unread,
Apr 19, 2010, 4:49:55 PM4/19/10
to testedb...@googlegroups.com
Revision: 186
Author: maestri.stefano
Date: Mon Apr 19 13:49:00 2010
Log: better exception message
http://code.google.com/p/testedby/source/detail?r=186

Modified:

/trunk/src/main/java/it/javalinux/testedby/factories/ClassUnderTestFactory.java

=======================================
---
/trunk/src/main/java/it/javalinux/testedby/factories/ClassUnderTestFactory.java
Tue Nov 17 00:21:40 2009
+++
/trunk/src/main/java/it/javalinux/testedby/factories/ClassUnderTestFactory.java
Mon Apr 19 13:49:00 2010
@@ -30,19 +30,20 @@
public class ClassUnderTestFactory {
@SuppressWarnings("unchecked")
public static <T> T instanceClassUnderTest(Class<T> clazz) throws
InstantiationException, IllegalAccessException, ClassNotFoundException {
-
- InvocationTracker tracker = InvocationTracker.getInstance();
- Class<?> cls =
Thread.currentThread().getContextClassLoader().loadClass(tracker.getCurrentClassUnderTest());
- if (clazz.isAssignableFrom(cls)) {
- if (cls.getAnnotation(TestedByFactory.class)!= null) {
- return
cls.getAnnotation(TestedByFactory.class).value().newInstance().createInstance((Class<T>)
cls);
- } else {
- return
DefaultClassUnderTestInstanceFactory.class.newInstance().createInstance((Class<T>)
cls);
- }
+
+ InvocationTracker tracker = InvocationTracker.getInstance();
+ Class<?> cls =
Thread.currentThread().getContextClassLoader().loadClass(tracker.getCurrentClassUnderTest());
+ if (clazz.isAssignableFrom(cls)) {
+ if (cls.getAnnotation(TestedByFactory.class) != null) {
+ return
cls.getAnnotation(TestedByFactory.class).value().newInstance().createInstance((Class<T>)
cls);
} else {
- throw new IllegalAccessException("This test try to instantiate a generic
type not assignable from current class under test");
- }
-
- }
-
-}
+ return
DefaultClassUnderTestInstanceFactory.class.newInstance().createInstance((Class<T>)
cls);
+ }
+ } else {
+ throw new IllegalAccessException("This test try to instantiate a
generic type (" + clazz +
+ ") not assignable from current class under test ( " + cls + ")");
+ }
+
+ }
+
+}

--
You received this message because you are subscribed to the Google Groups "testedby-commit" group.
To post to this group, send email to testedb...@googlegroups.com.
To unsubscribe from this group, send email to testedby-comm...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testedby-commit?hl=en.

Reply all
Reply to author
Forward
0 new messages