Package org.pentaho.platform.web.servlet

Examples of org.pentaho.platform.web.servlet.LocalizationServlet


    microPlatform.stop();
  }

  @Test
  public void getBundle() {
    LocalizationServlet ls = new LocalizationServlet();
    String json = ls.getJSONBundle( TestPluginProvider.TEST_PLUGIN, "messages/messages" );
    assertNotNull( json );
    assertTrue( json.contains( "\"2\":\"two\"" ) );
  }
View Full Code Here


    assertTrue( json.contains( "\"2\":\"two\"" ) );
  }

  @Test
  public void getBundle_invalid_plugin() {
    LocalizationServlet ls = new LocalizationServlet();
    try {
      ls.getJSONBundle( "invalid-plugin", "messages/messages" );
      fail( "Expected exception" );
    } catch ( RuntimeException ex ) {
      assertTrue( ex.getCause() instanceof IllegalArgumentException );
      assertTrue( "Unexpected exception: " + ex.getCause().getMessage(), ex.getCause().getMessage().contains(
          "LocalizationServlet.ERROR_0001" ) );
View Full Code Here

    }
  }

  @Test
  public void getBundle_invalid_name() {
    LocalizationServlet ls = new LocalizationServlet();
    try {
      ls.getJSONBundle( "test-plugin", null );
      fail( "Expected exception" );
    } catch ( RuntimeException ex ) {
      assertTrue( ex.getCause() instanceof IllegalArgumentException );
      assertTrue( "Unexpected exception: " + ex.getCause().getMessage(), ex.getCause().getMessage().contains(
          "LocalizationServlet.ERROR_0002" ) );
    }

    try {
      ls.getJSONBundle( "test-plugin", "" );
      fail( "Expected exception" );
    } catch ( RuntimeException ex ) {
      assertTrue( ex.getCause() instanceof IllegalArgumentException );
      assertTrue( "Unexpected exception: " + ex.getCause().getMessage(), ex.getCause().getMessage().contains(
          "LocalizationServlet.ERROR_0002" ) );
View Full Code Here

    }
  }

  @Test
  public void getBundle_es() {
    LocalizationServlet ls = new LocalizationServlet();
    try {
      LocaleHelper.setLocale( new Locale( "es" ) );
      String json = ls.getJSONBundle( TestPluginProvider.TEST_PLUGIN, "messages/messages" );
      assertNotNull( json );
      assertTrue( json.contains( "\"2\":\"dos\"" ) );
    } finally {
      LocaleHelper.setLocale( null );
    }
View Full Code Here

    }
  }

  @Test
  public void isMessageCachingEnabled() {
    LocalizationServlet ls = new LocalizationServlet();

    assertTrue( ls.isMessageCachingEnabled( PentahoSystem.get( IPluginManager.class ),
      TestPluginProvider.TEST_PLUGIN ) );
    assertFalse( ls.isMessageCachingEnabled( PentahoSystem.get( IPluginManager.class ),
        TestPluginProvider.TEST_PLUGIN_2 ) );
  }
View Full Code Here

        TestPluginProvider.TEST_PLUGIN_2 ) );
  }

  @Test
  public void doGet() throws IOException, ServletException {
    LocalizationServlet ls = new LocalizationServlet();
    MockHttpServletRequest req = new MockHttpServletRequest();
    MockHttpServletResponse resp = new MockHttpServletResponse();
    req.setParameter( "plugin", "test-plugin" );
    req.setParameter( "name", "messages/messages" );
    ls.doGet( req, resp );
  }
View Full Code Here

    ls.doGet( req, resp );
  }

  @Test
  public void doGet_invalid_plugin() throws IOException, ServletException {
    LocalizationServlet ls = new LocalizationServlet();
    MockHttpServletRequest req = new MockHttpServletRequest();
    MockHttpServletResponse resp = new MockHttpServletResponse();
    req.setParameter( "plugin", "invalid-plugin" );
    ls.doGet( req, resp );
    assertEquals( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, resp.getStatus() );
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.web.servlet.LocalizationServlet

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.