FileDocCategorySizeDatePackage
CheckResourceAdapterClass.javaAPI DocGlassfish v2 API5979Fri May 04 22:33:28 BST 2007com.sun.enterprise.tools.verifier.tests.connector

CheckResourceAdapterClass

public class CheckResourceAdapterClass extends com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest implements com.sun.enterprise.tools.verifier.tests.connector.ConnectorCheck
Test that "resourceadapter-class" implements "javax.resource.spi.ResourceAdapter".
author
Anisha Malhotra
version

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

Test that "resourceadapter-class" implements "javax.resource.spi.ResourceAdapter".

param
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();
    String resourceAdapterClass = descriptor.getResourceAdapterClass();
    if(resourceAdapterClass.equals(""))
    {
      if(descriptor.getInBoundDefined())
      {
        // resourceadapter-class cannot be null
        result.addErrorDetails(smh.getLocalString
            ("tests.componentNameConstructor",
             "For [ {0} ]",
             new Object[] {compName.toString()}));
        result.failed(smh.getLocalString
            (getClass().getName() + ".failed1",
             "resourceadapter-class cannot be empty if the resource" + 
             " adapter provides inbound communication"));
      }
      else
      {
          result.addNaDetails(smh.getLocalString
              ("tests.componentNameConstructor",
               "For [ {0} ]",
               new Object[] {compName.toString()}));
          result.notApplicable(smh.getLocalString
              ("com.sun.enterprise.tools.verifier.tests.connector.resourceadapter.notApp",
               "resourceadapter-class is not specified."));
      }
      return result;
    }
    Context context = getVerifierContext();
    ClassLoader jcl = context.getRarClassLoader();
    Class implClass = null;
    try
    {
      implClass = Class.forName(resourceAdapterClass, 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." + 
          "CheckResourceAdapter.nonexist",
           "Error: The class [ {0} ] as defined under resourceadapter-class " +            "in the deployment descriptor does not exist",
           new Object[] {resourceAdapterClass}));
      return result;
    }
    if(!isImplementorOf(implClass, "javax.resource.spi.ResourceAdapter"))
    {
      result.addErrorDetails(smh.getLocalString
          ("tests.componentNameConstructor",
           "For [ {0} ]",
           new Object[] {compName.toString()}));
      result.failed(smh.getLocalString(getClass().getName() + ".failed",
            "Error: resourceadapter-class [ {0} ] does not implement javax.resource.spi.ResourceAdapter",
            new Object[] {resourceAdapterClass}));
    }
    else
    {
      result.addGoodDetails(smh.getLocalString
          ("tests.componentNameConstructor",
           "For [ {0} ]",
           new Object[] {compName.toString()}));	
      result.passed(smh.getLocalString(getClass().getName() + ".passed",
            "Success: resourceadapter-class implements javax.resource.spi.ResourceAdapter"));                     
    }
    return result;