[weld-commits] Weld SVN: r6876 - in core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators: genericobserver and 1 other directory.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Tue Aug 3 06:51:24 EDT 2010
Author: aslak
Date: 2010-08-03 06:51:24 -0400 (Tue, 03 Aug 2010)
New Revision: 6876
Added:
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/DecorateGenericObserverTest.java
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/Dog.java
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/Service.java
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/ServiceDecorator.java
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/ServiceImpl.java
Log:
WELD-579 Test case to expose error, marked as Broken
Added: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/DecorateGenericObserverTest.java
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/DecorateGenericObserverTest.java (rev 0)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/DecorateGenericObserverTest.java 2010-08-03 10:51:24 UTC (rev 6876)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.genericobserver;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+
+import org.jboss.arquillian.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.tests.category.Broken;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+/**
+ *
+ * 5.5.6: "Invoke the observer method on the resulting instance, if any, as a business method invocation,
+ * as defined in Section 7.2, “Container invocations and interception”.
+ *
+ * 7.2 : "Invocations of producer, disposer and observer methods by the container are business method invocations
+ * and are intercepted by method interceptors and decorators."
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ *
+ */
+ at RunWith(Arquillian.class)
+public class DecorateGenericObserverTest
+{
+ @Deployment
+ public static Archive<?> deploy()
+ {
+ return ShrinkWrap.create(BeanArchive.class)
+ .decorate(ServiceDecorator.class)
+ .addPackage(DecorateGenericObserverTest.class.getPackage());
+ }
+
+ @Inject
+ private Event<Dog> dogEvent;
+
+ /*
+ * description = "WELD-579"
+ */
+ @Category(Broken.class)
+ @Test
+ public void shouldInvokeDecoratorsWhenObservingGenericEvents()
+ {
+ ServiceImpl.invocationCount = 0;
+ ServiceDecorator.invocationCount = 0;
+
+ dogEvent.fire(new Dog());
+
+ Assert.assertEquals(1, ServiceImpl.invocationCount);
+ Assert.assertEquals(1, ServiceDecorator.invocationCount);
+ }
+}
\ No newline at end of file
Added: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/Dog.java
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/Dog.java (rev 0)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/Dog.java 2010-08-03 10:51:24 UTC (rev 6876)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.genericobserver;
+
+/**
+ * Dog
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class Dog {
+
+}
Added: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/Service.java
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/Service.java (rev 0)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/Service.java 2010-08-03 10:51:24 UTC (rev 6876)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.genericobserver;
+
+/**
+ * Service
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ * @param <T>
+ */
+public interface Service<T>
+{
+ void on(T dog);
+}
\ No newline at end of file
Added: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/ServiceDecorator.java
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/ServiceDecorator.java (rev 0)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/ServiceDecorator.java 2010-08-03 10:51:24 UTC (rev 6876)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.genericobserver;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ * ServiceDecorator
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at Decorator
+public class ServiceDecorator implements Service<Dog>
+{
+ @Inject @Delegate
+ private Service<Dog> service;
+
+ public static int invocationCount = 0;
+
+ public void on(Dog dog)
+ {
+ invocationCount++;
+ service.on(dog);
+ }
+}
\ No newline at end of file
Added: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/ServiceImpl.java
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/ServiceImpl.java (rev 0)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/genericobserver/ServiceImpl.java 2010-08-03 10:51:24 UTC (rev 6876)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.genericobserver;
+
+import javax.enterprise.event.Observes;
+
+/**
+ * ServiceImpl
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class ServiceImpl implements Service<Dog>
+{
+ public static int invocationCount = 0;
+
+ public void on(@Observes Dog dog)
+ {
+ invocationCount++;
+ }
+}
\ No newline at end of file
More information about the weld-commits
mailing list