@Before public void setUp() { initMocks(this); httpClient = PowerMockito.mock(DefaultHttpClient.class); repoUrl = "fake:fake"; indexers = new HashSet<Indexer<Object>>(); indexers.add(indexer); indexerGroup = new IndexerGroup(); indexerGroup.setHttpClient(httpClient); indexerGroup.setIndexers(indexers); indexerGroup.setRepositoryURL(repoUrl); }
@Test public void testReindex() throws Exception { mockContent("", true, null); when(indexer.getIndexerType()).thenReturn(Indexer.IndexerType.RDF); indexerGroup.reindex(); verify(indexer, atLeastOnce()).update(eq(repoUrl), any()); }
@Test public void testInvalidMessage() { try { indexerGroup.onMessage(createBrokenMessage()); fail("Broken message should result in an exception!"); } catch (Exception e) { } }
@Test public void testNonIndexableObjectUpdateMessage() throws Exception { String id = "/test"; indexerGroup.onMessage( createUnindexableMessage( REPOSITORY_NAMESPACE + EventType.valueOf(NODE_ADDED).toString(), id)); verify(indexer, never()).update(anyString(), any()); }
@Test public void testRDFIndexablePropertyUpdateMessage() throws Exception { when(indexer.getIndexerType()).thenReturn(Indexer.IndexerType.RDF); String id = "/test/dc:title"; indexerGroup.onMessage( createIndexablePropertyMessage( REPOSITORY_NAMESPACE + EventType.valueOf(PROPERTY_CHANGED).toString(), id)); verify(indexer, atLeastOnce()).update(anyString(), any()); }
@Test public void testNamedFieldsIndexableObjectUpdateMessage() throws Exception { when(indexer.getIndexerType()).thenReturn(Indexer.IndexerType.NAMEDFIELDS); String id = "/test"; indexerGroup.onMessage( createIndexableMessage( REPOSITORY_NAMESPACE + EventType.valueOf(NODE_ADDED).toString(), id)); verify(indexer, atLeastOnce()).update(anyString(), any()); }
@Test public void testGetters() { assertEquals(repoUrl, indexerGroup.getRepositoryURL()); assertEquals(indexers, indexerGroup.getIndexers()); assertEquals(httpClient, indexerGroup.getHttpClient()); }