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: package org.apache.tools.ant.taskdefs;
019:
020: import org.apache.tools.ant.BuildException;
021: import org.apache.tools.ant.BuildFileTest;
022:
023: /**
024: * Test the load file task
025: *
026: * @created 10 December 2001
027: */
028: public class LoadFileTest extends BuildFileTest {
029:
030: /**
031: * Constructor for the LoadFileTest object
032: *
033: * @param name Description of Parameter
034: */
035: public LoadFileTest(String name) {
036: super (name);
037: }
038:
039: /**
040: * The JUnit setup method
041: */
042: public void setUp() {
043: configureProject("src/etc/testcases/taskdefs/loadfile.xml");
044: }
045:
046: /**
047: * The teardown method for JUnit
048: */
049: public void tearDown() {
050: executeTarget("cleanup");
051: }
052:
053: /**
054: * A unit test for JUnit
055: */
056: public void testNoSourcefileDefined() {
057: expectBuildException("testNoSourcefileDefined",
058: "source file not defined");
059: }
060:
061: /**
062: * A unit test for JUnit
063: */
064: public void testNoPropertyDefined() {
065: expectBuildException("testNoPropertyDefined",
066: "output property not defined");
067: }
068:
069: /**
070: * A unit test for JUnit
071: */
072: public void testNoSourcefilefound() {
073: expectBuildExceptionContaining("testNoSourcefilefound",
074: "File not found", " doesn't exist");
075: }
076:
077: /**
078: * A unit test for JUnit
079: */
080: public void testFailOnError() throws BuildException {
081: expectPropertyUnset("testFailOnError", "testFailOnError");
082: }
083:
084: /**
085: * A unit test for JUnit
086: */
087: public void testLoadAFile() throws BuildException {
088: executeTarget("testLoadAFile");
089: if (project.getProperty("testLoadAFile").indexOf("eh?") < 0) {
090: fail("property is not all in the file");
091: }
092: }
093:
094: /**
095: * A unit test for JUnit
096: */
097: public void testLoadAFileEnc() throws BuildException {
098: executeTarget("testLoadAFileEnc");
099: if (project.getProperty("testLoadAFileEnc") == null) {
100: fail("file load failed");
101: }
102: }
103:
104: /**
105: * A unit test for JUnit
106: */
107: public void testEvalProps() throws BuildException {
108: executeTarget("testEvalProps");
109: if (project.getProperty("testEvalProps").indexOf("rain") < 0) {
110: fail("property eval broken");
111: }
112: }
113:
114: /**
115: * Test FilterChain and FilterReaders
116: */
117: public void testFilterChain() throws BuildException {
118: executeTarget("testFilterChain");
119: if (project.getProperty("testFilterChain").indexOf("World!") < 0) {
120: fail("Filter Chain broken");
121: }
122: }
123:
124: /**
125: * Test StripJavaComments filterreader functionality.
126: */
127: public final void testStripJavaComments() throws BuildException {
128: executeTarget("testStripJavaComments");
129: final String expected = project.getProperty("expected");
130: final String generated = project
131: .getProperty("testStripJavaComments");
132: assertEquals(expected, generated);
133: }
134:
135: /**
136: * A unit test for JUnit
137: */
138: public void testOneLine() throws BuildException {
139: expectPropertySet("testOneLine", "testOneLine", "1,2,3,4");
140:
141: }
142: }
|