KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > net > sourceforge > pmd > util > ApplierTest


1 /**
2  * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3  */

4 package test.net.sourceforge.pmd.util;
5
6 import junit.framework.TestCase;
7 import net.sourceforge.pmd.util.Applier;
8 import net.sourceforge.pmd.util.UnaryFunction;
9
10 import java.util.ArrayList JavaDoc;
11 import java.util.List JavaDoc;
12
13 public class ApplierTest extends TestCase {
14
15     private static class MyFunction implements UnaryFunction {
16         private boolean gotCallback;
17
18         public void applyTo(Object JavaDoc o) {
19             this.gotCallback = true;
20         }
21
22         public boolean gotCallback() {
23             return this.gotCallback;
24         }
25     }
26
27     public void testSimple() {
28         MyFunction f = new MyFunction();
29         List JavaDoc l = new ArrayList JavaDoc();
30         l.add(new Object JavaDoc());
31         Applier.apply(f, l.iterator());
32         assertTrue(f.gotCallback());
33     }
34 }
35
Popular Tags