Files
guice/core/test/com/google/inject/ModuleTest.java
T
lukesandSam Berlin 713c06cce9 Fix issues reported by errorprone
99% of this is adding missing @Override annotations, in the long tail we also have

* insert missing calls to Assert.fail() in tests that are testing exception behavior
* rewrite a few cases of Foo.class.instanceof(c) to c instanceof Foo
* rewrite Class.newInstance - > Class.getConstructor().newInstance() which doesn't break checked exception checking.
* adding @javax.inject.Inject annotations to methods that override methods annotated with @javax.inject.Inject

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131839622
2016-09-07 17:45:54 -04:00

61 lines
1.2 KiB
Java

// 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 {
@Override
public void configure(Binder binder) {
binder.bind(X.class);
binder.install(new B());
binder.install(new C());
}
}
static class B implements Module {
@Override
public void configure(Binder binder) {
binder.bind(Y.class);
binder.install(new D());
}
}
static class C implements Module {
@Override
public void configure(Binder binder) {
binder.bind(Z.class);
binder.install(new D());
}
}
static class D implements Module {
@Override
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());
}
}