Mercurial > hg > release > thermostat-0.9
changeset 96:ca890e99eb15
Add test for Translate class.
Reviewed-by: vanaltj
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-March/000190.html
author | Mario Torre <neugens.limasoftware@gmail.com> |
---|---|
date | Thu, 01 Mar 2012 18:28:57 +0100 |
parents | f337c6583c07 |
children | 34b68fe9add6 |
files | client/src/test/java/com/redhat/thermostat/client/locale/TranslateTest.java |
diffstat | 1 files changed, 58 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/test/java/com/redhat/thermostat/client/locale/TranslateTest.java Thu Mar 01 18:28:57 2012 +0100 @@ -0,0 +1,58 @@ +package com.redhat.thermostat.client.locale; + +import java.util.Locale; +import java.util.MissingResourceException; + +import junit.framework.Assert; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static com.redhat.thermostat.client.Translate.localize; + +public class TranslateTest { + + private Locale lang; + + @Before + public void setUp() { + this.lang = Locale.getDefault(); + Locale.setDefault(Locale.US); + } + + @After + public void tearDown() { + Locale.setDefault(lang); + } + + @Test + public void testMissingInfo() { + String testString = localize("MISSING_INFO"); + Assert.assertEquals("Missing Information", testString); + } + + @Test + public void testLocalization() { + String testString = localize("APPLICATION_INFO_VERSION", "test"); + Assert.assertEquals("Version test", testString); + + testString = localize("APPLICATION_INFO_DESCRIPTION"); + Assert.assertEquals("A monitoring and serviceability tool for OpenJDK", + testString); + } + + @Test(expected = MissingResourceException.class) + public void testLocalizationError1() { + + localize("INVALID_BLABLABLA_FLUFF"); + Assert.fail("java.util.MissingResourceException expected"); + } + + @Test(expected = MissingResourceException.class) + public void testLocalizationError2() { + + localize("INVALID_BLABLABLA_FLUFF", "test"); + Assert.fail("java.util.MissingResourceException expected"); + } +}