diff --git a/core/src/com/google/inject/internal/ChildBindingAlreadySetError.java b/core/src/com/google/inject/internal/ChildBindingAlreadySetError.java index b2362ac53a..46a3271d90 100644 --- a/core/src/com/google/inject/internal/ChildBindingAlreadySetError.java +++ b/core/src/com/google/inject/internal/ChildBindingAlreadySetError.java @@ -21,8 +21,10 @@ final class ChildBindingAlreadySetError extends InternalErrorDetail clazz) { } private String inChildMessage(Class clazz) { - return "Unable to create binding for " - + "JitBindingsTest$" + return "A binding for JitBindingsTest$" + clazz.getSimpleName() - + " because it was already configured on one or more child injectors or private modules"; + + " already exists in one or more child" + + " injectors or private modules. Bindings from children can only be used by a parent if" + + " the child was a PrivateModule and the binding was exposed. Parent injectors cannot" + + " create bindings that already exist in a child."; } public void testLinkedBindingWorks() { diff --git a/core/test/com/google/inject/ParentInjectorTest.java b/core/test/com/google/inject/ParentInjectorTest.java index 59ecb62573..8290278bb6 100644 --- a/core/test/com/google/inject/ParentInjectorTest.java +++ b/core/test/com/google/inject/ParentInjectorTest.java @@ -41,7 +41,9 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** @author jessewilson@google.com (Jesse Wilson) */ +/** + * @author jessewilson@google.com (Jesse Wilson) + */ @RunWith(JUnit4.class) public class ParentInjectorTest { @@ -70,8 +72,10 @@ public void testParentJitBindingWontClobberChildBinding() { } catch (ConfigurationException e) { assertContains( e.getMessage(), - "Unable to create binding for ParentInjectorTest$A because it was already configured on" - + " one or more child injectors or private modules.", + "A binding for ParentInjectorTest$A already exists in one or more child injectors or" + + " private modules. Bindings from children can only be used by a parent if the child" + + " was a PrivateModule and the binding was exposed. Parent injectors cannot create" + + " bindings that already exist in a child.", "ParentInjectorTest$9.configure"); } } diff --git a/core/test/com/google/inject/PrivateModuleTest.java b/core/test/com/google/inject/PrivateModuleTest.java index fe09b983f9..d4b12818fd 100644 --- a/core/test/com/google/inject/PrivateModuleTest.java +++ b/core/test/com/google/inject/PrivateModuleTest.java @@ -32,7 +32,9 @@ import java.util.List; import junit.framework.TestCase; -/** @author jessewilson@google.com (Jesse Wilson) */ +/** + * @author jessewilson@google.com (Jesse Wilson) + */ public class PrivateModuleTest extends TestCase { public void testBasicUsage() { @@ -589,8 +591,10 @@ public void testParentBindsSomethingInPrivate() { assertEquals(1, expected.getErrorMessages().size()); assertContains( expected.toString(), - "Unable to create binding for List ", - "because it was already configured on one or more child injectors or private modules.", + "A binding for List already exists in one or more child injectors", + " or private modules. Bindings from children can only be used by a parent if the child", + " was a PrivateModule and the binding was exposed. Parent injectors cannot create", + " bindings that already exist in a child.", "1 : PrivateModuleTest$FailingPrivateModule.configure", "PrivateModuleTest$FailingModule -> PrivateModuleTest$ManyPrivateModules ->" + " PrivateModuleTest$FailingPrivateModule", @@ -610,8 +614,10 @@ public void testParentBindingToPrivateLinkedJitBinding() { assertEquals(1, expected.getErrorMessages().size()); assertContains( expected.toString(), - "Unable to create binding for List because it was already configured on one or" - + " more child injectors or private modules", + "A binding for List already exists in one or more child injectors", + " or private modules. Bindings from children can only be used by a parent if the child", + " was a PrivateModule and the binding was exposed. Parent injectors cannot create", + " bindings that already exist in a child.", "1 : PrivateModuleTest$FailingPrivateModule.configure", "PrivateModuleTest$ManyPrivateModules -> PrivateModuleTest$FailingPrivateModule", "2 : PrivateModuleTest$SecondFailingPrivateModule.configure", @@ -628,8 +634,10 @@ public void testParentBindingToPrivateJitBinding() { assertEquals(1, expected.getErrorMessages().size()); assertContains( expected.toString(), - "Unable to create binding for PrivateModuleTest$PrivateFoo because it was already" - + " configured on one or more child injectors or private modules.", + "A binding for PrivateModuleTest$PrivateFoo already exists in one or more child", + " injectors or private modules. Bindings from children can only be used by a parent if", + " the child was a PrivateModule and the binding was exposed. Parent injectors cannot", + " create bindings that already exist in a child.", "as a just-in-time binding"); } } diff --git a/core/test/com/google/inject/errors/testdata/child_binding_already_set_by_just_in_time_binding.txt b/core/test/com/google/inject/errors/testdata/child_binding_already_set_by_just_in_time_binding.txt index aceeb94acc..93907409d9 100644 --- a/core/test/com/google/inject/errors/testdata/child_binding_already_set_by_just_in_time_binding.txt +++ b/core/test/com/google/inject/errors/testdata/child_binding_already_set_by_just_in_time_binding.txt @@ -1,6 +1,6 @@ Guice configuration errors: -1) [Guice/ChildBindingAlreadySet]: Unable to create binding for ChildBindingAlreadySetErrorTest$DependsOnFoo because it was already configured on one or more child injectors or private modules. +1) [Guice/ChildBindingAlreadySet]: A binding for ChildBindingAlreadySetErrorTest$DependsOnFoo already exists in one or more child injectors or private modules. Bindings from children can only be used by a parent if the child was a PrivateModule and the binding was exposed. Parent injectors cannot create bindings that already exist in a child. Bound at: 1 : ChildBindingAlreadySetErrorTest$ChildModule4.configure(ChildBindingAlreadySetErrorTest.java:105) diff --git a/core/test/com/google/inject/errors/testdata/child_binding_already_set_error.txt b/core/test/com/google/inject/errors/testdata/child_binding_already_set_error.txt index dad306c3f8..ed0c81a309 100644 --- a/core/test/com/google/inject/errors/testdata/child_binding_already_set_error.txt +++ b/core/test/com/google/inject/errors/testdata/child_binding_already_set_error.txt @@ -1,6 +1,6 @@ Guice configuration errors: -1) [Guice/ChildBindingAlreadySet]: Unable to create binding for ChildBindingAlreadySetErrorTest$Foo because it was already configured on one or more child injectors or private modules. +1) [Guice/ChildBindingAlreadySet]: A binding for ChildBindingAlreadySetErrorTest$Foo already exists in one or more child injectors or private modules. Bindings from children can only be used by a parent if the child was a PrivateModule and the binding was exposed. Parent injectors cannot create bindings that already exist in a child. Bound at: 1 : ChildBindingAlreadySetErrorTest$ChildModule.configure(ChildBindingAlreadySetErrorTest.java:34) diff --git a/core/test/com/google/inject/errors/testdata/child_binding_already_set_multiple_times_error.txt b/core/test/com/google/inject/errors/testdata/child_binding_already_set_multiple_times_error.txt index f55cdff782..d0c3f8f155 100644 --- a/core/test/com/google/inject/errors/testdata/child_binding_already_set_multiple_times_error.txt +++ b/core/test/com/google/inject/errors/testdata/child_binding_already_set_multiple_times_error.txt @@ -1,6 +1,6 @@ Guice configuration errors: -1) [Guice/ChildBindingAlreadySet]: Unable to create binding for ChildBindingAlreadySetErrorTest$Foo because it was already configured on one or more child injectors or private modules. +1) [Guice/ChildBindingAlreadySet]: A binding for ChildBindingAlreadySetErrorTest$Foo already exists in one or more child injectors or private modules. Bindings from children can only be used by a parent if the child was a PrivateModule and the binding was exposed. Parent injectors cannot create bindings that already exist in a child. Bound at: 1 : ChildBindingAlreadySetErrorTest$ChildModule.configure(ChildBindingAlreadySetErrorTest.java:34) diff --git a/core/test/com/google/inject/errors/testdata/multiple_child_binding_already_set_errors.txt b/core/test/com/google/inject/errors/testdata/multiple_child_binding_already_set_errors.txt index e0663cd354..93a5388996 100644 --- a/core/test/com/google/inject/errors/testdata/multiple_child_binding_already_set_errors.txt +++ b/core/test/com/google/inject/errors/testdata/multiple_child_binding_already_set_errors.txt @@ -1,6 +1,6 @@ Unable to create injector, see the following errors: -1) [Guice/ChildBindingAlreadySet]: Unable to create binding for ChildBindingAlreadySetErrorTest$Foo because it was already configured on one or more child injectors or private modules. +1) [Guice/ChildBindingAlreadySet]: A binding for ChildBindingAlreadySetErrorTest$Foo already exists in one or more child injectors or private modules. Bindings from children can only be used by a parent if the child was a PrivateModule and the binding was exposed. Parent injectors cannot create bindings that already exist in a child. Bound at: 1 : ChildBindingAlreadySetErrorTest$ChildModule.configure(ChildBindingAlreadySetErrorTest.java:34)