org.opencms.i18n
Class TestCmsMessageBundles

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.opencms.i18n.TestCmsMessageBundles
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
TestCmsCoreMessageBundles, TestCmsModuleMessageBundles

public abstract class TestCmsMessageBundles
extends junit.framework.TestCase

Tests for the CmsMessageBundles.

Since:
6.0.0

Constructor Summary
TestCmsMessageBundles()
           
 
Method Summary
protected  String doPreTestBundle(String className, String bundleName, Locale locale, boolean client)
          Performs some key and language independent tests.
protected  String doTestBundle(Class<?> clazz, String bundleName, Locale locale)
          Tests an individual message bundle.
protected  List<I_CmsMessageBundle> getExcludedLocalizedBundles(Locale locale)
          Returns the resource bundles to be excluded from additional locales tests.
protected  CmsMessages getMessageBundle(String bundleName, Locale locale)
          Prepares the test for the given bundle and locale and returns a message bundle that DOES NOT include the default keys.
protected  String getMessageBundleSourceName(String bundleName, Locale locale)
          Returns the file name of the source message bundle.
protected  String getModuleMessagesBundleSourceName(String bundleName, Locale locale)
          Returns the file name of the source message bundle from the module.
protected abstract  List<I_CmsMessageBundle> getNotLocalizedBundles(Locale locale)
          Returns a list of bundles not to be localized.
protected abstract  I_CmsClientMessageBundle[] getTestClientMessageBundles()
          Template method that has to be overwritten to return the client class that will be tested.
protected abstract  I_CmsMessageBundle[] getTestMessageBundles()
          Template method that has to be overwritten to return the I_CmsMessageBundle instances that will be tested.
protected  void messagesBundleConstantTest(Locale locale)
          Checks all OpenCms internal message bundles if the are correctly build.
 void testLocale_DE_MessagesBundles()
          Checks all message bundles for the DE locale.
 void testLocale_EN_MessagesBundles()
          Checks all message bundles for the EN locale.
 void testLocale_ES_MessagesBundles()
          Checks all message bundles for the ES locale.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestCmsMessageBundles

public TestCmsMessageBundles()
Method Detail

testLocale_DE_MessagesBundles

public void testLocale_DE_MessagesBundles()
                                   throws Exception
Checks all message bundles for the DE locale.

Throws:
Exception - if the test fails

testLocale_EN_MessagesBundles

public void testLocale_EN_MessagesBundles()
                                   throws Exception
Checks all message bundles for the EN locale.

Throws:
Exception - if the test fails

testLocale_ES_MessagesBundles

public void testLocale_ES_MessagesBundles()
                                   throws Exception
Checks all message bundles for the ES locale.

Throws:
Exception - if the test fails

doPreTestBundle

protected String doPreTestBundle(String className,
                                 String bundleName,
                                 Locale locale,
                                 boolean client)
Performs some key and language independent tests.

Parameters:
className - the bundle implementing class name
bundleName - the bundle name to test
locale - the locale to test
client - if the bundle to test is a client bundle
Returns:
a description of all errors found

doTestBundle

protected String doTestBundle(Class<?> clazz,
                              String bundleName,
                              Locale locale)
                       throws Exception
Tests an individual message bundle.

Parameters:
clazz - the bundle class
bundleName - the bundle class name
locale - the locale to test
Returns:
a description of all errors found
Throws:
Exception - if the test fails

getExcludedLocalizedBundles

protected List<I_CmsMessageBundle> getExcludedLocalizedBundles(Locale locale)
Returns the resource bundles to be excluded from additional locales tests.

Parameters:
locale - the locale to get the excluded bundles for
Returns:
the resource bundles to be excluded from additional locales tests

getMessageBundle

protected CmsMessages getMessageBundle(String bundleName,
                                       Locale locale)
                                throws IOException
Prepares the test for the given bundle and locale and returns a message bundle that DOES NOT include the default keys.

Parameters:
bundleName - the resource bundle to prepare
locale - the locale to prepare the resource bundle for
Returns:
a message bundle that DOES NOT include the default keys
Throws:
IOException - if something goes wrong

getMessageBundleSourceName

protected String getMessageBundleSourceName(String bundleName,
                                            Locale locale)
Returns the file name of the source message bundle.

Parameters:
bundleName - the resource bundle to get the file name for
locale - the locale to get the file name for
Returns:
the file name of the source message bundle

getModuleMessagesBundleSourceName

protected String getModuleMessagesBundleSourceName(String bundleName,
                                                   Locale locale)
Returns the file name of the source message bundle from the module.

Parameters:
bundleName - the resource bundle to get the file name for
locale - the locale to get the file name for
Returns:
the file name of the source message bundle of the module

getNotLocalizedBundles

protected abstract List<I_CmsMessageBundle> getNotLocalizedBundles(Locale locale)
Returns a list of bundles not to be localized.

Parameters:
locale - the locale to get the not localized bundles for
Returns:
a list of bundles not to be localized

getTestClientMessageBundles

protected abstract I_CmsClientMessageBundle[] getTestClientMessageBundles()
                                                                   throws Exception
Template method that has to be overwritten to return the client class that will be tested.

Returns:
the classes to test
Throws:
Exception - if the test fails

getTestMessageBundles

protected abstract I_CmsMessageBundle[] getTestMessageBundles()
Template method that has to be overwritten to return the I_CmsMessageBundle instances that will be tested.

Returns:
the I_CmsMessageBundle instances to test: these will be the singleton instances of the Messages classes residing in every localized package.

messagesBundleConstantTest

protected void messagesBundleConstantTest(Locale locale)
                                   throws Exception
Checks all OpenCms internal message bundles if the are correctly build.

Parameters:
locale - the locale to test
Throws:
Exception - if the test fails