001 package com.mockrunner.struts; 002 003 import java.util.Map; 004 005 import org.apache.struts.util.MessageResources; 006 import org.apache.struts.util.MessageResourcesFactory; 007 008 /** 009 * Factory for {@link MapMessageResources}. 010 * If you want this factory to be the default 011 * factory used in your actions in the tests, 012 * you should call 013 * <code>MessageResourcesFactory.setFactoryClass("com.mockrunner.struts.MapMessageResourcesFactory")</code> 014 */ 015 public class MapMessageResourcesFactory extends MessageResourcesFactory 016 { 017 private static Map theMessages; 018 019 /** 020 * Sets the messages <code>Map</code> for returned 021 * {@link MapMessageResources} objects. 022 * @param messages the message <code>Map</code> 023 */ 024 public static void setMessageMap(Map messages) 025 { 026 theMessages = messages; 027 } 028 029 public MessageResources createResources(String config) 030 { 031 return new MapMessageResources(theMessages, this, config, this.returnNull); 032 } 033 }