[weld-commits] Weld SVN: r5538 - in core/trunk/tests/src/test: java/org/jboss/weld/tests/decorators/interceptor and 2 other directories.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Wed Jan 20 16:23:52 EST 2010
Author: marius.bogoevici
Date: 2010-01-20 16:23:51 -0500 (Wed, 20 Jan 2010)
New Revision: 5538
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/Intercepted.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/InterceptorAndDecoratorTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/Service.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceDecorator.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceImpl.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceInterceptor.java
core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/interceptor/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/interceptor/beans.xml
Log:
Tests for WELD-314
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/Intercepted.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/Intercepted.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/Intercepted.java 2010-01-20 21:23:51 UTC (rev 5538)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright2010, 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.weld.tests.decorators.interceptor;
+
+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;
+
+import javax.interceptor.InterceptorBinding;
+
+ at Inherited
+ at InterceptorBinding
+ at Target({ElementType.TYPE, ElementType.METHOD})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Intercepted
+{
+}
Copied: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/InterceptorAndDecoratorTest.java (from rev 5529, core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/stackoverflow/StackOverFlowTest.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/InterceptorAndDecoratorTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/InterceptorAndDecoratorTest.java 2010-01-20 21:23:51 UTC (rev 5538)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright2010, 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.weld.tests.decorators.interceptor;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.weld.test.AbstractWeldTest;
+
+import org.testng.annotations.Test;
+
+ at Artifact
+ at BeansXml("beans.xml")
+public class InterceptorAndDecoratorTest extends AbstractWeldTest
+{
+
+ @Test(description="WELD-314", groups = "broken")
+ public void test()
+ {
+ ServiceImpl.invocationCount = 0;
+ ServiceDecorator.invocationCount = 0;
+ ServiceInterceptor.invocationCount = 0;
+ getReference(Service.class).execute();
+ assert ServiceImpl.invocationCount == 1;
+ assert ServiceDecorator.invocationCount == 1;
+ assert ServiceInterceptor.invocationCount == 1;
+ }
+
+}
\ No newline at end of file
Copied: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/Service.java (from rev 5529, core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/stackoverflow/PaymentService.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/Service.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/Service.java 2010-01-20 21:23:51 UTC (rev 5538)
@@ -0,0 +1,23 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright2010, 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.weld.tests.decorators.interceptor;
+
+public interface Service
+{
+ void execute();
+}
\ No newline at end of file
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/Service.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceDecorator.java (from rev 5529, core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/stackoverflow/SecurePaymentService.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceDecorator.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceDecorator.java 2010-01-20 21:23:51 UTC (rev 5538)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright2010, 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.
+ */
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.jboss.weld.tests.decorators.interceptor;
+
+import java.math.BigDecimal;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ * Secure PaymentService implemented by decator
+ *
+ * @author wayne
+ */
+ at Decorator
+class ServiceDecorator implements Service
+{
+
+ @Inject
+ @Delegate
+ private Service service;
+
+ public static int invocationCount = 0;
+
+ public void execute()
+ {
+ invocationCount++;
+ service.execute();
+ }
+}
\ No newline at end of file
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceDecorator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceImpl.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceImpl.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceImpl.java 2010-01-20 21:23:51 UTC (rev 5538)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright2010, 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.weld.tests.decorators.interceptor;
+
+public class ServiceImpl implements Service
+{
+
+ public static int invocationCount = 0;
+
+ @Intercepted
+ public void execute()
+ {
+ invocationCount ++;
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceInterceptor.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceInterceptor.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/interceptor/ServiceInterceptor.java 2010-01-20 21:23:51 UTC (rev 5538)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.weld.tests.decorators.interceptor;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+ at Intercepted @Interceptor
+public class ServiceInterceptor
+{
+
+ public static int invocationCount = 0;
+
+ @AroundInvoke
+ public Object interceptService(InvocationContext invocationContext) throws Exception
+ {
+ this.invocationCount++;
+ return invocationContext.proceed();
+ }
+
+}
Copied: core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/interceptor/beans.xml (from rev 5529, core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/stackoverflow/beans.xml)
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/interceptor/beans.xml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/interceptor/beans.xml 2010-01-20 21:23:51 UTC (rev 5538)
@@ -0,0 +1,8 @@
+<beans>
+ <decorators>
+ <class>org.jboss.weld.tests.decorators.interceptor.ServiceDecorator</class>
+ </decorators>
+ <interceptors>
+ <class>org.jboss.weld.tests.decorators.interceptor.ServiceInterceptor</class>
+ </interceptors>
+</beans>
\ No newline at end of file
More information about the weld-commits
mailing list