1 15 package org.apache.tapestry.services.impl; 16 17 import java.util.Locale ; 18 19 import org.apache.hivemind.test.HiveMindTestCase; 20 import org.apache.tapestry.engine.IPropertySource; 21 import org.easymock.MockControl; 22 23 29 public class TestLocalizedPropertySource extends HiveMindTestCase 30 { 31 public void testFound() 32 { 33 MockControl control = newControl(IPropertySource.class); 34 IPropertySource ps = (IPropertySource) control.getMock(); 35 36 ps.getPropertyValue("property-name_en"); 37 control.setReturnValue(null); 38 39 ps.getPropertyValue("property-name"); 40 control.setReturnValue("fred"); 41 42 replayControls(); 43 44 LocalizedPropertySource lps = new LocalizedPropertySource(ps); 45 46 String result = lps.getPropertyValue("property-name", Locale.ENGLISH); 47 48 assertEquals("fred", result); 49 50 verifyControls(); 51 } 52 53 public void testNotFound() 54 { 55 MockControl control = newControl(IPropertySource.class); 56 IPropertySource ps = (IPropertySource) control.getMock(); 57 58 ps.getPropertyValue("property-name_fr"); 59 control.setReturnValue(null); 60 61 ps.getPropertyValue("property-name"); 62 control.setReturnValue(null); 63 64 replayControls(); 65 66 LocalizedPropertySource lps = new LocalizedPropertySource(ps); 67 68 assertNull(lps.getPropertyValue("property-name", Locale.FRENCH)); 69 70 verifyControls(); 71 } 72 } | Popular Tags |