use of com.github.dreamhead.moco.HttpServer in project moco by dreamhead.
the class ActualHttpServerTest method should_merge_http_server_with_any_handler_one_side.
@Test
public void should_merge_http_server_with_any_handler_one_side() throws Exception {
HttpServer mergedServer = ((ActualHttpServer) anotherServer).mergeServer((ActualHttpServer) httpServer);
running(mergedServer, () -> assertThat(helper.get(remoteUrl("/foo/anything")), is("foo")));
}
use of com.github.dreamhead.moco.HttpServer in project moco by dreamhead.
the class ActualHttpServerTest method should_merge_http_server_with_same_port.
@Test
public void should_merge_http_server_with_same_port() throws Exception {
httpServer = httpServer(12306, context("/foo"));
anotherServer = httpServer(12306, context("/bar"));
final HttpServer mergedServer = ((ActualHttpServer) anotherServer).mergeServer((ActualHttpServer) httpServer);
running(mergedServer, () -> assertThat(mergedServer.port(), is(12306)));
}
use of com.github.dreamhead.moco.HttpServer in project moco by dreamhead.
the class ActualHttpServerTest method should_config_handler_correctly_other_side_while_merging.
@Test
public void should_config_handler_correctly_other_side_while_merging() throws Exception {
httpServer = httpServer(12306, fileRoot("src/test/resources"));
httpServer.response(file("foo.response"));
HttpServer mergedServer = ((ActualHttpServer) httpServer).mergeServer((ActualHttpServer) anotherServer);
running(mergedServer, () -> assertThat(helper.get(root()), is("foo.response")));
}
use of com.github.dreamhead.moco.HttpServer in project moco by dreamhead.
the class ActualHttpServerTest method should_merge_two_https_servers.
@Test
public void should_merge_two_https_servers() throws Exception {
httpServer = httpsServer(12306, DEFAULT_CERTIFICATE, context("/foo"));
httpServer.response("foo");
anotherServer = httpsServer(12306, DEFAULT_CERTIFICATE, context("/bar"));
anotherServer.request(by(uri("/bar"))).response("bar");
HttpServer mergedServer = ((ActualHttpServer) anotherServer).mergeServer((ActualHttpServer) httpServer);
running(mergedServer, () -> {
assertThat(helper.get(remoteHttpsUrl("/foo/anything")), is("foo"));
assertThat(helper.get(remoteHttpsUrl("/bar/bar")), is("bar"));
});
}
use of com.github.dreamhead.moco.HttpServer in project moco by dreamhead.
the class ActualHttpServerTest method should_merge_http_server_without_port_for_first_server.
@Test
public void should_merge_http_server_without_port_for_first_server() throws Exception {
httpServer = httpServer(12306, context("/foo"));
anotherServer = httpServer(context("/bar"));
final HttpServer mergedServer = ((ActualHttpServer) anotherServer).mergeServer((ActualHttpServer) httpServer);
running(mergedServer, () -> assertThat(mergedServer.port(), is(12306)));
}
Aggregations