Author: marius.bogoevici
Date: 2009-10-05 19:01:36 -0400 (Mon, 05 Oct 2009)
New Revision: 3861
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Ball.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/BallImpl.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Defender.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTests.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Goalkeeper.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Pass.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Shot.java
ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/interceptor/ejb/
ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/interceptor/ejb/beans.xml
Log:
Testing interceptor metadata discovery to SessionBeans.
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Ball.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Ball.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Ball.java 2009-10-05
23:01:36 UTC (rev 3861)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.webbeans.test.unit.interceptor.ejb;
+
+import javax.ejb.Local;
+
+/**
+ * @author Marius Bogoevici
+ */
+@Local
+public interface Ball
+{
+
+ void shoot();
+
+ void pass();
+}
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/BallImpl.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/BallImpl.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/BallImpl.java 2009-10-05
23:01:36 UTC (rev 3861)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.webbeans.test.unit.interceptor.ejb;
+
+import javax.ejb.Stateless;
+
+/**
+ * @author <a href="mailto:mariusb@redhat.com">Marius
Bogoevici</a>
+ */
+@Stateless
+public class BallImpl implements Ball
+{
+ @Shot
+ public void shoot()
+ {
+ }
+
+ @Pass
+ public void pass()
+ {
+ }
+}
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Defender.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Defender.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Defender.java 2009-10-05
23:01:36 UTC (rev 3861)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.webbeans.test.unit.interceptor.ejb;
+
+import javax.interceptor.Interceptor;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author <a href="mailto:mariusb@redhat.com">Marius
Bogoevici</a>
+ */
+@Pass @Interceptor
+public class Defender
+{
+ @AroundInvoke
+ public Object defend(InvocationContext context) throws Exception
+ {
+ return context.proceed();
+ }
+}
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTests.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTests.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTests.java 2009-10-05
23:01:36 UTC (rev 3861)
@@ -0,0 +1,45 @@
+package org.jboss.webbeans.test.unit.interceptor.ejb;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.inject.spi.Interceptor;
+
+import org.jboss.interceptor.model.InterceptionModel;
+import static org.jboss.interceptor.model.InterceptionType.AROUND_INVOKE;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.webbeans.bean.SessionBean;
+import org.jboss.webbeans.test.AbstractWebBeansTest;
+
+import org.testng.annotations.Test;
+
+@Artifact
+(a)Packaging(PackagingType.EAR)
+(a)BeansXml("beans.xml")
+public class EnterpriseBeanInterceptionTests extends AbstractWebBeansTest
+{
+
+ @Test(groups = { "interceptors"})
+ public void testEnterpriseBeanInterceptionMetadataAdded() throws Exception
+ {
+ SessionBean<Ball> ballSessionBean =
(SessionBean<Ball>)getCurrentManager().getBeans(Ball.class).iterator().next();
+ InterceptionModel<Class<?>, Interceptor> interceptionModel =
getCurrentManager().getBoundInterceptorsRegistry().getInterceptionModel(ballSessionBean.getType());
+ List<javax.enterprise.inject.spi.Interceptor> interceptors =
+ new
ArrayList<javax.enterprise.inject.spi.Interceptor>(interceptionModel.getAllInterceptors());
+
+ assert interceptors.size() == 2;
+ assert interceptors.get(0).getBeanClass().equals(Goalkeeper.class);
+ assert interceptors.get(1).getBeanClass().equals(Defender.class);
+
+ assert interceptionModel.getInterceptors(AROUND_INVOKE,
ballSessionBean.getType().getMethod("shoot")).size() == 1;
+ assert interceptionModel.getInterceptors(AROUND_INVOKE,
ballSessionBean.getType().getMethod("shoot")).get(0).getBeanClass().equals(Goalkeeper.class);
+
+ assert interceptionModel.getInterceptors(AROUND_INVOKE,
ballSessionBean.getType().getMethod("pass")).size() == 1;
+ assert interceptionModel.getInterceptors(AROUND_INVOKE,
ballSessionBean.getType().getMethod("pass")).get(0).getBeanClass().equals(Defender.class);
+
+ }
+
+}
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Goalkeeper.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Goalkeeper.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Goalkeeper.java 2009-10-05
23:01:36 UTC (rev 3861)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.webbeans.test.unit.interceptor.ejb;
+
+import javax.interceptor.Interceptor;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author <a href="mailto:mariusb@redhat.com">Marius
Bogoevici</a>
+ */
+@Shot @Interceptor
+public class Goalkeeper
+{
+
+ @AroundInvoke
+ public Object catchBall(InvocationContext invocationContext) throws Exception
+ {
+ return invocationContext.proceed();
+ }
+}
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Pass.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Pass.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Pass.java 2009-10-05
23:01:36 UTC (rev 3861)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.webbeans.test.unit.interceptor.ejb;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * @author <a href="mailto:mariusb@redhat.com">Marius
Bogoevici</a>
+ */
+@InterceptorBinding
+@Retention(RUNTIME)
+(a)Target({ElementType.METHOD, ElementType.TYPE})
+@Documented
+public @interface Pass
+{
+}
\ No newline at end of file
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Shot.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Shot.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/interceptor/ejb/Shot.java 2009-10-05
23:01:36 UTC (rev 3861)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.webbeans.test.unit.interceptor.ejb;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * @author <a href="mailto:mariusb@redhat.com">Marius
Bogoevici</a>
+ */
+@InterceptorBinding
+@Retention(RUNTIME)
+(a)Target({ElementType.METHOD, ElementType.TYPE})
+@Documented
+public @interface Shot
+{
+}
Added:
ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/interceptor/ejb/beans.xml
===================================================================
---
ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/interceptor/ejb/beans.xml
(rev 0)
+++
ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/interceptor/ejb/beans.xml 2009-10-05
23:01:36 UTC (rev 3861)
@@ -0,0 +1,6 @@
+<beans>
+ <interceptors>
+ <class>org.jboss.webbeans.test.unit.interceptor.ejb.Goalkeeper</class>
+ <class>org.jboss.webbeans.test.unit.interceptor.ejb.Defender</class>
+ </interceptors>
+</beans>