diff --git a/test/src/main/java/org/jvnet/hudson/test/DefaultConstructorChecker.java b/test/src/main/java/org/jvnet/hudson/test/DefaultConstructorChecker.java new file mode 100644 index 0000000000000000000000000000000000000000..9c862edc4773d6a89af2497dcc74a39b9d124130 --- /dev/null +++ b/test/src/main/java/org/jvnet/hudson/test/DefaultConstructorChecker.java @@ -0,0 +1,28 @@ +package org.jvnet.hudson.test; + +import junit.framework.TestCase; + +/** + * Tests that the specified class has the default constructor. + * + * @author Kohsuke Kawaguchi + */ +public class DefaultConstructorChecker extends TestCase { + private final Class clazz; + + public DefaultConstructorChecker(Class clazz) { + this.clazz = clazz; + setName(clazz.getName()+".verifyDefaultConstructor"); + } + + @Override + protected void runTest() throws Throwable { + try { + clazz.getConstructor(); + } catch (NoSuchMethodException e) { + throw new Error(clazz+" must have the default constructor",e); + } catch (SecurityException e) { + throw new Error(clazz+" must have the default constructor",e); + } + } +}