All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dreamhead.moco.internal.BaseServerRunner Maven / Gradle / Ivy

Go to download

Moco is an easy setup stub framework, mainly focusing on testing and integration.

There is a newer version: 1.5.0
Show newest version
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 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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy