use of com.github.dreamhead.moco.SocketServer in project moco by dreamhead.
the class SocketServerParser method createServer.
@Override
protected SocketServer createServer(final ImmutableList<SessionSetting> sessionSettings, final Optional<Integer> port, final MocoConfig... configs) {
SocketServer server = ActualSocketServer.createLogServer(port);
for (SessionSetting session : sessionSettings) {
logger.debug("Parse session: {}", session);
session.bindTo(server);
}
return server;
}
use of com.github.dreamhead.moco.SocketServer 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.SocketServer 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();
}
});
}
use of com.github.dreamhead.moco.SocketServer in project moco by dreamhead.
the class ActualSocketServerTest method should_merge_socket_servers_without_ports_for_both_server.
@Test
public void should_merge_socket_servers_without_ports_for_both_server() throws Exception {
SocketServer server = socketServer();
SocketServer secondServer = socketServer();
final ActualSocketServer newServer = ((ActualSocketServer) server).mergeServer((ActualSocketServer) secondServer);
assertThat(newServer.getPort().isPresent(), is(false));
}
use of com.github.dreamhead.moco.SocketServer in project moco by dreamhead.
the class ActualSocketServerTest method should_merge_socket_servers_with_second_port.
@Test
public void should_merge_socket_servers_with_second_port() throws Exception {
SocketServer server = socketServer();
SocketServer secondServer = socketServer(12307);
final SocketServer newServer = ((ActualSocketServer) server).mergeServer((ActualSocketServer) secondServer);
running(newServer, new Runnable() {
@Override
public void run() throws Exception {
assertThat(newServer.port(), is(12307));
}
});
}
Aggregations