Search in sources :

Example 11 with ResourceReferenceRequestHandler

use of org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler in project wicket by apache.

the class BasicResourceReferenceMapperTest method decode1.

/**
 */
@Test
public void decode1() {
    Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference1");
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    assertThat(handler, instanceOf(ResourceReferenceRequestHandler.class));
    ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler) handler;
    assertEquals(resource1, h.getResource());
    assertEquals(0, h.getPageParameters().getIndexedCount());
    assertEquals(0, h.getPageParameters().getNamedKeys().size());
}
Also used : ResourceReferenceRequestHandler(org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler) IRequestHandler(org.apache.wicket.request.IRequestHandler) ResourceUrl(org.apache.wicket.request.resource.caching.ResourceUrl) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 12 with ResourceReferenceRequestHandler

use of org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler in project wicket by apache.

the class BasicResourceReferenceMapperTest method encode1.

/**
 */
@Test
public void encode1() {
    ResourceReferenceRequestHandler handler = new ResourceReferenceRequestHandler(reference1, null);
    Url url = encoder.mapHandler(handler);
    assertEquals("wicket/resource/" + CLASS_NAME + "/reference1", url.toString());
}
Also used : ResourceReferenceRequestHandler(org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler) ResourceUrl(org.apache.wicket.request.resource.caching.ResourceUrl) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 13 with ResourceReferenceRequestHandler

use of org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler in project wicket by apache.

the class BasicResourceReferenceMapperTest method encode6.

/**
 */
@Test
public void encode6() {
    PageParameters parameters = new PageParameters();
    parameters.set(0, "X");
    parameters.add("p1", "v1", INamedParameters.Type.QUERY_STRING);
    parameters.add("p2", "v2", INamedParameters.Type.QUERY_STRING);
    ResourceReferenceRequestHandler handler = new ResourceReferenceRequestHandler(reference3, parameters);
    Url url = encoder.mapHandler(handler);
    assertEquals("wicket/resource/" + CLASS_NAME + "/reference3?-style&p1=v1&p2=v2", url.toString());
}
Also used : ResourceReferenceRequestHandler(org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) ResourceUrl(org.apache.wicket.request.resource.caching.ResourceUrl) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 14 with ResourceReferenceRequestHandler

use of org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler in project wicket by apache.

the class BasicResourceReferenceMapperTest method decode2.

/**
 */
@Test
public void decode2() {
    Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference1?p1=v1&p2=v2");
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    assertThat(handler, instanceOf(ResourceReferenceRequestHandler.class));
    ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler) handler;
    assertEquals(resource1, h.getResource());
    assertEquals(null, h.getLocale());
    assertEquals(null, h.getStyle());
    assertEquals(null, h.getVariation());
    assertEquals(0, h.getPageParameters().getIndexedCount());
    assertEquals("v1", h.getPageParameters().get("p1").toString());
    assertEquals("v2", h.getPageParameters().get("p2").toString());
}
Also used : ResourceReferenceRequestHandler(org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler) IRequestHandler(org.apache.wicket.request.IRequestHandler) ResourceUrl(org.apache.wicket.request.resource.caching.ResourceUrl) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 15 with ResourceReferenceRequestHandler

use of org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler in project wicket by apache.

the class BasicResourceReferenceMapperTest method decode4.

/**
 */
@Test
public void decode4() {
    Url url = Url.parse("wicket/resource/" + CLASS_NAME + "/reference2/name2?en_EN&p1=v1&p2=v2");
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    assertThat(handler, instanceOf(ResourceReferenceRequestHandler.class));
    ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler) handler;
    assertEquals(resource2, h.getResource());
    assertEquals(new Locale("en", "en"), h.getLocale());
    assertEquals(null, h.getStyle());
    assertEquals(null, h.getVariation());
    assertEquals("v1", h.getPageParameters().get("p1").toString());
    assertEquals("v2", h.getPageParameters().get("p2").toString());
}
Also used : Locale(java.util.Locale) ResourceReferenceRequestHandler(org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler) IRequestHandler(org.apache.wicket.request.IRequestHandler) ResourceUrl(org.apache.wicket.request.resource.caching.ResourceUrl) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Aggregations

ResourceReferenceRequestHandler (org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler)41 Url (org.apache.wicket.request.Url)33 Test (org.junit.Test)31 ResourceUrl (org.apache.wicket.request.resource.caching.ResourceUrl)26 IRequestHandler (org.apache.wicket.request.IRequestHandler)20 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)9 PackageResourceReference (org.apache.wicket.request.resource.PackageResourceReference)6 ResourceReference (org.apache.wicket.request.resource.ResourceReference)6 Request (org.apache.wicket.request.Request)5 Locale (java.util.Locale)3 IResource (org.apache.wicket.request.resource.IResource)3 IStaticCacheableResource (org.apache.wicket.request.resource.caching.IStaticCacheableResource)3 ContextRelativeResource (org.apache.wicket.request.resource.ContextRelativeResource)2 MetaInfStaticResourceReference (org.apache.wicket.request.resource.MetaInfStaticResourceReference)2 UrlResourceReference (org.apache.wicket.request.resource.UrlResourceReference)2 ResourceBundleReference (org.apache.wicket.resource.bundles.ResourceBundleReference)2 JSONObject (com.github.openjson.JSONObject)1 StringTokenizer (java.util.StringTokenizer)1 Conversation (javax.enterprise.context.Conversation)1 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)1