source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/testcases/org/apache/tools/ant/taskdefs/ReplaceTest.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 3.1 KB
Line 
1/*
2 * Copyright 2000-2001,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
18package org.apache.tools.ant.taskdefs;
19
20import org.apache.tools.ant.BuildFileTest;
21
22import java.io.*;
23
24import junit.framework.AssertionFailedError;
25
26/**
27 */
28public class ReplaceTest extends BuildFileTest {
29
30 private static final String TEST_PATH = "src/etc/testcases/taskdefs/replace/";
31 public ReplaceTest(String name) {
32 super(name);
33 }
34
35 public void setUp() {
36 configureProject("src/etc/testcases/taskdefs/replace.xml");
37 }
38
39 public void test1() {
40 expectBuildException("test1", "required argument not specified");
41 }
42
43 public void test2() {
44 expectBuildException("test2", "required argument not specified");
45 }
46
47 public void test3() {
48 expectBuildException("test3", "required argument not specified");
49 }
50
51 public void test4() {
52 expectBuildException("test4", "empty token not allowed");
53 }
54
55 public void test5() {
56 executeTarget("test5");
57 }
58
59 public void test6() {
60 expectBuildException("test6", "required argument not specified");
61 }
62
63 public void test7() {
64 expectBuildException("test7", "empty token not allowed");
65 }
66
67 public void test8() {
68 executeTarget("test8");
69 }
70
71 public void test9() throws IOException{
72 executeTarget("test9");
73 String tmpdir = project.getProperty("tmp.dir");
74 assertEqualContent(new File(tmpdir, "result.txt"),
75 new File(tmpdir, "output.txt"));
76 }
77 public void tearDown() {
78 executeTarget("cleanup");
79 }
80 public void assertEqualContent(File expect, File result)
81 throws AssertionFailedError, IOException {
82 if (!result.exists()) {
83 fail("Expected file "+result+" doesn\'t exist");
84 }
85
86 InputStream inExpect = null;
87 InputStream inResult = null;
88 try {
89 inExpect = new BufferedInputStream(new FileInputStream(expect));
90 inResult = new BufferedInputStream(new FileInputStream(result));
91
92 int expectedByte = inExpect.read();
93 while (expectedByte != -1) {
94 assertEquals(expectedByte, inResult.read());
95 expectedByte = inExpect.read();
96 }
97 assertEquals("End of file", -1, inResult.read());
98 } finally {
99 if (inResult != null) {
100 inResult.close();
101 }
102 if (inExpect != null) {
103 inExpect.close();
104 }
105 }
106 }
107}
Note: See TracBrowser for help on using the repository browser.