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

ConnectionFactoryGetConnection

public class ConnectionFactoryGetConnection extends ConnectionFactoryTest implements com.sun.enterprise.tools.verifier.tests.connector.ConnectorCheck
Check that the getConnection method of the client API Connection factory is implemented accordingly to the spec
author
Jerome Dochez
version

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

all connector tests should implement this method. it run an individual test against the resource adapter deployment descriptor.

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();
    if(isCCIImplemented(descriptor, result))
    {
      Class cf = testConnectionFactoryImpl(descriptor, result);
      if (cf == null) 
        return result;
      String className = cf.getName();

      do {
        Method[] allMethods = cf.getMethods();
        for (int i=0;i<allMethods.length;i++) {
          if (allMethods[i].getName().equals("getConnection")) {
            // found it, check the return type
            String connection = getConnectionInterface(descriptor, result);
            if (isSubclassOf(allMethods[i].getReturnType(), connection)) {
              result.addGoodDetails(smh.getLocalString
                  ("tests.componentNameConstructor",
                   "For [ {0} ]",
                   new Object[] {compName.toString()}));
              result.passed(smh.getLocalString(
                    getClass().getName() + ".passed",
                    "The getConnection method of the [ {0} ] returns the [ {1} ] interface",
                    new Object[] {cf.getName(), connection} ));        
            } else {
              result.addErrorDetails(smh.getLocalString
                  ("tests.componentNameConstructor",
                   "For [ {0} ]",
                   new Object[] {compName.toString()}));
              result.failed(smh.getLocalString(                        
                    getClass().getName() + ".failed",
                    "Error: The getConnection method of the [ {0} ] does not return the [ {1} ] interface",
                    new Object[] {cf.getName(), connection} ));        
            }
            return result;
          } 
        }
        cf = cf.getSuperclass();
      } while (cf!=null);
      result.addWarningDetails(smh.getLocalString
          ("tests.componentNameConstructor",
           "For [ {0} ]",
           new Object[] {compName.toString()}));
      result.warning(smh.getLocalString(
            getClass().getName() + ".warning",
            "Warning: The getConnection method is not defined by [ {0} ]",
            new Object[] {className} ));
    }
    else
    {
      result.addNaDetails(smh.getLocalString
          ("tests.componentNameConstructor",
           "For [ {0} ]",
           new Object[] {compName.toString()}));
      result.notApplicable(smh.getLocalString
          ("com.sun.enterprise.tools.verifier.tests.connector.cci.notApp",
           "The CCI interfaces do not seem to be implemented by this resource adapter"));
    }
    return result;