use of org.apache.wicket.request.resource.ResourceReference.UrlAttributes in project wicket by apache.
the class PackageResourceReferenceTest method resourceResolution.
/**
*/
@Test
public void resourceResolution() {
for (Locale locale : locales) {
for (String style : styles) {
for (String variation : variations) {
ResourceReference reference = new PackageResourceReference(scope, "resource.txt", locale, style, variation);
UrlAttributes urlAttributes = reference.getUrlAttributes();
assertEquals(locale, urlAttributes.getLocale());
assertEquals(style, urlAttributes.getStyle());
assertEquals(variation, urlAttributes.getVariation());
ByteArrayResponse byteResponse = new ByteArrayResponse();
Attributes mockAttributes = new Attributes(tester.getRequestCycle().getRequest(), byteResponse);
reference.getResource().respond(mockAttributes);
String fileContent = new String(byteResponse.getBytes());
if (locale != null) {
assertTrue(fileContent.contains(locale.getLanguage()));
if (locale.getCountry() != null) {
assertTrue(fileContent.contains(locale.getCountry()));
}
}
if (style != null) {
assertTrue(fileContent.contains(style));
}
if (variation != null) {
assertTrue(fileContent.contains(variation));
}
}
}
}
}
use of org.apache.wicket.request.resource.ResourceReference.UrlAttributes in project wicket by apache.
the class PackageResourceReferenceTest method sessionAttributesRelevance.
/**
* Asserting if user did not set any locale or style, those from session get used if any
*/
@Test
public void sessionAttributesRelevance() {
for (Locale locale : new Locale[] { new Locale("en"), new Locale("en", "US") }) {
tester.getSession().setLocale(locale);
for (String style : styles) {
tester.getSession().setStyle(style);
for (String variation : variations) {
ResourceReference reference = new PackageResourceReference(scope, "resource.txt", null, null, variation);
UrlAttributes urlAttributes = reference.getUrlAttributes();
assertEquals(tester.getSession().getLocale(), urlAttributes.getLocale());
assertEquals(tester.getSession().getStyle(), urlAttributes.getStyle());
assertEquals(variation, urlAttributes.getVariation());
}
}
}
}
Aggregations