use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method test12.
/**
* <a href="https://issues.apache.org/jira/browse/WICKET-3567">WICKET-3567</a>
*/
@Test
public void test12() {
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("?0")));
assertEquals("./", r1.renderUrl(Url.parse("")));
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method renderFullUrlWithNoOpLeadingSegments.
/**
* https://issues.apache.org/jira/browse/WICKET-5774
*/
@Test
public void renderFullUrlWithNoOpLeadingSegments() {
UrlRenderer renderer = new UrlRenderer(new MockWebRequest(Url.parse("any/thing")));
String fullUrl = renderer.renderFullUrl(Url.parse("http://www.example.com:8888/./../one/two/three"));
assertEquals("http://www.example.com:8888/one/two/three", fullUrl);
fullUrl = renderer.renderFullUrl(Url.parse("http://www.example.com:8888/.././one/two/three"));
assertEquals("http://www.example.com:8888/one/two/three", fullUrl);
fullUrl = renderer.renderFullUrl(Url.parse("http://www.example.com:8888/one/.././two/three"));
assertEquals("http://www.example.com:8888/two/three", fullUrl);
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class WriteCallbackTest method writeStream.
/**
*/
@Test
public void writeStream() throws IOException {
WriteCallback callback = new WriteCallback() {
@Override
public void writeData(Attributes attributes) {
}
};
ByteArrayResponse response = new ByteArrayResponse();
Attributes attributes = new Attributes(new MockWebRequest(new Url()), response);
byte[] srcData = new byte[5000];
for (int i = 0; i < srcData.length; i++) {
srcData[i] = (byte) i;
}
InputStream in = new ByteArrayInputStream(srcData);
callback.writeStream(attributes, in);
assertTrue("Content not equal", Arrays.equals(response.getBytes(), srcData));
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method renderFullUrlWithAbsoluteArgument.
/**
* https://issues.apache.org/jira/browse/WICKET-4514
*/
@Test
public void renderFullUrlWithAbsoluteArgument() {
Url baseUrl = Url.parse("one/two/three");
baseUrl.setProtocol("http");
baseUrl.setHost("www.example.com");
baseUrl.setPort(8888);
UrlRenderer renderer = new UrlRenderer(new MockWebRequest(baseUrl));
// this is needed because MockWebRequest cuts data
renderer.setBaseUrl(baseUrl);
// url starting with slash is
String fullUrl = renderer.renderFullUrl(Url.parse("/four"));
// considered absolute
assertEquals("http://www.example.com:8888/four", fullUrl);
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method rendersRelativeUrl.
@Test
public void rendersRelativeUrl() {
Url contextRelativeUrl = new Url();
contextRelativeUrl.setProtocol("http");
contextRelativeUrl.setHost("localshot");
contextRelativeUrl.setPort(8080);
contextRelativeUrl.setContextRelative(true);
contextRelativeUrl.getSegments().addAll(asList("", ""));
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(contextRelativeUrl));
assertThat(r1.renderRelativeUrl(Url.parse("foo")), is("../foo"));
}
Aggregations