org.apache.commons.i18n
Class MessageProviderTestBase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.commons.i18n.MessageProviderTestBase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
JdbcMessageProviderTest, ResourceBundleMessageProviderTest, XMLMessageProviderTest

public abstract class MessageProviderTestBase
extends junit.framework.TestCase

This class tests that the behaviour of a MessageProvider implementation is correct. If creating new implementations, consider subclassing this class to test the behaviour of that implementation. The tests assume the provided MessageProvider contains the following entries:

Language/Locale ID Entry Message
English (en) helloWorld title Hello World
English (en) helloWorld text Hello World, we are in {0}.
German (de) helloWorld title Hallo Welt
German (de) helloWorld text Hallo Welt, wir sind in {0}.
The entry below is used only if possible. If not possible, set hasNonTranslatedEntry to false.
English (en) helloWorld helloWorld This entry is not translated to any other languages

Specifically, the ID nonExistentId and the entry nonExistentEntry of ID helloWorld must NOT be existent.


Constructor Summary
protected MessageProviderTestBase()
           
protected MessageProviderTestBase(java.lang.String testName)
           
 
Method Summary
 void setUp()
          Set English as default Locale.
 void tearDown()
           
protected  void testGetEntries(org.apache.commons.i18n.MessageProvider messageProvider, boolean hasNonTranslatedEntry)
           
protected  void testGetText(org.apache.commons.i18n.MessageProvider messageProvider)
          Test functionality of getText() method, which should be common for all implementations of the MessageProvider interface.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MessageProviderTestBase

protected MessageProviderTestBase()

MessageProviderTestBase

protected MessageProviderTestBase(java.lang.String testName)
Method Detail

setUp

public void setUp()
           throws java.lang.Exception
Set English as default Locale. If overridden, please remember to call super.setUp()

Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception - No exception is thrown, but allow for overriding methods to throw exceptions.

tearDown

public void tearDown()
              throws java.lang.Exception
Overrides:
tearDown in class junit.framework.TestCase
Throws:
java.lang.Exception

testGetText

protected void testGetText(org.apache.commons.i18n.MessageProvider messageProvider)
Test functionality of getText() method, which should be common for all implementations of the MessageProvider interface.

Parameters:
messageProvider -

testGetEntries

protected void testGetEntries(org.apache.commons.i18n.MessageProvider messageProvider,
                              boolean hasNonTranslatedEntry)


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.