public void testSharedGroupNamesStaleCacheTestAfterModificationUnsharedToOtherGroups() throws Exception
    {
        final DefaultGroupProvider provider = new DefaultGroupProvider();
        final Group group = provider.createGroup("Test Group A");
        provider.createGroup("Test Group B");

        // Execute system under test;
        provider.getSharedGroupNames(); // populate cache.
        group.shareWithUsersInGroups(Collections.singletonList("Test Group B"), "Users in group A");
        final Collection<String> result = provider.getSharedGroupNames();

        // Verify result.
        assertEquals(1, result.size());
        assertTrue(result.contains("Test Group A"));
    }
Verifies that a {@link AbstractGroupProvider#getSharedGroupNames()} does not return a stale cache entry after a
previously obtained group has reconfigured to be shared with a different set of users.
xmppserver/src/test/java/org/jivesoftware/openfire/group/AbstractGroupProviderTest.java