FileDocCategorySizeDatePackage
ManagedConnectionFactoryTest.javaAPI DocGlassfish v2 API6996Fri May 04 22:33:30 BST 2007com.sun.enterprise.tools.verifier.tests.connector.managed

ManagedConnectionFactoryTest

public abstract class ManagedConnectionFactoryTest extends com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest
Superclass for all ManagedConnectionFactory related tests
author
Jerome Dochez
version

Fields Summary
private String
managedConnectionFactoryImpl
Constructors Summary
Methods Summary
protected java.lang.ClassgetManagedConnectionFactoryImpl(com.sun.enterprise.deployment.ConnectorDescriptor descriptor)

Get the Class object of the class declared to be implementing the javax.resource.spi.ManagedConnectionFactory interface in the archive deployment descriptor

param
descriptor the rar file deployment descriptor
throws
ClassNotFoundException if the class identified by className cannot be loaded

      OutboundResourceAdapter outboundRA =
        descriptor.getOutboundResourceAdapter();
      if(outboundRA == null)
      {
        return null;
      }
      Set connDefs = outboundRA.getConnectionDefs();
      Iterator iter = connDefs.iterator();
      while(iter.hasNext()) 
      {
        ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor)
          iter.next();
        managedConnectionFactoryImpl = 
          connDefDesc.getManagedConnectionFactoryImpl();
        Class implClass = Class.forName(managedConnectionFactoryImpl, false, getVerifierContext().getClassLoader());
        if(isImplementorOf(implClass, "javax.resource.spi.ManagedConnectionFactory"))
        {
          return implClass;
        }
      }
      return null;

      /*  String className = descriptor.getManagedConnectionFactoryImpl();
          if (className == null) 
          return null;

          Context context = getVerifierContext();
          ClassLoader jcl = context.getRarClassLoader();
          return jcl.loadClass(className);   */ 
    
protected booleantestImplementationOf(com.sun.enterprise.deployment.ConnectorDescriptor descriptor, java.lang.String interfaceName, Result result)

Test wether the class declared in the deployemnt descriptor under the managedconnecttionfactory-class tag implements an interface

param
descriptor the deployment descriptor
param
interfaceName the interface name we look for
param
result instance to use to put the result of the test
return
true if the test succeeds

      Class mcf = testManagedConnectionFactoryImpl(descriptor, result);
      if (mcf != null) 
        return testImplementationOf(mcf, interfaceName, result);
      return false;
    
protected java.lang.ClasstestManagedConnectionFactoryImpl(com.sun.enterprise.deployment.ConnectorDescriptor descriptor, Result result)

Test whether the class declared in the deployemnt descriptor under the managedconnecttionfactory-class tag is available

param
descriptor the deployment descriptor
param
result instance to use to put the result of the test
return
true if the test succeeds

      Class mcf = null;
      ComponentNameConstructor compName = null;
      try {
        compName = getVerifierContext().getComponentNameConstructor();
        mcf = getManagedConnectionFactoryImpl(descriptor);
        if (mcf == null) {
          result.addErrorDetails(smh.getLocalString
              ("tests.componentNameConstructor",
               "For [ {0} ]",
               new Object[] {compName.toString()}));
          result.failed(smh.getLocalString
              ("com.sun.enterprise.tools.verifier.tests.connector.managed.ManagedConnectionFactoryTest.nonimpl", 
               "Error: The resource adapter must implement the javax.resource.spi.ManagedConnectionFactory interface and declare it in the managedconnecttionfactory-class deployment descriptor."));                
        }
      } catch(ClassNotFoundException cnfe) {
        cnfe.printStackTrace();
        result.addErrorDetails(smh.getLocalString
            ("tests.componentNameConstructor",
             "For [ {0} ]",
             new Object[] {compName.toString()}));
        result.failed(smh.getLocalString
            ("com.sun.enterprise.tools.verifier.tests.connector.managed.ManagedConnectionFactoryTest.nonexist",
             "Error: The class [ {0} ] as defined in the managedconnecttionfactory-class deployment descriptor does not exist",
             new Object[] {managedConnectionFactoryImpl}));
      }            
      return mcf;