1 | /*
|
---|
2 | * Copyright 2002,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.types;
|
---|
19 |
|
---|
20 | import org.apache.tools.ant.BuildFileTest;
|
---|
21 | import org.apache.tools.ant.Project;
|
---|
22 | import org.apache.tools.ant.BuildException;
|
---|
23 |
|
---|
24 | public class FlexIntegerTest extends BuildFileTest {
|
---|
25 |
|
---|
26 | public FlexIntegerTest(String name) {
|
---|
27 | super(name);
|
---|
28 | }
|
---|
29 |
|
---|
30 | public void setUp() {
|
---|
31 | configureProject("src/etc/testcases/types/flexinteger.xml");
|
---|
32 | }
|
---|
33 |
|
---|
34 | public void testFlexInteger() {
|
---|
35 | executeTarget("test");
|
---|
36 | assertEquals(project.getProperty("flexint.value1"), "10");
|
---|
37 | assertEquals(project.getProperty("flexint.value2"), "8");
|
---|
38 | }
|
---|
39 |
|
---|
40 | // This class acts as a custom Ant task also
|
---|
41 | // and uses these variables/methods in that mode
|
---|
42 | private Project taskProject;
|
---|
43 | String propName;
|
---|
44 | private FlexInteger value;
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * To make taskdef happy
|
---|
48 | */
|
---|
49 | public FlexIntegerTest() {
|
---|
50 | super("FlexIntegerTest");
|
---|
51 | }
|
---|
52 |
|
---|
53 | public void setPropName(String propName) {
|
---|
54 | this.propName = propName;
|
---|
55 | }
|
---|
56 |
|
---|
57 | public void setValue(FlexInteger value) {
|
---|
58 | this.value = value;
|
---|
59 | }
|
---|
60 |
|
---|
61 | public void setProject(Project project) {
|
---|
62 | taskProject = project;
|
---|
63 | }
|
---|
64 |
|
---|
65 | public void execute() {
|
---|
66 | if (propName == null || value == null) {
|
---|
67 | throw new BuildException("name and value required");
|
---|
68 | }
|
---|
69 |
|
---|
70 | taskProject.setNewProperty(propName, value.toString());
|
---|
71 | }
|
---|
72 | }
|
---|