Revision: 1577
Author:   limpbizkit
Date:     Mon Aug  8 22:44:38 2011
Log:      Failing test for a multibinder bug reported here:
http://groups.google.com/group/google-guice/browse_thread/thread/934e30b7ed0da98f/b90383ad4cd1228c
http://code.google.com/p/google-guice/source/detail?r=1577

Modified:
/trunk/extensions/multibindings/test/com/google/inject/multibindings/MultibinderTest.java

=======================================
--- /trunk/extensions/multibindings/test/com/google/inject/multibindings/MultibinderTest.java Thu Jul 7 17:34:16 2011 +++ /trunk/extensions/multibindings/test/com/google/inject/multibindings/MultibinderTest.java Mon Aug 8 22:44:38 2011
@@ -351,7 +351,7 @@
       injector.getInstance(Key.get(setOfString));
       fail();
     } catch(ProvisionException expected) {
-      assertContains(expected.getMessage(),
+      assertContains(expected.getMessage(),
           "1) Set injection failed due to null element");
     }
   }
@@ -365,7 +365,7 @@
       });
       fail();
     } catch (CreationException expected) {
- assertContains(expected.getMessage(), "No implementation for java.lang.Integer", + assertContains(expected.getMessage(), "No implementation for java.lang.Integer",
           "at " + getClass().getName());
     }
   }
@@ -393,7 +393,7 @@
     }
     assertEquals(ImmutableSet.of("A", "B"), elements);
   }
-
+
   /**
* We just want to make sure that multibinder's binding depends on each of its values. We don't * really care about the underlying structure of those bindings, which are implementation details.
@@ -404,7 +404,7 @@
Multibinder<String> multibinder = Multibinder.newSetBinder(binder(), String.class);
           multibinder.addBinding().toInstance("A");
multibinder.addBinding().to(Key.get(String.class, Names.named("b")));
-
+
           bindConstant().annotatedWith(Names.named("b")).to("B");
         }});

@@ -416,8 +416,8 @@
// the right values are returned -- in tool stage we can't do that. It's also a // little difficult to validate the dependencies & bindings, because they're
     // bindings created internally within Multibinder.
- // To workaround this, we just validate that the dependencies lookup to a single - // InstanceBinding whose value is "A" and another LinkedBinding whose target is + // To workaround this, we just validate that the dependencies lookup to a single + // InstanceBinding whose value is "A" and another LinkedBinding whose target is
     // the Key of @Named("b") String=B
     for (Dependency<?> dependency : withDependencies.getDependencies()) {
       Binding<?> b = injector.getBinding(dependency.getKey());
@@ -437,10 +437,10 @@
         fail("Unexpected dependency of: " + dependency);
       }
     }
-
+
     assertNotNull(instanceBinding);
     assertNotNull(linkedBinding);
-
+
     assertEquals("A", instanceBinding.getInstance());
assertEquals(Key.get(String.class, Names.named("b")), linkedBinding.getLinkedKey());
   }
@@ -599,4 +599,18 @@
     expected.add(2);
     assertEquals(expected, s1);
   }
-}
+
+  public void testSetAndMapValueConflict() {
+    Injector injector = Guice.createInjector(new AbstractModule() {
+      @Override protected void configure() {
+        Multibinder.newSetBinder(binder(), String.class)
+            .addBinding().toInstance("A");
+
+        MapBinder.newMapBinder(binder(), String.class, String.class)
+            .addBinding("B").toInstance("b");
+      }
+    });
+
+ assertEquals(ImmutableSet.<String>of("A"), injector.getInstance(Key.get(setOfString)));
+  }
+}

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to google-guice-dev@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en.

Reply via email to