Debian Codegraph @

test/src/net/sf/antcontrib/antserver/AntServerTest.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.antserver;
17
18 import net.sf.antcontrib.BuildFileTestBase;
19
20
21 /****************************************************************************
22 * Place class description here.
23 *
24 * @author inger
25 * @author <additional author>
26 *
27 * @since
28 *
29 ****************************************************************************/
30
31
32 public class AntServerTest
33 extends BuildFileTestBase
34 {
35 public AntServerTest(String name)
36 {
37 super(name);
38 }
39
40
41 public void setUp()
42 {
43 configureProject("test/resources/antserver/antservertest.xml");
44 }
45
46 public void tearDown()
47 {
48 executeTarget("cleanup");
49 }
50
51 public void test1()
52 {
53 String expected[] = new String[]
54 {
55 "Test1 Successfully Called",
56 "[test1_remote]"
57 };
58
59 expectLogContaining("test1", expected);
60 }
61
62 public void test2()
63 {
64 String expected[] = new String[]
65 {
66 "Test2 Successfully Called",
67 "[test2_remote]"
68 };
69
70 expectLogContaining("test2", expected);
71 }
72
73 public void test3()
74 {
75 String expected[] = new String[]
76 {
77 "Test3 Successfully Called",
78 "[test3_remote]"
79 };
80
81 expectLogContaining("test3", expected);
82 }
83
84 public void test4()
85 {
86 String expected[] = new String[]
87 {
88 "Test4 Successfully Called",
89 "[test4_remote]"
90 };
91
92 expectLogContaining("test4", expected);
93 }
94
95 public void test5()
96 {
97 this.executeTarget("test5");
98 }
99
100 /**
101 * Assert that the given message has been logged with a priority
102 * &gt;= INFO when running the given target.
103 */
104 protected void expectLogContaining(String target,
105 String logs[])
106 {
107 executeTarget(target);
108 String realLog = getLog();
109
110 int cnt = 0;
111 StringBuffer sb = new StringBuffer();
112 for (int i = 0; i < logs.length; i++)
113 {
114 if (realLog.indexOf(logs[i]) >= 0)
115 cnt++;
116 if (i != 0)
117 sb.append(" and ");
118 sb.append("\"").append(logs[i]).append("\"");
119 }
120
121
122 assertTrue("expecting log to contain " + sb.toString()
123 + " log was \"" + realLog + "\"",
124 cnt == logs.length);
125 }
126
127 }