KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > archive > update > ArcUpdateTestCase


1 package com.openedit.archive.update;
2
3 import java.util.Iterator JavaDoc;
4 import java.util.List JavaDoc;
5
6 import com.openedit.archive.ArchiveTest;
7
8 public abstract class ArcUpdateTestCase extends ArchiveTest {
9
10     public ArcUpdateTestCase(String JavaDoc inArg0) {
11         super(inArg0);
12     }
13
14     final private String JavaDoc Q = "\"";
15
16     protected CommandLineWithOutput findKeywords(String JavaDoc filename) {
17         String JavaDoc cmd[] = new String JavaDoc[6];
18         cmd[0] = "exiflist";
19         cmd[1] = "/o";
20         cmd[2] = "ln";
21         cmd[3] = "/f";
22         cmd[4] = "ip-keyword";
23         cmd[5] = Q + filename + Q;
24         CommandLineWithOutput findKeywords = new CommandLineWithOutput();
25         findKeywords.exec(cmd);
26         return findKeywords;
27     }
28
29     protected CommandLineWithOutput findComment(String JavaDoc filename) {
30         String JavaDoc cmd[] = new String JavaDoc[6];
31         cmd[0] = "exiflist";
32         cmd[1] = "/o";
33         cmd[2] = "ln";
34         cmd[3] = "/f";
35         cmd[4] = "comment";
36         cmd[5] = Q + filename + Q;
37             CommandLineWithOutput findKeywords = new CommandLineWithOutput();
38         findKeywords.exec(cmd);
39         return findKeywords;
40     }
41
42     protected void removeKeywords(String JavaDoc filename) {
43         String JavaDoc cmd[] = new String JavaDoc[5];
44         cmd[0] = "exifedit";
45         cmd[1] = "/b";
46         cmd[2] = "/r";
47         cmd[3] = "ip-keyword";
48         cmd[4] = Q + filename + Q;
49         CommandLine removeKeys = new CommandLine();
50         removeKeys.exec(cmd);
51         assertListDoesNotContain("ip-keyword", findKeywords(filename)
52                 .getOutput());
53     }
54
55     protected void assertListContains(String JavaDoc toFind, List JavaDoc output) {
56         for (Iterator JavaDoc iter = output.iterator(); iter.hasNext();) {
57             String JavaDoc oneLine = (String JavaDoc) iter.next();
58             if (oneLine.indexOf(toFind) > 0)
59                 return;
60         }
61         fail("[" + toFind + "] not found in given list of Strings");
62     }
63     
64     protected void assertListDoesNotContain(String JavaDoc toFind, List JavaDoc output) {
65         for (Iterator JavaDoc iter = output.iterator(); iter.hasNext();) {
66             String JavaDoc oneLine = (String JavaDoc) iter.next();
67             if (oneLine.indexOf(toFind) > 0)
68                 fail("[" + toFind + "] found in given list of Strings");
69         }
70     }
71
72 }
73
Popular Tags