1 15 package org.apache.hivemind.impl; 16 17 import java.net.URL ; 18 import java.net.URLClassLoader ; 19 20 import org.apache.hivemind.test.HiveMindTestCase; 21 22 26 public class TestMessageFormatter extends HiveMindTestCase 27 { 28 29 public void testWithNoPackage() 30 throws Exception 31 { 32 final ClassLoader loader = new NoPackageClassLoader(); 33 34 new MessageFormatter(loader.loadClass(MessageFormatterTarget.class.getName()), "MessageFinder"); 35 } 36 37 private class NoPackageClassLoader extends URLClassLoader 38 { 39 40 public NoPackageClassLoader() 41 { 42 super(new URL [] { TestMessageFormatter.class.getProtectionDomain().getCodeSource().getLocation() }); 43 } 44 45 protected Package getPackage(String name) 46 { 47 return null; 48 } 49 50 public Class loadClass(String name) 51 throws ClassNotFoundException 52 { 53 try 54 { 55 return findClass(name); 56 } 57 catch (ClassNotFoundException e) 58 { 59 return super.loadClass(name); 60 } 61 62 } 63 } 64 } 65 | Popular Tags |