FileDocCategorySizeDatePackage
ConnectionFactoryTest.javaAPI DocGlassfish v2 API6762Fri May 04 22:33:30 BST 2007com.sun.enterprise.tools.verifier.tests.connector.cci

ConnectionFactoryTest

public abstract class ConnectionFactoryTest extends CCITest
Contains helper methods for all tests pertinent to the ConnectionFactory interface or implementation classes.
author
Jerome Dochez
version

Fields Summary
Constructors Summary
Methods Summary
protected java.lang.ClassgetConnectionFactoryImpl(com.sun.enterprise.deployment.ConnectorDescriptor descriptor, Result result)

Get the Class object of the class declared as implementing the javax.resource.cci.ConnectionFactory interface and declared in the archive deployment descriptors under the connection-factory-impl-class

param
descriptor the rar file deployment descriptor
param
result instance to use to put the result of the test
return
Class object for the connectionfactoryimpl-class that implements javax.resource.cci.ConnectionFactory

    ComponentNameConstructor compName = 
      getVerifierContext().getComponentNameConstructor();
    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();
      String impl = connDefDesc.getConnectionFactoryImpl();
      Class implClass = null;
      try
      {
        implClass = Class.forName(impl, false, getVerifierContext().getClassLoader());
      } catch(ClassNotFoundException cnfe) {
        result.addErrorDetails(smh.getLocalString
            ("tests.componentNameConstructor",
             "For [ {0} ]",
             new Object[] {compName.toString()}));
        result.failed(smh.getLocalString
            ("com.sun.enterprise.tools.verifier.tests.connector.cci.ConnectionFactoryTest.nonexist",
             "Error: The class [ {0} ] as defined in the connectionfactory-impl-class deployment descriptor does not exist",
             new Object[] {impl}));
        return null;
      }            
      if(isImplementorOf(implClass, "javax.resource.cci.ConnectionFactory"))
        return implClass;
    }
    return null;
    /*String className = descriptor.getConnectionFactoryImpl();
      if (className == null) 
      return null;

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

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

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 = getConnectionFactoryImpl(descriptor, result);
    if (mcf == null) {
      ComponentNameConstructor compName = 
        getVerifierContext().getComponentNameConstructor();
      result.addErrorDetails(smh.getLocalString
          ("tests.componentNameConstructor",
           "For [ {0} ]",
           new Object[] {compName.toString()}));
      result.failed(smh.getLocalString
          ("com.sun.enterprise.tools.verifier.tests.connector.cci.ConnectionFactoryTest.nonimpl", 
           "Error: The resource adapter must implement the javax.resource.cci.ConnectionFactory interface and declare it in the connectionfactory-impl-class deployment descriptor."));                           
    }
    return mcf;
  
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 connectionfactory-impl-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 = testConnectionFactoryImpl(descriptor, result);
    if (mcf != null) 
      return testImplementationOf(mcf, interfaceName, result);
    return false;