1 16 17 package org.springframework.mock.web.portlet; 18 19 import java.util.Enumeration ; 20 import java.util.HashMap ; 21 import java.util.Locale ; 22 import java.util.Properties ; 23 import java.util.ResourceBundle ; 24 25 import javax.portlet.PortletConfig; 26 import javax.portlet.PortletContext; 27 28 import org.springframework.util.Assert; 29 30 37 public class MockPortletConfig implements PortletConfig { 38 39 private final PortletContext portletContext; 40 41 private final String portletName; 42 43 private final HashMap resourceBundles = new HashMap (); 44 45 private final Properties initParameters = new Properties (); 46 47 48 52 public MockPortletConfig(PortletContext portletContext) { 53 this(portletContext, ""); 54 } 55 56 61 public MockPortletConfig(PortletContext portletContext, String portletName) { 62 this.portletContext = (portletContext != null ? portletContext : new MockPortletContext()); 63 this.portletName = portletName; 64 } 65 66 67 public String getPortletName() { 68 return portletName; 69 } 70 71 public PortletContext getPortletContext() { 72 return portletContext; 73 } 74 75 public void setResourceBundle(Locale locale, ResourceBundle resourceBundle) { 76 Assert.notNull(locale, "Locale must not be null"); 77 this.resourceBundles.put(locale, resourceBundle); 78 } 79 80 public ResourceBundle getResourceBundle(Locale locale) { 81 Assert.notNull(locale, "Locale must not be null"); 82 return (ResourceBundle ) this.resourceBundles.get(locale); 83 } 84 85 public void addInitParameter(String name, String value) { 86 Assert.notNull(name, "Parameter name must not be null"); 87 this.initParameters.setProperty(name, value); 88 } 89 90 public String getInitParameter(String name) { 91 Assert.notNull(name, "Parameter name must not be null"); 92 return this.initParameters.getProperty(name); 93 } 94 95 public Enumeration getInitParameterNames() { 96 return this.initParameters.keys(); 97 } 98 99 } 100 | Popular Tags |