1 23 24 29 30 package com.sun.enterprise.tools.verifier.tests.util; 31 32 import com.sun.enterprise.tools.verifier.Result; 33 import java.io.File ; 34 import java.io.FileInputStream ; 35 import java.util.StringTokenizer ; 36 import java.util.jar.Attributes ; 37 import java.util.jar.JarFile ; 38 import java.util.jar.Manifest ; 39 40 53 public class BundledOptPkgHasDependencies { 54 public static void test(String explodedJarPath, Result result){ 55 try{ 56 boolean failed=false; 57 Manifest manifest=new Manifest (new FileInputStream (new File (explodedJarPath+File.separator+JarFile.MANIFEST_NAME))); 58 String depClassPath=manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH); 59 if(depClassPath!=null){ 60 for(StringTokenizer st=new StringTokenizer (depClassPath);st.hasMoreTokens();){ 61 String entry=st.nextToken(); 62 String entryPath=new File (explodedJarPath).getParent()+File.separator+entry; 63 File bundledOptPkg=new File (entryPath); 64 if(!bundledOptPkg.isDirectory()){ 65 Manifest bundledManifest=new JarFile (bundledOptPkg).getManifest(); 66 String bundledCP=bundledManifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH); 67 if(bundledCP!=null && bundledCP.length()!=0){ 68 failed=true; 69 result.failed(entry + " contains Class-Path in it's manifest."); 70 } 71 } 72 } 73 } if(!failed){ 75 result.setStatus(Result.PASSED); 76 } 77 }catch(Exception e){ 78 result.failed(e.toString()); 79 } 80 } 81 } 82 | Popular Tags |