01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: package org.apache.tools.ant;
20:
21: import org.apache.tools.ant.taskdefs.ConditionTask;
22: import org.apache.tools.ant.taskdefs.Echo;
23: import org.apache.tools.ant.types.FileSet;
24:
25: public class LocationTest extends BuildFileTest {
26:
27: public void setUp() {
28: configureProject("src/etc/testcases/core/location.xml");
29: }
30:
31: public void testPlainTask() {
32: executeTarget("testPlainTask");
33: Echo e = (Echo) getProject().getReference("echo");
34: assertFalse(e.getLocation() == Location.UNKNOWN_LOCATION);
35: assertFalse(e.getLocation().getLineNumber() == 0);
36: }
37:
38: public void testStandaloneType() {
39: executeTarget("testStandaloneType");
40: Echo e = (Echo) getProject().getReference("echo2");
41: FileSet f = (FileSet) getProject().getReference("fs");
42: assertFalse(f.getLocation() == Location.UNKNOWN_LOCATION);
43: assertEquals(e.getLocation().getLineNumber() + 1, f
44: .getLocation().getLineNumber());
45: }
46:
47: public void testConditionTask() {
48: executeTarget("testConditionTask");
49: TaskAdapter ta = (TaskAdapter) getProject()
50: .getReference("cond");
51: ConditionTask c = (ConditionTask) ta.getProxy();
52: assertFalse(c.getLocation() == Location.UNKNOWN_LOCATION);
53: assertFalse(c.getLocation().getLineNumber() == 0);
54: }
55:
56: public void testMacrodefWrappedTask() {
57: executeTarget("testMacrodefWrappedTask");
58: Echo e = (Echo) getProject().getReference("echo3");
59: assertTrue(getLog().indexOf(
60: "Line: " + (e.getLocation().getLineNumber() + 1)) > -1);
61: }
62:
63: public void testPresetdefWrappedTask() {
64: executeTarget("testPresetdefWrappedTask");
65: Echo e = (Echo) getProject().getReference("echo4");
66: assertTrue(getLog().indexOf(
67: "Line: " + (e.getLocation().getLineNumber() + 1)) > -1);
68: }
69:
70: public static class EchoLocation extends Task {
71: public void execute() {
72: log("Line: " + getLocation().getLineNumber(),
73: Project.MSG_INFO);
74: }
75: }
76: }
|