@Test
public void testListPublicKeys() throws Exception {

    
    JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
    Mockito.when(mockResultSet.getInt(1)).thenReturn(5).thenReturn(7); // return domain/service id
    
    Mockito.when(mockResultSet.next())
        .thenReturn(true) // this one is for domain id
        .thenReturn(true) // this one is for service id
        .thenReturn(true)
        .thenReturn(true)
        .thenReturn(true)
        .thenReturn(false);
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_KEY_ID))
        .thenReturn("zms1.zone1")
        .thenReturn("zms2.zone1")
        .thenReturn("zms3.zone1");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_KEY_VALUE))
        .thenReturn("Value1")
        .thenReturn("Value2")
        .thenReturn("Value3");
    
    List<PublicKeyEntry> publicKeys = jdbcConn.listPublicKeys("my-domain", "service1");
    
    // data back is sorted
    
    assertEquals(3, publicKeys.size());
    assertEquals("zms1.zone1", publicKeys.get(0).getId());
    assertEquals("Value1", publicKeys.get(0).getKey());
    assertEquals("zms2.zone1", publicKeys.get(1).getId());
    assertEquals("Value2", publicKeys.get(1).getKey());
    assertEquals("zms3.zone1", publicKeys.get(2).getId());
    assertEquals("Value3", publicKeys.get(2).getKey());
    jdbcConn.close();
}