Package org.apache.wicket.settings

Examples of org.apache.wicket.settings.ResourceSettings


   * @throws Exception
   */
  @Test
  public void testExceptionOnMissingResourceDefaultValue() throws Exception
  {
    ResourceSettings settings = new ResourceSettings(new MockApplication());
    Assert.assertTrue("exceptionOnMissingResource should default to true",
      settings.getThrowExceptionOnMissingResource());
  }
View Full Code Here


   */
  public String getString(final String key, final Component component, final IModel<?> model,
    final Locale locale, final String style, final String defaultValue)
    throws MissingResourceException
  {
    final ResourceSettings resourceSettings = Application.get().getResourceSettings();

    String value = getStringIgnoreSettings(key, component, model, locale, style, null);
    if ((value == null) && (defaultValue != null))
    {
      // Resource not found, so handle missing resources based on
      // application configuration and try the default value
      if (resourceSettings.getUseDefaultOnMissingResource())
      {
        value = defaultValue;

        // If a property value has been found, or a default value was given,
        // than replace the placeholder and we are done
        return substitutePropertyExpressions(component, value, model);
      }
    }

    // If a property value has been found, or a default value was given,
    // than replace the placeholder and we are done
    if (value != null)
    {
      return value;
    }

    if (resourceSettings.getThrowExceptionOnMissingResource())
    {
      AppendingStringBuffer message = new AppendingStringBuffer("Unable to find property: '");
      message.append(key);
      message.append('\'');

View Full Code Here

   * @throws Exception
   */
  @Test
  public void testExceptionOnMissingResourceSetsCorrectly() throws Exception
  {
    ResourceSettings settings = new ResourceSettings(new MockApplication());
    settings.setThrowExceptionOnMissingResource(false);
    Assert.assertFalse("exceptionOnMissingResource should have been set to false",
      settings.getThrowExceptionOnMissingResource());
  }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testUseDefaultOnMissingResourceDefaultValue() throws Exception
  {
    ResourceSettings settings = new ResourceSettings(new MockApplication());
    Assert.assertTrue("useDefaultOnMissingResource should default to true",
      settings.getUseDefaultOnMissingResource());
  }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testUseDefaultOnMissingResourceSetsCorrectly() throws Exception
  {
    ResourceSettings settings = new ResourceSettings(new MockApplication());
    settings.setUseDefaultOnMissingResource(false);
    Assert.assertFalse("useDefaultOnMissingResource should have been set to false",
      settings.getUseDefaultOnMissingResource());
  }
View Full Code Here

   *
   */
  @Test
  public void testDefaultStringResourceLoaderSetup()
  {
    ResourceSettings settings = new ResourceSettings(new MockApplication());
    List<IStringResourceLoader> loaders = settings.getStringResourceLoaders();
    Assert.assertEquals("There should be 5 default loaders", 5, loaders.size());
    Assert.assertTrue("First loader one should be the component one",
      loaders.get(0) instanceof ComponentStringResourceLoader);
    Assert.assertTrue("Second loader should be the package one",
      loaders.get(1) instanceof PackageStringResourceLoader);
View Full Code Here

   *
   */
  @Test
  public void testOverrideStringResourceLoaderSetup()
  {
    ResourceSettings settings = new ResourceSettings(new MockApplication());
    settings.getStringResourceLoaders().clear();
    settings.getStringResourceLoaders().add(
      new BundleStringResourceLoader("org.apache.wicket.resource.DummyResources"));
    settings.getStringResourceLoaders().add(new ComponentStringResourceLoader());
    List<IStringResourceLoader> loaders = settings.getStringResourceLoaders();
    Assert.assertEquals("There should be 2 overridden loaders", 2, loaders.size());
    Assert.assertTrue("First loader one should be the bundle one",
      loaders.get(0) instanceof BundleStringResourceLoader);
    Assert.assertTrue("Second loader should be the component one",
      loaders.get(1) instanceof ComponentStringResourceLoader);
View Full Code Here

  public final ResourceSettings getResourceSettings()
  {
    checkSettingsAvailable();
    if (resourceSettings == null)
    {
      resourceSettings = new ResourceSettings(this);
    }
    return resourceSettings;
  }
View Full Code Here

    super.commonBefore();
  }

  @Test
  public void check() {
    ResourceSettings settings = tester.getApplication().getResourceSettings();
    assertThat(settings.getParentFolderPlaceholder(), is(equalTo(expected)));
  }
View Full Code Here

  public final ResourceSettings getResourceSettings()
  {
    checkSettingsAvailable();
    if (resourceSettings == null)
    {
      resourceSettings = new ResourceSettings(this);
    }
    return resourceSettings;
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.settings.ResourceSettings

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.