@Test
  public void testConnectionRefreshOnException() throws Exception {

    //1. Add account to db
    Account a1 = new AccountBuilder((short) 101, "a1", Account.AccountStatus.ACTIVE).build();
    mySqlAccountService.updateAccounts(Collections.singletonList(a1));

    //2. query db - should be successful
    assertEquals("Mismatch in account read from db", a1, mySqlAccountStore.getNewAccounts(0).iterator().next());

    //3. close db connection manually
    mySqlAccountStore.getMySqlDataAccessor().getDatabaseConnection(true).close();

    //4. query db - should establish new connection and get results.
    assertEquals("Mismatch in account read from db", a1, mySqlAccountStore.getNewAccounts(0).iterator().next());
  }
Tests connection refresh for all non transient sql exceptions
ambry-account/src/integration-test/java/com/github/ambry/account/MySqlAccountServiceIntegrationTest.java