| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package net.sf.antcontrib.antserver; |
| 17 |
|
| 18 |
import net.sf.antcontrib.BuildFileTestBase; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 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 |
|
| 102 |
|
| 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 |
} |