Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks some downstream tests that assumed the error message was written a certain way. #1847

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ final class ChildBindingAlreadySetError extends InternalErrorDetail<ChildBinding
super(
ErrorId.CHILD_BINDING_ALREADY_SET,
String.format(
"A binding for %s 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.",
"Unable to create binding for %s because it was already configured on one or more"
+ " child injectors or private modules.",
Messages.convert(key)),
sources,
null);
Expand Down
8 changes: 3 additions & 5 deletions core/test/com/google/inject/JitBindingsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ private String jitInParentFailed(TypeLiteral<?> clazz) {
}

private String inChildMessage(Class<?> clazz) {
return "A binding for JitBindingsTest$"
return "Unable to create binding for "
+ "JitBindingsTest$"
+ clazz.getSimpleName()
+ " 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.";
+ " because it was already configured on one or more child injectors or private modules";
}

public void testLinkedBindingWorks() {
Expand Down
10 changes: 3 additions & 7 deletions core/test/com/google/inject/ParentInjectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
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 {

Expand Down Expand Up @@ -72,10 +70,8 @@ public void testParentJitBindingWontClobberChildBinding() {
} catch (ConfigurationException e) {
assertContains(
e.getMessage(),
"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.",
"Unable to create binding for ParentInjectorTest$A because it was already configured on"
+ " one or more child injectors or private modules.",
"ParentInjectorTest$9.configure");
}
}
Expand Down
22 changes: 7 additions & 15 deletions core/test/com/google/inject/PrivateModuleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
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() {
Expand Down Expand Up @@ -591,10 +589,8 @@ public void testParentBindsSomethingInPrivate() {
assertEquals(1, expected.getErrorMessages().size());
assertContains(
expected.toString(),
"A binding for List<String> 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.",
"Unable to create binding for List<String> ",
"because it was already configured on one or more child injectors or private modules.",
"1 : PrivateModuleTest$FailingPrivateModule.configure",
"PrivateModuleTest$FailingModule -> PrivateModuleTest$ManyPrivateModules ->"
+ " PrivateModuleTest$FailingPrivateModule",
Expand All @@ -614,10 +610,8 @@ public void testParentBindingToPrivateLinkedJitBinding() {
assertEquals(1, expected.getErrorMessages().size());
assertContains(
expected.toString(),
"A binding for List<String> 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.",
"Unable to create binding for List<String> because it was already configured on one or"
+ " more child injectors or private modules",
"1 : PrivateModuleTest$FailingPrivateModule.configure",
"PrivateModuleTest$ManyPrivateModules -> PrivateModuleTest$FailingPrivateModule",
"2 : PrivateModuleTest$SecondFailingPrivateModule.configure",
Expand All @@ -634,10 +628,8 @@ public void testParentBindingToPrivateJitBinding() {
assertEquals(1, expected.getErrorMessages().size());
assertContains(
expected.toString(),
"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.",
"Unable to create binding for PrivateModuleTest$PrivateFoo because it was already"
+ " configured on one or more child injectors or private modules.",
"as a just-in-time binding");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Guice configuration errors:

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.
1) [Guice/ChildBindingAlreadySet]: Unable to create binding for ChildBindingAlreadySetErrorTest$DependsOnFoo because it was already configured on one or more child injectors or private modules.

Bound at:
1 : ChildBindingAlreadySetErrorTest$ChildModule4.configure(ChildBindingAlreadySetErrorTest.java:105)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Guice configuration errors:

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.
1) [Guice/ChildBindingAlreadySet]: Unable to create binding for ChildBindingAlreadySetErrorTest$Foo because it was already configured on one or more child injectors or private modules.

Bound at:
1 : ChildBindingAlreadySetErrorTest$ChildModule.configure(ChildBindingAlreadySetErrorTest.java:34)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Guice configuration errors:

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.
1) [Guice/ChildBindingAlreadySet]: Unable to create binding for ChildBindingAlreadySetErrorTest$Foo because it was already configured on one or more child injectors or private modules.

Bound at:
1 : ChildBindingAlreadySetErrorTest$ChildModule.configure(ChildBindingAlreadySetErrorTest.java:34)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Unable to create injector, see the following errors:

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.
1) [Guice/ChildBindingAlreadySet]: Unable to create binding for ChildBindingAlreadySetErrorTest$Foo because it was already configured on one or more child injectors or private modules.

Bound at:
1 : ChildBindingAlreadySetErrorTest$ChildModule.configure(ChildBindingAlreadySetErrorTest.java:34)
Expand Down
Loading