public class ClientServerFixture implements MicroKernelFixture {
@Override
public void setUpCluster(MicroKernel[] cluster) {
MicroKernel mk = new MicroKernelImpl();
final Server server = new Server(mk);
try {
server.start();
} catch (IOException e) {
throw new IllegalArgumentException(e.getMessage());
}
InetSocketAddress address = server.getAddress();
cluster[0] = new Client(address) {
@Override
public synchronized void dispose() {
super.dispose();
server.stop();
}
};
for (int i = 1; i < cluster.length; i++) {
cluster[i] = new Client(address);
}