use of org.apache.wicket.resource.loader.ComponentStringResourceLoader in project wicket by apache.
the class LocalizerTest method testTwoComponents.
/**
* Unit test for bug number [1416582] Resource loading caches wrong.
*/
@Test
public void testTwoComponents() {
Session.get().setLocale(Locale.ENGLISH);
MyMockPage page = new MyMockPage();
Application.get().getResourceSettings().getStringResourceLoaders().add(new ComponentStringResourceLoader());
Localizer localizer = Application.get().getResourceSettings().getLocalizer();
assertEquals("value 1", localizer.getString("null", page.drop1));
assertEquals("value 2", localizer.getString("null", page.drop2));
Session.get().setLocale(new Locale("nl"));
assertEquals("waarde 1", localizer.getString("null", page.drop1));
assertEquals("waarde 2", localizer.getString("null", page.drop2));
}
use of org.apache.wicket.resource.loader.ComponentStringResourceLoader in project wicket by apache.
the class ApplicationSettingsTest method testDefaultStringResourceLoaderSetup.
/**
*/
@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);
Assert.assertTrue("Third loader should be the application one", loaders.get(2) instanceof ClassStringResourceLoader);
Assert.assertTrue("Fourth loader should be the validator one", loaders.get(3) instanceof ValidatorStringResourceLoader);
Assert.assertTrue("Fifth should be the initializer one", loaders.get(4) instanceof InitializerStringResourceLoader);
}
use of org.apache.wicket.resource.loader.ComponentStringResourceLoader in project wicket by apache.
the class ComponentStringResourceLoaderTest method loaderUnknownResources.
/**
* @see org.apache.wicket.resource.StringResourceLoaderTestBase#testLoaderUnknownResources()
*/
@Override
@Test
public void loaderUnknownResources() {
Component c = new DummyComponent("hello", tester.getApplication()) {
private static final long serialVersionUID = 1L;
};
DummyPage page = new DummyPage();
page.add(c);
IStringResourceLoader loader = new ComponentStringResourceLoader();
assertNull("Missing resource should return null", loader.loadStringResource(c.getClass(), "test.string.bad", Locale.getDefault(), null, null));
}
use of org.apache.wicket.resource.loader.ComponentStringResourceLoader in project wicket by apache.
the class ComponentStringResourceLoaderTest method loadDirectFromPage.
/**
*/
@Test
public void loadDirectFromPage() {
DummyPage p = new DummyPage();
IStringResourceLoader loader = new ComponentStringResourceLoader();
assertEquals("Valid resourse string should be found", "Another string", loader.loadStringResource(p.getClass(), "another.test.string", Locale.getDefault(), null, null));
}
use of org.apache.wicket.resource.loader.ComponentStringResourceLoader in project wicket by apache.
the class ComponentStringResourceLoaderTest method multiLevelEmbeddedComponentLoadFromComponent.
/**
*/
@Test
public void multiLevelEmbeddedComponentLoadFromComponent() {
DummyPage p = new DummyPage();
Panel panel = new EmptyPanel("panel");
p.add(panel);
DummyComponent c = new DummyComponent("hello", tester.getApplication());
panel.add(c);
IStringResourceLoader loader = new ComponentStringResourceLoader();
assertEquals("Valid resourse string should be found", "Component string", loader.loadStringResource(c.getClass(), "component.string", Locale.getDefault(), null, null));
}
Aggregations