1   package net.sourceforge.jpotpourri.util;
2   
3   import java.lang.reflect.Constructor;
4   
5   import org.apache.commons.logging.Log;
6   import org.apache.commons.logging.LogFactory;
7   
8   import junit.framework.TestCase;
9   
10  /**
11   * @author christoph.pickl@bmi.gv.at
12   */
13  public abstract class AbstractUtilTestCase extends TestCase {
14  
15      private static final Log LOG = LogFactory.getLog(AbstractUtilTestCase.class);
16  
17  	public final void testNoInstantiation() throws Exception {
18  		final Class<?> thisClass = this.getClass();
19  		LOG.debug("Checking protected constructor for class: " + thisClass.getName());
20  		final Constructor<?>[] constructors = thisClass.getDeclaredConstructors();
21  		assertEquals(1, constructors.length);
22  		
23  		final Constructor<?> c = constructors[0];
24  		assertFalse(c.isAccessible());
25  //		System.out.println(c.getModifiers());
26  		
27  		c.setAccessible(true);
28  		final Object utilInstance = c.newInstance((Object[]) null); 
29  		assertNotNull(utilInstance);
30  	}
31  	
32  }