Error messaging test cases:
http://groups.google.com/group/google-guice-dev/browse_thread/thread/3a1bc9fc820c8e49
git-svn-id: https://google-guice.googlecode.com/svn/trunk@390 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/test/com/google/inject/AllTests.java b/test/com/google/inject/AllTests.java
index 58a176b..3f699c6 100644
--- a/test/com/google/inject/AllTests.java
+++ b/test/com/google/inject/AllTests.java
@@ -39,6 +39,7 @@
suite.addTestSuite(BoundProviderTest.class);
suite.addTestSuite(CircularDependencyTest.class);
suite.addTestSuite(ConstantConversionTest.class);
+ suite.addTestSuite(ErrorMessagesTest.class);
suite.addTestSuite(InjectorTest.class);
suite.addTestSuite(GenericInjectionTest.class);
suite.addTestSuite(ImplicitBindingTest.class);
diff --git a/test/com/google/inject/ErrorMessagesTest.java b/test/com/google/inject/ErrorMessagesTest.java
index 0fb4c21..ad3431b 100644
--- a/test/com/google/inject/ErrorMessagesTest.java
+++ b/test/com/google/inject/ErrorMessagesTest.java
@@ -39,6 +39,35 @@
}
}
+ public void testExplicitBindingOfAnAbstractClass() {
+ try {
+ Guice.createInjector(new AbstractModule() {
+ protected void configure() {
+ bind(AbstractClass.class);
+ }
+ });
+ fail();
+ } catch(CreationException e) {
+ assertTrue(e.getMessage().contains(
+ "Injecting into abstract types is not supported."));
+ }
+ }
+
+ public void testGetInstanceOfAnAbstractClass() {
+ Injector injector = Guice.createInjector();
+ try {
+ injector.getInstance(AbstractClass.class);
+ fail();
+ } catch(ConfigurationException e) {
+ assertTrue(e.getMessage().contains(
+ "Injecting into abstract types is not supported."));
+ }
+ }
+
+ static abstract class AbstractClass {
+ @Inject AbstractClass() { }
+ }
+
// TODO(kevinb): many many more
}