Search in sources :

Example 76 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class LinkImplTest method force_secure_URI_from_insecure_link.

@Test
public void force_secure_URI_from_insecure_link() {
    Response response = mockResponse();
    BaseURLSource baseURLSource = mockBaseURLSource();
    train_getBaseURL(baseURLSource, true, SECURE_BASE_URL);
    train_encodeURL(response, SECURE_BASE_URL + BASE_PATH, ENCODED);
    replay();
    Link link = new LinkImpl(BASE_PATH, false, LinkSecurity.INSECURE, response, null, baseURLSource);
    assertEquals(link.toAbsoluteURI(true), ENCODED);
    verify();
}
Also used : Response(org.apache.tapestry5.http.services.Response) BaseURLSource(org.apache.tapestry5.http.services.BaseURLSource) Link(org.apache.tapestry5.http.Link) Test(org.testng.annotations.Test)

Example 77 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class LinkImplTest method url_with_anchor.

@Test
public void url_with_anchor() {
    Response response = mockResponse();
    String url = "/foo/bar";
    train_encodeURL(response, url, ENCODED);
    replay();
    Link link = new LinkImpl(url, false, LinkSecurity.INSECURE, response, null, null);
    link.setAnchor("wilma");
    assertSame(link.getAnchor(), "wilma");
    assertEquals(link.toURI(), ENCODED + "#" + "wilma");
    verify();
}
Also used : Response(org.apache.tapestry5.http.services.Response) Link(org.apache.tapestry5.http.Link) Test(org.testng.annotations.Test)

Example 78 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class LinkImplTest method simple_redirect.

@Test
public void simple_redirect() {
    Response response = mockResponse();
    String URI = "/base/context/" + RAW_PATH;
    train_encodeRedirectURL(response, URI, ENCODED);
    replay();
    Link link = new LinkImpl(URI, false, LinkSecurity.INSECURE, response, null, null);
    assertEquals(link.toRedirectURI(), ENCODED);
    verify();
}
Also used : Response(org.apache.tapestry5.http.services.Response) Link(org.apache.tapestry5.http.Link) Test(org.testng.annotations.Test)

Example 79 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class LinkImplTest method remove_parameter.

@Test
public void remove_parameter() {
    Link link = new LinkImpl("/baseURI", false, null, null, null, null);
    link.addParameter("fred", "flintstone");
    link.addParameter("barney", "rubble");
    link.removeParameter("fred");
    assertNull(link.getParameterValue("fred"));
    assertListsEquals(link.getParameterNames(), "barney");
}
Also used : Link(org.apache.tapestry5.http.Link) Test(org.testng.annotations.Test)

Example 80 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class LinkImplTest method absolute_URI_for_default_insecure_link.

@Test
public void absolute_URI_for_default_insecure_link() {
    Response response = mockResponse();
    BaseURLSource baseURLSource = mockBaseURLSource();
    train_getBaseURL(baseURLSource, false, INSECURE_BASE_URL);
    train_encodeURL(response, INSECURE_BASE_URL + BASE_PATH, ENCODED);
    replay();
    Link link = new LinkImpl(BASE_PATH, false, LinkSecurity.INSECURE, response, null, baseURLSource);
    assertEquals(link.toAbsoluteURI(), ENCODED);
    verify();
}
Also used : Response(org.apache.tapestry5.http.services.Response) BaseURLSource(org.apache.tapestry5.http.services.BaseURLSource) Link(org.apache.tapestry5.http.Link) Test(org.testng.annotations.Test)

Aggregations

Link (org.apache.tapestry5.http.Link)66 Test (org.testng.annotations.Test)37 Response (org.apache.tapestry5.http.services.Response)19 MarkupWriter (org.apache.tapestry5.MarkupWriter)10 JSONObject (org.apache.tapestry5.json.JSONObject)10 ComponentEventLinkEncoder (org.apache.tapestry5.services.ComponentEventLinkEncoder)10 Request (org.apache.tapestry5.http.services.Request)8 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)8 Element (org.apache.tapestry5.dom.Element)7 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)7 Link (org.apache.tapestry5.Link)6 LinkCreationListener2 (org.apache.tapestry5.services.LinkCreationListener2)6 EventContext (org.apache.tapestry5.EventContext)5 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)5 IOException (java.io.IOException)4 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)4 BaseURLSource (org.apache.tapestry5.http.services.BaseURLSource)4 Page (org.apache.tapestry5.internal.structure.Page)4 List (java.util.List)3 ComponentResources (org.apache.tapestry5.ComponentResources)3