use of org.sonatype.goodies.httpfixture.server.jetty.behaviour.Content in project goodies by sonatype.
the class JettyServerProvider method addDefaultServices.
public void addDefaultServices() {
addServlet("/error/*", new ErrorServlet());
addBehaviour("/content/*", new Content());
addBehaviour("/stutter/*", new Stutter());
addBehaviour("/pause/*", new Pause(), new Content());
addBehaviour("/truncate/*", new Truncate());
addBehaviour("/timeout/*", new Pause());
addBehaviour("/redirect/*", new Redirect(), new Content());
}
use of org.sonatype.goodies.httpfixture.server.jetty.behaviour.Content in project goodies by sonatype.
the class JettyServerProviderIT method testBehaviour.
@Test
public void testBehaviour() throws Exception {
provider.addBehaviour("/behave/*", new Pause(550), new Content());
long begin = System.currentTimeMillis();
URL url = new URL("http://localhost:" + provider.getPort() + "/behave/baby");
URLConnection conn = url.openConnection();
InputStream in = conn.getInputStream();
BufferedReader r = new BufferedReader(new InputStreamReader(in));
String line = r.readLine();
long end = System.currentTimeMillis();
assertEquals("Received content was not correct.", "baby", line);
assertTrue("expected 500ms, real delta: " + (end - begin), end - begin >= 500);
}
Aggregations