KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > filters > HeadTailTest


1 /*
2  * Copyright 2003-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 package org.apache.tools.ant.filters;
19
20 import java.io.File JavaDoc;
21 import java.io.IOException JavaDoc;
22
23 import org.apache.tools.ant.BuildFileTest;
24 import org.apache.tools.ant.util.FileUtils;
25
26 /** JUnit Testcases for TailFilter and HeadFilter
27  */

28 /* I wrote the testcases in one java file because I want also to test the
29  * combined behaviour (see end of the class).
30 */

31 public class HeadTailTest extends BuildFileTest {
32
33     public HeadTailTest(String JavaDoc name) {
34         super(name);
35     }
36
37     public void setUp() {
38         configureProject("src/etc/testcases/filters/head-tail.xml");
39     }
40
41     public void tearDown() {
42         executeTarget("cleanup");
43     }
44
45     public void testHead() throws IOException JavaDoc {
46         executeTarget("testHead");
47         File JavaDoc expected = getProject().resolveFile("expected/head-tail.head.test");
48         File JavaDoc result = getProject().resolveFile("result/head-tail.head.test");
49         FileUtils fu = FileUtils.newFileUtils();
50         assertTrue("testHead: Result not like expected", fu.contentEquals(expected, result));
51     }
52
53     public void testHeadLines() throws IOException JavaDoc {
54         executeTarget("testHeadLines");
55         File JavaDoc expected = getProject().resolveFile("expected/head-tail.headLines.test");
56         File JavaDoc result = getProject().resolveFile("result/head-tail.headLines.test");
57         FileUtils fu = FileUtils.newFileUtils();
58         assertTrue("testHeadLines: Result not like expected", fu.contentEquals(expected, result));
59     }
60
61     public void testHeadSkip() throws IOException JavaDoc {
62         executeTarget("testHeadSkip");
63         File JavaDoc expected = getProject().resolveFile("expected/head-tail.headSkip.test");
64         File JavaDoc result = getProject().resolveFile("result/head-tail.headSkip.test");
65         FileUtils fu = FileUtils.newFileUtils();
66         assertTrue("testHeadSkip: Result not like expected", fu.contentEquals(expected, result));
67     }
68
69     public void testHeadLinesSkip() throws IOException JavaDoc {
70         executeTarget("testHeadLinesSkip");
71         File JavaDoc expected = getProject().resolveFile("expected/head-tail.headLinesSkip.test");
72         File JavaDoc result = getProject().resolveFile("result/head-tail.headLinesSkip.test");
73         FileUtils fu = FileUtils.newFileUtils();
74         assertTrue("testHeadLinesSkip: Result not like expected", fu.contentEquals(expected, result));
75     }
76
77     public void testFilterReaderHeadLinesSkip() throws IOException JavaDoc {
78         executeTarget("testFilterReaderHeadLinesSkip");
79         File JavaDoc expected = getProject().resolveFile(
80             "expected/head-tail.headLinesSkip.test");
81         File JavaDoc result = getProject().resolveFile(
82             "result/head-tail.filterReaderHeadLinesSkip.test");
83         FileUtils fu = FileUtils.newFileUtils();
84         assertTrue("testFilterReaderHeadLinesSkip: Result not like expected",
85                    fu.contentEquals(expected, result));
86     }
87
88     public void testTail() throws IOException JavaDoc {
89         executeTarget("testTail");
90         File JavaDoc expected = getProject().resolveFile("expected/head-tail.tail.test");
91         File JavaDoc result = getProject().resolveFile("result/head-tail.tail.test");
92         FileUtils fu = FileUtils.newFileUtils();
93         assertTrue("testTail: Result not like expected", fu.contentEquals(expected, result));
94     }
95
96     public void testTailLines() throws IOException JavaDoc {
97         executeTarget("testTailLines");
98         File JavaDoc expected = getProject().resolveFile("expected/head-tail.tailLines.test");
99         File JavaDoc result = getProject().resolveFile("result/head-tail.tailLines.test");
100         FileUtils fu = FileUtils.newFileUtils();
101         assertTrue("testTailLines: Result not like expected", fu.contentEquals(expected, result));
102     }
103
104     public void testTailSkip() throws IOException JavaDoc {
105         executeTarget("testTailSkip");
106         File JavaDoc expected = getProject().resolveFile("expected/head-tail.tailSkip.test");
107         File JavaDoc result = getProject().resolveFile("result/head-tail.tailSkip.test");
108         FileUtils fu = FileUtils.newFileUtils();
109         assertTrue("testTailSkip: Result not like expected", fu.contentEquals(expected, result));
110     }
111
112     public void testTailLinesSkip() throws IOException JavaDoc {
113         executeTarget("testTailLinesSkip");
114         File JavaDoc expected = getProject().resolveFile("expected/head-tail.tailLinesSkip.test");
115         File JavaDoc result = getProject().resolveFile("result/head-tail.tailLinesSkip.test");
116         FileUtils fu = FileUtils.newFileUtils();
117         assertTrue("testTailLinesSkip: Result not like expected", fu.contentEquals(expected, result));
118     }
119
120     public void testFilterReaderTailLinesSkip() throws IOException JavaDoc {
121         executeTarget("testFilterReaderTailLinesSkip");
122         File JavaDoc expected = getProject().resolveFile(
123             "expected/head-tail.tailLinesSkip.test");
124         File JavaDoc result = getProject().resolveFile(
125             "result/head-tail.filterReaderTailLinesSkip.test");
126         FileUtils fu = FileUtils.newFileUtils();
127         assertTrue("testFilterReaderTailLinesSkip: Result not like expected",
128                    fu.contentEquals(expected, result));
129     }
130
131     public void testHeadTail() throws IOException JavaDoc {
132         executeTarget("testHeadTail");
133         File JavaDoc expected = getProject().resolveFile("expected/head-tail.headtail.test");
134         File JavaDoc result = getProject().resolveFile("result/head-tail.headtail.test");
135         FileUtils fu = FileUtils.newFileUtils();
136         assertTrue("testHeadTail: Result not like expected", fu.contentEquals(expected, result));
137     }
138
139 }
140
Popular Tags