package com.tax.token.job;

import lombok.extern.slf4j.Slf4j;
import org.h2.tools.Server;
import org.junit.AfterClass;
import org.junit.BeforeClass;

import java.sql.SQLException;

@Slf4j
public class H2Server {

    private static final int SERVER_PORT = 9092;

    @BeforeClass
    public static void beforeClass() throws SQLException {
        Server.createTcpServer("-tcpPort", String.valueOf(SERVER_PORT), "-tcpPassword", "sa", "-ifNotExists", "-tcpAllowOthers").start();
        log.info("start h2 server success");
    }

    @AfterClass
    public static void afterClass() throws SQLException {
        Server.shutdownTcpServer("tcp://localhost:" + SERVER_PORT, "sa", true, true);
        log.info("shutdown h2 server success");
    }
}
