1 16 17 package com.google.inject; 18 19 import java.util.Arrays ; 20 import java.util.List ; 21 import junit.framework.TestCase; 22 23 26 public class GenericInjectionTest extends TestCase { 27 28 public void testGenericInjection() throws CreationException { 29 List <String > names = Arrays.asList("foo", "bar", "bob"); 30 BinderImpl builder = new BinderImpl(); 31 builder.bind(new TypeLiteral<List <String >>() {}).toInstance(names); 32 Injector injector = builder.createInjector(); 33 Foo foo = injector.getInstance(Foo.class); 34 assertEquals(names, foo.names); 35 } 36 37 static class Foo { 38 @Inject List <String > names; 39 } 40 } 41 | Popular Tags |