1 23 package com.sun.enterprise.tools.verifier.tests.appclient; 24 25 import com.sun.enterprise.tools.verifier.Result; 26 import com.sun.enterprise.tools.verifier.apiscan.classfile.ClosureCompiler; 27 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 28 import com.sun.enterprise.tools.verifier.tests.util.ArchiveClassesLoadableHelper; 29 import com.sun.enterprise.deployment.ApplicationClientDescriptor; 30 import com.sun.enterprise.deployment.deploy.shared.FileArchive; 31 32 import java.util.Enumeration ; 33 34 42 public class AppClientArchiveClassesLoadable extends AppClientTest implements AppClientCheck { 43 44 public Result check(ApplicationClientDescriptor descriptor) { 45 Result result = getInitializedResult(); 46 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 47 String archiveUri = getAbstractArchiveUri(descriptor); 48 49 boolean allPassed = true; 50 FileArchive arch = null; 51 Enumeration entries= null; 52 ClosureCompiler closureCompiler=getVerifierContext().getClosureCompiler(); 53 54 try { 55 String uri = getAbstractArchiveUri(descriptor); 56 arch = new FileArchive(); 57 arch.open(uri); 58 entries = arch.entries(); 59 arch.close(); 60 } catch(Exception e) { 61 e.printStackTrace(); 62 result.failed(smh.getLocalString(getClass().getName() + ".exception", 63 "Error: [ {0} ] exception while loading the archive [ {1} ].", 64 new Object [] {e, descriptor.getName()})); 65 return result; 66 } 67 Object entry; 68 while (entries.hasMoreElements()) { 69 String name=null; 70 entry = entries.nextElement(); 71 name = (String )entry; 72 if (name.endsWith(".class")) { 74 String className = name.substring(0, name.length()-".class".length()).replace('/','.'); 75 boolean status=closureCompiler.buildClosure(className); 76 allPassed=status && allPassed; 77 } 78 } 79 if (allPassed) { 80 result.setStatus(Result.PASSED); 81 addGoodDetails(result, compName); 82 result.passed(smh.getLocalString 83 (getClass().getName() + ".passed", 84 "All the classes are loadable within [ {0} ] without any linkage error.", 85 new Object [] {archiveUri})); 86 } else { 88 result.setStatus(Result.FAILED); 89 addErrorDetails(result, compName); 90 result.addErrorDetails(ArchiveClassesLoadableHelper. 91 getFailedResult(closureCompiler)); 92 result.addErrorDetails(smh.getLocalString 93 ("com.sun.enterprise.tools.verifier.tests.loadableError", 94 "Please either bundle the above mentioned classes in the application " + 95 "or use optional packaging support for them.")); 96 } 97 return result; 98 } 99 } 100 | Popular Tags |