1 18 23 package org.apache.roller.ui; 24 25 import java.io.FileInputStream ; 26 import java.util.Iterator ; 27 import java.util.Properties ; 28 import java.util.Set ; 29 30 import junit.framework.Test; 31 import junit.framework.TestCase; 32 import junit.framework.TestSuite; 33 34 48 public class ApplicationResourcesTest extends TestCase 49 { 50 private String userDir = null; 51 private Properties baseProps = null; 52 53 56 public ApplicationResourcesTest(String name) 57 { 58 super(name); 59 } 60 61 public static Test suite() { 62 TestSuite suite = new TestSuite(); 63 suite.addTest( 65 new ApplicationResourcesTest("testApplicationResources_nl")); 66 suite.addTest( 67 new ApplicationResourcesTest("testApplicationResources_zh_cn")); 68 suite.addTest( 69 new ApplicationResourcesTest("testApplicationResources_zh_tw")); 70 suite.addTest( 71 new ApplicationResourcesTest("testApplicationResources_vi")); 72 return suite; 73 } 74 75 78 protected void setUp() throws Exception 79 { 80 super.setUp(); 81 userDir = System.getProperty("user.dir"); 82 83 baseProps = new Properties (); 85 baseProps.load(new FileInputStream ( 86 userDir + "/WEB-INF/classes/ApplicationResources.properties")); 87 } 88 89 94 public void testApplicationResources_nl() throws Exception 95 { 96 verifyResourceBundle("ApplicationResources_nl"); 97 } 98 99 104 public void testApplicationResources_zh_cn() throws Exception 105 { 106 verifyResourceBundle("ApplicationResources_zh_cn"); 107 } 108 109 114 public void testApplicationResources_zh_tw() throws Exception 115 { 116 verifyResourceBundle("ApplicationResources_zh_tw"); 117 } 118 119 124 public void testApplicationResources_vi() throws Exception 125 { 126 verifyResourceBundle("ApplicationResources_vi"); 127 } 128 129 public void testSystemProperties() 130 { 131 Properties sysProps = System.getProperties(); 132 Set keys = sysProps.keySet(); 133 for (Iterator iter = keys.iterator(); iter.hasNext();) 134 { 135 String key = (String ) iter.next(); 136 System.out.println(key + " = " + sysProps.getProperty(key)); 137 } 138 } 139 140 146 private void verifyResourceBundle(String bundle) throws Exception 147 { 148 assertNotNull(userDir); 150 assertTrue(userDir.endsWith("roller")); 151 152 Properties props = new Properties (); 154 props.load( 155 new FileInputStream ( 156 userDir 157 + "/web/WEB-INF/classes/" 158 + bundle 159 + ".properties")); 160 161 Set keys = baseProps.keySet(); 162 boolean missingMessage = false; 163 164 System.out.println("Veriyfing " + bundle + "..."); 166 for (Iterator iter = keys.iterator(); iter.hasNext();) 167 { 168 String key = (String ) iter.next(); 169 if (props.getProperty(key) == null) 170 { 171 System.err.println(key + " = " + baseProps.getProperty(key)); 172 missingMessage = true; 173 } 174 } 175 176 assertFalse(missingMessage); 177 } 178 179 } 180 | Popular Tags |