Search in sources :

Example 1 with PackageResource

use of org.apache.wicket.request.resource.PackageResource in project wicket by apache.

the class PackageResourceTest method textFileWithEncoding.

@Test
public void textFileWithEncoding() {
    final String encoding = "Klingon-8859-42";
    final PackageResource resource = new PackageResource(PackageResourceTest.class, "packaged1.txt", null, null, null) {

        private static final long serialVersionUID = 1L;
    };
    resource.setTextEncoding(encoding);
    tester.startResource(resource);
    final String contentType = tester.getLastResponse().getContentType();
    assertEquals("text/plain; charset=" + encoding, contentType);
}
Also used : JavaScriptPackageResource(org.apache.wicket.request.resource.JavaScriptPackageResource) PackageResource(org.apache.wicket.request.resource.PackageResource) Test(org.junit.Test)

Example 2 with PackageResource

use of org.apache.wicket.request.resource.PackageResource in project wicket by apache.

the class PackageResourceTest method contentType.

/**
 * Test that {@link PackageResource} writes its Content-Type header in the response
 *
 * https://issues.apache.org/jira/browse/WICKET-4119
 */
@Test
public void contentType() {
    PackageResource textResource = new PackageResource(PackageResourceTest.class, "packaged1.txt", null, null, null) {

        private static final long serialVersionUID = 1L;
    };
    tester.startResource(textResource);
    assertEquals("text/plain", tester.getLastResponse().getContentType());
    PackageResource jsResource = new PackageResource(PackageResourceTest.class, "packaged3.js", null, null, null) {

        private static final long serialVersionUID = 1L;
    };
    tester.startResource(jsResource);
    assertEquals("text/javascript", tester.getLastResponse().getContentType());
}
Also used : JavaScriptPackageResource(org.apache.wicket.request.resource.JavaScriptPackageResource) PackageResource(org.apache.wicket.request.resource.PackageResource) Test(org.junit.Test)

Aggregations

JavaScriptPackageResource (org.apache.wicket.request.resource.JavaScriptPackageResource)2 PackageResource (org.apache.wicket.request.resource.PackageResource)2 Test (org.junit.Test)2