use of org.apache.wicket.resource.loader.IStringResourceLoader 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.IStringResourceLoader 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.IStringResourceLoader 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.IStringResourceLoader 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));
}
use of org.apache.wicket.resource.loader.IStringResourceLoader in project webanno by webanno.
the class WicketApplicationBase method initNestedStringResourceLoader.
protected void initNestedStringResourceLoader() {
List<IStringResourceLoader> loaders = new ArrayList<>(getResourceSettings().getStringResourceLoaders());
NestedStringResourceLoader nestedLoader = new NestedStringResourceLoader(loaders, Pattern.compile("#\\(([^ ]*?)\\)"));
getResourceSettings().getStringResourceLoaders().clear();
getResourceSettings().getStringResourceLoaders().add(nestedLoader);
}
Aggregations