Revision: 1059
Author: limpbizkit
Date: Mon Aug 10 16:30:46 2009
Log: some test fixes for ScopeChecker and Multibinder

http://code.google.com/p/google-guice/source/detail?r=1059

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

=======================================
---  
/trunk/extensions/multibindings/test/com/google/inject/multibindings/MultibinderTest.java
        
Mon Jun 22 23:30:37 2009
+++  
/trunk/extensions/multibindings/test/com/google/inject/multibindings/MultibinderTest.java
        
Mon Aug 10 16:30:46 2009
@@ -35,6 +35,7 @@
  import static com.google.inject.name.Names.named;
  import com.google.inject.spi.Dependency;
  import com.google.inject.spi.HasDependencies;
+import com.google.inject.util.Modules;
  import com.google.inject.util.Providers;
  import java.lang.annotation.Retention;
  import static java.lang.annotation.RetentionPolicy.RUNTIME;
@@ -368,4 +369,37 @@
      result.addAll(Arrays.asList(elements));
      return result;
    }
-}
+
+  /**
+   * With overrides, we should get the union of all multibindings.
+   */
+  public void testModuleOverrideAndMultibindings() {
+    Module ab = new AbstractModule() {
+      protected void configure() {
+        Multibinder<String> multibinder =  
Multibinder.newSetBinder(binder(), String.class);
+        multibinder.addBinding().toInstance("A");
+        multibinder.addBinding().toInstance("B");
+      }
+    };
+    Module cd = new AbstractModule() {
+      protected void configure() {
+        Multibinder<String> multibinder =  
Multibinder.newSetBinder(binder(), String.class);
+        multibinder.addBinding().toInstance("C");
+        multibinder.addBinding().toInstance("D");
+      }
+    };
+    Module ef = new AbstractModule() {
+      protected void configure() {
+        Multibinder<String> multibinder =  
Multibinder.newSetBinder(binder(), String.class);
+        multibinder.addBinding().toInstance("E");
+        multibinder.addBinding().toInstance("F");
+      }
+    };
+
+    Module abcd = Modules.override(ab).with(cd);
+    Injector injector = Guice.createInjector(abcd, ef);
+    assertEquals(ImmutableSet.of("A", "B", "C", "D", "E", "F"),
+        injector.getInstance(Key.get(setOfString)));
+
+  }
+}
=======================================
--- /trunk/test/com/google/inject/util/ScopeCheckerTest.java    Thu Jul 23  
17:48:12 2009
+++ /trunk/test/com/google/inject/util/ScopeCheckerTest.java    Mon Aug 10  
16:30:46 2009
@@ -58,11 +58,11 @@

    /** change your shirt daily. Depends on the sleeve length appropriate  
for the weather */
    static class Shirt {
-    @Inject SleeveLenth sleeveLenth;
+    @Inject SleeveLength sleeveLength;
    }

    /** long sleeves in the winter, short sleeves in the summer, etc. */
-  static class SleeveLenth {
+  static class SleeveLength {
      @Inject Style style;
    }

@@ -78,7 +78,7 @@
      Module module = new AbstractModule() {
        protected void configure() {
          bind(Style.class).in(Annually.class);
-        bind(SleeveLenth.class).in(Seasonally.class);
+        bind(SleeveLength.class).in(Seasonally.class);
          bind(Shirt.class).in(Daily.class);
        }
      };
@@ -91,7 +91,7 @@
      Module module = new AbstractModule() {
        protected void configure() {
          bind(Style.class);
-        bind(SleeveLenth.class);
+        bind(SleeveLength.class);
          bind(Shirt.class).in(Daily.class);
        }
      };
@@ -104,7 +104,7 @@
      Module module = new AbstractModule() {
        protected void configure() {
          bind(Style.class).in(Annually.class);
-        bind(SleeveLenth.class);
+        bind(SleeveLength.class);
          bind(Shirt.class);
        }
      };
@@ -117,7 +117,7 @@
      Module module = new AbstractModule() {
        protected void configure() {
          bind(Style.class).in(Annually.class);
-        bind(SleeveLenth.class).in(Seasonally.class);
+        bind(SleeveLength.class).in(Seasonally.class);
          bind(Shirt.class).in(Annually.class);
        }
      };
@@ -129,7 +129,7 @@
      } catch (ConfigurationException expected) {
        assertContains(expected.getMessage(),
            "1) Illegal scoped dependency: " + Shirt.class.getName() + " in  
@Annually",
-          "  depends on " + SleeveLenth.class.getName() + " in  
@Seasonally");
+          "  depends on " + SleeveLength.class.getName() + " in  
@Seasonally");
      }
    }

@@ -160,7 +160,7 @@
      } catch (ConfigurationException expected) {
        assertContains(expected.getMessage(),
            "1) Illegal scoped dependency: " + Shirt.class.getName() + " in  
@Annually",
-          "  depends on " + SleeveLenth.class.getName(),
+          "  depends on " + SleeveLength.class.getName(),
            "  depends on " + Style.class.getName() + " in @Seasonally");
      }
    }

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

Reply via email to