1 15 package org.apache.hivemind; 16 17 import java.util.Locale ; 18 19 import org.apache.hivemind.impl.RegistryBuilder; 20 import org.apache.hivemind.service.ThreadLocale; 21 import org.apache.hivemind.test.HiveMindTestCase; 22 23 30 public class TestThreadLocale extends HiveMindTestCase 31 { 32 public void testThreadSpecific() throws Exception 33 { 34 final Registry r = RegistryBuilder.constructDefaultRegistry(); 35 36 final ThreadLocale tl = (ThreadLocale) r.getService(ThreadLocale.class); 37 38 assertSame(r.getLocale(), tl.getLocale()); 39 40 tl.setLocale(Locale.KOREAN); 41 42 assertSame(Locale.KOREAN, tl.getLocale()); 43 44 Thread t = new Thread () 45 { 46 public void run() 47 { 48 assertSame(r.getLocale(), tl.getLocale()); 49 } 50 }; 51 52 t.start(); 53 t.join(); 54 } 55 56 public void testResetOnThreadCleanup() throws Exception 57 { 58 Registry r = RegistryBuilder.constructDefaultRegistry(); 59 60 ThreadLocale tl = (ThreadLocale) r.getService(ThreadLocale.class); 61 62 Locale start = r.getLocale(); 63 64 assertSame(start, tl.getLocale()); 65 66 tl.setLocale(Locale.CANADA_FRENCH); 67 68 r.cleanupThread(); 69 70 assertSame(start, tl.getLocale()); 71 } 72 73 } | Popular Tags |