Debian Codegraph @

test/src/net/sf/antcontrib/logic/OutOfDateTest.java

raw symbols SCIP
1 /*
2 * Copyright (c) 2001-2004 Ant-Contrib project. All rights reserved.
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 package net.sf.antcontrib.logic;
17
18 import org.apache.tools.ant.BuildFileTest;
19 import org.apache.tools.ant.types.Path;
20
21 /**
22 * Testcase for <outofdate>.
23 *
24 * @author Peter Reilly
25 */
26 public class OutOfDateTest extends BuildFileTest {
27
28 public OutOfDateTest(String name) {
29 super(name);
30 }
31
32 public void setUp() {
33 configureProject("test/resources/logic/outofdate.xml");
34 }
35
36 public void tearDown() {
37 executeTarget("cleanup");
38 }
39
40 public void testSimple() {
41 executeTarget("simple");
42 }
43
44 public void testVerbose() {
45 executeTarget("verbose");
46 assertTrue(getLog().indexOf("outofdate with regard to") > -1);
47 }
48
49 public void testDelete() {
50 executeTarget("delete");
51 }
52
53 public void testDeleteAll() {
54 executeTarget("delete-all");
55 }
56
57 public void testDeleteQuiet() {
58 executeTarget("init");
59 executeTarget("delete-quiet");
60 assertTrue("No deleting message", getLog().indexOf("Deleting") == -1);
61 }
62
63 public void testFileset() {
64 executeTarget("outofdate.init");
65 executeTarget("outofdate.test");
66 assertTrue(getLog().indexOf("outofdate triggered") > -1);
67 String outofdateSources =
68 getProject().getProperty("outofdate.sources");
69 // switch \ to / if present
70 outofdateSources.replace('\\', '/');
71 assertTrue("newer.text empty", outofdateSources.indexOf(
72 "newer.text") > -1);
73 assertTrue("file.notdone", outofdateSources.indexOf(
74 "outofdate/source/1/2/file.notdone") > -1);
75 assertTrue("file.done", outofdateSources.indexOf(
76 "outofdate/source/1/2/file.done") == -1);
77 assertTrue("done.y", outofdateSources.indexOf(
78 "outofdate/source/1/done.y") == -1);
79 assertTrue("partial.y", outofdateSources.indexOf(
80 "outofdate/source/1/partial.y") > -1);
81 String outofdateTargets =
82 getProject().getProperty("outofdate.targets");
83 assertTrue(outofdateTargets.indexOf(
84 "outofdate.xml") > -1);
85 assertTrue(outofdateTargets.indexOf(
86 "outofdate/gen/1/2/file.notdone") > -1);
87 assertTrue(outofdateTargets.indexOf(
88 "outofdate/gen/1/partial.h") > -1);
89 assertTrue(outofdateTargets.indexOf(
90 "outofdate/gen/1/partial.c") == -1);
91 assertTrue(outofdateTargets.indexOf(
92 "outofdate/gen/1/done.h") == -1);
93
94 Path sourcesPath = (Path) getProject().getReference(
95 "outofdate.sources.path");
96 assertTrue(sourcesPath != null);
97 String[] sources = sourcesPath.list();
98 assertTrue(sources.length == 3);
99 Path targetsPath = (Path) getProject().getReference(
100 "outofdate.targets.path");
101 String[] targets = targetsPath.list();
102 assertTrue(targetsPath != null);
103 assertTrue(targets.length == 3);
104 }
105
106 public void testEmptySources() {
107 executeTarget("empty-sources");
108 }
109
110 }