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

WSDLFileCheck

public class WSDLFileCheck 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();

        InputStream deploymentEntry=null;

        // wsdl file
        if (descriptor.hasWsdlFile()) {
            String wsdlUri = descriptor.getWsdlFileUri();
            URL url = null;
            try {
                url = new URL(wsdlUri);
            } catch(java.net.MalformedURLException e) {
                // don't care, will eventuall fail below
            }
            if (url != null) {
                if ("http".equals(url.getProtocol()) || "https".equals(url.getProtocol())) {
                    return result;
                }
            }
            try {
                String uri = getAbstractArchiveUri(descriptor);
                FileArchive arch = new FileArchive();
                arch.open(uri);
                deploymentEntry = arch.getEntry(wsdlUri);

                if (deploymentEntry == null) {
                    //result.fail,
                    result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                            "For [ {0} ]", new Object[] {compName.toString()}));
                    result.failed(smh.getLocalString (getClass().getName() + ".failed",
                            "WSDL file does not exist in the archive at uri [{0}].",
                            new Object[] {wsdlUri}));
                }
                else {
                    //result.pass
                    result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor",
                            "For [ {0} ]", new Object[] {compName.toString()}));
                    result.passed(smh.getLocalString (getClass().getName() + ".passed",
                            "WSDL file exists in the archive at uri [{0}].",
                            new Object[] {wsdlUri}));

                }
            }catch (Exception e) {
                // result.fail
                result.addErrorDetails(smh.getLocalString
                        ("com.sun.enterprise.tools.verifier.tests.webservices.Error",
                                "Error: Unexpected error occurred [ {0} ]",
                                new Object[] {e.getMessage()}));
            }
            finally {
                try {
                    if (deploymentEntry != null)
                        deploymentEntry.close();
                }catch (IOException e) {}
            }

        }
        else {
            //result.notapplicable since no wsdl specified
            result.addNaDetails(smh.getLocalString
                    ("tests.componentNameConstructor", "For [ {0} ]",
                            new Object[] {compName.toString()}));
            result.notApplicable(smh.getLocalString
                    ( getClass().getName() + ".notapp",
                            "Not applicable since Service Client does not have a WSDL file specified."));

        }

        return result;