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

CCITest

public abstract class CCITest extends com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest
Contains helper methods for all tests pertinent to CCI
author
Anisha Malhotra
version

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

Returns the connection-interface that implements "javax.resource.cci.Connection"

param
descriptor the deployment descriptor
param
result to put the result
return
interface name

    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 intf = connDefDesc.getConnectionIntf();
      Context context = getVerifierContext();
      ClassLoader jcl = context.getRarClassLoader();
      Class intfClass = null;
      try
      {
        intfClass = Class.forName(intf, false, getVerifierContext().getClassLoader());    
      }
      catch(ClassNotFoundException e)
      {
        result.addErrorDetails(smh.getLocalString
            ("tests.componentNameConstructor",
             "For [ {0} ]",
             new Object[] {compName.toString()}));
        result.failed(smh.getLocalString
            ("com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest.isClassLoadable.failed", 
             "The class [ {0} ] is not contained in the archive file",
             new Object[] {intf}));                
        continue;
      }
      if(isImplementorOf(intfClass, "javax.resource.cci.Connection"))
      {
        return intf;
      }
    }
    return null;
  
protected booleanisCCIImplemented(com.sun.enterprise.deployment.ConnectorDescriptor descriptor, Result result)

Checks whether the resource adapater is implementing the CCI interfaces

param
descriptor the deployment descriptor
param
result to put the result
return
true if the CCI is implemented

    ComponentNameConstructor compName = 
      getVerifierContext().getComponentNameConstructor();
    OutboundResourceAdapter outboundRA =
      descriptor.getOutboundResourceAdapter();
    if(outboundRA == null)
    {
      return false;
    }
    Set connDefs = outboundRA.getConnectionDefs();
    Iterator iter = connDefs.iterator();
    while(iter.hasNext()) 
    {
      ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor)
        iter.next();
      // check if intf implements javax.resource.cci.ConnectionFactory
      String intf = connDefDesc.getConnectionFactoryIntf();
      Class implClass = null;
      try
      {
        implClass = Class.forName(intf, false, getVerifierContext().getClassLoader());
      }
      catch(ClassNotFoundException e)
      {
      result.addErrorDetails(smh.getLocalString
          ("tests.componentNameConstructor",
           "For [ {0} ]",
           new Object[] {compName.toString()}));
        result.failed(smh.getLocalString
            ("com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest.isClassLoadable.failed", 
             "The class [ {0} ] is not contained in the archive file",
             new Object[] {intf}));                
        continue;
      }
      if(isImplementorOf(implClass, "javax.resource.cci.ConnectionFactory"))
      {
        return true;
      }
    }
    return false;