001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.tools.ant.taskdefs;
020:
021: import java.io.BufferedInputStream;
022: import java.io.File;
023: import java.io.FileInputStream;
024: import java.io.IOException;
025: import java.io.InputStream;
026:
027: import junit.framework.AssertionFailedError;
028:
029: import org.apache.tools.ant.BuildFileTest;
030:
031: /**
032: */
033: public class FixCrLfTest extends BuildFileTest {
034:
035: public FixCrLfTest(String name) {
036: super (name);
037: }
038:
039: public void setUp() {
040: configureProject("src/etc/testcases/taskdefs/fixcrlf/build.xml");
041: }
042:
043: public void tearDown() {
044: executeTarget("cleanup");
045: }
046:
047: public void test1() throws IOException {
048: executeTarget("test1");
049: }
050:
051: public void test2() throws IOException {
052: executeTarget("test2");
053: }
054:
055: public void test3() throws IOException {
056: executeTarget("test3");
057: }
058:
059: public void test4() throws IOException {
060: executeTarget("test4");
061: }
062:
063: public void test5() throws IOException {
064: executeTarget("test5");
065: }
066:
067: public void test6() throws IOException {
068: executeTarget("test6");
069: }
070:
071: public void test7() throws IOException {
072: executeTarget("test7");
073: }
074:
075: public void test8() throws IOException {
076: executeTarget("test8");
077: }
078:
079: public void test9() throws IOException {
080: executeTarget("test9");
081: }
082:
083: public void testMacLines() throws IOException {
084: executeTarget("testMacLines");
085: }
086:
087: public void testNoOverwrite() throws IOException {
088: executeTarget("testNoOverwrite");
089: }
090:
091: public void testEncoding() throws IOException {
092: executeTarget("testEncoding");
093: }
094:
095: public void testOutputEncoding() throws IOException {
096: executeTarget("testOutputEncoding");
097: }
098:
099: public void testLongLines() throws IOException {
100: executeTarget("testLongLines");
101: }
102:
103: public void testCrCrLfSequenceUnix() throws IOException {
104: executeTarget("testCrCrLfSequence-unix");
105: }
106:
107: public void testCrCrLfSequenceDos() throws IOException {
108: executeTarget("testCrCrLfSequence-dos");
109: }
110:
111: public void testCrCrLfSequenceMac() throws IOException {
112: executeTarget("testCrCrLfSequence-mac");
113: }
114:
115: public void testFixlastDos() throws IOException {
116: executeTarget("testFixlastDos");
117: }
118:
119: public void testFixlastFalseMac() throws IOException {
120: executeTarget("testFixlastFalseMac");
121: }
122:
123: public void testFixFile() throws Exception {
124: executeTarget("testFixFile");
125: }
126:
127: public void testFixFileExclusive() throws Exception {
128: expectBuildExceptionContaining("testFixFileExclusive",
129: FixCRLF.ERROR_FILE_AND_SRCDIR,
130: FixCRLF.ERROR_FILE_AND_SRCDIR);
131: }
132:
133: /**
134: * Bugzilla Report 20840
135: *
136: * Will fail with an exception if the parent directories do not
137: * get created.
138: */
139: public void testCreateParentDirs() {
140: executeTarget("createParentDirs");
141: }
142:
143: public void testPreserveLastModified() {
144: executeTarget("testPreserveLastModified");
145: }
146:
147: public void testFilter1() {
148: executeTarget("testFilter1");
149: }
150:
151: public void testFilter2() {
152: executeTarget("testFilter2");
153: }
154:
155: public void testFilter3() {
156: executeTarget("testFilter3");
157: }
158:
159: public void testFilter4() {
160: executeTarget("testFilter4");
161: }
162:
163: public void testFilter5() {
164: executeTarget("testFilter5");
165: }
166:
167: public void testFilter6() {
168: executeTarget("testFilter6");
169: }
170:
171: public void testFilter7() {
172: executeTarget("testFilter7");
173: }
174:
175: public void testFilter8() {
176: executeTarget("testFilter8");
177: }
178:
179: public void testFilter9() {
180: executeTarget("testFilter9");
181: }
182:
183: public void testCannotDoubleEof() {
184: executeTarget("testCannotDoubleEof");
185: }
186:
187: public void testTabInLiteralInComment() {
188: executeTarget("testTabInLiteralInComment");
189: }
190:
191: // not used, but public so theoretically must remain for BC?
192: public void assertEqualContent(File expect, File result)
193: throws AssertionFailedError, IOException {
194: if (!result.exists()) {
195: fail("Expected file " + result + " doesn\'t exist");
196: }
197:
198: InputStream inExpect = null;
199: InputStream inResult = null;
200: try {
201: inExpect = new BufferedInputStream(new FileInputStream(
202: expect));
203: inResult = new BufferedInputStream(new FileInputStream(
204: result));
205:
206: int expectedByte = inExpect.read();
207: while (expectedByte != -1) {
208: assertEquals(expectedByte, inResult.read());
209: expectedByte = inExpect.read();
210: }
211: assertEquals("End of file", -1, inResult.read());
212: } finally {
213: if (inResult != null) {
214: inResult.close();
215: }
216: if (inExpect != null) {
217: inExpect.close();
218: }
219: }
220: }
221:
222: }
|