specify that interceptors are called in the order they are listed in bindInterceptor(Matcher, Matcher, Interceptor...).  add a test that guarantees it.

git-svn-id: https://google-guice.googlecode.com/svn/trunk@1542 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/core/src/com/google/inject/Binder.java b/core/src/com/google/inject/Binder.java
index a96addd..2780957 100644
--- a/core/src/com/google/inject/Binder.java
+++ b/core/src/com/google/inject/Binder.java
@@ -216,7 +216,8 @@
    *     example: {@code only(Runnable.class)}.
    * @param methodMatcher matches methods the interceptor should apply to. For
    *     example: {@code annotatedWith(Transactional.class)}.
-   * @param interceptors to bind
+   * @param interceptors to bind.  The interceptors are called in the order they
+   *     are given.
    */
   void bindInterceptor(Matcher<? super Class<?>> classMatcher,
       Matcher<? super Method> methodMatcher,
diff --git a/core/test/com/google/inject/MethodInterceptionTest.java b/core/test/com/google/inject/MethodInterceptionTest.java
index 3f27683..30fa574 100644
--- a/core/test/com/google/inject/MethodInterceptionTest.java
+++ b/core/test/com/google/inject/MethodInterceptionTest.java
@@ -19,6 +19,7 @@
 import com.google.inject.internal.util.ImmutableList;
 import com.google.inject.internal.util.ImmutableMap;
 import com.google.inject.internal.util.Iterables;
+import com.google.inject.internal.util.Lists;
 import com.google.inject.matcher.AbstractMatcher;
 import com.google.inject.matcher.Matchers;
 import static com.google.inject.matcher.Matchers.only;
@@ -264,5 +265,38 @@
       RetType aMethod(RetType obj);
   }
   public static class Impl extends Superclass<RetType> implements Interface {
-  }  
+  }
+  
+  public void testInterceptionOrder() {
+    final List<String> callList = Lists.newArrayList();
+    Injector injector = Guice.createInjector(new AbstractModule() {
+      protected void configure() {
+        bindInterceptor(Matchers.any(), Matchers.any(), 
+          new NamedInterceptor("a", callList),
+          new NamedInterceptor("b", callList),
+          new NamedInterceptor("c", callList));
+      }
+    });
+
+    Interceptable interceptable = injector.getInstance(Interceptable.class);
+    assertEquals(0, callList.size());
+    interceptable.foo();
+    assertEquals(Arrays.asList("a", "b", "c"), callList);
+  }
+  
+  private final class NamedInterceptor implements MethodInterceptor {
+    private final String name;
+    final List<String> called;
+    
+    NamedInterceptor(String name, List<String> callList) {
+      this.name = name;
+      this.called = callList;
+    }
+    
+    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
+      called.add(name);
+      return methodInvocation.proceed();
+    }
+  }
+  
 }