use of org.apache.tomcat.unittest.TesterRequest in project tomcat by apache.
the class TestRequest method localeParsePerformance.
@Test
@Ignore("Used to check performance of different parsing approaches")
public void localeParsePerformance() throws Exception {
TesterRequest req = new TesterRequest();
req.addHeader("accept-encoding", "en-gb,en");
long start = System.nanoTime();
// Takes about 0.3s on a quad core 2.7Ghz 2013 MacBook
for (int i = 0; i < 10000000; i++) {
req.parseLocales();
req.localesParsed = false;
req.locales.clear();
}
long time = System.nanoTime() - start;
System.out.println(time);
}
use of org.apache.tomcat.unittest.TesterRequest in project tomcat by apache.
the class TestResponse method doTestEncodeURL.
private void doTestEncodeURL(String location, String expected) {
Request req = new TesterRequest(true);
req.setRequestedSessionId("1234");
req.setRequestedSessionURL(true);
Response resp = new Response();
resp.setRequest(req);
String result = resp.encodeURL(location);
Assert.assertEquals(expected, result);
}
use of org.apache.tomcat.unittest.TesterRequest in project tomcat by apache.
the class TestResponse method testBug53062o.
@Test
public void testBug53062o() throws Exception {
Request req = new TesterRequest();
Response resp = new Response();
resp.setRequest(req);
String result = resp.toAbsolute("./..#/../../");
Assert.assertEquals("http://localhost:8080/level1/#/../../", result);
}
use of org.apache.tomcat.unittest.TesterRequest in project tomcat by apache.
the class TestResponse method testBug53062h.
@Test
public void testBug53062h() throws Exception {
Request req = new TesterRequest();
Response resp = new Response();
resp.setRequest(req);
String result = resp.toAbsolute("bar.html?x=/../../");
Assert.assertEquals("http://localhost:8080/level1/level2/bar.html?x=/../../", result);
}
use of org.apache.tomcat.unittest.TesterRequest in project tomcat by apache.
the class TestResponse method testBug53062b.
@Test
public void testBug53062b() throws Exception {
Request req = new TesterRequest();
Response resp = new Response();
resp.setRequest(req);
String result = resp.toAbsolute(".");
Assert.assertEquals("http://localhost:8080/level1/level2/", result);
}
Aggregations