1 | /*
|
---|
2 | * Copyright 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 |
|
---|
18 | package org.apache.tools.ant.taskdefs;
|
---|
19 |
|
---|
20 | import org.apache.tools.ant.BuildFileTest;
|
---|
21 | import org.apache.tools.ant.BuildException;
|
---|
22 | import org.apache.tools.ant.Project;
|
---|
23 | import org.apache.tools.ant.Task;
|
---|
24 | import org.apache.tools.ant.types.FileSet;
|
---|
25 |
|
---|
26 | /**
|
---|
27 | */
|
---|
28 | public class PreSetDefTest extends BuildFileTest {
|
---|
29 | public PreSetDefTest(String name) {
|
---|
30 | super(name);
|
---|
31 | }
|
---|
32 |
|
---|
33 | public void setUp() {
|
---|
34 | configureProject("src/etc/testcases/taskdefs/presetdef.xml");
|
---|
35 | }
|
---|
36 |
|
---|
37 | public void testSimple() {
|
---|
38 | expectLog("simple", "Hello world");
|
---|
39 | }
|
---|
40 |
|
---|
41 | public void testText() {
|
---|
42 | expectLog("text", "Inner Text");
|
---|
43 | }
|
---|
44 |
|
---|
45 | public void testUri() {
|
---|
46 | expectLog("uri", "Hello world");
|
---|
47 | }
|
---|
48 |
|
---|
49 | public void testDefaultTest() {
|
---|
50 | expectLog("defaulttest", "attribute is false");
|
---|
51 | }
|
---|
52 |
|
---|
53 | public void testDoubleDefault() {
|
---|
54 | expectLog("doubledefault", "attribute is falseattribute is true");
|
---|
55 | }
|
---|
56 |
|
---|
57 | public void testTextOptional() {
|
---|
58 | expectLog("text.optional", "MyTextoverride text");
|
---|
59 | }
|
---|
60 |
|
---|
61 | public void testElementOrder() {
|
---|
62 | expectLog("element.order", "Line 1Line 2");
|
---|
63 | }
|
---|
64 |
|
---|
65 | public void testElementOrder2() {
|
---|
66 | expectLog("element.order2", "Line 1Line 2Line 3");
|
---|
67 | }
|
---|
68 |
|
---|
69 | public void testAntTypeTest() {
|
---|
70 | expectLog("antTypeTest", "");
|
---|
71 | }
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * A test class to check default properties
|
---|
75 | */
|
---|
76 | public static class DefaultTest extends Task {
|
---|
77 | boolean isSet = false;
|
---|
78 | boolean attribute = false;
|
---|
79 | public void setAttribute(boolean b) {
|
---|
80 | if (isSet) {
|
---|
81 | throw new BuildException("Attribute Already set");
|
---|
82 | }
|
---|
83 | attribute = b;
|
---|
84 | isSet = true;
|
---|
85 | }
|
---|
86 |
|
---|
87 | public void execute() {
|
---|
88 | getProject().log("attribute is " + attribute);
|
---|
89 | }
|
---|
90 | }
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * A test class to check presetdef with add and addConfigured and ant-type
|
---|
94 | */
|
---|
95 | public static class AntTypeTest extends Task {
|
---|
96 | public void addFileSet(FileSet fileset) {
|
---|
97 | }
|
---|
98 | public void addConfiguredConfigured(FileSet fileset) {
|
---|
99 | }
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|