Author: limpbizkit
Date: Sat Dec 27 17:58:57 2008
New Revision: 746
Modified:
trunk/test/com/google/inject/MethodInterceptionTest.java
Log:
Tests for bug 281. We didn't have coverage for getThis().
Modified: trunk/test/com/google/inject/MethodInterceptionTest.java
==============================================================================
--- trunk/test/com/google/inject/MethodInterceptionTest.java (original)
+++ trunk/test/com/google/inject/MethodInterceptionTest.java Sat Dec 27
17:58:57 2008
@@ -17,6 +17,7 @@
package com.google.inject;
import com.google.inject.matcher.Matchers;
+import java.util.concurrent.atomic.AtomicReference;
import junit.framework.TestCase;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
@@ -64,6 +65,25 @@
assertSame("Child injectors should share proxy classes, otherwise
memory leaks!",
nullFoos.getClass(), bothNull.getClass());
+ }
+
+ public void testGetThis() {
+ final AtomicReference<Object> lastTarget = new
AtomicReference<Object>();
+
+ Injector injector = Guice.createInjector(new AbstractModule() {
+ protected void configure() {
+ bindInterceptor(Matchers.any(), Matchers.any(), new
MethodInterceptor() {
+ public Object invoke(MethodInvocation methodInvocation) throws
Throwable {
+ lastTarget.set(methodInvocation.getThis());
+ return methodInvocation.proceed();
+ }
+ });
+ }
+ });
+
+ Interceptable interceptable =
injector.getInstance(Interceptable.class);
+ interceptable.foo();
+ assertSame(interceptable, lastTarget.get());
}
static class Foo {}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---