Package fi.luomus.commons.languagesupport

Examples of fi.luomus.commons.languagesupport.LanguageFileReader


 
  public static class OpeningANewReader extends TestCase {
   
    public void test_it_only_accepts_one_or_more_languages() {
      try {
        new LanguageFileReader("a", "a");
        fail("Should not accept no languages");
      } catch (IllegalArgumentException e) {
      } catch (Exception e) {
      }
     
      try {
        new LanguageFileReader("a", "a", "");
        fail("Should not accept empty_strings a language");
      } catch (IllegalArgumentException e) {
      } catch (Exception e) {
      }
     
View Full Code Here


    public void test_it_only_accepts_parameters_that_can_find_a_language_file() throws Exception {
     
      String folder = TestConfig.getConfig().languagefileFolder();
     
      try {
        new LanguageFileReader("doesnotexist", "doesnotexist", "FI");
        fail("Should fail");
      } catch (FileNotFoundException e) {
      }
     
      try {
        new LanguageFileReader(folder, "doesnotexist", "FI");
        fail("Should fail");
      } catch (FileNotFoundException e) {
      }
     
      try {
        new LanguageFileReader(folder, "langfile_", "FI");
      } catch (FileNotFoundException e) {
        fail("Should not fail: " + e);
      }
     
      try {
        new LanguageFileReader(folder, "langfile_", "FI", "EN");
      } catch (FileNotFoundException e) {
        fail("Should not fail: " + e);
      }
     
    }
View Full Code Here

    public void setUp() throws Exception {
      folder = TestConfig.getConfig().languagefileFolder();
    }
   
    public void test_it_reads_a_text() throws Exception {
      LanguageFileReader r = new LanguageFileReader(folder, "langfile_", "FI");
      LocalizedTextsContainer uiTexts = r.readUITexts();
     
      assertEquals("Testi", uiTexts.getText("text.test", "FI"));
    }
View Full Code Here

     
      assertEquals("Testi", uiTexts.getText("text.test", "FI"));
    }
   
    public void test_it_reads_a_text_in_all_languages() throws Exception {
      LanguageFileReader r = new LanguageFileReader(folder, "langfile_", "FI", "EN");
      LocalizedTextsContainer uiTexts = r.readUITexts();
     
      assertEquals("Testi", uiTexts.getText("text.test", "FI"));
      assertEquals("Test", uiTexts.getText("text.test", "EN"));
    }
View Full Code Here

      assertEquals("Testi", uiTexts.getText("text.test", "FI"));
      assertEquals("Test", uiTexts.getText("text.test", "EN"));
    }
   
    public void test_it_throws_exception_if_a_text_is_not_found_from_all_lang_files() throws Exception {
      LanguageFileReader r = new LanguageFileReader(folder, "langfile_", "FI", "EN", "SE");
      try {
        r.readUITexts();
        fail("Should fail because 'error.general_required' not found from  se-langfile");
      } catch (NoSuchFieldException e) {
        assertTrue("Should contain the name of the field missing", e.toString().contains("error.general_required"));
      }
    }
View Full Code Here

    System.out.println(this.getClass().getCanonicalName() +": static content initialized.");
  }
 
  private void initLocalizedTexts() throws ServletException {
    try {
      localizedTextsContainer = new LanguageFileReader(this.config).readUITexts();
    } catch (Exception e) {
      throw new ServletException(e);
    }
  }
View Full Code Here

TOP

Related Classes of fi.luomus.commons.languagesupport.LanguageFileReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.