Search in sources :

Example 1 with SearchService

use of org.elasticsearch.search.SearchService in project elasticsearch by elastic.

the class MockNodeTests method testComponentsMockedByMarkerPlugins.

/**
     * Test that we add the appropriate mock services when their plugins are added. This is a very heavy test for a testing component but
     * we've broken it in the past so it is important.
     */
public void testComponentsMockedByMarkerPlugins() throws IOException {
    Settings settings = // All these are required or MockNode will fail to build.
    Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME).put("http.enabled", false).build();
    List<Class<? extends Plugin>> plugins = new ArrayList<>();
    plugins.add(MockTcpTransportPlugin.class);
    boolean useMockBigArrays = randomBoolean();
    boolean useMockSearchService = randomBoolean();
    if (useMockBigArrays) {
        plugins.add(NodeMocksPlugin.class);
    }
    if (useMockSearchService) {
        plugins.add(MockSearchService.TestPlugin.class);
    }
    try (MockNode node = new MockNode(settings, plugins)) {
        BigArrays bigArrays = node.injector().getInstance(BigArrays.class);
        SearchService searchService = node.injector().getInstance(SearchService.class);
        if (useMockBigArrays) {
            assertSame(bigArrays.getClass(), MockBigArrays.class);
        } else {
            assertSame(bigArrays.getClass(), BigArrays.class);
        }
        if (useMockSearchService) {
            assertSame(searchService.getClass(), MockSearchService.class);
        } else {
            assertSame(searchService.getClass(), SearchService.class);
        }
    }
}
Also used : BigArrays(org.elasticsearch.common.util.BigArrays) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) MockSearchService(org.elasticsearch.search.MockSearchService) SearchService(org.elasticsearch.search.SearchService) ArrayList(java.util.ArrayList) MockSearchService(org.elasticsearch.search.MockSearchService) Settings(org.elasticsearch.common.settings.Settings) Plugin(org.elasticsearch.plugins.Plugin) MockTcpTransportPlugin(org.elasticsearch.transport.MockTcpTransportPlugin)

Aggregations

ArrayList (java.util.ArrayList)1 Settings (org.elasticsearch.common.settings.Settings)1 BigArrays (org.elasticsearch.common.util.BigArrays)1 MockBigArrays (org.elasticsearch.common.util.MockBigArrays)1 Plugin (org.elasticsearch.plugins.Plugin)1 MockSearchService (org.elasticsearch.search.MockSearchService)1 SearchService (org.elasticsearch.search.SearchService)1 MockTcpTransportPlugin (org.elasticsearch.transport.MockTcpTransportPlugin)1