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.optional.jdepend;
|
---|
19 |
|
---|
20 | import java.io.File;
|
---|
21 | import java.io.FileReader;
|
---|
22 | import java.io.IOException;
|
---|
23 | import java.util.Date;
|
---|
24 | import java.util.Vector;
|
---|
25 | import java.util.Enumeration;
|
---|
26 | import java.util.Hashtable;
|
---|
27 | import org.apache.tools.ant.BuildFileTest;
|
---|
28 | import org.apache.tools.ant.Project;
|
---|
29 | import org.apache.tools.ant.types.FileSet;
|
---|
30 | import org.apache.tools.ant.DirectoryScanner;
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Testcase for the JDepend optional task.
|
---|
34 | *
|
---|
35 | */
|
---|
36 | public class JDependTest extends BuildFileTest {
|
---|
37 | public static final String RESULT_FILESET = "result";
|
---|
38 |
|
---|
39 | public JDependTest(String name) {
|
---|
40 | super(name);
|
---|
41 | }
|
---|
42 |
|
---|
43 | public void setUp() {
|
---|
44 | configureProject(
|
---|
45 | "src/etc/testcases/taskdefs/optional/jdepend/jdepend.xml");
|
---|
46 | }
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Test simple
|
---|
50 | */
|
---|
51 | public void testSimple() {
|
---|
52 | expectOutputContaining(
|
---|
53 | "simple", "Package: org.apache.tools.ant.util.facade");
|
---|
54 | }
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Test xml
|
---|
58 | */
|
---|
59 | public void testXml() {
|
---|
60 | expectOutputContaining(
|
---|
61 | "xml", "<DependsUpon>");
|
---|
62 | }
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Test fork
|
---|
66 | * - forked output goes to log
|
---|
67 | */
|
---|
68 | public void testFork() {
|
---|
69 | expectLogContaining(
|
---|
70 | "fork", "Package: org.apache.tools.ant.util.facade");
|
---|
71 | }
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * Test fork xml
|
---|
75 | */
|
---|
76 | public void testForkXml() {
|
---|
77 | expectLogContaining(
|
---|
78 | "fork-xml", "<DependsUpon>");
|
---|
79 | }
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Test timeout
|
---|
83 | */
|
---|
84 | public void testTimeout() {
|
---|
85 | expectLogContaining(
|
---|
86 | "fork-timeout", "JDepend FAILED - Timed out");
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Test timeout without timing out
|
---|
92 | */
|
---|
93 | public void testTimeoutNot() {
|
---|
94 | expectLogContaining(
|
---|
95 | "fork-timeout-not", "Package: org.apache.tools.ant.util.facade");
|
---|
96 | }
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Assert that the given substring is in the output messages
|
---|
100 | */
|
---|
101 |
|
---|
102 | protected void assertOutputContaining(String substring) {
|
---|
103 | String realOutput = getOutput();
|
---|
104 | assertTrue("expecting output to contain \"" + substring + "\" output was \""
|
---|
105 | + realOutput + "\"",
|
---|
106 | realOutput.indexOf(substring) >= 0);
|
---|
107 | }
|
---|
108 |
|
---|
109 | /**
|
---|
110 | * Assert that the given message has been outputted
|
---|
111 | */
|
---|
112 | protected void expectOutputContaining(String target, String substring) {
|
---|
113 | executeTarget(target);
|
---|
114 | assertOutputContaining(substring);
|
---|
115 | }
|
---|
116 |
|
---|
117 | }
|
---|