com.github.dreamhead.moco.internal.BaseServerRunner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moco-core Show documentation
Show all versions of moco-core Show documentation
Moco is an easy setup stub framework, mainly focusing on testing and integration.
package com.github.dreamhead.moco.internal;
import com.github.dreamhead.moco.ResponseSetting;
import com.github.dreamhead.moco.Runner;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
public abstract class BaseServerRunner, U extends BaseActualServer> extends Runner {
protected abstract BaseActualServer serverSetting();
protected abstract ChannelInitializer extends Channel> channelInitializer();
private final MocoServer server = new MocoServer();
@Override
public void start() {
BaseActualServer setting = serverSetting();
int port = this.server.start(setting.getPort().or(0), channelInitializer());
setting.setPort(port);
}
@Override
public void stop() {
server.stop();
}
}