1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.commons.pipeline.stage;
20
21 import junit.framework.*;
22 import java.lang.reflect.Method;
23 import java.util.ArrayList;
24
25
26
27
28
29 public class InvokeMethodStageTest extends AbstractStageTest {
30
31 public InvokeMethodStageTest(String testName) {
32 super(testName);
33 }
34
35 public static Test suite() {
36 TestSuite suite = new TestSuite(InvokeMethodStageTest.class);
37
38 return suite;
39 }
40
41
42
43
44 public void testReflectionConstructor() throws Exception {
45 InvokeMethodStage stage = new InvokeMethodStage("java.lang.String", "lastIndexOf", "foo");
46 Method method = stage.getMethod();
47 assertNotNull(method);
48 assertSame(String.class, method.getDeclaringClass());
49 assertEquals("lastIndexOf", method.getName());
50 }
51
52
53
54
55 public void testProcess() throws Exception {
56 InvokeMethodStage stage = new InvokeMethodStage("java.lang.String", "toUpperCase", new Object[0]);
57 this.init(stage);
58
59 stage.process("some text");
60
61 assertEquals(1, testFeeder.receivedValues.size());
62
63 Object o = testFeeder.receivedValues.get(0);
64 assertNotNull(o);
65 assertTrue(o instanceof String);
66 assertEquals("SOME TEXT", o);
67 }
68 }