mirror of
https://github.com/google/guice.git
synced 2024-04-21 12:32:36 +00:00
Issue 552: (step 1) move core code to its own subdirectory
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1300 d779f126-a31b-0410-b53b-1d3aecad763e
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
// Copyright 2007 Google Inc. All Rights Reserved.
|
||||
|
||||
package com.google.inject;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Tests relating to modules.
|
||||
*
|
||||
* @author kevinb
|
||||
*/
|
||||
public class ModuleTest extends TestCase {
|
||||
|
||||
static class A implements Module {
|
||||
public void configure(Binder binder) {
|
||||
binder.bind(X.class);
|
||||
binder.install(new B());
|
||||
binder.install(new C());
|
||||
}
|
||||
}
|
||||
|
||||
static class B implements Module {
|
||||
public void configure(Binder binder) {
|
||||
binder.bind(Y.class);
|
||||
binder.install(new D());
|
||||
}
|
||||
}
|
||||
|
||||
static class C implements Module {
|
||||
public void configure(Binder binder) {
|
||||
binder.bind(Z.class);
|
||||
binder.install(new D());
|
||||
}
|
||||
}
|
||||
|
||||
static class D implements Module {
|
||||
public void configure(Binder binder) {
|
||||
binder.bind(W.class);
|
||||
}
|
||||
@Override public boolean equals(Object obj) {
|
||||
return obj.getClass() == D.class; // we're all equal in the eyes of guice
|
||||
}
|
||||
@Override public int hashCode() {
|
||||
return D.class.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
static class X {}
|
||||
static class Y {}
|
||||
static class Z {}
|
||||
static class W {}
|
||||
|
||||
public void testDiamond() throws Exception {
|
||||
Guice.createInjector(new A());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user