Search in sources :

Example 6 with ComponentStringResourceLoader

use of org.apache.wicket.resource.loader.ComponentStringResourceLoader in project wicket by apache.

the class ApplicationSettingsTest method testOverrideStringResourceLoaderSetup.

/**
 */
@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);
}
Also used : ComponentStringResourceLoader(org.apache.wicket.resource.loader.ComponentStringResourceLoader) MockApplication(org.apache.wicket.mock.MockApplication) ResourceSettings(org.apache.wicket.settings.ResourceSettings) IStringResourceLoader(org.apache.wicket.resource.loader.IStringResourceLoader) BundleStringResourceLoader(org.apache.wicket.resource.loader.BundleStringResourceLoader) Test(org.junit.Test)

Example 7 with ComponentStringResourceLoader

use of org.apache.wicket.resource.loader.ComponentStringResourceLoader in project wicket by apache.

the class ComponentStringResourceLoaderTest method searchClassHierarchyFromPage.

/**
 */
@Test
public void searchClassHierarchyFromPage() {
    DummySubClassPage p = new DummySubClassPage();
    IStringResourceLoader loader = new ComponentStringResourceLoader();
    assertEquals("Valid resource string should be found", "SubClass Test String", loader.loadStringResource(p.getClass(), "subclass.test.string", Locale.getDefault(), null, null));
    assertEquals("Valid resource string should be found", "Another string", loader.loadStringResource(p.getClass(), "another.test.string", Locale.getDefault(), null, null));
}
Also used : ComponentStringResourceLoader(org.apache.wicket.resource.loader.ComponentStringResourceLoader) IStringResourceLoader(org.apache.wicket.resource.loader.IStringResourceLoader) Test(org.junit.Test)

Aggregations

ComponentStringResourceLoader (org.apache.wicket.resource.loader.ComponentStringResourceLoader)7 Test (org.junit.Test)7 IStringResourceLoader (org.apache.wicket.resource.loader.IStringResourceLoader)6 MockApplication (org.apache.wicket.mock.MockApplication)2 ResourceSettings (org.apache.wicket.settings.ResourceSettings)2 Locale (java.util.Locale)1 Component (org.apache.wicket.Component)1 EmptyPanel (org.apache.wicket.markup.html.panel.EmptyPanel)1 Panel (org.apache.wicket.markup.html.panel.Panel)1 BundleStringResourceLoader (org.apache.wicket.resource.loader.BundleStringResourceLoader)1 ClassStringResourceLoader (org.apache.wicket.resource.loader.ClassStringResourceLoader)1 InitializerStringResourceLoader (org.apache.wicket.resource.loader.InitializerStringResourceLoader)1 PackageStringResourceLoader (org.apache.wicket.resource.loader.PackageStringResourceLoader)1 ValidatorStringResourceLoader (org.apache.wicket.resource.loader.ValidatorStringResourceLoader)1