1 23 package com.sun.enterprise.tools.verifier.tests.appclient; 24 25 import com.sun.enterprise.deployment.*; 26 import com.sun.enterprise.tools.verifier.*; 27 import com.sun.enterprise.deployment.io.DescriptorConstants; 28 import com.sun.enterprise.tools.verifier.tests.*; 29 import java.io.*; 30 import java.util.jar.*; 31 32 import com.sun.enterprise.deployment.deploy.shared.FileArchive; 33 34 39 public class JarContainsXML extends AppClientTest implements AppClientCheck { 40 41 42 43 52 public Result check(ApplicationClientDescriptor descriptor) { 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 65 JarFile jarFile = null; 66 InputStream deploymentEntry=null; 67 try { 68 70 74 String uri = getAbstractArchiveUri(descriptor); 76 try { 77 FileArchive arch = new FileArchive(); 78 arch.open(uri); 79 deploymentEntry = arch.getEntry( 80 DescriptorConstants.APP_CLIENT_DD_ENTRY); 81 }catch (IOException e) { throw e;} 82 91 if (deploymentEntry != null) { 92 result.addGoodDetails(smh.getLocalString 93 ("tests.componentNameConstructor", 94 "For [ {0} ]", 95 new Object [] {compName.toString()})); 96 result.passed(smh.getLocalString 97 (getClass().getName() + ".passed", 98 "Found deployment descriptor xml file [ {0} ]", 99 new Object [] {DescriptorConstants.APP_CLIENT_DD_ENTRY})); 100 } else { 101 result.addErrorDetails(smh.getLocalString 102 ("tests.componentNameConstructor", 103 "For [ {0} ]", 104 new Object [] {compName.toString()})); 105 result.failed(smh.getLocalString 106 (getClass().getName() + ".failed", 107 "Error: No deployment descriptor xml file found, looking for [ {0} ]", 108 new Object [] {DescriptorConstants.APP_CLIENT_DD_ENTRY})); 109 } 110 111 } catch (FileNotFoundException ex) { 112 Verifier.debug(ex); 113 result.addErrorDetails(smh.getLocalString 114 ("tests.componentNameConstructor", 115 "For [ {0} ]", 116 new Object [] {compName.toString()})); 117 result.failed(smh.getLocalString 118 (getClass().getName() + ".failedException", 119 "Error: File not found trying to read deployment descriptor file [ {0} ]", 120 new Object [] {DescriptorConstants.APP_CLIENT_DD_ENTRY})); 121 } catch (IOException ex) { 122 Verifier.debug(ex); 123 result.addErrorDetails(smh.getLocalString 124 ("tests.componentNameConstructor", 125 "For [ {0} ]", 126 new Object [] {compName.toString()})); 127 result.failed(smh.getLocalString 128 (getClass().getName() + ".failedException1", 129 "Error: IO Error trying to read deployment descriptor file [ {0} ]", 130 new Object [] {DescriptorConstants.APP_CLIENT_DD_ENTRY})); 131 } finally { 132 try { 133 if (jarFile != null) 134 jarFile.close(); 135 if (deploymentEntry != null) 136 deploymentEntry.close(); 137 } catch (Exception x) {} 138 } 139 140 return result; 141 } 142 } 143 | Popular Tags |