minor cleanups of r1195 - put tests in existing OverrideModuleTest class, bind with a binder that has the PrivateElement's source.

git-svn-id: https://google-guice.googlecode.com/svn/trunk@1196 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/src/com/google/inject/util/Modules.java b/src/com/google/inject/util/Modules.java
index 7846c9a..bc1215f 100644
--- a/src/com/google/inject/util/Modules.java
+++ b/src/com/google/inject/util/Modules.java
@@ -183,9 +183,10 @@
         @Override
         public void configure() {
           PrivateElements privateElements = (PrivateElements)Iterables.getOnlyElement(Elements.getElements(baseModule));
-          override(Elements.getModule(privateElements.getElements())).with(overrides).configure(binder());
+          PrivateBinder binder = binder().withSource(privateElements.getSource());
+          override(Elements.getModule(privateElements.getElements())).with(overrides).configure(binder);
           for(Key exposed : privateElements.getExposedKeys()) {
-            binder().withSource(privateElements.getExposedSource(exposed)).expose(exposed);
+            binder.withSource(privateElements.getExposedSource(exposed)).expose(exposed);
           }
         }
       };
diff --git a/test/com/google/inject/ModulesTest.java b/test/com/google/inject/ModulesTest.java
index a3dd97a..fcf8f9c 100644
--- a/test/com/google/inject/ModulesTest.java
+++ b/test/com/google/inject/ModulesTest.java
@@ -16,9 +16,6 @@
 
 package com.google.inject;
 
-import static com.google.inject.name.Names.named;
-
-import com.google.inject.name.Named;
 import com.google.inject.util.Modules;
 import java.util.Arrays;
 import junit.framework.TestCase;
@@ -67,49 +64,4 @@
       }
     };
   }
-  
-  private static final String RESULT = "RESULT";
-  private static final String PRIVATE_INPUT = "PRIVATE_INPUT";
-  private static final String OVERRIDDEN_INPUT = "FOO";
-  private static final String OVERRIDDEN_RESULT = "Size: 3";
-  private static final Key<String> RESULT_KEY = Key.get(String.class, named(RESULT));
-  private static final Key<String> INPUT_KEY = Key.get(String.class, named(PRIVATE_INPUT));
-
-
-  public void testExposedBindingOverride() throws Exception {
-    Injector inj = Guice.createInjector(
-        Modules.override(new ExampleModule()).with(
-            new AbstractModule() {
-              @Override protected void configure() {
-                bind(RESULT_KEY).toInstance(OVERRIDDEN_RESULT);
-              }
-            }));
-    assertEquals(inj.getInstance(RESULT_KEY), OVERRIDDEN_RESULT);
-  }
-
-  public void testPrivateBindingOverride() throws Exception {
-    Injector inj = Guice.createInjector(
-        Modules.override(new ExampleModule()).with(
-            new AbstractModule() {
-              @Override protected void configure() {
-                bind(INPUT_KEY).toInstance(OVERRIDDEN_INPUT);
-              }
-            }));
-    assertEquals(inj.getInstance(RESULT_KEY), OVERRIDDEN_RESULT);
-  }
-
-  public static class ExampleModule extends PrivateModule {
-    @Provides @Exposed @Named(RESULT)
-    public String provideResult(@Named(PRIVATE_INPUT) String input) {
-      return "Size: " + input.length();
-    }
-
-    @Provides @Named(PRIVATE_INPUT)
-    public String provideInput() {
-      return "Hello World";
-    }
-
-    @Override protected void configure() {
-    }
-  }  
 }
diff --git a/test/com/google/inject/OverrideModuleTest.java b/test/com/google/inject/OverrideModuleTest.java
index 9ce3020..f530ed0 100644
--- a/test/com/google/inject/OverrideModuleTest.java
+++ b/test/com/google/inject/OverrideModuleTest.java
@@ -19,6 +19,8 @@
 import static com.google.inject.Asserts.assertContains;
 import static com.google.inject.Guice.createInjector;
 import static com.google.inject.name.Names.named;
+
+import com.google.inject.name.Named;
 import com.google.inject.util.Modules;
 import static java.lang.annotation.ElementType.TYPE;
 import java.lang.annotation.Retention;
@@ -463,4 +465,48 @@
       }
     };
   }
+  
+  private static final String RESULT = "RESULT";
+  private static final String PRIVATE_INPUT = "PRIVATE_INPUT";
+  private static final String OVERRIDDEN_INPUT = "FOO";
+  private static final String OVERRIDDEN_RESULT = "Size: 3";
+  private static final Key<String> RESULT_KEY = Key.get(String.class, named(RESULT));
+  private static final Key<String> INPUT_KEY = Key.get(String.class, named(PRIVATE_INPUT));
+
+  public void testExposedBindingOverride() throws Exception {
+    Injector inj = Guice.createInjector(
+        Modules.override(new ExampleModule()).with(
+            new AbstractModule() {
+              @Override protected void configure() {
+                bind(RESULT_KEY).toInstance(OVERRIDDEN_RESULT);
+              }
+            }));
+    assertEquals(inj.getInstance(RESULT_KEY), OVERRIDDEN_RESULT);
+  }
+
+  public void testPrivateBindingOverride() throws Exception {
+    Injector inj = Guice.createInjector(
+        Modules.override(new ExampleModule()).with(
+            new AbstractModule() {
+              @Override protected void configure() {
+                bind(INPUT_KEY).toInstance(OVERRIDDEN_INPUT);
+              }
+            }));
+    assertEquals(inj.getInstance(RESULT_KEY), OVERRIDDEN_RESULT);
+  }
+
+  public static class ExampleModule extends PrivateModule {
+    @Provides @Exposed @Named(RESULT)
+    public String provideResult(@Named(PRIVATE_INPUT) String input) {
+      return "Size: " + input.length();
+    }
+
+    @Provides @Named(PRIVATE_INPUT)
+    public String provideInput() {
+      return "Hello World";
+    }
+
+    @Override protected void configure() {
+    }
+  }  
 }