-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...arquillian/src/test/java/org/jboss/weld/tests/interceptors/bridgemethods/BaseService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.jboss.weld.tests.interceptors.bridgemethods; | ||
|
||
/** | ||
* | ||
*/ | ||
public interface BaseService<T> { | ||
public void doSomething(T param); | ||
} |
51 changes: 51 additions & 0 deletions
51
...llian/src/test/java/org/jboss/weld/tests/interceptors/bridgemethods/BridgeMethodTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.jboss.weld.tests.interceptors.bridgemethods; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.BeanArchive; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.weld.test.util.Utils; | ||
import org.jboss.weld.tests.category.Integration; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.junit.runner.RunWith; | ||
|
||
import javax.ejb.EJB; | ||
import javax.inject.Inject; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
@Category(Integration.class) | ||
@RunWith(Arquillian.class) | ||
public class BridgeMethodTest { | ||
|
||
@Deployment | ||
public static Archive<?> deploy() { | ||
return ShrinkWrap.create(BeanArchive.class) | ||
.intercept(SomeInterceptor.class) | ||
.addPackage(BridgeMethodTest.class.getPackage()) | ||
.addClass(Utils.class); | ||
} | ||
|
||
@Inject | ||
private SpecialService specialService; | ||
|
||
@Before | ||
public void setUp() { | ||
SomeInterceptor.invocationCount = 0; | ||
} | ||
|
||
@Test | ||
public void testBridgeMethodInterceptor() { | ||
specialService.doSomething("foo"); | ||
assertEquals(1, SomeInterceptor.invocationCount); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...illian/src/test/java/org/jboss/weld/tests/interceptors/bridgemethods/SomeInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.jboss.weld.tests.interceptors.bridgemethods; | ||
|
||
import javax.interceptor.AroundInvoke; | ||
import javax.interceptor.Interceptor; | ||
import javax.interceptor.InvocationContext; | ||
|
||
/** | ||
* | ||
*/ | ||
@Interceptor | ||
@SomeInterceptorBinding | ||
public class SomeInterceptor { | ||
|
||
public static int invocationCount; | ||
|
||
@AroundInvoke | ||
public Object intercept(InvocationContext invocationContext) throws Exception { | ||
invocationCount++; | ||
System.out.println("invocationContext = " + invocationContext); | ||
System.out.println("invocationContext.getMethod() = " + invocationContext.getMethod()); | ||
return invocationContext.proceed(); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...src/test/java/org/jboss/weld/tests/interceptors/bridgemethods/SomeInterceptorBinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.jboss.weld.tests.interceptors.bridgemethods; | ||
|
||
import javax.interceptor.InterceptorBinding; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
/** | ||
* | ||
*/ | ||
@InterceptorBinding | ||
@Inherited | ||
@Target({ TYPE, METHOD }) | ||
@Retention(RUNTIME) | ||
public @interface SomeInterceptorBinding { | ||
} |
7 changes: 7 additions & 0 deletions
7
...uillian/src/test/java/org/jboss/weld/tests/interceptors/bridgemethods/SpecialService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.jboss.weld.tests.interceptors.bridgemethods; | ||
|
||
/** | ||
* | ||
*/ | ||
public interface SpecialService extends BaseService<String> { | ||
} |
17 changes: 17 additions & 0 deletions
17
...ian/src/test/java/org/jboss/weld/tests/interceptors/bridgemethods/SpecialServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.jboss.weld.tests.interceptors.bridgemethods; | ||
|
||
import javax.ejb.Local; | ||
import javax.ejb.Stateless; | ||
|
||
/** | ||
* | ||
*/ | ||
@Stateless | ||
@Local(SpecialService.class) | ||
@SomeInterceptorBinding | ||
public class SpecialServiceImpl implements SpecialService { | ||
|
||
public void doSomething(String param) { | ||
System.out.println("SpecialServiceImpl.doSomething"); | ||
} | ||
} |