@Test public void onFirst() { statsLogger.noClassCacheAvailable(); verify(log, times(1)).isWarnEnabled(); verify(log, times(1)).warn(anyString()); verifyNoMoreInteractions(log); }
@Test public void onSecondUntilInfinity() { // log should be executed onces statsLogger.noClassCacheAvailable(); verify(log, times(1)).isWarnEnabled(); verify(log, times(1)).warn(anyString()); // log shouldn't be executed twice statsLogger.noClassCacheAvailable(); verify(log, times(2)).isWarnEnabled(); verify(log, times(1)).warn(anyString()); verifyNoMoreInteractions(log); } }
@Test public void noClassCacheWarningShouldBeLoggedOnce() throws Exception { when(connection.isConnected()).thenReturn(true); BusinessException businessException = new BusinessException(AgentManagementErrorCodeEnum.AGENT_DOES_NOT_EXIST); doThrow(businessException).when(connection).analyzeJmxAttributes(anyLong(), Matchers.anyList()); jmxSensor.mbeanServerAdded(mBeanServer); verify(agentStatisticsLogger, times(1)).noClassCacheAvailable(); } }
BusinessException businessException = (BusinessException) executionException.getCause(); if (AgentManagementErrorCodeEnum.AGENT_DOES_NOT_EXIST.equals(businessException.getErrorCode())) { agentStatisticsLogger.noClassCacheAvailable(); return null;
agentStatisticsLogger.noClassCacheAvailable(); } else { log.warn("Error registering JMX attributes on the server.", e);
verify(agentStatisticsLogger, times(1)).noClassCacheAvailable();