Add binding for Linguistics to HandlersConfigurerTestWrapper.
The binding has been removed from HandlersConfigurerDi to
prevent creating a SimpleLinguistics there.
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.core.config.testutil;
+import com.google.inject.AbstractModule;
import com.google.inject.Guice;
+import com.google.inject.Injector;
import com.yahoo.component.AbstractComponent;
import com.yahoo.component.provider.ComponentRegistry;
import com.yahoo.config.subscription.ConfigSourceSet;
@@ -10,6 +12,8 @@ import com.yahoo.container.di.CloudSubscriberFactory;
import com.yahoo.container.di.ComponentDeconstructor;
import com.yahoo.container.core.config.HandlersConfigurerDi;
import com.yahoo.jdisc.handler.RequestHandler;
+import com.yahoo.language.Linguistics;
+import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.osgi.MockOsgi;
import java.io.File;
@@ -92,7 +96,7 @@ public class HandlersConfigurerTestWrapper {
container,
configId,
testDeconstructor,
- Guice.createInjector(),
+ guiceInjector(),
mockOsgi);
this.container = container;
}
@@ -111,7 +115,7 @@ public class HandlersConfigurerTestWrapper {
public void reloadConfig() {
configurer.reloadConfig(++lastGeneration);
- configurer.getNewComponentGraph(Guice.createInjector(), false);
+ configurer.getNewComponentGraph(guiceInjector(), false);
}
public void shutdown() {
@@ -125,4 +129,14 @@ public class HandlersConfigurerTestWrapper {
return container.getRequestHandlerRegistry();
}
+ private static Injector guiceInjector() {
+ return Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ // Needed by e.g. SearchHandler
+ bind(Linguistics.class).toInstance(new SimpleLinguistics());
+ }
+ });
+ }
+
}
