001 package org.picocontainer.script; 002 003 import java.io.File; 004 005 public class TestHelper { 006 007 public static File getTestCompJarFile() { 008 String testcompJarProperty = System.getProperty("testcomp.jar"); 009 if (testcompJarProperty != null) { 010 return new File(testcompJarProperty); 011 } 012 013 Class<TestHelper> aClass = TestHelper.class; 014 File base = new File(aClass.getProtectionDomain().getCodeSource().getLocation().getFile()); 015 if (base == null) { 016 throw new NullPointerException("base"); 017 } 018 019 File tj = new File(base,"src/test-comp/testcomp.jar"); 020 while (!tj.exists()) { 021 base = base.getParentFile(); 022 if (base == null) { 023 throw new NullPointerException("Could not find testcomp.jar"); 024 } 025 tj = new File(base,"src/test-comp/testcomp.jar"); 026 } 027 return tj; 028 } 029 030 031 }