source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/testcases/org/apache/tools/ant/taskdefs/PropertyTest.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 3.3 KB
Line 
1/*
2 * Copyright 2001-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
18package org.apache.tools.ant.taskdefs;
19
20import java.net.URL;
21import java.io.File;
22
23import org.apache.tools.ant.BuildFileTest;
24import org.apache.tools.ant.BuildException;
25import org.apache.tools.ant.util.FileUtils;
26
27/**
28 */
29public class PropertyTest extends BuildFileTest {
30
31 public PropertyTest(String name) {
32 super(name);
33 }
34
35 public void setUp() {
36 configureProject("src/etc/testcases/taskdefs/property.xml");
37 }
38
39 public void test1() {
40 // should get no output at all
41 expectOutputAndError("test1", "", "");
42 }
43
44 public void test2() {
45 expectLog("test2", "testprop1=aa, testprop3=xxyy, testprop4=aazz");
46 }
47
48 public void test3() {
49 try {
50 executeTarget("test3");
51 }
52 catch (BuildException e) {
53 assertEquals("Circular definition not detected - ", true,
54 e.getMessage().indexOf("was circularly defined") != -1);
55 return;
56 }
57 fail("Did not throw exception on circular exception");
58 }
59
60 public void test4() {
61 expectLog("test4", "http.url is http://localhost:999");
62 }
63
64 public void test5() {
65 String baseDir = getProject().getProperty("basedir");
66 try {
67 String uri = FileUtils.newFileUtils().toURI(
68 baseDir + "/property3.properties");
69 getProject().setNewProperty(
70 "test5.url", uri);
71 } catch (Exception ex) {
72 throw new BuildException(ex);
73 }
74 expectLog("test5", "http.url is http://localhost:999");
75 }
76
77 public void testPrefixSuccess() {
78 executeTarget("prefix.success");
79 assertEquals("80", project.getProperty("server1.http.port"));
80 }
81
82 public void testPrefixFailure() {
83 try {
84 executeTarget("prefix.fail");
85 }
86 catch (BuildException e) {
87 assertEquals("Prefix allowed on non-resource/file load - ", true,
88 e.getMessage().indexOf("Prefix is only valid") != -1);
89 return;
90 }
91 fail("Did not throw exception on invalid use of prefix");
92 }
93
94 public void testCircularReference() {
95 try {
96 executeTarget("testCircularReference");
97 } catch (BuildException e) {
98 assertEquals("Circular definition not detected - ", true,
99 e.getMessage().indexOf("was circularly defined")
100 != -1);
101 return;
102 }
103 fail("Did not throw exception on circular exception");
104 }
105
106 public void testThisIsNotACircularReference() {
107 expectLog("thisIsNotACircularReference", "b is A/A/A");
108 }
109
110}
Note: See TracBrowser for help on using the repository browser.