use of com.github.dreamhead.moco.Runnable 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, new Runnable() {
@Override
public void run() throws Exception {
assertThat(mergedServer.port(), is(12306));
}
});
}
use of com.github.dreamhead.moco.Runnable in project moco by dreamhead.
the class ActualHttpServerTest method should_config_handler_correctly_while_merging.
@Test
public void should_config_handler_correctly_while_merging() throws Exception {
httpServer = httpServer(12306, fileRoot("src/test/resources"));
httpServer.response(file("foo.response"));
HttpServer mergedServer = ((ActualHttpServer) anotherServer).mergeServer((ActualHttpServer) httpServer);
running(mergedServer, new Runnable() {
@Override
public void run() throws IOException {
assertThat(helper.get(root()), is("foo.response"));
}
});
}
use of com.github.dreamhead.moco.Runnable in project moco by dreamhead.
the class ActualHttpServerTest method should_merge_https_server_into_http_server.
@Test
public void should_merge_https_server_into_http_server() throws Exception {
httpServer = httpsServer(12306, DEFAULT_CERTIFICATE, context("/foo"));
httpServer.response("foo");
HttpServer mergedServer = ((ActualHttpServer) anotherServer).mergeServer((ActualHttpServer) httpServer);
running(mergedServer, new Runnable() {
@Override
public void run() throws Exception {
assertThat(helper.get(remoteHttpsUrl("/foo/anything")), is("foo"));
}
});
}
use of com.github.dreamhead.moco.Runnable in project moco by dreamhead.
the class ActualSocketServerTest method should_merge_socket_servers_with_first_port.
@Test
public void should_merge_socket_servers_with_first_port() throws Exception {
SocketServer server = socketServer(12306);
SocketServer secondServer = socketServer();
final SocketServer newServer = ((ActualSocketServer) server).mergeServer((ActualSocketServer) secondServer);
running(newServer, new Runnable() {
@Override
public void run() throws Exception {
assertThat(newServer.port(), is(12306));
}
});
}
use of com.github.dreamhead.moco.Runnable in project moco by dreamhead.
the class ActualSocketServerTest method should_merge_socket_servers.
@Test
public void should_merge_socket_servers() throws Exception {
SocketServer server = socketServer(12306);
SocketServer secondServer = socketServer(12306);
server.request(by("foo")).response(line("bar"));
secondServer.request(by("foo1")).response(line("bar1"));
SocketServer newServer = ((ActualSocketServer) server).mergeServer((ActualSocketServer) secondServer);
running(newServer, new Runnable() {
@Override
public void run() throws Exception {
helper.connect();
assertThat(helper.send("foo"), is("bar"));
assertThat(helper.send("foo1"), is("bar1"));
helper.close();
}
});
}
Aggregations