• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2007 Google Inc. All Rights Reserved.
2 
3 package com.google.inject;
4 
5 import junit.framework.TestCase;
6 
7 /**
8  * Tests relating to modules.
9  *
10  * @author kevinb
11  */
12 public class ModuleTest extends TestCase {
13 
14   static class A implements Module {
configure(Binder binder)15     public void configure(Binder binder) {
16       binder.bind(X.class);
17       binder.install(new B());
18       binder.install(new C());
19     }
20   }
21 
22   static class B implements Module {
configure(Binder binder)23     public void configure(Binder binder) {
24       binder.bind(Y.class);
25       binder.install(new D());
26     }
27   }
28 
29   static class C implements Module {
configure(Binder binder)30     public void configure(Binder binder) {
31       binder.bind(Z.class);
32       binder.install(new D());
33     }
34   }
35 
36   static class D implements Module {
configure(Binder binder)37     public void configure(Binder binder) {
38       binder.bind(W.class);
39     }
equals(Object obj)40     @Override public boolean equals(Object obj) {
41       return obj.getClass() == D.class; // we're all equal in the eyes of guice
42     }
hashCode()43     @Override public int hashCode() {
44       return D.class.hashCode();
45     }
46   }
47 
48   static class X {}
49   static class Y {}
50   static class Z {}
51   static class W {}
52 
testDiamond()53   public void testDiamond() throws Exception {
54     Guice.createInjector(new A());
55   }
56 }
57