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

CheckConnectionFactoryImplClass

public class CheckConnectionFactoryImplClass extends com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest implements com.sun.enterprise.tools.verifier.tests.connector.ConnectorCheck
Test for each connection-definition, that "connectionfactory-impl-class" implements "connectionfactory-interface".
author
Anisha Malhotra
version

Fields Summary
Constructors Summary
Methods Summary
public com.sun.enterprise.tools.verifier.Resultcheck(com.sun.enterprise.deployment.ConnectorDescriptor descriptor)

Test for each connection-definition, that "connection-impl-class" implements "connection-interface".

paramm descriptor deployment descriptor for the rar file
return
result object containing the result of the individual test performed


    Result result = getInitializedResult();
    ComponentNameConstructor compName = 
      getVerifierContext().getComponentNameConstructor();
    // test NA for inboundRA
    if(!descriptor.getOutBoundDefined())
    {
      result.addNaDetails(smh.getLocalString
          ("tests.componentNameConstructor",
           "For [ {0} ]",
           new Object[] {compName.toString()}));
      result.notApplicable(smh.getLocalString
          ("com.sun.enterprise.tools.verifier.tests.connector.managed.notApplicableForInboundRA",
           "Resource Adapter does not provide outbound communication"));
      return result;
    }
    OutboundResourceAdapter outboundRA =
      descriptor.getOutboundResourceAdapter();
    if(outboundRA == null)
    {
      return null;
    }
    boolean oneFailed = false;
    Set connDefs = outboundRA.getConnectionDefs();
    Iterator iter = connDefs.iterator();
    while(iter.hasNext()) 
    {
      ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor)
        iter.next();
      String connectionInterface = connDefDesc.getConnectionFactoryIntf();
      String connectionImpl = connDefDesc.getConnectionFactoryImpl();
      Class implClass = null;
      try
      {
      implClass = Class.forName(connectionImpl, false, getVerifierContext().getClassLoader());
      }
      catch(ClassNotFoundException e)
      {
        result.addErrorDetails(smh.getLocalString
            ("tests.componentNameConstructor",
             "For [ {0} ]",
             new Object[] {compName.toString()}));
        result.failed(smh.getLocalString
            (getClass().getName() + ".nonexist",
             "Error: The class [ {0} ] as defined under connectionfactory-impl-class in the deployment descriptor does not exist",
             new Object[] {connectionImpl}));
        return result;
      }
      if(!isImplementorOf(implClass, connectionInterface))
      {
        oneFailed = true;
        result.addErrorDetails(smh.getLocalString
            ("tests.componentNameConstructor",
             "For [ {0} ]",
             new Object[] {compName.toString()}));
        result.failed(smh.getLocalString(getClass().getName() + ".failed",
              "Error: connectionfactory-impl-class [ {0} ] does not implement connectionfactory-interface [ {1} ].",
              new Object[] {implClass.getName(), connectionInterface}));
        return result;                
      }
    }
    if(!oneFailed)
    {
      result.addGoodDetails(smh.getLocalString
          ("tests.componentNameConstructor",
           "For [ {0} ]",
           new Object[] {compName.toString()}));	
      result.passed(smh.getLocalString(getClass().getName() + ".passed",
            "Success: all connectionfactory-impl-class implement their corresponding connectionfactory-interface"));                     
    }
    return result;