Search in sources :

Example 41 with Injector

use of com.google.inject.Injector in project hadoop by apache.

the class TestHSWebApp method testLogsView1.

@Test
public void testLogsView1() throws IOException {
    LOG.info("HsLogsPage");
    Injector injector = WebAppTests.testPage(AggregatedLogsPage.class, AppContext.class, new MockAppContext(0, 1, 1, 1));
    PrintWriter spyPw = WebAppTests.getPrintWriter(injector);
    verify(spyPw).write("Cannot get container logs without a ContainerId");
    verify(spyPw).write("Cannot get container logs without a NodeId");
    verify(spyPw).write("Cannot get container logs without an app owner");
}
Also used : MockAppContext(org.apache.hadoop.mapreduce.v2.app.MockAppContext) Injector(com.google.inject.Injector) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 42 with Injector

use of com.google.inject.Injector in project useful-java-links by Vedenin.

the class GuiceConstructor method main.

public static void main(String[] args) throws Exception {
    Injector injector = Guice.createInjector(new TestModule());
    Notifier notifier = injector.getInstance(Notifier.class);
    // Print "I send email: Hello world!"
    notifier.send("Hello world!");
}
Also used : Injector(com.google.inject.Injector)

Example 43 with Injector

use of com.google.inject.Injector in project useful-java-links by Vedenin.

the class GuiceFieldInject method main.

public static void main(String[] args) throws Exception {
    Injector injector = Guice.createInjector(new TestModule());
    Notifier notifier = injector.getInstance(Notifier.class);
    // Print "I send email: Hello world!"
    notifier.send("Hello world!");
}
Also used : Injector(com.google.inject.Injector)

Example 44 with Injector

use of com.google.inject.Injector in project useful-java-links by Vedenin.

the class GuiceSetterInject method main.

public static void main(String[] args) throws Exception {
    Injector injector = Guice.createInjector(new TestModule());
    Notifier notifier = injector.getInstance(Notifier.class);
    // Print "I send email: Hello world!"
    notifier.send("Hello world!");
}
Also used : Injector(com.google.inject.Injector)

Example 45 with Injector

use of com.google.inject.Injector in project ribbon by Netflix.

the class RxMovieProxyExampleTest method shouldBindCustomClientConfigFactory.

@Test
public void shouldBindCustomClientConfigFactory() {
    ConfigurationManager.getConfigInstance().setProperty(MovieService.class.getSimpleName() + ".MyConfig.listOfServers", "localhost:" + port);
    Injector injector = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(RibbonResourceFactory.class).to(DefaultResourceFactory.class).in(Scopes.SINGLETON);
            bind(RibbonTransportFactory.class).to(DefaultRibbonTransportFactory.class).in(Scopes.SINGLETON);
            bind(AnnotationProcessorsProvider.class).to(DefaultAnnotationProcessorsProvider.class).in(Scopes.SINGLETON);
            bind(ClientConfigFactory.class).to(MyClientConfigFactory.class).in(Scopes.SINGLETON);
        }
    }, new AbstractModule() {

        @Override
        protected void configure() {
            bind(MovieService.class).toProvider(new RibbonResourceProvider<MovieService>(MovieService.class)).asEagerSingleton();
        }
    });
    RxMovieProxyExample example = injector.getInstance(RxMovieProxyExample.class);
    assertTrue(example.runExample());
}
Also used : MovieService(com.netflix.ribbon.examples.rx.proxy.MovieService) Injector(com.google.inject.Injector) DefaultClientConfigFactory(com.netflix.client.config.ClientConfigFactory.DefaultClientConfigFactory) ClientConfigFactory(com.netflix.client.config.ClientConfigFactory) RibbonTransportFactory(com.netflix.ribbon.RibbonTransportFactory) DefaultRibbonTransportFactory(com.netflix.ribbon.RibbonTransportFactory.DefaultRibbonTransportFactory) RibbonResourceFactory(com.netflix.ribbon.RibbonResourceFactory) DefaultAnnotationProcessorsProvider(com.netflix.ribbon.proxy.processor.AnnotationProcessorsProvider.DefaultAnnotationProcessorsProvider) AnnotationProcessorsProvider(com.netflix.ribbon.proxy.processor.AnnotationProcessorsProvider) RxMovieProxyExample(com.netflix.ribbon.examples.rx.proxy.RxMovieProxyExample) AbstractModule(com.google.inject.AbstractModule) Test(org.junit.Test)

Aggregations

Injector (com.google.inject.Injector)2117 AbstractModule (com.google.inject.AbstractModule)624 Test (org.junit.Test)513 Module (com.google.inject.Module)386 Binder (com.google.inject.Binder)140 Before (org.junit.Before)116 Properties (java.util.Properties)110 Test (org.testng.annotations.Test)105 Key (com.google.inject.Key)91 HttpServletRequest (javax.servlet.http.HttpServletRequest)78 Map (java.util.Map)75 Provider (com.google.inject.Provider)74 TypeLiteral (com.google.inject.TypeLiteral)70 IOException (java.io.IOException)69 Set (java.util.Set)63 BeforeClass (org.junit.BeforeClass)61 File (java.io.File)59 ImmutableList (com.google.common.collect.ImmutableList)58 CConfiguration (co.cask.cdap.common.conf.CConfiguration)55 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)55