1 package com.openedit.archive.update; 2 3 import java.util.ArrayList ; 4 import java.util.List ; 5 6 import junit.framework.TestCase; 7 8 public class ExifEditBuilderTest extends TestCase { 9 final private static String _TIFF = "somefile.tiff"; 10 11 private final static String Q = "\""; 12 13 private final static String EscQ = "\\\""; 14 15 List keywords; 16 17 ExifEditBuilder exif; 18 19 protected void setUp() throws Exception { 20 keywords = new ArrayList (); 21 keywords.add("one"); 22 exif = new ExifEditBuilder(_TIFF); 23 } 24 25 public void testZeroKeywords() throws Exception { 26 exif.setKeys(new ArrayList ()); 27 assertEquals(null, exif.cmdLineStr()); 28 } 29 30 public void testOneKeyword() throws Exception { 31 exif.setKeys(keywords); 32 assertEquals("exifedit /b /a " + Q + "ip-keyword=" + EscQ + "one" 33 + EscQ + Q + " " + _TIFF, exif.cmdLineStr()); 34 } 35 36 public void testOneKeywordAndComment() throws Exception { 37 exif.setKeys(keywords); 38 final String NOTE = "note: this, and that"; 39 exif.setComments(NOTE); 40 assertEquals("exifedit /b /a " + Q + "ip-keyword=" + EscQ + "one" 41 + EscQ + ",comment=" + EscQ + NOTE + EscQ + Q + " " + _TIFF, 42 exif.cmdLineStr()); 43 } 44 public void testTwoKeywords() throws Exception { 45 keywords.add("two"); 46 exif.setKeys(keywords); 47 assertEquals( 48 "exifedit /b /a " + Q + "ip-keyword=" + EscQ + "one" + EscQ 49 + ",ip-keyword=" + EscQ + "two" + EscQ + Q + " " 50 + _TIFF, exif.cmdLineStr()); 51 } 52 53 public void testKeywordSemicolonIsInvalid() throws Exception { 54 keywords.add("two;things"); 55 exif.setKeys(keywords); 56 assertEquals(null, exif.cmdLineStr()); 57 } 58 59 public void testWithImageBackup() throws Exception { 60 exif.setKeys(keywords); 61 exif.makeBackupImage(); 62 assertEquals("exifedit /a " + Q + "ip-keyword=" + EscQ + "one" + EscQ 63 + Q + " " + _TIFF, exif.cmdLineStr()); 64 } 65 66 public void testQuote() throws Exception { 67 assertEquals("\"\"", exif.quote("")); 68 assertEquals("\"something\"", exif.quote("something")); 69 assertEquals("\"some\\\"thing\\\"\"", exif.quote("some\"thing\"")); 70 71 } 72 } 73 | Popular Tags |