Search in sources :

Example 11 with BaseURLSource

use of org.apache.tapestry5.http.services.BaseURLSource 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)

Example 12 with BaseURLSource

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

the class LinkImplTest method force_insecure_URI_from_secure_link.

@Test
public void force_insecure_URI_from_secure_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.SECURE, response, null, baseURLSource);
    assertEquals(link.toAbsoluteURI(false), 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 13 with BaseURLSource

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

the class BaseURLSourceImplTest method getBaseURLWithContributedNonStandardSecurePort.

@Test
public void getBaseURLWithContributedNonStandardSecurePort() {
    replay();
    BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "localhost", 80, 8443);
    assertEquals(baseURLSource.getBaseURL(true), "https://localhost:8443");
    verify();
}
Also used : BaseURLSourceImpl(org.apache.tapestry5.http.internal.services.BaseURLSourceImpl) BaseURLSource(org.apache.tapestry5.http.services.BaseURLSource) Test(org.testng.annotations.Test)

Example 14 with BaseURLSource

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

the class BaseURLSourceImplTest method secure_url_without_configured_hostports.

@Test
public void secure_url_without_configured_hostports() {
    expect(request.isSecure()).andReturn(false).once();
    replay();
    BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "localhost", 0, 0);
    // In other words, in the absense of any other configuration, it assumes that you have SSL on port 443
    // and there's no need for that in the URL, since that's what the browser is going to do.
    assertEquals(baseURLSource.getBaseURL(true), "https://localhost");
    verify();
}
Also used : BaseURLSourceImpl(org.apache.tapestry5.http.internal.services.BaseURLSourceImpl) BaseURLSource(org.apache.tapestry5.http.services.BaseURLSource) Test(org.testng.annotations.Test)

Example 15 with BaseURLSource

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

the class BaseURLSourceImplTest method server_name_from_request_object.

@Test
public void server_name_from_request_object() {
    expect(request.getServerName()).andReturn("localhost").once();
    expect(request.getServerPort()).andReturn(80).once();
    expect(request.isSecure()).andReturn(false);
    replay();
    BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "", 0, 0);
    assertEquals(baseURLSource.getBaseURL(false), "http://localhost");
    verify();
}
Also used : BaseURLSourceImpl(org.apache.tapestry5.http.internal.services.BaseURLSourceImpl) BaseURLSource(org.apache.tapestry5.http.services.BaseURLSource) Test(org.testng.annotations.Test)

Aggregations

BaseURLSource (org.apache.tapestry5.http.services.BaseURLSource)13 Test (org.testng.annotations.Test)12 Link (org.apache.tapestry5.http.Link)7 BaseURLSourceImpl (org.apache.tapestry5.http.internal.services.BaseURLSourceImpl)7 Response (org.apache.tapestry5.http.services.Response)5 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)1