blob: 8d89be063e26017dec88ff65a1e23cc4fdb24dd4 [file] [log] [blame]
crazybobleeabc4dd02007-02-01 01:44:36 +00001/**
2 * Copyright (C) 2006 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
crazyboblee63b592b2007-01-25 02:45:24 +000016
17package com.google.inject;
18
19import junit.framework.TestCase;
20
21import java.util.List;
22import java.util.Arrays;
23
24/**
25 * @author crazybob@google.com (Bob Lee)
26 */
27public class GenericInjectionTest extends TestCase {
28
crazyboblee9bb62022007-02-01 00:06:53 +000029 public void testGenericInjection() throws ContainerCreationException {
crazyboblee63b592b2007-01-25 02:45:24 +000030 List<String> names = Arrays.asList("foo", "bar", "bob");
31 ContainerBuilder builder = new ContainerBuilder();
crazyboblee0baa9fc2007-01-31 02:38:54 +000032 builder.bind(new TypeLiteral<List<String>>() {}).to(names);
crazyboblee63b592b2007-01-25 02:45:24 +000033 Container container = builder.create(false);
crazybobleef1ba2b52007-01-29 21:19:53 +000034 Foo foo = container.getCreator(Foo.class).get();
crazyboblee63b592b2007-01-25 02:45:24 +000035 assertEquals(names, foo.names);
36 }
37
38 static class Foo {
39 @Inject List<String> names;
40 }
41}