-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebdav-test
executable file
·749 lines (566 loc) · 19.5 KB
/
webdav-test
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
#!/bin/bash
# These tests are designed to test the WebDAV server's capabilities against
# multiple common tools.
# The default delay between a file being saved, and it being uploaded by davfs (plus a small margin)
UPLOAD_DELAY=12
DOWNLOAD_DELAY=15
MOUNT_DIR="/mnt/pressgang/TOPICS"
TEST_FILENAME=3737.xml
TEST_DIR="${MOUNT_DIR}/3/7/3/7/TOPIC3737"
TEST_DOC=${TEST_DIR}/${TEST_FILENAME}
TEMP_DIR=/tmp
TEMP_DOC=${TEMP_DIR}/${TEST_FILENAME}
#DOCBOOK_HTML_XSL=/usr/share/sgml/docbook/xsl-stylesheets-1.75.2/html/docbook.xsl
#DOCBOOK_HTML_XSL=/usr/share/sgml/docbook/xsl-stylesheets-1.78.1/html/docbook.xsl
DOCBOOK_HTML_XSL=/usr/share/xml/docbook/stylesheet/docbook-xsl/html/docbook.xsl
#DOCBOOK_DTD=/usr/share/sgml/docbook/xml-dtd-4.5-1.0-51.el6/docbookx.dtd
#DOCBOOK_DTD=/usr/share/sgml/docbook/xml-dtd-4.5/docbookx.dtd
DOCBOOK_DTD=/usr/share/xml/docbook/schema/dtd/4.5/docbookx.dtd
JING_JAR=/opt/jing-20091111/bin/jing.jar
XML_FORMAT_LOCATION=/opt/xmlformat-1.04
#sudo mount.davfs http://skynet-dev.usersys.redhat.com:8080/pressgang-ccms-webdav /mnt/pressgang -o uid=matthew
# start with a clean directory
cd "${TEST_DIR}"
find * -maxdepth 0 -name '3737.xml' -prune -o -exec rm -rf '{}' ';'
echo '<!-- Clean Slate -->' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
# touch test 1
# This is a tricky situation, because we are doing something that the file system does
# not expect. we create, delete and touch a file to simulate the "deletion" and
# reappearance of a file. The file was never deleted, but the caching done by davfs2
# makes it seem that way. Hence all the sleeps
echo Starting touch test 1
echo " Redirect an echo"
echo '<!-- rm test 1 -->' > "${TEST_DOC}"
echo '<!-- rm test 1 -->' > "${TEMP_DOC}"
# wait for echo above to be uploaded to the server
sleep ${UPLOAD_DELAY}
# delete the file and wait for the delete to be propagated to the server
echo " Delete and touch the file"
rm "${TEST_DOC}"
# create an empty file and wait for the creation to be propagated to the server
touch "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
# I don't know why this works, but it does. Two reads with two second delays between will
# cause the local cache to sync.
cat "${TEST_DOC}" > /dev/null
sleep 2
cat "${TEST_DOC}" > /dev/null
sleep 2
echo " Diff the file"
diff "${TEST_DOC}" "${TEMP_DOC}"
if [[ $? -ne 0 ]]
then
echo "************ touch test 1 failed ************"
read -n 1 -s
fi
# touch test 2
echo Starting touch test 2
echo '<section><title>test</title><para>hi</para></section>' > "${TEMP_DOC}"
echo '<section><title>test</title><para>hi</para></section>' > "${TEST_DOC}"
> /tmp/empty
sleep ${UPLOAD_DELAY}
# touching the file should clear the cache
> "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
cat "${TEST_DOC}" > /dev/null
sleep 2
cat "${TEST_DOC}" > /dev/null
sleep 2
# the test doc should be formatted, while the temp doc will not be
diff "${TEST_DOC}" "${TEMP_DOC}" > /dev/null
if [[ $? -eq 0 ]]
then
echo "************ touch test 2 failed ************"
read -n 1 -s
fi
diff "${TEST_DOC}" /tmp/empty > /dev/null
if [[ $? -eq 0 ]]
then
echo "************ touch test 2 failed ************"
read -n 1 -s
fi
# cp test 1
echo Starting cp test 1
# it is possible that this file was deleted by some other script
if [[ -f "${TEST_DOC}" ]]
then
cp "${TEST_DOC}" "${TEMP_DIR}"
diff "${TEST_DOC}" "${TEMP_DOC}"
if [[ $? -ne 0 ]]
then
echo "************ cp test 1 failed ************"
read -n 1 -s
fi
fi
# cp test 2
echo Starting cp test 2
echo '<!-- cp test 2 -->' > "${TEMP_DOC}"
cp "${TEMP_DOC}" "${TEST_DIR}"
sleep ${UPLOAD_DELAY}
diff "${TEST_DOC}" "${TEMP_DOC}"
if [[ $? -ne 0 ]]
then
echo "************ cp test 2 failed ************"
read -n 1 -s
fi
# cp test 3
echo Starting cp test 3
echo '<!-- cp test 3 -->' > "${TEST_DOC}"
cp "${TEST_DOC}" "${TEST_DOC}".copy
sleep ${UPLOAD_DELAY}
diff "${TEST_DOC}" "${TEST_DOC}".copy
if [[ $? -ne 0 ]]
then
echo "************ cp test 3 failed ************"
read -n 1 -s
fi
# mv test 1
echo Starting mv test 1
echo '<!-- cp test 1 -->' > "${TEST_DOC}"
cp "${TEST_DOC}" "${TEST_DOC}".copy
sleep ${UPLOAD_DELAY}
mv "${TEST_DOC}".copy "${TEST_DOC}".move
sleep ${UPLOAD_DELAY}
diff "${TEST_DOC}" "${TEST_DOC}".move
if [[ $? -ne 0 ]]
then
echo "************ mv test 1 failed ************"
read -n 1 -s
fi
# mv test 2
echo Starting mv test 2
echo '<!-- mv test 2 -->' > "${TEST_DOC}.move"
sleep ${UPLOAD_DELAY}
mv "${TEST_DOC}.move" "${TEST_DOC}.move1"
sleep ${UPLOAD_DELAY}
if [ -f "${TEST_DOC}.move" ]
then
echo "************ mv test 2 failed - item not deleted ************"
read -n 1 -s
fi
if [ ! -f "${TEST_DOC}.move1" ]
then
echo "************ mv test 2 failed - item not exist ************"
read -n 1 -s
fi
# rm test 1
echo Starting rm test 1
echo '<!-- rm test 1 -->' > "${TEST_DOC}".delete
rm "${TEST_DOC}".delete
sleep ${UPLOAD_DELAY}
if [ -f "${TEST_DOC}".delete ]
then
echo "************ rm test 1 failed - item not deleted ************"
read -n 1 -s
fi
# rm test 2
echo Starting rm test 2
echo '<!-- rm test 1 -->' > "${TEST_DOC}"
rm "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
if [ -f "${TEST_DOC}" ]
then
echo "************ rm test 1 failed ************"
read -n 1 -s
fi
# cat test 1
echo Starting cat test 1
echo '<!-- cp test 1 -->' > "${TEST_DOC}".cat
sleep ${UPLOAD_DELAY}
if [ ! -f "${TEST_DOC}".cat ]
then
echo "************ cat test 1 failed - item not exist ************"
read -n 1 -s
fi
# cat test 2
echo Starting cat test 2
echo '<!-- cat test 2 -->' > "${TEMP_DOC}"
echo '<!-- cat test 2 -->' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
cat "${TEMP_DOC}" > /tmp/cattest1
cat "${TEST_DOC}" > /tmp/cattest2
diff /tmp/cattest1 /tmp/cattest2
if [[ $? -ne 0 ]]
then
echo "************ cat test 2 failed ************"
read -n 1 -s
fi
# redirect test 1
echo Starting redirect test 1
echo '<!-- redirect test 1 -->' > "${TEMP_DOC}"
echo '<!-- redirect test 1 -->' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
diff "${TEST_DOC}" "${TEMP_DOC}"
if [[ $? -ne 0 ]]
then
echo "************ redirect test 1 failed ************"
read -n 1 -s
fi
# rsync test 1
echo Starting rsync test 1
rm -rf /tmp/rsynctmp
mkdir /tmp/rsynctmp
dd if=/dev/urandom of=/tmp/rsynctmp/a1.log bs=1K count=50 > /dev/null 2>&1
dd if=/dev/urandom of=/tmp/rsynctmp/a2.log bs=1K count=75 > /dev/null 2>&1
dd if=/dev/urandom of=/tmp/rsynctmp/a3.log bs=1K count=100 > /dev/null 2>&1
echo -e "I love rsync\nrsync is the best" > /tmp/rsynctmp/3737.xml
rsync -vr /tmp/rsynctmp/ /mnt/pressgang/TOPICS/3/7/3/7/TOPIC3737 > /dev/null 2>&1
sleep ${UPLOAD_DELAY}
diff /tmp/rsynctmp/3737.xml /mnt/pressgang/TOPICS/3/7/3/7/TOPIC3737/3737.xml
if [[ $? -ne 0 ]]
then
echo "************ rsync test 1 failed - 3737.xml ************"
read -n 1 -s
fi
diff /tmp/rsynctmp/a1.log /mnt/pressgang/TOPICS/3/7/3/7/TOPIC3737/a1.log
if [[ $? -ne 0 ]]
then
echo "************ rsync test 1 failed ************"
read -n 1 -s
fi
diff /tmp/rsynctmp/a2.log /mnt/pressgang/TOPICS/3/7/3/7/TOPIC3737/a2.log
if [[ $? -ne 0 ]]
then
echo "************ rsync test 1 failed ************"
read -n 1 -s
fi
diff /tmp/rsynctmp/a3.log /mnt/pressgang/TOPICS/3/7/3/7/TOPIC3737/a3.log
if [[ $? -ne 0 ]]
then
echo "************ rsync test 1 failed ************"
read -n 1 -s
fi
# grep test 1
echo Starting grep test 1
echo -e "I love grep\ngrep is the best" > "${TEMP_DOC}"
echo -e "I love grep\ngrep is the best" > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
grep grep "${TEMP_DOC}" > /tmp/grep1.tmp
grep grep "${TEST_DOC}" > /tmp/grep2.tmp
diff /tmp/grep1.tmp /tmp/grep2.tmp
if [[ $? -ne 0 ]]
then
echo "************ grep test 1 failed ************"
read -n 1 -s
fi
# tail test 1
echo Starting tail test 1
echo -e "100 Thomas Manager Sales $5,000\n200 Jason Developer Technology $5,500\n300 Sanjay Sysadmin Technology $7,000\n400 Nisha Manager Marketing $9,500\n500 Randy DBA Technology $6,000" > "${TEMP_DOC}"
echo -e "100 Thomas Manager Sales $5,000\n200 Jason Developer Technology $5,500\n300 Sanjay Sysadmin Technology $7,000\n400 Nisha Manager Marketing $9,500\n500 Randy DBA Technology $6,000" > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
tail "${TEMP_DOC}" > /tmp/tail1.tmp
tail "${TEST_DOC}" > /tmp/tail2.tmp
diff /tmp/tail1.tmp /tmp/tail2.tmp
if [[ $? -ne 0 ]]
then
echo "************ tail test 1 failed ************"
read -n 1 -s
fi
# xmllint test 1
echo Starting xmllint test 1
echo '<section></section1>' > "${TEMP_DOC}"
echo '<section></section1>' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
xmllint --valid "${TEMP_DOC}" 2> /tmp/xml1.tmp
xmllint --valid "${TEST_DOC}" 2> /tmp/xml2.tmp
sed -i -e 's#'${TEMP_DOC}'##g' /tmp/xml1.tmp
sed -i -e 's#'${TEST_DOC}'##g' /tmp/xml2.tmp
diff /tmp/xml1.tmp /tmp/xml2.tmp
if [[ $? -ne 0 ]]
then
echo "************ xmllint test 1 failed ************"
read -n 1 -s
fi
# xmllint test 2
echo Starting xmllint test 2
echo '<section></section>' > "${TEMP_DOC}"
echo '<section></section>' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
xmllint --output "${TEMP_DOC}" "${TEMP_DOC}"
xmllint --output "${TEST_DOC}" "${TEST_DOC}"
diff "${TEST_DOC}" "${TEMP_DOC}"
if [[ $? -ne 0 ]]
then
echo "************ xmllint test 2 failed ************"
read -n 1 -s
fi
# sed test 1
echo Starting sed test 1
echo '<!-- sed test -->' > "${TEMP_DOC}"
echo '<!-- sed test -->' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
sed -i -e 's/test/sedreplaced/g' "${TEMP_DOC}"
sed -i -e 's/test/sedreplaced/g' "${TEST_DOC}"
diff "${TEST_DOC}" "${TEMP_DOC}"
if [[ $? -ne 0 ]]
then
echo "************ sed test 1 failed ************"
read -n 1 -s
fi
# sponge test 1
echo Starting sponge test 1
echo '<!-- sponge test -->' > "${TEMP_DOC}"
echo '<!-- sponge test -->' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
sed -e 's/test/sedreplaced/g' "${TEMP_DOC}" | sponge "${TEMP_DOC}"
sed -e 's/test/sedreplaced/g' "${TEST_DOC}" | sponge "${TEST_DOC}"
diff "${TEST_DOC}" "${TEMP_DOC}"
if [[ $? -ne 0 ]]
then
echo "************ sponge test 1 failed ************"
read -n 1 -s
fi
# imagemagick test 1
echo Starting imagemagick test 1
convert -size 100x100 gradient:blue "${TEST_DIR}/gradient_range1.jpg"
convert -size 100x100 gradient:blue "${TEMP_DIR}/gradient_range1.jpg"
sleep ${UPLOAD_DELAY}
diff "${TEST_DIR}/gradient_range1.jpg" "${TEMP_DIR}/gradient_range1.jpg"
if [[ $? -ne 0 ]]
then
echo "************ imagemagick test 1 failed ************"
read -n 1 -s
fi
# imagemagick test 2
echo Starting imagemagick test 2
convert "${TEST_DIR}/gradient_range1.jpg" -virtual-pixel tile -blur 0x1 -auto-level "${TEST_DIR}/gradient_range1_blurred.jpg"
convert "${TEMP_DIR}/gradient_range1.jpg" -virtual-pixel tile -blur 0x1 -auto-level "${TEMP_DIR}/gradient_range1_blurred.jpg"
sleep ${UPLOAD_DELAY}
diff "${TEST_DIR}/gradient_range1_blurred.jpg" "${TEMP_DIR}/gradient_range1_blurred.jpg"
if [[ $? -ne 0 ]]
then
echo "************ imagemagick test 2 failed ************"
read -n 1 -s
fi
# awk test 1
echo Starting awk test 1
echo -e "100 Thomas Manager Sales $5,000\n200 Jason Developer Technology $5,500\n300 Sanjay Sysadmin Technology $7,000\n400 Nisha Manager Marketing $9,500\n500 Randy DBA Technology $6,000" > "${TEMP_DOC}"
echo -e "100 Thomas Manager Sales $5,000\n200 Jason Developer Technology $5,500\n300 Sanjay Sysadmin Technology $7,000\n400 Nisha Manager Marketing $9,500\n500 Randy DBA Technology $6,000" > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
awk '{print $2,$5;}' "${TEMP_DOC}" > /tmp/awk1.tmp
awk '{print $2,$5;}' "${TEST_DOC}" > /tmp/awk2.tmp
diff /tmp/awk1.tmp /tmp/awk2.tmp
if [[ $? -ne 0 ]]
then
echo "************ awk test 1 failed ************"
read -n 1 -s
fi
# bz2 test 1
echo Starting bz2 test 1
echo '<!-- bzip2 test -->' > "${TEMP_DOC}"
echo '<!-- bzip2 test -->' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
bzip2 -k -f "${TEMP_DOC}"
bzip2 -k -f "${TEST_DOC}"
bzcmp "${TEMP_DOC}.bz2" "${TEST_DOC}.bz2"
if [[ $? -ne 0 ]]
then
echo "************ bz2 test 2 failed ************"
read -n 1 -s
fi
# tar test 1
echo Starting tar test 1
echo '<!-- tar test -->' > "${TEMP_DOC}"
echo '<!-- tar test -->' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
tar -C "${TEMP_DIR}" -cjf /tmp/tar1.tar.bz2 "${TEST_FILENAME}"
tar -C "${TEST_DIR}" -cjf /tmp/tar2.tar.bz2 "${TEST_FILENAME}"
if [ -d /tmp/temp ]
then
rm -rf /tmp/temp
fi
if [ -d /tmp/temp2 ]
then
rm -rf /tmp/temp2
fi
mkdir /tmp/temp
mkdir /tmp/temp2
cd /tmp/temp; tar -xjf /tmp/tar1.tar.bz2
cd /tmp/temp2; tar -xjf /tmp/tar2.tar.bz2
sleep ${UPLOAD_DELAY}
diff "/tmp/temp/${TEST_FILENAME}" "/tmp/temp2/${TEST_FILENAME}"
if [[ $? -ne 0 ]]
then
echo "************ tar test 1 failed ************"
read -n 1 -s
fi
# python test 1
echo Starting python test 1
echo 'print "Hello WebDAV"' > "${TEMP_DOC}"
echo 'print "Hello WebDAV"' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
python "${TEMP_DOC}" > /tmp/python1.tmp
python "${TEST_DOC}" > /tmp/python2.tmp
diff /tmp/python1.tmp /tmp/python2.tmp
if [[ $? -ne 0 ]]
then
echo "************ python test 1 failed ************"
read -n 1 -s
fi
# nodejs test 1
echo Starting nodejs test 1
echo 'console.log("Hello World from NodeJS")' > "${TEMP_DOC}"
echo 'console.log("Hello World from NodeJS")' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
nodejs "${TEMP_DOC}" > /tmp/nodejs1.tmp
nodejs "${TEST_DOC}" > /tmp/nodejs2.tmp
diff /tmp/nodejs1.tmp /tmp/nodejs2.tmp
if [[ $? -ne 0 ]]
then
echo "************ nodejs test 1 failed ************"
read -n 1 -s
fi
# vi test 1
echo Starting vi test 1
echo '<article><title>test</title><para>Hello World</para></article>' > "${TEMP_DOC}"
echo '<article><title>test</title><para>Hello World</para></article>' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
diff "${TEMP_DOC}" "${TEST_DOC}"
if [[ $? -ne 0 ]]
then
echo "************ vi test 1 failed - source files not equal ************"
read -n 1 -s
fi
vi -E -s "${TEMP_DOC}" << EOF
:%substitute/Hello/Hi/
:update
:quit
EOF
vi -E -s "${TEST_DOC}" << EOF
:%substitute/Hello/Hi/
:update
:quit
EOF
sleep ${UPLOAD_DELAY}
diff "${TEMP_DOC}" "${TEST_DOC}"
if [[ $? -ne 0 ]]
then
echo "************ vi test 1 failed ************"
read -n 1 -s
fi
# hunspell test 1
echo Starting hunspell test 1
echo 'mispealled word' > "${TEMP_DOC}"
echo 'mispealled word' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
hunspell -L "${TEMP_DOC}" > /tmp/hunspell1.tmp
hunspell -L "${TEST_DOC}" > /tmp/hunspell2.tmp
diff /tmp/hunspell1.tmp /tmp/hunspell2.tmp
if [[ $? -ne 0 ]]
then
echo "************ hunspell test 1 failed ************"
read -n 1 -s
fi
# saxon test 1
echo Starting saxon test 1
echo '<article><title>test</title><para>hi</para></article>' > "${TEMP_DOC}"
echo '<article><title>test</title><para>hi</para></article>' > "${TEST_DOC}"
#echo 'saxon-xslt -o /tmp/docbook1.html "'${TEMP_DOC}'" "'${DOCBOOK_HTML_XSL}'" 2> /dev/null'
#echo 'saxon-xslt -o /tmp/docbook2.html "'${TEST_DOC}'" "'${DOCBOOK_HTML_XSL}'" 2> /dev/null'
sleep ${UPLOAD_DELAY}
saxon-xslt -o /tmp/docbook1.html "${TEMP_DOC}" "${DOCBOOK_HTML_XSL}" 2> /dev/null
saxon-xslt -o /tmp/docbook2.html "${TEST_DOC}" "${DOCBOOK_HTML_XSL}" 2> /dev/null
diff /tmp/docbook1.html /tmp/docbook2.html
if [[ $? -ne 0 ]]
then
echo "************ saxon test 1 failed ************"
read -n 1 -s
fi
# xsltproc test 1
echo Starting xsltproc test 1
echo '<article><title>test</title><para>hi</para></article>' > "${TEMP_DOC}"
echo '<article><title>test</title><para>hi</para></article>' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
xsltproc -o /tmp/docbook1.html "${DOCBOOK_HTML_XSL}" "${TEMP_DOC}"
xsltproc -o /tmp/docbook2.html "${DOCBOOK_HTML_XSL}" "${TEST_DOC}"
# the name attributes change
sed -i -e 's/name=\".*\"//g' /tmp/docbook1.html
sed -i -e 's/name=\".*\"//g' /tmp/docbook2.html
diff /tmp/docbook1.html /tmp/docbook2.html
if [[ $? -ne 0 ]]
then
echo "************ xsltproc test 1 failed ************"
read -n 1 -s
fi
# xmlformat test 1
echo Starting xmlformat test 1
echo '<article><title>test</title><para>hi</para></article>' > "${TEMP_DOC}"
echo '<article><title>test</title><para>hi</para></article>' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
${XML_FORMAT_LOCATION}/xmlformat.pl -i "${TEMP_DOC}"
${XML_FORMAT_LOCATION}/xmlformat.pl -i "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
diff "${TEMP_DOC}" "${TEST_DOC}"
if [[ $? -ne 0 ]]
then
echo "************ xmlformat test 1 failed ************"
read -n 1 -s
fi
# publican test 1
echo Starting publican test 1
echo '<section><title>Test</title><para>hi</para></section>' > "${TEMP_DOC}"
echo '<section><title>Test</title><para>hi</para></section>' > "${TEST_DOC}"
sleep ${UPLOAD_DELAY}
cd /tmp
rm -rf book
publican create --name=book > /dev/null 2>&1
echo '<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE bookinfo PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [<!ENTITY % BOOK_ENTITIES SYSTEM "book.ent">%BOOK_ENTITIES;]><chapter><title>Book</title><xi:include href="'${TEMP_DOC}'" xmlns:xi="http://www.w3.org/2001/XInclude"/></chapter>' > /tmp/book/en-US/Chapter.xml
cd /tmp/book
publican build --langs=en-US --formats=html-single > /dev/null 2>&1
cd /tmp
rm -rf bookwebdav
publican create --name=bookwebdav > /dev/null 2>&1
echo '<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE bookinfo PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [<!ENTITY % BOOK_ENTITIES SYSTEM "book.ent">%BOOK_ENTITIES;]><chapter><title>Book</title><xi:include href="'${TEST_DOC}'" xmlns:xi="http://www.w3.org/2001/XInclude"/></chapter>' > /tmp/bookwebdav/en-US/Chapter.xml
cd /tmp/bookwebdav
publican build --langs=en-US --formats=html-single > /dev/null 2>&1
# the id and href attributes change, as well as the book title and entity references
sed -i -e 's/id=\".*\"//g' /tmp/bookwebdav/tmp/en-US/html-single/index.html
sed -i -e 's/href=\".*\"//g' /tmp/bookwebdav/tmp/en-US/html-single/index.html
sed -i -e 's/<title>bookwebdav<\/title>//g' /tmp/bookwebdav/tmp/en-US/html-single/index.html
sed -i -e 's/bookwebdav.ent//g' /tmp/bookwebdav/tmp/en-US/html-single/index.html
sed -i -e 's/id=\".*\"//g' /tmp/book/tmp/en-US/html-single/index.html
sed -i -e 's/href=\".*\"//g' /tmp/book/tmp/en-US/html-single/index.html
sed -i -e 's/<title>book<\/title>//g' /tmp/book/tmp/en-US/html-single/index.html
sed -i -e 's/book.ent//g' /tmp/book/tmp/en-US/html-single/index.html
diff /tmp/book/tmp/en-US/html-single/index.html /tmp/bookwebdav/tmp/en-US/html-single/index.html
if [[ $? -ne 0 ]]
then
echo "************ publican test 1 failed ************"
read -n 1 -s
fi
# find test 1
echo starting find test 1
cd /mnt/pressgang/TOPICS/3/7/3/7/TOPIC3737
find . -name ${TEST_FILENAME} > find.tmp
RESULT=$(head -1 find.tmp)
EXPECTED=./3737.xml
if [[ ! ${RESULT} == ${EXPECTED} ]]
then
echo "find test 1 failed"
fi
# jing test 1
echo Starting jing test 1
echo '<!DOCTYPE article PUBLIC '"'"'-//OASIS//DTD DocBook XML V4.5//EN'"'"' '"'"'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd'"'"'>
<article><title>test</title><para>hi</para></article>' > "${TEMP_DOC}"
echo '<!DOCTYPE article PUBLIC '"'"'-//OASIS//DTD DocBook XML V4.5//EN'"'"' '"'"'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd'"'"'>
<article><title>test</title><para>hi</para></article>' > "${TEST_DOC}"
java -jar "${JING_JAR}" "${TEMP_DOC}" "${DOCBOOK_DTD}" > /tmp/jing1.tmp
java -jar "${JING_JAR}" "${TEST_DOC}" "${DOCBOOK_DTD}" > /tmp/jing2.tmp
# The file names change
sed -i -e 's#'${TEMP_DOC}'##g' /tmp/jing1.tmp
sed -i -e 's#'${TEST_DOC}'##g' /tmp/jing2.tmp
sleep ${UPLOAD_DELAY}
diff /tmp/jing1.tmp /tmp/jing2.tmp
if [[ $? -ne 0 ]]
then
echo "************ jing test 1 failed ************"
read -n 1 -s
fi
# find test 1
#echo Starting find test 1. Grab a coffee, this will take a while.
#find /mnt/pressgang -name 3737.xml
#if [[ $? -ne 0 ]]
#then
# echo "find test 1 failed"
#fi