FileDocCategorySizeDatePackage
MappingFileCheck.javaAPI DocGlassfish v2 API8364Fri May 04 22:34:18 BST 2007com.sun.enterprise.tools.verifier.tests.wsclients

MappingFileCheck

public class MappingFileCheck extends WSClientTest implements WSClientCheck

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(ServiceReferenceDescriptor descriptor)

param
descriptor the WebServices descriptor
return
Result the results for this assertion


	Result result = getInitializedResult();
        ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();

        if (descriptor.hasWsdlFile()) {

           if(descriptor.hasMappingFile()) {
             //result.pass
             result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
                                    "For [ {0} ]", new Object[] {compName.toString()}));
             result.passed(smh.getLocalString (getClass().getName() + ".passed1",
                           "Mapping file specified because WSDL file is also specified."));

           }
           else {
             //result.fail, has wsdl but no mapping
             result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                                   "For [ {0} ]", new Object[] {compName.toString()}));
             result.failed(smh.getLocalString (getClass().getName() + ".failed1",
                "The webservice client [{0}] has a WSDL file specified but no Mapping File.",
                 new Object[] {compName.toString()}));
           }
         }
         else {
           if(descriptor.hasMappingFile()) {
             //result.fail, mapping without WSDL
             result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                                   "For [ {0} ]", new Object[] {compName.toString()}));
             result.failed(smh.getLocalString (getClass().getName() + ".failed1",
                "The webservice client [{0}] has a Mapping file specified but no WSDL File.",
                 new Object[] {compName.toString()}));
           }
           else {
             //result.pass, neither WSDL nor Mapping
              result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
                                    "For [ {0} ]", new Object[] {compName.toString()}));
              result.passed(smh.getLocalString (getClass().getName() + ".passed2",
                           "Mapping file found at location [{0}] in archive.",
                           new Object[] {descriptor.getMappingFileUri()}));
           }
        }

        if (descriptor.hasMappingFile()) {
           // maybe we should not depend on DOL to get the location of Mapping file
           String mappingFile = descriptor.getMappingFileUri();

//           File f = Verifier.getArchiveFile(descriptor.getBundleDescriptor().
//                    getModuleDescriptor().getArchiveUri());
//           JarFile jarFile = null;
           InputStream deploymentEntry=null;

           try {
          
//             if (f == null) {
                 String uri = getAbstractArchiveUri(descriptor);
//                 try {
                    FileArchive arch = new FileArchive();
                    arch.open(uri);
                    deploymentEntry = arch.getEntry(mappingFile);
//                 }catch (IOException e) { throw e;}
//                }
//                else {
//
//                  jarFile = new JarFile(f);
//                  ZipEntry deploymentEntry1 =
//                      jarFile.getEntry(mappingFile);
//                  deploymentEntry = jarFile.getInputStream(deploymentEntry1);
//               }
               if (deploymentEntry == null) {
                  //result.fail, mapping file does not exist at that location
                   result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                                   "For [ {0} ]", new Object[] {compName.toString()}));
                   result.failed(smh.getLocalString (getClass().getName() + ".failed",
                    "The mapping file does not exist at the specified location [{0}] in the archive.",
                   new Object[] {mappingFile}));
               }
               else {

                    result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
                                    "For [ {0} ]", new Object[] {compName.toString()}));
                    result.passed(smh.getLocalString (getClass().getName() + ".passed",
                           "Mapping file found at location [{0}] in archive.",
                           new Object[] {mappingFile}));
               }
           }catch (Exception e) {
             // result.fail, mapping file does not exist at that location
             result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                                   "For [ {0} ]", new Object[] {compName.toString()}));
             result.failed(smh.getLocalString (getClass().getName() + ".failed",
              "The mapping file does not exist at the specified location [{0}] in the archive.",
               new Object[] {mappingFile}));

           }
           finally {
              try {
              if (deploymentEntry != null)
                  deploymentEntry.close();
              }catch(IOException e) {}
           }
        }
        else {
           //result.notapplicable. Mapping file exists check not applicable
            result.addNaDetails(smh.getLocalString
                     ("tests.componentNameConstructor", "For [ {0} ]",
                      new Object[] {compName.toString()}));
            result.notApplicable(smh.getLocalString
                 ( getClass().getName() + ".notapp",
                 "This webservice client does not have a Mapping File."));
        }

        return result;