List of usage examples for org.springframework.data.gemfire IndexFactoryBean setQueryService
public void setQueryService(QueryService service)
From source file:org.springframework.data.gemfire.IndexFactoryBeanTest.java
private IndexFactoryBean newIndexFactoryBean() { IndexFactoryBean indexFactoryBean = spy(new IndexFactoryBean() { @Override/*from w w w. j av a2s. c om*/ protected Log newLog() { return mockLog; } }); indexFactoryBean.setBeanFactory(mockBeanFactory); indexFactoryBean.setCache(mockCache); indexFactoryBean.setQueryService(mockQueryService); return indexFactoryBean; }
From source file:org.springframework.data.gemfire.IndexFactoryBeanTest.java
@Test public void doLookupQueryService() { QueryService mockQueryServiceOne = mockQueryService("testDoLookupQueryService.MockQueryService.One"); IndexFactoryBean indexFactoryBean = newIndexFactoryBean(); indexFactoryBean.setQueryService(mockQueryServiceOne); assertThat(indexFactoryBean.doLookupQueryService()).isSameAs(mockQueryServiceOne); verify(mockCache, never()).getQueryService(); }
From source file:org.springframework.data.gemfire.IndexFactoryBeanTest.java
@Test public void doLookupQueryServiceOnClientCache() { ClientCache mockClientCache = mock(ClientCache.class); QueryService mockQueryService = mockQueryService("testDoLookupQueryServiceOnClientCache.MockQueryService"); when(mockClientCache.getLocalQueryService()).thenReturn(mockQueryService); IndexFactoryBean indexFactoryBean = newIndexFactoryBean(); indexFactoryBean.setCache(mockClientCache); indexFactoryBean.setQueryService(null); assertThat(indexFactoryBean.doLookupQueryService()).isSameAs(mockQueryService); verify(mockClientCache, times(1)).getLocalQueryService(); verify(mockClientCache, never()).getQueryService(); }
From source file:org.springframework.data.gemfire.IndexFactoryBeanTest.java
@Test public void doLookupQueryServiceOnPeerCache() { IndexFactoryBean indexFactoryBean = newIndexFactoryBean(); indexFactoryBean.setCache(mockCache); indexFactoryBean.setQueryService(null); assertThat(indexFactoryBean.doLookupQueryService()).isSameAs(mockQueryService); verify(mockCache, times(1)).getQueryService(); }
From source file:org.springframework.data.gemfire.IndexFactoryBeanTest.java
@Test public void lookupQueryServiceFromCache() { QueryService mockQueryService = mockQueryService("testLookupQueryServiceFromCache.MockQueryService"); when(mockBeanFactory.containsBean(eq(GemfireConstants.DEFAULT_GEMFIRE_INDEX_DEFINITION_QUERY_SERVICE))) .thenReturn(false);//from w w w . j ava 2 s. c om when(mockCache.getQueryService()).thenReturn(mockQueryService); IndexFactoryBean indexFactoryBean = newIndexFactoryBean(); indexFactoryBean.setDefine(false); indexFactoryBean.setQueryService(null); assertThat(indexFactoryBean.lookupQueryService()).isSameAs(mockQueryService); verify(mockBeanFactory, times(1)) .containsBean(eq(GemfireConstants.DEFAULT_GEMFIRE_INDEX_DEFINITION_QUERY_SERVICE)); verify(mockBeanFactory, never()).getBean( eq(GemfireConstants.DEFAULT_GEMFIRE_INDEX_DEFINITION_QUERY_SERVICE), eq(QueryService.class)); verify(mockCache, times(1)).getQueryService(); }
From source file:org.springframework.data.gemfire.IndexFactoryBeanTest.java
@Test public void resolveQueryServiceReturnsQueryServiceFromLookup() { QueryService mockQueryService = mockQueryService( "testResolveQueryServiceReturnsQueryServiceFromLookup.MockQueryService"); IndexFactoryBean indexFactoryBean = newIndexFactoryBean(); indexFactoryBean.setQueryService(null); doReturn(mockQueryService).when(indexFactoryBean).lookupQueryService(); assertThat(indexFactoryBean.resolveQueryService()).isSameAs(mockQueryService); verify(indexFactoryBean, times(1)).lookupQueryService(); }
From source file:org.springframework.data.gemfire.IndexFactoryBeanTest.java
@Test(expected = IllegalStateException.class) public void resolveQueryServiceThrowsExceptionForUnresolvableQueryService() { IndexFactoryBean indexFactoryBean = newIndexFactoryBean(); try {/*from w ww.ja v a2s . c o m*/ indexFactoryBean.setQueryService(null); doReturn(null).when(indexFactoryBean).lookupQueryService(); indexFactoryBean.resolveQueryService(); } catch (IllegalStateException expected) { assertThat(expected).hasMessage("QueryService is required to create an Index"); assertThat(expected).hasNoCause(); throw expected; } finally { verify(indexFactoryBean, times(1)).lookupQueryService(); } }