Overriding Properties While Testing Wicket

When you are testing a component that gets its properties from a parent (typically an application), the Wicket test will blow up because it won’t be able to find the string. this is because the test has no knowledge of the properties file.

In order to resolve these values in the test, add this in your test case setup()….

Application.get().getResourceSettings().addStringResourceLoader(new IStringResourceLoader() {
	@Override
	public String loadStringResource(Class<?> clazz, String key, Locale locale, String style) {
		return key;
	}

	@Override
	public String loadStringResource(Component component, String key) {
		return key;
	}
});

Note: You will obviously not get the proper value back from the property file, rather just the key. This should be good enough.

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply