-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.xml
145 lines (124 loc) · 5.05 KB
/
test.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<project name="dma.cat.sync.test">
<condition property="waitMilliseconds" value="2000" else="20">
<os family="unix" />
</condition>
<target name="test" depends="build">
<antcall target="test.init"/>
<antcall target="test.run"/>
<assertFileExists file="test.out/a1.txt"/>
<assertFileExists file="test.out/a2.txt"/>
<assertFileExists file="test.out/c.txt"/>
<assertFileExists file="test.out/b"/>
<assertFileExists file="test.out/b/b.txt"/>
<delete file="test.in/a1.txt"/>
<antcall target="test.run"/>
<assertFileExists file="test.out/.deleted/a1.txt"/>
<assertFileNotExists file="test.out/a1.txt"/>
<delete file="test.out/a2.txt"/>
<antcall target="test.run"/>
<assertFileExists file="test.in/.deleted/a2.txt"/>
<assertFileNotExists file="test.in/a2.txt"/>
<delete dir="test.in/b"/>
<antcall target="test.run"/>
<assertFileNotExists file="test.out/b"/>
<echo message="d" file="test.in/d.txt"/>
<antcall target="test.run"/>
<assertFileExists file="test.out/d.txt"/>
<sleep milliseconds="${waitMilliseconds}"/>
<echo message="d0" file="test.out/d.txt"/>
<antcall target="test.run"/>
<assertFileContains file="test.in/d.txt" content="d0"/>
<mkdir dir="test.in/e"/>
<mkdir dir="test.out/e"/>
<echo message="e1" file="test.in/e/e1.txt"/>
<echo message="e2" file="test.out/e/e2.txt"/>
<antcall target="test.run"/>
<assertFileExists file="test.out/e/e1.txt"/>
<assertFileExists file="test.in/e/e2.txt"/>
<echo message="f1" file="test.in/e/f1.txt"/>
<antcall target="test.run"/>
<assertFileExists file="test.out/e/f1.txt"/>
<echo message="f2" file="test.out/e/f2.txt"/>
<antcall target="test.run"/>
<assertFileExists file="test.in/e/f2.txt"/>
<echo message="d1" file="test.in/d.txt"/>
<sleep milliseconds="${waitMilliseconds}"/>
<echo message="d2" file="test.out/d.txt"/>
<antcall target="test.run"/>
<assertFileContains file="test.in/d.txt" content="d2"/>
<sleep milliseconds="${waitMilliseconds}"/>
<move file="test.in/d.txt" tofile="test.in/d2.txt"/>
<antcall target="test.run"/>
<assertFileExists file="test.in/d2.txt"/>
<assertFileNotExists file="test.in/d.txt"/>
<sleep milliseconds="${waitMilliseconds}"/>
<move file="test.in/e" tofile="test.in/e2"/>
<antcall target="test.run"/>
<assertFileExists file="test.out/e2"/>
<assertFileNotExists file="test.out/e"/>
<sleep milliseconds="${waitMilliseconds}"/>
<mkdir dir="test.out/e"/>
<echo message="g" file="test.out/e/f"/>
<antcall target="test.run"/>
<assertFileExists file="test.in/e/f"/>
<echo message="a2" file="test.in/a2.txt"/>
<antcall target="test.run"/>
<assertFileExists file="test.out/a2.txt"/>
<move file="test.out/.deleted" tofile="test.out/ARCHIVE"/>
<delete dir="test.in/e2"/>
<antcall target="test.run"/>
<assertFileNotExists file="test.out/e2"/>
<assertFileExists file="test.out/ARCHIVE/e2"/>
</target>
<target name="test.init">
<delete dir="test.out" />
<delete dir="test.in" />
<copy todir="test.in" preservelastmodified="true">
<fileset dir="test" excludes="**/.backup"/>
</copy>
<mkdir dir="test.out"/>
</target>
<target name="test.run">
<java classpath="classes" classname="dma.cat.sync.MainSync" failonerror="true">
<arg value="test.in"/>
<arg value="test.out"/>
</java>
</target>
<macrodef name="assertFileExists">
<attribute name="file"/>
<sequential>
<fail message="Missing file '@{file}'">
<condition>
<not>
<available file="@{file}"/>
</not>
</condition>
</fail>
</sequential>
</macrodef>
<macrodef name="assertFileNotExists">
<attribute name="file"/>
<sequential>
<fail message="Existing file '@{file}'">
<condition>
<available file="@{file}"/>
</condition>
</fail>
</sequential>
</macrodef>
<macrodef name="assertFileContains">
<attribute name="file"/>
<attribute name="content"/>
<sequential>
<local name="contents"/>
<loadfile property="contents" srcFile="@{file}"/>
<fail message="Missing content '@{content}' in '@{file}'. Found '${contents}'">
<condition>
<not>
<contains string="${contents}" substring="@{content}"/>
</not>
</condition>
</fail>
</sequential>
</macrodef>
</project>