1 19 20 package org.netbeans.modules.j2ee.sun.share.configbean; 21 22 import java.beans.BeanDescriptor ; 23 import java.beans.BeanInfo ; 24 import java.beans.EventSetDescriptor ; 25 import java.beans.FeatureDescriptor ; 26 import java.beans.MethodDescriptor ; 27 import java.beans.PropertyDescriptor ; 28 import junit.framework.TestCase; 29 30 34 public class DConfigBeanBeanInfoTest extends TestCase { 35 36 39 41 public DConfigBeanBeanInfoTest(String testName) { 42 super(testName); 43 } 44 45 48 50 public void testWebAppRootBeanInfo() { 51 testBeanInfo(new WebAppRootBeanInfo()); 52 } 53 54 56 59 60 62 public void testServletRefBeanInfo() { 63 testBeanInfo(new ServletRefBeanInfo()); 64 } 65 66 68 public void testSecurityRoleMappingBeanInfo() { 69 testBeanInfo(new SecurityRoleMappingBeanInfo()); 70 } 71 72 74 public void testEjbRefBeanInfo() { 75 testBeanInfo(new EjbRefBeanInfo()); 76 } 77 78 80 public void testResourceRefBeanInfo() { 81 testBeanInfo(new ResourceRefBeanInfo()); 82 } 83 84 86 public void testResourceEnvRefBeanInfo() { 87 testBeanInfo(new ResourceEnvRefBeanInfo()); 88 } 89 90 92 public void testServiceRefBeanInfo() { 93 testBeanInfo(new ServiceRefBeanInfo()); 94 } 95 96 98 private void testBeanInfo(BeanInfo beanInfo) { 99 String beanInfoName = beanInfo.getClass().getName(); 100 System.out.println("Testing integrity of " + beanInfoName); 102 103 BeanDescriptor bd = beanInfo.getBeanDescriptor(); 104 assertNotNull(beanInfoName + " does not specify a customizer", bd.getCustomizerClass()); 105 106 PropertyDescriptor pd[] = beanInfo.getPropertyDescriptors(); 107 verifyDescriptorArray("PropertDescriptor", pd); 108 109 MethodDescriptor md[] = beanInfo.getMethodDescriptors(); 110 verifyDescriptorArray("MethodDescriptor", md); 111 112 EventSetDescriptor esd[] = beanInfo.getEventSetDescriptors(); 113 verifyDescriptorArray("EventSetDescriptor", esd); 114 } 115 116 private void verifyDescriptorArray(String descriptorName, FeatureDescriptor [] fd) { 117 if(fd == null) { 118 return; } 120 121 for(int i = 0; i < fd.length; i++) { 122 if(fd[i] == null) { 123 fail(descriptorName + " array null at index " + i); 124 } 125 } 126 } 127 } 128 | Popular Tags |