1 package com.tirsen.nanning.attribute; 2 3 9 10 import junit.framework.TestCase; 11 import org.xml.sax.SAXException ; 12 13 import java.io.IOException ; 14 import java.io.InputStream ; 15 import java.lang.reflect.Field ; 16 import java.lang.reflect.Method ; 17 18 26 public class AttributesXMLParserTest extends TestCase { 27 public void testAttributes() throws IOException , NoSuchMethodException , NoSuchFieldException , SAXException { 28 ClassAttributes jobClassAttributes = new ClassAttributes(Job.class); 29 new AttributesXMLParser().load(jobClassAttributes); 30 31 33 assertEquals("true", jobClassAttributes.getAttribute("persistant")); 35 36 assertEquals("true", jobClassAttributes.getAttribute("secure")); 37 38 Field descriptionField = Job.class.getDeclaredField("description"); 40 assertEquals("true", jobClassAttributes.getAttribute(descriptionField, "persistant")); 41 42 Field bossField = Job.class.getDeclaredField("boss"); 43 assertEquals("true", jobClassAttributes.getAttribute(bossField, "bastard")); 44 45 Method fireAllEmployeesMethod = Job.class.getDeclaredMethod("fireAllEmployees", null); 47 Method hireEmployeeMethod = Job.class.getDeclaredMethod("hireEmployee", new Class [] {String .class, Employee.class}); 48 assertEquals("true", jobClassAttributes.getAttribute(fireAllEmployeesMethod, "secure")); 49 assertEquals("false", jobClassAttributes.getAttribute(hireEmployeeMethod, "secure")); 50 } 51 52 }
| Popular Tags
|