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