1 23 package com.sun.enterprise.tools.verifier.tests.app; 24 25 import com.sun.enterprise.tools.verifier.tests.app.ApplicationTest; 26 27 import com.sun.enterprise.deployment.io.ApplicationDeploymentDescriptorFile; 28 import com.sun.enterprise.deployment.Application; 29 import com.sun.enterprise.tools.verifier.*; 30 import java.io.*; 31 import java.util.jar.*; 32 33 import com.sun.enterprise.deployment.deploy.shared.FileArchive; 34 35 38 public class JarContainsXMLFile extends ApplicationTest implements AppCheck { 39 40 41 48 public Result check(Application descriptor) { 49 50 Result result = getInitializedResult(); 51 52 if(getVerifierContext().getJavaEEVersion(). 55 compareTo(SpecVersionMapper.JavaEEVersion_5) >= 0) { 56 result.setStatus(Result.NOT_APPLICABLE); 57 return result; 58 } 59 60 61 JarFile jarFile = null; 62 InputStream deploymentEntry=null; 63 try { 64 68 72 FileArchive arch = (FileArchive)getVerifierContext(). 75 getAbstractArchive(); 76 deploymentEntry = arch.getEntry( 77 ApplicationDeploymentDescriptorFile.DESC_PATH); 78 88 if (deploymentEntry != null) { 89 result.passed(smh.getLocalString 90 (getClass().getName() + ".passed", 91 "Found deployment descriptor xml file [ {0} ]", 92 new Object [] {ApplicationDeploymentDescriptorFile.DESC_PATH})); 93 } else { 94 95 result.failed(smh.getLocalString 96 (getClass().getName() + ".failed", 97 "Error: No deployment descriptor xml file found, looking for [ {0} ]", 98 new Object [] {ApplicationDeploymentDescriptorFile.DESC_PATH})); 99 } 100 101 } catch (FileNotFoundException ex) { 102 Verifier.debug(ex); 103 104 result.failed(smh.getLocalString 105 (getClass().getName() + ".failedException", 106 "Error: File not found trying to read deployment descriptor file [ {0} ]", 107 new Object [] {ApplicationDeploymentDescriptorFile.DESC_PATH})); 108 } catch (IOException ex) { 109 Verifier.debug(ex); 110 111 result.failed(smh.getLocalString 112 (getClass().getName() + ".failedException1", 113 "Error: IO Error trying to read deployment descriptor file [ {0} ]", 114 new Object [] {ApplicationDeploymentDescriptorFile.DESC_PATH})); 115 } finally { 116 try { 117 if (jarFile != null) 118 jarFile.close(); 119 if (deploymentEntry != null) 120 deploymentEntry.close(); 121 } catch (Exception x) {} 122 } 123 124 return result; 125 } 126 } 127 | Popular Tags |