Skip to content

Commit

Permalink
Merge remote-tracking branch 'luksa_https/weld894' into luksa_20120305
Browse files Browse the repository at this point in the history
  • Loading branch information
alesj committed Mar 5, 2012
2 parents a1541aa + 52d474e commit adc4dd0
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 0 deletions.
2 changes: 2 additions & 0 deletions impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java
Expand Up @@ -88,6 +88,8 @@ public Object intercept(InterceptionType type, T instance, InvocationContext ctx
Collection<InterceptorInvocation<?>> invocations = new ArrayList<InterceptorInvocation<?>>();
invocations.add(new InterceptorInvocation<T>(instance, interceptorMetadata, interceptionType));
return new SimpleInterceptionChain(invocations, instance, ctx.getMethod()).invokeNextInterceptor(ctx);
} catch (RuntimeException e) {
throw e;
} catch (Throwable e) {
throw new WeldException(e);
}
Expand Down
@@ -0,0 +1,19 @@
package org.jboss.weld.tests.interceptors.exceptions;

import org.jboss.weld.exceptions.WeldException;

/**
*
*/
@FooBinding
public class Foo {

public void throwCheckedException() throws FooCheckedException {
throw new FooCheckedException();
}

public void throwUncheckedException() throws FooUncheckedException {
throw new FooUncheckedException();
}

}
@@ -0,0 +1,18 @@
package org.jboss.weld.tests.interceptors.exceptions;

import javax.interceptor.InterceptorBinding;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
*
*/
@Inherited
@InterceptorBinding
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface FooBinding {
}
@@ -0,0 +1,7 @@
package org.jboss.weld.tests.interceptors.exceptions;

/**
*
*/
public class FooCheckedException extends Exception {
}
@@ -0,0 +1,7 @@
package org.jboss.weld.tests.interceptors.exceptions;

/**
*
*/
public class FooUncheckedException extends RuntimeException {
}
@@ -0,0 +1,32 @@
package org.jboss.weld.tests.interceptors.exceptions;

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.junit.Test;
import org.junit.runner.RunWith;

/**
* author Marko Luksa
*/
@RunWith(Arquillian.class)
public class InterceptorExceptionWrappingTest {
@Deployment
public static Archive<?> deploy() {
return ShrinkWrap.create(BeanArchive.class)
.intercept(MyInterceptor.class)
.addPackage(InterceptorExceptionWrappingTest.class.getPackage());
}

@Test(expected = FooCheckedException.class)
public void testCheckedExceptionIsNotWrapped(Foo foo) throws Exception {
foo.throwCheckedException();
}

@Test(expected = FooUncheckedException.class)
public void testUncheckedExceptionIsNotWrapped(Foo foo) throws Exception {
foo.throwUncheckedException();
}
}
@@ -0,0 +1,19 @@
package org.jboss.weld.tests.interceptors.exceptions;

import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;

/**
*
*/
@Interceptor
@FooBinding
public class MyInterceptor {

@AroundInvoke
public Object aroundInvoke(final InvocationContext invocation) throws Exception {
return invocation.proceed();
}

}

0 comments on commit adc4dd0

Please sign in to comment.