public void testSettings() throws Exception {
new WicketTester();
final StringBuffer sb = new StringBuffer(128);
HeaderContributor hc = JSLib.getHeaderContribution(VersionDescriptor
.exactVersion(Library.JQUERY, 1, 3, 1), CDN.GOOGLE);
HeaderResponse mockResponse = new HeaderResponse() {
@Override
protected Response getRealResponse() {
return new Response() {
@Override
public void write(CharSequence arg0) {
sb.append(arg0);
}
@Override
public OutputStream getOutputStream() {
// TODO Auto-generated method stub
return null;
}
};
}
};
hc.renderHead(mockResponse);
String scriptTag = sb.toString();
assertTrue(scriptTag.contains("google")); // must be in as selected
assertFalse(scriptTag.contains("resources/org.wicketstuff.jsl"));
sb.setLength(0);
// now set applicationwide setting to local only:
JSLib.setOverrideProviders(Application.get(), LocalProvider.DEFAULT);
// and retest
hc = JSLib.getHeaderContribution(VersionDescriptor.exactVersion(
Library.JQUERY, 1, 3, 1), CDN.GOOGLE);
hc.renderHead(mockResponse);
scriptTag = sb.toString();
assertFalse(scriptTag.contains("google"));
assertTrue(scriptTag.contains("resources/org.wicketstuff.jsl"));
}