@Test
public void testGetServicePublicKeyEntryServiceUnavailable() {

    final String domainName = "test1";
    final String serviceName = "service1";
    final String keyId = "0";
    ObjectStore saveStore = zms.dbService.store;
    zms.dbService.store = mockObjStore;
    ObjectStoreConnection mockConn = Mockito.mock(ObjectStoreConnection.class);
    Mockito.when(mockObjStore.getConnection(true, false)).thenReturn(mockConn);
    Mockito.when(mockConn.getPublicKeyEntry(domainName, serviceName, keyId, false))
            .thenThrow(new ResourceException(ResourceException.SERVICE_UNAVAILABLE));
    try {
        zms.dbService.getServicePublicKeyEntry(domainName, serviceName, keyId, false);
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), ResourceException.SERVICE_UNAVAILABLE);
    }
    zms.dbService.store = saveStore;
}