@AfterClass
  public static void afterClass() throws Exception {
    if (localConnection != null) {
      localConnection.close();
      localConnection = null;
    }

    if (start != null) {
      start.stop();
    }
  }
  @BeforeClass
  public static void beforeClass() throws Exception {
    localConnection = CalciteAssert.hr().connect();

    // Make sure we pick an ephemeral port for the server
    start =
        Main.start(
            new String[] {Factory.class.getName()},
            0,
            new HandlerFactory() {
              public AvaticaJsonHandler createHandler(Service service) {
                return new AvaticaJsonHandler(service);
              }
            });
    final int port = start.getPort();
    remoteConnection =
        DriverManager.getConnection("jdbc:avatica:remote:url=http://localhost:" + port);
  }