Skip to content

Commit

Permalink
Added test for WELD-1162
Browse files Browse the repository at this point in the history
  • Loading branch information
luksa committed Sep 7, 2012
1 parent 7564e40 commit 16604c5
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 0 deletions.
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);
}
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);
}

}
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();
}

}
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 {
}
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> {
}
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");
}
}

0 comments on commit 16604c5

Please sign in to comment.