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