@Test public void test002AssetNotNullWithNonNullObject() { AbstractCommandsSupport.assertNotNull(new Object(), ""); }
protected void logInfo(final String message) { logInfo(message, null); }
protected DistributedMember getMember(final Cache cache, final String memberName) { for (final DistributedMember member : getMembers(cache)) { if (memberName.equalsIgnoreCase(member.getName()) || memberName.equalsIgnoreCase(member.getId())) { return member; } } throw new MemberNotFoundException(CliStrings.format(CliStrings.MEMBER_NOT_FOUND_ERROR_MESSAGE, memberName)); }
protected boolean isLogging() { return (getGfsh() != null); }
@Test public void test009GetMemberWithMatchingMemberNameCaseInsensitive() { final Cache mockCache = mockContext.mock(Cache.class, "Cache"); 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 AbstractCommandsSupport commands = createAbstractCommandsSupport(mockCache); assertSame(mockMemberSelf, commands.getMember(mockCache, "self")); }
@Test public void test000AssertArgumentIsLegal() { AbstractCommandsSupport.assertArgument(true, ""); }
@Test public void test004AssertStateIsValid() { AbstractCommandsSupport.assertState(true, ""); }
protected void logSevere(final String message) { logSevere(message, null); }
@SuppressWarnings("deprecated") protected DistributedMember getMember(final Cache cache, final String memberName) { for (final DistributedMember member : getMembers(cache)) { if (memberName.equalsIgnoreCase(member.getName()) || memberName.equalsIgnoreCase(member.getId())) { return member; } } throw new MemberNotFoundException(CliStrings.format(CliStrings.MEMBER_NOT_FOUND_ERROR_MESSAGE, memberName)); }
protected boolean isLogging() { return (getGfsh() != null); }
@Test public void test007GetMemberWithMatchingMemberId() { final Cache mockCache = mockContext.mock(Cache.class, "Cache"); 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 AbstractCommandsSupport commands = createAbstractCommandsSupport(mockCache); assertSame(mockMemberTwo, commands.getMember(mockCache, "2")); }
@Test(expected = IllegalArgumentException.class) public void test001AssertArgumentIsIllegal() { try { AbstractCommandsSupport.assertArgument(false, "The actual argument is %1$s!", "illegal"); } catch (IllegalArgumentException expected) { assertEquals("The actual argument is illegal!", expected.getMessage()); throw expected; } }
@Test(expected = IllegalStateException.class) public void test005AssertStateIsInvalid() { try { AbstractCommandsSupport.assertState(false, "The actual state is %1$s!", "invalid"); } catch (IllegalStateException expected) { assertEquals("The actual state is invalid!", expected.getMessage()); throw expected; } }
protected void logSevere(final Throwable cause) { logSevere(cause.getMessage(), cause); }
@Test public void test012GetMembersContainsOnlySelf() { final Cache mockCache = mockContext.mock(Cache.class, "Cache"); final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem"); final DistributedMember mockMemberSelf = createMockMember("S", "Self"); mockContext.checking(new Expectations() {{ oneOf(mockCache).getMembers(); will(returnValue(Collections.emptySet())); oneOf(mockCache).getDistributedSystem(); will(returnValue(mockDistributedSystem)); oneOf(mockDistributedSystem).getDistributedMember(); will(returnValue(mockMemberSelf)); }}); final AbstractCommandsSupport commands = createAbstractCommandsSupport(mockCache); final Set<DistributedMember> expectedMembers = CollectionUtils.asSet(mockMemberSelf); final Set<DistributedMember> actualMembers = commands.getMembers(mockCache); assertNotNull(actualMembers); assertEquals(expectedMembers.size(), actualMembers.size()); assertTrue(actualMembers.containsAll(expectedMembers)); }
@Test public void test008GetMemberWithMatchingMemberName() { final Cache mockCache = mockContext.mock(Cache.class, "Cache"); 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 AbstractCommandsSupport commands = createAbstractCommandsSupport(mockCache); assertSame(mockMemberOne, commands.getMember(mockCache, "One")); }
@Test(expected = NullPointerException.class) public void test003AssertNotNullWithNullObject() { try { AbstractCommandsSupport.assertNotNull(null, "This is an %1$s message!", "expected"); } catch (NullPointerException expected) { assertEquals("This is an expected message!", expected.getMessage()); throw expected; } }