1 23 28 29 package com.sun.enterprise.tools.verifier.tests.connector.cci; 30 31 import com.sun.enterprise.tools.verifier.*; 32 import com.sun.enterprise.deployment.ConnectorDescriptor; 33 import com.sun.enterprise.deployment.ConnectionDefDescriptor; 34 import com.sun.enterprise.deployment.OutboundResourceAdapter; 35 import com.sun.enterprise.tools.verifier.tests.*; 36 import java.util.Iterator ; 37 import java.util.Set ; 38 45 public abstract class ConnectionFactoryTest extends CCITest { 46 47 59 protected Class getConnectionFactoryImpl(ConnectorDescriptor descriptor, 60 Result result) 61 { 62 ComponentNameConstructor compName = 63 getVerifierContext().getComponentNameConstructor(); 64 OutboundResourceAdapter outboundRA = 65 descriptor.getOutboundResourceAdapter(); 66 if(outboundRA == null) 67 { 68 return null; 69 } 70 Set connDefs = outboundRA.getConnectionDefs(); 71 Iterator iter = connDefs.iterator(); 72 while(iter.hasNext()) 73 { 74 ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor) 75 iter.next(); 76 String impl = connDefDesc.getConnectionFactoryImpl(); 77 Class implClass = null; 78 try 79 { 80 implClass = Class.forName(impl, false, getVerifierContext().getClassLoader()); 81 } catch(ClassNotFoundException cnfe) { 82 result.addErrorDetails(smh.getLocalString 83 ("tests.componentNameConstructor", 84 "For [ {0} ]", 85 new Object [] {compName.toString()})); 86 result.failed(smh.getLocalString 87 ("com.sun.enterprise.tools.verifier.tests.connector.cci.ConnectionFactoryTest.nonexist", 88 "Error: The class [ {0} ] as defined in the connectionfactory-impl-class deployment descriptor does not exist", 89 new Object [] {impl})); 90 return null; 91 } 92 if(isImplementorOf(implClass, "javax.resource.cci.ConnectionFactory")) 93 return implClass; 94 } 95 return null; 96 103 } 104 105 116 protected Class testConnectionFactoryImpl(ConnectorDescriptor descriptor, Result result) 117 { 118 Class mcf = getConnectionFactoryImpl(descriptor, result); 119 if (mcf == null) { 120 ComponentNameConstructor compName = 121 getVerifierContext().getComponentNameConstructor(); 122 result.addErrorDetails(smh.getLocalString 123 ("tests.componentNameConstructor", 124 "For [ {0} ]", 125 new Object [] {compName.toString()})); 126 result.failed(smh.getLocalString 127 ("com.sun.enterprise.tools.verifier.tests.connector.cci.ConnectionFactoryTest.nonimpl", 128 "Error: The resource adapter must implement the javax.resource.cci.ConnectionFactory interface and declare it in the connectionfactory-impl-class deployment descriptor.")); 129 } 130 return mcf; 131 } 132 133 144 protected boolean testImplementationOf(ConnectorDescriptor descriptor, String interfaceName, Result result) 145 { 146 Class mcf = testConnectionFactoryImpl(descriptor, result); 147 if (mcf != null) 148 return testImplementationOf(mcf, interfaceName, result); 149 return false; 150 } 151 } 152 | Popular Tags |