1 16 package cintoo.messages.context; 17 18 import cintoo.messages.bundle.DefaultBundleManager; 19 20 import java.util.Locale ; 21 22 import api.cintoo.messages.context.Context; 23 import org.testng.annotations.*; 24 import org.testng.Assert; 25 26 public class TestIdContext { 27 private static Context ID1 = IdContext.id("ID1"); 28 private static Context ID2 = IdContext.id("ID2"); 29 30 @Test 31 public void testMatches() { 32 Assert.assertTrue(ID1.matches(ID1), "ID1 matches ID1"); 33 } 34 35 @Test 36 public void testDoesNotMatch() { 37 Assert.assertFalse( (ID2.matches(ID1)), "ID2 does not match ID1"); 38 Assert.assertFalse( (ID1.matches(ID2)), "ID1 does not match ID2"); 39 } 40 41 @Test 42 public void testHash() { 43 Assert.assertTrue( ID2.hashCode() != ID1.hashCode(), "Hashcodes of ID1 and ID2 are different"); 44 } 45 46 47 @Test 48 public void testIdWithBundleManager() { 49 DefaultBundleManager manager = new DefaultBundleManager(new DefaultContextCache()); 50 manager.setBundle("testp1", ID1); 51 manager.setBundle("testp2", ID2); 52 53 Assert.assertEquals(manager.getBundle(ID1, new Locale ("de", "de")).getString("testKey1"), "testValue1", "Manager returns correct bundle for ID1"); 54 Assert.assertEquals(manager.getBundle(ID2, new Locale ("de", "de")).getString("testKey2"), "testValue2", "Manager returns correct bundle for ID2"); 55 } 56 57 } 58 | Popular Tags |