1 16 package org.apache.commons.attributes.test; 17 18 import java.lang.reflect.Field ; 19 import java.lang.reflect.Method ; 20 import java.lang.reflect.Constructor ; 21 import java.io.File ; 22 import java.net.URL ; 23 import java.net.URLClassLoader ; 24 import java.util.Collection ; 25 import java.util.Iterator ; 26 import org.apache.commons.attributes.Attributes; 27 import org.apache.commons.attributes.AttributeIndex; 28 import junit.framework.TestCase; 29 30 public class SealableTestCase extends TestCase { 31 32 public void testSealable () throws Exception { 33 Method m = Sample.class.getMethod ("methodWithNamedParameters", new Class []{ }); 34 BeanAttribute attribute = (BeanAttribute) Attributes.getAttributes (m, BeanAttribute.class).iterator ().next (); 35 36 try { 37 attribute.setName ("Joe Doe"); 38 fail ("Attribute should be sealed!"); 39 } catch (IllegalStateException ise) { 40 } 42 } 43 } | Popular Tags |