1 23 28 29 package com.sun.enterprise.tools.verifier.tests.connector.messageinflow; 30 31 import com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest; 32 import com.sun.enterprise.tools.verifier.tests.connector.ConnectorCheck; 33 import com.sun.enterprise.tools.verifier.Result; 34 import com.sun.enterprise.tools.verifier.*; 35 import com.sun.enterprise.deployment.ConnectorDescriptor; 36 import com.sun.enterprise.deployment.InboundResourceAdapter; 37 import com.sun.enterprise.deployment.MessageListener; 38 import com.sun.enterprise.deployment.EnvironmentProperty; 39 import com.sun.enterprise.tools.verifier.tests.*; 40 import java.util.*; 41 import java.beans.*; 42 43 49 public class CheckActivationSpecJavaBean 50 extends ConnectorTest 51 implements ConnectorCheck 52 { 53 54 62 public Result check(ConnectorDescriptor descriptor) { 63 64 Result result = getInitializedResult(); 65 ComponentNameConstructor compName = 66 getVerifierContext().getComponentNameConstructor(); 67 if(!descriptor.getInBoundDefined()) 68 { 69 result.addNaDetails(smh.getLocalString 70 ("tests.componentNameConstructor", 71 "For [ {0} ]", 72 new Object [] {compName.toString()})); 73 result.notApplicable(smh.getLocalString 74 ("com.sun.enterprise.tools.verifier.tests.connector.messageinflow.notApp", 75 "Resource Adapter does not provide inbound communication")); 76 return result; 77 } 78 InboundResourceAdapter ra = descriptor.getInboundResourceAdapter(); 79 Set msgListeners = ra.getMessageListeners(); 80 boolean oneFailed = false; 81 Iterator iter = msgListeners.iterator(); 82 while(iter.hasNext()) 83 { 84 MessageListener msgListener = (MessageListener) iter.next(); 85 String impl = msgListener.getActivationSpecClass(); 86 Class implClass = null; 87 try 88 { 89 implClass = Class.forName(impl, false, getVerifierContext().getClassLoader()); 90 } 91 catch(ClassNotFoundException e) 92 { 93 result.addErrorDetails(smh.getLocalString 94 ("tests.componentNameConstructor", 95 "For [ {0} ]", 96 new Object [] {compName.toString()})); 97 result.failed(smh.getLocalString 98 ("com.sun.enterprise.tools.verifier.tests.connector.messageinflow.nonexist", 99 "Error: The class [ {0} ] as defined under activationspec-class in the deployment descriptor does not exist", 100 new Object [] {impl})); 101 return result; 102 } 103 Set configProps = msgListener.getConfigProperties(); 104 Iterator propIter = configProps.iterator(); 105 BeanInfo bi = null; 106 try 107 { 108 bi = Introspector.getBeanInfo(implClass, Object .class); 109 } 110 catch (IntrospectionException ie) { 111 oneFailed = true; 112 result.addErrorDetails(smh.getLocalString 113 ("tests.componentNameConstructor", 114 "For [ {0} ]", 115 new Object [] {compName.toString()})); 116 result.failed(smh.getLocalString 117 (getClass().getName() + ".failed", 118 "Error: The activationspec-class [ {0} ] is not JavaBeans compliant", 119 new Object [] {impl} )); 120 return result; 121 } 122 123 PropertyDescriptor[] properties = bi.getPropertyDescriptors(); 124 Hashtable<String , PropertyDescriptor> props = new Hashtable<String , PropertyDescriptor>(); 125 for(int i=0;i<properties.length;i++) 126 { 127 props.put(properties[i].getName(), properties[i]); 128 } 129 while(propIter.hasNext()) 130 { 131 EnvironmentProperty envProp = (EnvironmentProperty) propIter.next(); 132 String name = envProp.getName(); 133 String type = envProp.getType(); 134 135 PropertyDescriptor propDesc = (PropertyDescriptor) props.get( 136 name.substring(0,1).toLowerCase() + name.substring(1)); 137 if(propDesc != null) 138 { 139 if (propDesc.getReadMethod()==null || propDesc.getWriteMethod()==null) 140 { 141 oneFailed = true; 142 result.addErrorDetails(smh.getLocalString 143 ("tests.componentNameConstructor", 144 "For [ {0} ]", 145 new Object [] {compName.toString()})); 146 result.failed(smh.getLocalString 147 (getClass().getName() + ".failed1", 148 "Error: The activationspec-class [ {0} ] does not provide accessor methods for [ {1} ].", 149 new Object [] {impl, name} )); 150 return result; 151 } 152 } 153 else 154 { 155 oneFailed = true; 156 result.addErrorDetails(smh.getLocalString 157 ("tests.componentNameConstructor", 158 "For [ {0} ]", 159 new Object [] {compName.toString()})); 160 result.failed(smh.getLocalString 161 (getClass().getName() + ".failed1", 162 "Error: The activationspec-class [ {0} ] does not provide accessor methods for [ {1} ].", 163 new Object [] {impl, name} )); 164 return result; 165 } 166 } 167 } 168 if(!oneFailed) 169 { 170 result.addGoodDetails(smh.getLocalString 171 ("tests.componentNameConstructor", 172 "For [ {0} ]", 173 new Object [] {compName.toString()})); 174 result.passed(smh.getLocalString(getClass().getName() + ".passed", 175 "Success: Each activationspec-class is a Java Bean")); 176 } 177 return result; 178 } 179 } 180 | Popular Tags |