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

ConnectionTest

public abstract class ConnectionTest extends CCITest
Utility methods for all tests related to java.resource.cci.Connection interface implementation
author
Jerome Dochez
version

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

Get the Class object of the class declared as implementing the javax.resource.cci.Connection interface and declared in the archive deployment descriptors under the connection-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 connectionimpl-class that implements javax.resource.cci.Connection

      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.getConnectionImpl();
        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.ConnectionTest.nonexist",
               "Error: The class [ {0} ] as defined in the connection-impl-class deployment descriptor does not exist",
               new Object[] {impl}));
          return null;
        }            
        if(isImplementorOf(implClass, "javax.resource.cci.Connection"))
          return implClass;
      }
      return null;
    
protected java.lang.ClasstestConnectionImpl(com.sun.enterprise.deployment.ConnectorDescriptor descriptor, Result result)

Test whether the class declared in the deployemnt descriptor under the connection-impl-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 = getConnectionImpl(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.ConnectionTest.nonimpl", 
             "Error: The resource adapter must implement the javax.resource.cci.Connection interface and declare it in the connection-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 = testConnectionImpl(descriptor, result);
      if (mcf != null) 
        return testImplementationOf(mcf, interfaceName, result);
      return false;