Return-Path: X-Original-To: apmail-deltaspike-commits-archive@www.apache.org Delivered-To: apmail-deltaspike-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 512EC17812 for ; Wed, 8 Oct 2014 08:22:00 +0000 (UTC) Received: (qmail 71300 invoked by uid 500); 8 Oct 2014 08:22:00 -0000 Delivered-To: apmail-deltaspike-commits-archive@deltaspike.apache.org Received: (qmail 71265 invoked by uid 500); 8 Oct 2014 08:22:00 -0000 Mailing-List: contact commits-help@deltaspike.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltaspike.apache.org Delivered-To: mailing list commits@deltaspike.apache.org Received: (qmail 71247 invoked by uid 99); 8 Oct 2014 08:22:00 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Oct 2014 08:22:00 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id E08C1906E05; Wed, 8 Oct 2014 08:21:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: gpetracek@apache.org To: commits@deltaspike.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: DELTASPIKE-736 added interceptor test Date: Wed, 8 Oct 2014 08:21:59 +0000 (UTC) Repository: deltaspike Updated Branches: refs/heads/master 13330996c -> 5abca5e88 DELTASPIKE-736 added interceptor test Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/5abca5e8 Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/5abca5e8 Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/5abca5e8 Branch: refs/heads/master Commit: 5abca5e887efbd927bd0a5fe42bf2d3b948e7d8a Parents: 1333099 Author: gpetracek Authored: Wed Oct 8 10:17:32 2014 +0200 Committer: gpetracek Committed: Wed Oct 8 10:21:27 2014 +0200 ---------------------------------------------------------------------- .../uc011/InterceptedBeanClassLevel.java | 31 ++++++++++ .../uc011/InterceptedBeanMethodLevel.java | 31 ++++++++++ .../testcontrol/uc011/InterceptedBeanTest.java | 62 ++++++++++++++++++++ .../uc011/InterceptionResultStorage.java | 37 ++++++++++++ .../test/testcontrol/uc011/TestInterceptor.java | 35 +++++++++++ .../uc011/TestInterceptorImplementation.java | 40 +++++++++++++ .../impl/src/test/resources/META-INF/beans.xml | 3 + 7 files changed, 239 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/5abca5e8/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptedBeanClassLevel.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptedBeanClassLevel.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptedBeanClassLevel.java new file mode 100644 index 0000000..c5a2ebc --- /dev/null +++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptedBeanClassLevel.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol.uc011; + +import javax.enterprise.context.RequestScoped; + +@RequestScoped +@TestInterceptor +public class InterceptedBeanClassLevel +{ + public void test() + { + //do nothing - any method is fine + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/5abca5e8/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptedBeanMethodLevel.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptedBeanMethodLevel.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptedBeanMethodLevel.java new file mode 100644 index 0000000..2f86158 --- /dev/null +++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptedBeanMethodLevel.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol.uc011; + +import javax.enterprise.context.RequestScoped; + +@RequestScoped +public class InterceptedBeanMethodLevel +{ + @TestInterceptor + public void test() + { + //do nothing - any method is fine + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/5abca5e8/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptedBeanTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptedBeanTest.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptedBeanTest.java new file mode 100644 index 0000000..4c7193c --- /dev/null +++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptedBeanTest.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol.uc011; + +import org.apache.deltaspike.test.category.SeCategory; +import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner; +import org.junit.Assert; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +import javax.inject.Inject; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Category(SeCategory.class) + + + +@RunWith(CdiTestRunner.class) +public class InterceptedBeanTest +{ + @Inject + private InterceptionResultStorage interceptionResultStorage; + + @Inject + private InterceptedBeanClassLevel interceptedBeanClassLevel; + + @Inject + private InterceptedBeanMethodLevel interceptedBeanMethodLevel; + + @Test + public void classLevelInterception() + { + Assert.assertFalse(this.interceptionResultStorage.isInterceptionDetected()); + this.interceptedBeanClassLevel.test(); + Assert.assertTrue(this.interceptionResultStorage.isInterceptionDetected()); + } + + @Test + public void methodLevelInterception() + { + Assert.assertFalse(this.interceptionResultStorage.isInterceptionDetected()); + this.interceptedBeanMethodLevel.test(); + Assert.assertTrue(this.interceptionResultStorage.isInterceptionDetected()); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/5abca5e8/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptionResultStorage.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptionResultStorage.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptionResultStorage.java new file mode 100644 index 0000000..2a3f9d3 --- /dev/null +++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/InterceptionResultStorage.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol.uc011; + +import javax.enterprise.context.RequestScoped; + +@RequestScoped +public class InterceptionResultStorage +{ + private boolean intercepted; + + public void markAsIntercepted() + { + this.intercepted = true; + } + + public boolean isInterceptionDetected() + { + return intercepted; + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/5abca5e8/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/TestInterceptor.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/TestInterceptor.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/TestInterceptor.java new file mode 100644 index 0000000..69a6dd9 --- /dev/null +++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/TestInterceptor.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol.uc011; + +import javax.interceptor.InterceptorBinding; +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 + +@Target({ METHOD, TYPE }) +@Retention(RUNTIME) +public @interface TestInterceptor +{ +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/5abca5e8/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/TestInterceptorImplementation.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/TestInterceptorImplementation.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/TestInterceptorImplementation.java new file mode 100644 index 0000000..8964d2a --- /dev/null +++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc011/TestInterceptorImplementation.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol.uc011; + +import javax.inject.Inject; +import javax.interceptor.AroundInvoke; +import javax.interceptor.Interceptor; +import javax.interceptor.InvocationContext; +import java.io.Serializable; + +@TestInterceptor +@Interceptor +public class TestInterceptorImplementation implements Serializable +{ + @Inject + private InterceptionResultStorage interceptionResultStorage; + + @AroundInvoke + public Object intercept(InvocationContext ctx) throws Exception + { + this.interceptionResultStorage.markAsIntercepted(); + return ctx.proceed(); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/5abca5e8/deltaspike/modules/test-control/impl/src/test/resources/META-INF/beans.xml ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/resources/META-INF/beans.xml b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/beans.xml index 4070730..4686946 100644 --- a/deltaspike/modules/test-control/impl/src/test/resources/META-INF/beans.xml +++ b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/beans.xml @@ -20,4 +20,7 @@ + + org.apache.deltaspike.test.testcontrol.uc011.TestInterceptorImplementation +