Search in sources :

Example 1 with MemberNotFoundException

use of org.apache.geode.management.internal.cli.util.MemberNotFoundException in project geode by apache.

the class DiskStoreCommandsJUnitTest method testGetDiskStoreDescriptionThrowsMemberNotFoundException.

@Test(expected = MemberNotFoundException.class)
public void testGetDiskStoreDescriptionThrowsMemberNotFoundException() {
    final String diskStoreName = "mockDiskStore";
    final String memberId = "mockMember";
    final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
    final DistributedMember mockMember = mockContext.mock(DistributedMember.class, "DistributedMember");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockMember).getName();
            will(returnValue(null));
            oneOf(mockMember).getId();
            will(returnValue("testMember"));
        }
    });
    final DiskStoreCommands commands = createDiskStoreCommands(mockCache, mockMember, null);
    try {
        commands.getDiskStoreDescription(memberId, diskStoreName);
    } catch (MemberNotFoundException expected) {
        assertEquals(CliStrings.format(CliStrings.MEMBER_NOT_FOUND_ERROR_MESSAGE, memberId), expected.getMessage());
        throw expected;
    }
}
Also used : Expectations(org.jmock.Expectations) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) MemberNotFoundException(org.apache.geode.management.internal.cli.util.MemberNotFoundException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 2 with MemberNotFoundException

use of org.apache.geode.management.internal.cli.util.MemberNotFoundException in project geode by apache.

the class GfshCommandJUnitTest method testGetMemberThrowsMemberNotFoundException.

@Test(expected = MemberNotFoundException.class)
public void testGetMemberThrowsMemberNotFoundException() {
    final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
    final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem");
    final DistributedMember mockMemberSelf = createMockMember("S", "Self");
    final DistributedMember mockMemberOne = createMockMember("1", "One");
    final DistributedMember mockMemberTwo = createMockMember("2", "Two");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockCache).getMembers();
            will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo)));
            oneOf(mockCache).getDistributedSystem();
            will(returnValue(mockDistributedSystem));
            oneOf(mockDistributedSystem).getDistributedMember();
            will(returnValue(mockMemberSelf));
        }
    });
    final GfshCommand commands = createAbstractCommandsSupport(mockCache);
    try {
        commands.getMember(mockCache, "zero");
    } catch (MemberNotFoundException expected) {
        assertEquals(CliStrings.format(CliStrings.MEMBER_NOT_FOUND_ERROR_MESSAGE, "zero"), expected.getMessage());
        throw expected;
    }
}
Also used : Expectations(org.jmock.Expectations) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) DistributedSystem(org.apache.geode.distributed.DistributedSystem) MemberNotFoundException(org.apache.geode.management.internal.cli.util.MemberNotFoundException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

DistributedMember (org.apache.geode.distributed.DistributedMember)2 InternalCache (org.apache.geode.internal.cache.InternalCache)2 MemberNotFoundException (org.apache.geode.management.internal.cli.util.MemberNotFoundException)2 UnitTest (org.apache.geode.test.junit.categories.UnitTest)2 Expectations (org.jmock.Expectations)2 Test (org.junit.Test)2 DistributedSystem (org.apache.geode.distributed.DistributedSystem)1