List of usage examples for org.springframework.data.gemfire.config.support DefinedIndexesApplicationListener onApplicationEvent
@Override @SuppressWarnings("all") public void onApplicationEvent(ContextRefreshedEvent event)
From source file:org.springframework.data.gemfire.config.support.DefinedIndexesApplicationListenerUnitTests.java
@Test public void createDefinedIndexesThrowingAnExceptionIsLogged() throws Exception { when(mockApplicationContext.containsBean(eq(QUERY_SERVICE_BEAN_NAME))).thenReturn(true); when(mockApplicationContext.getBean(eq(QUERY_SERVICE_BEAN_NAME), eq(QueryService.class))) .thenReturn(mockQueryService); when(mockQueryService.createDefinedIndexes()) .thenThrow(newMultiIndexCreationException("TestKey", new RuntimeException("TEST"))); final Log mockLog = mock(Log.class); DefinedIndexesApplicationListener listener = new DefinedIndexesApplicationListener() { @Override/*from w w w. j av a 2 s. co m*/ Log initLogger() { return mockLog; } }; listener.onApplicationEvent(mockEvent); verify(mockEvent, times(1)).getApplicationContext(); verify(mockApplicationContext, times(1)).containsBean(eq(QUERY_SERVICE_BEAN_NAME)); verify(mockApplicationContext, times(1)).getBean(eq(QUERY_SERVICE_BEAN_NAME), eq(QueryService.class)); verify(mockQueryService, times(1)).createDefinedIndexes(); verify(mockLog, times(1)).warn(startsWith("Failed to create pre-defined Indexes:"), isA(MultiIndexCreationException.class)); }