1 package com.puppycrawl.tools.checkstyle.checks; 2 3 import junit.framework.TestCase; 4 5 import java.util.Set ; 6 import java.util.HashSet ; 7 8 public class ClassResolverTest 9 extends TestCase 10 { 11 public void testMisc() throws ClassNotFoundException 12 { 13 final Set imps = new HashSet (); 14 imps.add("java.io.File"); 15 imps.add("nothing.will.match.*"); 16 imps.add("java.applet.*"); 17 ClassResolver cr = 18 new ClassResolver(Thread.currentThread().getContextClassLoader(), 19 null, imps); 20 assertNotNull(cr); 21 try { 22 cr.resolve("who.will.win.the.world.cup", ""); 23 fail("Should not resolve class"); 24 } 25 catch (ClassNotFoundException e) { 26 } 27 cr.resolve("java.lang.String", ""); 28 cr.resolve("StringBuffer", ""); 29 cr.resolve("AppletContext", ""); 30 31 try { 32 cr.resolve("ChoiceFormat", ""); 33 fail(); 34 } 35 catch (ClassNotFoundException e) { 36 } 37 38 imps.add("java.text.ChoiceFormat"); 39 cr.resolve("ChoiceFormat", ""); 40 41 cr = new ClassResolver(Thread.currentThread().getContextClassLoader(), 42 "java.util", imps); 43 cr.resolve("List", ""); 44 try { 45 cr.resolve("two.nil.england", ""); 46 fail(); 47 } 48 catch (ClassNotFoundException e) { 49 } 50 } 51 } 52 | Popular Tags |