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.taskdefs;
20:
21: import org.apache.tools.ant.BuildFileTest;
22: import org.apache.tools.ant.Task;
23: import org.apache.tools.ant.Project;
24:
25: /**
26: */
27: public class AntlibTest extends BuildFileTest {
28: public AntlibTest(String name) {
29: super (name);
30: }
31:
32: public void setUp() {
33: configureProject("src/etc/testcases/taskdefs/antlib.xml");
34: }
35:
36: /**
37: * only do the antlib tests if we are in the same JVM as ant.
38: * @return
39: */
40: private boolean isSharedJVM() {
41: String property = System
42: .getProperty("tests.and.ant.share.classloader");
43: return property != null && Project.toBoolean(property);
44: }
45:
46: public void testAntlibFile() {
47: expectLog("antlib.file", "MyTask called");
48: }
49:
50: /**
51: * Confirms that all matching resources will be used, so that you
52: * can collect several antlibs in one Definer call.
53: * @see "http://issues.apache.org/bugzilla/show_bug.cgi?id=24024"
54: */
55: public void testAntlibResource() {
56: expectLog("antlib.resource",
57: "MyTask called-and-then-MyTask2 called");
58: }
59:
60: public void testNsCurrent() {
61: expectLog("ns.current", "Echo2 inside a macroHello from x:p");
62: }
63:
64: public void testAntlib_uri() {
65: if (isSharedJVM()) {
66: executeTarget("antlib_uri");
67: }
68: }
69:
70: public void testAntlib_uri_auto() {
71: if (isSharedJVM()) {
72: executeTarget("antlib_uri_auto");
73: }
74: }
75:
76: public void testAntlib_uri_auto2() {
77: if (isSharedJVM()) {
78: executeTarget("antlib_uri_auto2");
79: }
80: }
81:
82: public static class MyTask extends Task {
83: public void execute() {
84: log("MyTask called");
85: }
86: }
87:
88: public static class MyTask2 extends Task {
89: public void execute() {
90: log("MyTask2 called");
91: }
92: }
93:
94: }
|