1 package org.exoplatform.services.portletcontainer.imp; 2 3 4 import javax.portlet.PortletConfig; 5 import org.exoplatform.Constants; 6 import org.exoplatform.services.portletcontainer.impl.PortletDataImp; 7 import org.exoplatform.services.portletcontainer.impl.portletAPIImp.PortletConfigImp; 8 import java.util.Enumeration ; 9 import java.util.Locale ; 10 import java.util.ResourceBundle ; 11 12 16 17 24 public class TestPortletConfig extends BaseTest{ 25 26 PortletConfig config; 27 28 public TestPortletConfig(String s) { 29 super(s); 30 } 31 32 public void setUp() throws Exception { 33 super.setUp(); 34 PortletDataImp portletDatas = (PortletDataImp) portletContainer. 35 getAllPortletMetaData().get("hello" + Constants.PORTLET_META_DATA_ENCODER 36 + "HelloWorld"); 37 38 config = new PortletConfigImp(portletDatas.getWrappedPortletTyped(), portletContext, 39 portletApp_.getSecurityConstraint(), 40 portletApp_.getUserAttribute(), 41 portletApp_.getCustomPortletMode(), 42 portletApp_.getCustomWindowState()); 43 } 44 45 52 public void testInitializationParam(){ 53 Enumeration e = config.getInitParameterNames(); 54 assertEquals("initName", e.nextElement()); 55 assertFalse(e.hasMoreElements()); 56 57 assertEquals("initValue", config.getInitParameter("initName")); 58 } 59 60 69 public void testResourceBundleCreation(){ 70 Locale l = Locale.ENGLISH ; 71 ResourceBundle rB = config.getResourceBundle(l); 72 73 assertEquals("HelloWorld title",rB.getString("javax.portlet.title")); 74 assertEquals("Hello World",rB.getString("javax.portlet.short-title")); 75 assertEquals("sample, hello",rB.getString("javax.portlet.keywords")); 76 assertEquals(l, rB.getLocale()); 78 79 l = Locale.FRENCH ; 80 rB = config.getResourceBundle(l); 81 assertEquals("Bonjour le monde Portlet",rB.getString("javax.portlet.title")); 82 assertEquals("Bonjour",rB.getString("javax.portlet.short-title")); 83 assertEquals("exemple, bonjour",rB.getString("javax.portlet.keywords")); 84 assertEquals(l, rB.getLocale()); 85 } 86 87 96 public void testInlineResourceBundleCreation(){ 97 PortletDataImp portletDatas = (PortletDataImp) portletContainer. 98 getAllPortletMetaData().get("hello" + Constants.PORTLET_META_DATA_ENCODER 99 + "HelloWorld2"); 100 101 config = new PortletConfigImp(portletDatas.getWrappedPortletTyped(), portletContext, 102 portletApp_.getSecurityConstraint(), 103 portletApp_.getUserAttribute(), 104 portletApp_.getCustomPortletMode(), 105 portletApp_.getCustomWindowState()); 106 107 Locale l = Locale.US; 108 ResourceBundle rB = config.getResourceBundle(l); 109 110 assertEquals("HelloWorld2",rB.getString("javax.portlet.title")); 111 assertEquals("HelloWorld2s",rB.getString("javax.portlet.short-title")); 112 assertEquals("Time, Zone, World, Clock",rB.getString("javax.portlet.keywords")); 113 assertEquals(l, rB.getLocale()); 114 } 115 116 117 } 118 | Popular Tags |