1 23 28 29 package com.sun.enterprise.tools.verifier.tests.connector.managed; 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 com.sun.enterprise.tools.verifier.tests.*; 37 import com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest; 38 import java.util.Set ; 39 import java.util.Iterator ; 40 41 47 public abstract class ManagedConnectionFactoryTest extends ConnectorTest { 48 49 private String managedConnectionFactoryImpl; 50 51 63 protected Class getManagedConnectionFactoryImpl(ConnectorDescriptor descriptor) 64 throws ClassNotFoundException 65 { 66 OutboundResourceAdapter outboundRA = 67 descriptor.getOutboundResourceAdapter(); 68 if(outboundRA == null) 69 { 70 return null; 71 } 72 Set connDefs = outboundRA.getConnectionDefs(); 73 Iterator iter = connDefs.iterator(); 74 while(iter.hasNext()) 75 { 76 ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor) 77 iter.next(); 78 managedConnectionFactoryImpl = 79 connDefDesc.getManagedConnectionFactoryImpl(); 80 Class implClass = Class.forName(managedConnectionFactoryImpl, false, getVerifierContext().getClassLoader()); 81 if(isImplementorOf(implClass, "javax.resource.spi.ManagedConnectionFactory")) 82 { 83 return implClass; 84 } 85 } 86 return null; 87 88 95 } 96 97 98 108 protected Class testManagedConnectionFactoryImpl(ConnectorDescriptor descriptor, Result result) 109 { 110 Class mcf = null; 111 ComponentNameConstructor compName = null; 112 try { 113 compName = getVerifierContext().getComponentNameConstructor(); 114 mcf = getManagedConnectionFactoryImpl(descriptor); 115 if (mcf == null) { 116 result.addErrorDetails(smh.getLocalString 117 ("tests.componentNameConstructor", 118 "For [ {0} ]", 119 new Object [] {compName.toString()})); 120 result.failed(smh.getLocalString 121 ("com.sun.enterprise.tools.verifier.tests.connector.managed.ManagedConnectionFactoryTest.nonimpl", 122 "Error: The resource adapter must implement the javax.resource.spi.ManagedConnectionFactory interface and declare it in the managedconnecttionfactory-class deployment descriptor.")); 123 } 124 } catch(ClassNotFoundException cnfe) { 125 cnfe.printStackTrace(); 126 result.addErrorDetails(smh.getLocalString 127 ("tests.componentNameConstructor", 128 "For [ {0} ]", 129 new Object [] {compName.toString()})); 130 result.failed(smh.getLocalString 131 ("com.sun.enterprise.tools.verifier.tests.connector.managed.ManagedConnectionFactoryTest.nonexist", 132 "Error: The class [ {0} ] as defined in the managedconnecttionfactory-class deployment descriptor does not exist", 133 new Object [] {managedConnectionFactoryImpl})); 134 } 135 return mcf; 136 } 137 138 149 protected boolean testImplementationOf(ConnectorDescriptor descriptor, String interfaceName, Result result) 150 { 151 Class mcf = testManagedConnectionFactoryImpl(descriptor, result); 152 if (mcf != null) 153 return testImplementationOf(mcf, interfaceName, result); 154 return false; 155 } 156 } 157 | Popular Tags |