ch.elca.el4j.services.i18n
Class CrossCheckingMessageSource

java.lang.Object
  extended by ch.elca.el4j.services.i18n.CrossCheckingMessageSource
All Implemented Interfaces:
InitializingBean, MessageSource

public class CrossCheckingMessageSource
extends Object
implements MessageSource, InitializingBean

Test class loading the same properties files in two or more message sources and comparing their behavior.

Usage

Replace the message source in the spring configuration with an instance of this class (leaving the basenames-assignment intact) and configure the types to be compared using m_types. This class will then resolve every message it is asked to resolve from both sources, and assert they agree about the message's value. (You should therefore enable assertions ...)

Author:
Adrian Moos (AMS)
File-location:
CrossCheckingMessageSource
Last check-in date:
2009-08-04 14:25:40 +0200 (Di, 04. Aug 2009) by swismer for revision 3874

Constructor Summary
CrossCheckingMessageSource()
           
 
Method Summary
 void afterPropertiesSet()
          Creates and initializes the requested message sources.
 String getMessage(MessageSourceResolvable resolvable, Locale locale)
          
 String getMessage(String code, Object[] args, Locale locale)
          
 String getMessage(String code, Object[] args, String defaultMessage, Locale locale)
          
 void setBasenames(String[] basenames)
          Like ResourceBundleMessageSource.setBasenames(String[]).
 void setTypes(String[] types)
          Sets the types of the message sources to be compared.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CrossCheckingMessageSource

public CrossCheckingMessageSource()
Method Detail

setTypes

public void setTypes(String[] types)
Sets the types of the message sources to be compared.


setBasenames

public void setBasenames(String[] basenames)
Like ResourceBundleMessageSource.setBasenames(String[]).


getMessage

public String getMessage(MessageSourceResolvable resolvable,
                         Locale locale)
                  throws NoSuchMessageException

Specified by:
getMessage in interface MessageSource
Throws:
NoSuchMessageException

getMessage

public String getMessage(String code,
                         Object[] args,
                         Locale locale)
                  throws NoSuchMessageException

Specified by:
getMessage in interface MessageSource
Throws:
NoSuchMessageException

getMessage

public String getMessage(String code,
                         Object[] args,
                         String defaultMessage,
                         Locale locale)

Specified by:
getMessage in interface MessageSource

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Creates and initializes the requested message sources.

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception


Copyright © 2005-2011 ELCA. All Rights Reserved.