blob: 08d069bca602888fd94b702ae2b70288d554516f [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
crazyboblee5746d5d2007-02-18 21:52:24 +000029 public void testGenericInjection() throws CreationException {
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);
crazyboblee278ee4d2007-02-15 19:23:13 +000033 Container container = builder.create();
crazyboblee5746d5d2007-02-18 21:52:24 +000034 Foo foo = container.getLocator(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}