KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.openedit.archive.update;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5
6 public class FunctionalTest extends ArcUpdateTestCase {
7     public static final String JavaDoc _TIFF = "etc\\test.tiff";
8
9     MetadataUpdater main = new MetadataUpdater();
10
11     List JavaDoc keywords = new ArrayList JavaDoc();
12
13     public FunctionalTest(String JavaDoc inArg0) {
14         super(inArg0);
15     }
16
17     protected void setUp() throws Exception JavaDoc {
18         super.setUp();
19         main = new MetadataUpdater();
20         keywords = new ArrayList JavaDoc();
21         removeKeywords(_TIFF);
22     }
23
24     public void testAddKeywords() throws Exception JavaDoc {
25         keywords.add("one");
26         // embedded comma is allowed
27
keywords.add("two,things");
28         keywords.add("three");
29         ExifEditBuilder exif = new ExifEditBuilder(_TIFF);
30         exif.setKeys(keywords);
31         boolean actual = main.addKeywords(exif);
32         assertTrue(actual);
33         List JavaDoc output = findKeywords(_TIFF).getOutput();
34         assertListContains("one", output);
35         assertListContains("two,things", output);
36
37         // FIXME: the following will only work with a licensed copy of ExifUtils
38
// the demo version is limited to 2 keywords at a time
39
// assertHasKeyword("etc\\test.tiff", "three");
40
}
41
42     public void testAddComment() throws Exception JavaDoc {
43         keywords.add("one");
44         ExifEditBuilder exif = new ExifEditBuilder(_TIFF);
45         exif.setKeys(keywords);
46         final String JavaDoc COMMENT = "This, That, The other";
47         exif.setComments(COMMENT);
48
49         // run
50
boolean actual = main.addKeywords(exif);
51         assertTrue(actual);
52
53         // find comment
54
List JavaDoc commentOutput = findComment(_TIFF).getOutput();
55         assertListContains(COMMENT, commentOutput);
56     }
57
58     public void testAddInvalidKeywords() throws Exception JavaDoc {
59         keywords.add("one");
60         keywords.add("two;parts");
61         keywords.add("three");
62         ExifEditBuilder exif = new ExifEditBuilder(_TIFF);
63         exif.setKeys(keywords);
64         boolean actual = main.addKeywords(exif);
65         assertFalse(actual);
66         List JavaDoc output = findKeywords(_TIFF).getOutput();
67         assertListDoesNotContain("one", output);
68         assertListDoesNotContain("two", output);
69         assertListDoesNotContain("two;parts", output);
70     }
71 }
72
Popular Tags