1 20 package org.enhydra.barracuda.taskdefs; 21 22 import junit.framework.TestCase; 24 25 import org.apache.log4j.Logger; 27 28 import java.io.File ; 30 import java.io.IOException ; 31 32 import org.enhydra.xml.xmlc.taskdef.*; 33 34 import org.enhydra.barracuda.testbed.*; 35 36 39 public class TestLocalizeFileNames extends DefaultTestCase { 40 41 45 50 public TestLocalizeFileNames( String theName) { 51 super( theName ); 52 } 53 54 58 protected void setUp() throws Exception { 59 super.setUp(); 60 this.myOriginalDefautlUtilsClass = 62 System.getProperty( XmlcUtils.DEFAULT_UTILS_CLASS_KEY, "" ); 63 System.setProperty(XmlcUtils.DEFAULT_UTILS_CLASS_KEY, 64 LocalizeXmlcUtilsImpl.class.getName()); 65 } 66 67 71 protected void tearDown() throws Exception { 72 super.tearDown(); 73 74 System.setProperty(XmlcUtils.DEFAULT_UTILS_CLASS_KEY, 76 this.myOriginalDefautlUtilsClass); 77 } 78 79 public void testBuildClassName() throws IOException { 83 XmlcUtils xmlcUtils = XmlcUtils.create(); 84 assertEquals( "Should have localize implementation", 85 LocalizeXmlcUtilsImpl.class, 86 xmlcUtils.getClass() ); 87 88 String filename = "config"; 89 String typeModifier = "HTML"; 90 String expectedClassName = "configHTML"; 91 String newClassName = xmlcUtils.buildClassName( filename, typeModifier ); 92 assertEquals("Class 0 should be as expected", 93 expectedClassName, 94 newClassName ); 95 96 filename = "config_aa"; 97 expectedClassName = "configHTML_aa"; 98 newClassName = xmlcUtils.buildClassName( filename, typeModifier ); 99 assertEquals("Class 1 should be as expected", 100 expectedClassName, 101 newClassName ); 102 103 filename = "config_test"; 104 expectedClassName = "config_testHTML"; 105 newClassName = xmlcUtils.buildClassName( filename, typeModifier ); 106 assertEquals("Class 2 should be as expected", 107 expectedClassName, 108 newClassName ); 109 110 filename = "config_eng"; 111 expectedClassName = "config_engHTML"; 112 newClassName = xmlcUtils.buildClassName( filename, typeModifier ); 113 assertEquals("Class 3 should be as expected", 114 expectedClassName, 115 newClassName ); 116 117 filename = "config_aaab"; 118 expectedClassName = "config_aaabHTML"; 119 newClassName = xmlcUtils.buildClassName( filename, typeModifier ); 120 assertEquals("Class 4 should be as expected", 121 expectedClassName, 122 newClassName ); 123 124 filename = "name1/name2/name1/name2/config_zu"; 125 expectedClassName = "name1.name2.name1.name2.configHTML_zu"; 126 newClassName = xmlcUtils.buildClassName( filename, typeModifier ); 127 assertEquals("Class 5 should be as expected", 128 expectedClassName, 129 newClassName ); 130 } 131 132 133 private String myOriginalDefautlUtilsClass; 137 138 private static final Logger theirLogger = Logger.getLogger( TestLocalizeFileNames.class.getName() ); 143 144 } 145 | Popular Tags |