Skip to content

Commit fd77c95

Browse files
java-team-github-botGuice Team
authored andcommitted
Breaks some downstream tests that assumed the error message was written a certain way.
PiperOrigin-RevId: 698877656
1 parent bf43b4f commit fd77c95

8 files changed

+19
-35
lines changed

core/src/com/google/inject/internal/ChildBindingAlreadySetError.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ final class ChildBindingAlreadySetError extends InternalErrorDetail<ChildBinding
2121
super(
2222
ErrorId.CHILD_BINDING_ALREADY_SET,
2323
String.format(
24-
"A binding for %s already exists in one or more child injectors or private modules."
25-
+ " Bindings from children can only be used by a parent if the child was a"
26-
+ " PrivateModule and the binding was exposed. Parent injectors cannot create"
27-
+ " bindings that already exist in a child.",
24+
"Unable to create binding for %s because it was already configured on one or more"
25+
+ " child injectors or private modules.",
2826
Messages.convert(key)),
2927
sources,
3028
null);

core/test/com/google/inject/JitBindingsTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ private String jitInParentFailed(TypeLiteral<?> clazz) {
5353
}
5454

5555
private String inChildMessage(Class<?> clazz) {
56-
return "A binding for JitBindingsTest$"
56+
return "Unable to create binding for "
57+
+ "JitBindingsTest$"
5758
+ clazz.getSimpleName()
58-
+ " already exists in one or more child"
59-
+ " injectors or private modules. Bindings from children can only be used by a parent if"
60-
+ " the child was a PrivateModule and the binding was exposed. Parent injectors cannot"
61-
+ " create bindings that already exist in a child.";
59+
+ " because it was already configured on one or more child injectors or private modules";
6260
}
6361

6462
public void testLinkedBindingWorks() {

core/test/com/google/inject/ParentInjectorTest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@
4141
import org.junit.runner.RunWith;
4242
import org.junit.runners.JUnit4;
4343

44-
/**
45-
* @author [email protected] (Jesse Wilson)
46-
*/
44+
/** @author [email protected] (Jesse Wilson) */
4745
@RunWith(JUnit4.class)
4846
public class ParentInjectorTest {
4947

@@ -72,10 +70,8 @@ public void testParentJitBindingWontClobberChildBinding() {
7270
} catch (ConfigurationException e) {
7371
assertContains(
7472
e.getMessage(),
75-
"A binding for ParentInjectorTest$A already exists in one or more child injectors or"
76-
+ " private modules. Bindings from children can only be used by a parent if the child"
77-
+ " was a PrivateModule and the binding was exposed. Parent injectors cannot create"
78-
+ " bindings that already exist in a child.",
73+
"Unable to create binding for ParentInjectorTest$A because it was already configured on"
74+
+ " one or more child injectors or private modules.",
7975
"ParentInjectorTest$9.configure");
8076
}
8177
}

core/test/com/google/inject/PrivateModuleTest.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
import java.util.List;
3333
import junit.framework.TestCase;
3434

35-
/**
36-
* @author [email protected] (Jesse Wilson)
37-
*/
35+
/** @author [email protected] (Jesse Wilson) */
3836
public class PrivateModuleTest extends TestCase {
3937

4038
public void testBasicUsage() {
@@ -591,10 +589,8 @@ public void testParentBindsSomethingInPrivate() {
591589
assertEquals(1, expected.getErrorMessages().size());
592590
assertContains(
593591
expected.toString(),
594-
"A binding for List<String> already exists in one or more child injectors",
595-
" or private modules. Bindings from children can only be used by a parent if the child",
596-
" was a PrivateModule and the binding was exposed. Parent injectors cannot create",
597-
" bindings that already exist in a child.",
592+
"Unable to create binding for List<String> ",
593+
"because it was already configured on one or more child injectors or private modules.",
598594
"1 : PrivateModuleTest$FailingPrivateModule.configure",
599595
"PrivateModuleTest$FailingModule -> PrivateModuleTest$ManyPrivateModules ->"
600596
+ " PrivateModuleTest$FailingPrivateModule",
@@ -614,10 +610,8 @@ public void testParentBindingToPrivateLinkedJitBinding() {
614610
assertEquals(1, expected.getErrorMessages().size());
615611
assertContains(
616612
expected.toString(),
617-
"A binding for List<String> already exists in one or more child injectors",
618-
" or private modules. Bindings from children can only be used by a parent if the child",
619-
" was a PrivateModule and the binding was exposed. Parent injectors cannot create",
620-
" bindings that already exist in a child.",
613+
"Unable to create binding for List<String> because it was already configured on one or"
614+
+ " more child injectors or private modules",
621615
"1 : PrivateModuleTest$FailingPrivateModule.configure",
622616
"PrivateModuleTest$ManyPrivateModules -> PrivateModuleTest$FailingPrivateModule",
623617
"2 : PrivateModuleTest$SecondFailingPrivateModule.configure",
@@ -634,10 +628,8 @@ public void testParentBindingToPrivateJitBinding() {
634628
assertEquals(1, expected.getErrorMessages().size());
635629
assertContains(
636630
expected.toString(),
637-
"A binding for PrivateModuleTest$PrivateFoo already exists in one or more child",
638-
" injectors or private modules. Bindings from children can only be used by a parent if",
639-
" the child was a PrivateModule and the binding was exposed. Parent injectors cannot",
640-
" create bindings that already exist in a child.",
631+
"Unable to create binding for PrivateModuleTest$PrivateFoo because it was already"
632+
+ " configured on one or more child injectors or private modules.",
641633
"as a just-in-time binding");
642634
}
643635
}

core/test/com/google/inject/errors/testdata/child_binding_already_set_by_just_in_time_binding.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Guice configuration errors:
22

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

55
Bound at:
66
1 : ChildBindingAlreadySetErrorTest$ChildModule4.configure(ChildBindingAlreadySetErrorTest.java:105)

core/test/com/google/inject/errors/testdata/child_binding_already_set_error.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Guice configuration errors:
22

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

55
Bound at:
66
1 : ChildBindingAlreadySetErrorTest$ChildModule.configure(ChildBindingAlreadySetErrorTest.java:34)

core/test/com/google/inject/errors/testdata/child_binding_already_set_multiple_times_error.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Guice configuration errors:
22

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

55
Bound at:
66
1 : ChildBindingAlreadySetErrorTest$ChildModule.configure(ChildBindingAlreadySetErrorTest.java:34)

core/test/com/google/inject/errors/testdata/multiple_child_binding_already_set_errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Unable to create injector, see the following errors:
22

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

55
Bound at:
66
1 : ChildBindingAlreadySetErrorTest$ChildModule.configure(ChildBindingAlreadySetErrorTest.java:34)

0 commit comments

Comments
 (0)