1 23 package com.sun.enterprise.tools.verifier.tests.web; 24 25 import com.sun.enterprise.deployment.deploy.shared.FileArchive; 26 import com.sun.enterprise.deployment.io.WebDeploymentDescriptorFile; 27 import com.sun.enterprise.deployment.WebBundleDescriptor; 28 import com.sun.enterprise.tools.verifier.*; 29 import com.sun.enterprise.tools.verifier.tests.*; 30 import com.sun.enterprise.tools.verifier.tests.web.WebTest; 31 import java.io.*; 32 33 37 38 public class JarContainsXMLFile extends WebTest implements WebCheck { 39 40 41 42 50 public Result check(WebBundleDescriptor descriptor) { 51 52 Result result = getInitializedResult(); 53 54 if(getVerifierContext().getJavaEEVersion(). 57 compareTo(SpecVersionMapper.JavaEEVersion_5) >= 0) { 58 result.setStatus(Result.NOT_APPLICABLE); 59 return result; 60 } 61 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 62 63 InputStream deploymentEntry=null; 65 try { 66 68 String uri = getAbstractArchiveUri(descriptor); 70 try { 71 FileArchive arch = new FileArchive(); 72 arch.open(uri); 73 deploymentEntry = arch.getEntry( 74 WebDeploymentDescriptorFile.DESC_PATH); 75 }catch (IOException e) { throw e;} 76 86 87 if (deploymentEntry != null) { 88 result.addGoodDetails(smh.getLocalString 89 ("tests.componentNameConstructor", 90 "For [ {0} ]", 91 new Object [] {compName.toString()})); 92 result.passed(smh.getLocalString 93 (getClass().getName() + ".passed", 94 "Found deployment descriptor xml file [ {0} ]", 95 new Object [] {WebDeploymentDescriptorFile.DESC_PATH})); 96 } else { 97 result.addErrorDetails(smh.getLocalString 98 ("tests.componentNameConstructor", 99 "For [ {0} ]", 100 new Object [] {compName.toString()})); 101 result.failed(smh.getLocalString 102 (getClass().getName() + ".failed", 103 "Error: No deployment descriptor xml file found, looking for [ {0} ]", 104 new Object [] {WebDeploymentDescriptorFile.DESC_PATH})); 105 } 106 107 } catch (FileNotFoundException ex) { 108 Verifier.debug(ex); 109 result.addErrorDetails(smh.getLocalString 110 ("tests.componentNameConstructor", 111 "For [ {0} ]", 112 new Object [] {compName.toString()})); 113 result.failed(smh.getLocalString 114 (getClass().getName() + ".failedException", 115 "Error: File not found trying to read deployment descriptor file [ {0} ]", 116 new Object [] {WebDeploymentDescriptorFile.DESC_PATH})); 117 } catch (IOException ex) { 118 Verifier.debug(ex); 119 result.addErrorDetails(smh.getLocalString 120 ("tests.componentNameConstructor", 121 "For [ {0} ]", 122 new Object [] {compName.toString()})); 123 result.failed(smh.getLocalString 124 (getClass().getName() + ".failedException1", 125 "Error: IO Error trying to read deployment descriptor file [ {0} ]", 126 new Object [] {WebDeploymentDescriptorFile.DESC_PATH})); 127 } finally { 128 try { 129 if (deploymentEntry != null) 132 deploymentEntry.close(); 133 } catch (Exception x) {} 134 } 135 136 return result; 137 } 138 } 139 | Popular Tags |