1 /**
2  * Copyright (C) 2009 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  */
16 
17 package com.googlecode.guice;
18 
19 import com.google.inject.AbstractModule;
20 import com.google.inject.Guice;
21 import com.google.inject.Provides;
22 
23 import junit.framework.Test;
24 import junit.framework.TestCase;
25 
26 import org.atinject.tck.Tck;
27 import org.atinject.tck.auto.Car;
28 import org.atinject.tck.auto.Convertible;
29 import org.atinject.tck.auto.Drivers;
30 import org.atinject.tck.auto.DriversSeat;
31 import org.atinject.tck.auto.Engine;
32 import org.atinject.tck.auto.FuelTank;
33 import org.atinject.tck.auto.Seat;
34 import org.atinject.tck.auto.Tire;
35 import org.atinject.tck.auto.V8Engine;
36 import org.atinject.tck.auto.accessories.Cupholder;
37 import org.atinject.tck.auto.accessories.SpareTire;
38 
39 import javax.inject.Named;
40 
41 public class GuiceTck extends TestCase {
42 
suite()43   public static Test suite() {
44     return Tck.testsFor(Guice.createInjector(new AbstractModule() {
45       protected void configure() {
46         bind(Car.class).to(Convertible.class);
47         bind(Seat.class).annotatedWith(Drivers.class).to(DriversSeat.class);
48         bind(Engine.class).to(V8Engine.class);
49         bind(Cupholder.class);
50         bind(Tire.class);
51         bind(FuelTank.class);
52         requestStaticInjection(Convertible.class, SpareTire.class);
53       }
54 
55       @Provides @Named("spare") Tire provideSpareTire(SpareTire spare) {
56         return spare;
57       }
58     }).getInstance(Car.class), true, true);
59   }
60 }
61