1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.pipeline.stage;
19
20 import java.util.ArrayList;
21 import java.util.List;
22 import junit.framework.*;
23 import org.apache.commons.pipeline.testFramework.TestFeeder;
24 import org.apache.commons.pipeline.testFramework.TestStageContext;
25
26
27
28
29 public class AddToCollectionStageTest extends AbstractStageTest {
30
31 public AddToCollectionStageTest(String testName) {
32 super(testName);
33 }
34
35 public static Test suite() {
36 TestSuite suite = new TestSuite(AddToCollectionStageTest.class);
37
38 return suite;
39 }
40
41
42
43
44 public void testProcess() throws Exception {
45
46 List<String> testCollection = new ArrayList<String>();
47 AddToCollectionStage<String> stage = new AddToCollectionStage<String>(testCollection, true);
48
49
50 this.init(stage);
51
52
53 stage.process("Hello, World!");
54
55 assertEquals("Incorrect number of objects in collection", 1, testCollection.size());
56 assertEquals("Incorrect object stored in collection", "Hello, World!", testCollection.get(0));
57 assertEquals("Incorrect number of objects received downstream", 1, testFeeder.receivedValues.size());
58 assertEquals("Incorrect value received downstream", "Hello, World!", testFeeder.receivedValues.get(0));
59 }
60 }