Weld SVN: r6877 - in core/trunk/tests/src/test: java/org/jboss/weld/tests/interceptors/invalidContract and 2 other directories.
by weld-commits@lists.jboss.org
Author: aslak
Date: 2010-08-03 08:13:00 -0400 (Tue, 03 Aug 2010)
New Revision: 6877
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/
core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/Intercept.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NoArgInterceptor.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NoArgInterceptorInvalidContractTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NotThrowingExceptionInterceptor.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NotThrowingExceptionInterceptorInvalidContractTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/Service.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/ServiceImpl.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/VoidInterceptor.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/VoidInterceptorInvalidContractTest.java
core/trunk/tests/src/test/resources/org/jboss/weld/tests/interceptors/invalidContract/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/interceptors/invalidContract/beans.xml
Log:
WELD-580 Added test cases for AroundInvoke interceptor contract
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/Intercept.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/Intercept.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/Intercept.java 2010-08-03 12:13:00 UTC (rev 6877)
@@ -0,0 +1,37 @@
+/*
+ * 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.interceptors.invalidContract;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * Intercept
+ *
+ * @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+@InterceptorBinding
+(a)Target({ElementType.TYPE, ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface Intercept {
+
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NoArgInterceptor.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NoArgInterceptor.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NoArgInterceptor.java 2010-08-03 12:13:00 UTC (rev 6877)
@@ -0,0 +1,36 @@
+/*
+ * 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.interceptors.invalidContract;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+
+/**
+ * By Contract this method should take InvocationContext as a argument, no arguments should result in DefinitionException
+ *
+ * @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+@Intercept @Interceptor
+public class NoArgInterceptor
+{
+ @AroundInvoke
+ public Object intercept() throws Exception
+ {
+ return null;
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NoArgInterceptorInvalidContractTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NoArgInterceptorInvalidContractTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NoArgInterceptorInvalidContractTest.java 2010-08-03 12:13:00 UTC (rev 6877)
@@ -0,0 +1,45 @@
+/*
+ * 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.interceptors.invalidContract;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.jboss.weld.exceptions.DefinitionException;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+/**
+ * Test to verify that a DefinitionException is thrown when the defined Interceptor
+ * does not follow the defined contract.
+ *
+ * "Around-invoke methods have the following signature:
+ * Object <METHOD>(InvocationContext) throws Exception"
+ *
+ * @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+(a)ExpectedDeploymentException(DefinitionException.class)
+@Artifact
+(a)Classes({Intercept.class, Service.class, ServiceImpl.class, NoArgInterceptor.class})
+public class NoArgInterceptorInvalidContractTest extends AbstractWeldTest
+{
+ @Test(groups = "broken", description = "WELD-580")
+ public void shouldHaveThrownDefinitionException() throws Exception
+ {
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NotThrowingExceptionInterceptor.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NotThrowingExceptionInterceptor.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NotThrowingExceptionInterceptor.java 2010-08-03 12:13:00 UTC (rev 6877)
@@ -0,0 +1,37 @@
+/*
+ * 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.interceptors.invalidContract;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+/**
+ * By Contract this method should throw Exception, not throwing should result in DefinitionException
+ *
+ * @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+@Intercept @Interceptor
+public class NotThrowingExceptionInterceptor
+{
+ @AroundInvoke
+ public Object intercept(final InvocationContext context)
+ {
+ return null;
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NotThrowingExceptionInterceptorInvalidContractTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NotThrowingExceptionInterceptorInvalidContractTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/NotThrowingExceptionInterceptorInvalidContractTest.java 2010-08-03 12:13:00 UTC (rev 6877)
@@ -0,0 +1,45 @@
+/*
+ * 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.interceptors.invalidContract;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.jboss.weld.exceptions.DefinitionException;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+/**
+ * Test to verify that a DefinitionException is thrown when the defined Interceptor
+ * does not follow the defined contract.
+ *
+ * "Around-invoke methods have the following signature:
+ * Object <METHOD>(InvocationContext) throws Exception"
+ *
+ * @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+(a)ExpectedDeploymentException(DefinitionException.class)
+@Artifact
+(a)Classes({Intercept.class, Service.class, ServiceImpl.class, NotThrowingExceptionInterceptor.class})
+public class NotThrowingExceptionInterceptorInvalidContractTest extends AbstractWeldTest
+{
+ @Test(groups = "broken", description = "WELD-580")
+ public void shouldHaveThrownDefinitionException() throws Exception
+ {
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/Service.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/Service.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/Service.java 2010-08-03 12:13:00 UTC (rev 6877)
@@ -0,0 +1,28 @@
+/*
+ * 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.interceptors.invalidContract;
+
+/**
+ * Service
+ *
+ * @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public interface Service
+{
+ void on();
+}
\ No newline at end of file
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/ServiceImpl.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/ServiceImpl.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/ServiceImpl.java 2010-08-03 12:13:00 UTC (rev 6877)
@@ -0,0 +1,31 @@
+/*
+ * 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.interceptors.invalidContract;
+
+/**
+ * ServiceImpl
+ *
+ * @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+@Intercept
+public class ServiceImpl implements Service
+{
+ public void on()
+ {
+ }
+}
\ No newline at end of file
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/VoidInterceptor.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/VoidInterceptor.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/VoidInterceptor.java 2010-08-03 12:13:00 UTC (rev 6877)
@@ -0,0 +1,37 @@
+/*
+ * 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.interceptors.invalidContract;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+/**
+ * By Contract this method should return Object, void methods should result in DefinitionException
+ *
+ * @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+@Intercept @Interceptor
+public class VoidInterceptor
+{
+ @AroundInvoke
+ public void intercept(final InvocationContext context) throws Exception
+ {
+ context.proceed();
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/VoidInterceptorInvalidContractTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/VoidInterceptorInvalidContractTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalidContract/VoidInterceptorInvalidContractTest.java 2010-08-03 12:13:00 UTC (rev 6877)
@@ -0,0 +1,45 @@
+/*
+ * 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.interceptors.invalidContract;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.jboss.weld.exceptions.DefinitionException;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+/**
+ * Test to verify that a DefinitionException is thrown when the defined Interceptor
+ * does not follow the defined contract.
+ *
+ * "Around-invoke methods have the following signature:
+ * Object <METHOD>(InvocationContext) throws Exception"
+ *
+ * @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+(a)ExpectedDeploymentException(DefinitionException.class)
+@Artifact
+(a)Classes({Intercept.class, Service.class, ServiceImpl.class, VoidInterceptor.class})
+public class VoidInterceptorInvalidContractTest extends AbstractWeldTest
+{
+ @Test(groups = "broken", description = "WELD-580")
+ public void shouldHaveThrownDefinitionException() throws Exception
+ {
+ }
+}
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/interceptors/invalidContract/beans.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/interceptors/invalidContract/beans.xml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/interceptors/invalidContract/beans.xml 2010-08-03 12:13:00 UTC (rev 6877)
@@ -0,0 +1,5 @@
+<beans>
+ <interceptors>
+ <class>org.jboss.weld.tests.interceptors.invalidContract.ServiceInterceptor</class>
+ </interceptors>
+</beans>
\ No newline at end of file
14 years, 6 months
Weld SVN: r6876 - in core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/decorators: genericobserver and 1 other directory.
by weld-commits@lists.jboss.org
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@redhat.com">Aslak Knutsen</a>
+ *
+ */
+(a)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@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@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@redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+@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@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
14 years, 6 months
Weld SVN: r6875 - in core/trunk/tests/src/test/resources/org/jboss/weld/tests: extensions and 2 other directories.
by weld-commits@lists.jboss.org
Author: aslak
Date: 2010-08-03 06:30:15 -0400 (Tue, 03 Aug 2010)
New Revision: 6875
Added:
core/trunk/tests/src/test/resources/org/jboss/weld/tests/extensions/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/extensions/annotatedType/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/extensions/annotatedType/invalidParameters/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/extensions/annotatedType/invalidParameters/javax.enterprise.inject.spi.Extension
Log:
WELD-493 Restored Extensions SPI file for AnnotatedTypeExtensionTest
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/extensions/annotatedType/invalidParameters/javax.enterprise.inject.spi.Extension
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/extensions/annotatedType/invalidParameters/javax.enterprise.inject.spi.Extension (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/extensions/annotatedType/invalidParameters/javax.enterprise.inject.spi.Extension 2010-08-03 10:30:15 UTC (rev 6875)
@@ -0,0 +1 @@
+org.jboss.weld.tests.extensions.annotatedType.invalidParameters.AnnotatedTypeExtension
\ No newline at end of file
14 years, 6 months
Weld SVN: r6874 - archetypes/javaee6-webapp/trunk/src/main/java/com/mycompany.
by weld-commits@lists.jboss.org
Author: sboscarine
Date: 2010-08-01 17:22:52 -0400 (Sun, 01 Aug 2010)
New Revision: 6874
Modified:
archetypes/javaee6-webapp/trunk/src/main/java/com/mycompany/MemberRegistration.java
Log:
updated comment
Modified: archetypes/javaee6-webapp/trunk/src/main/java/com/mycompany/MemberRegistration.java
===================================================================
--- archetypes/javaee6-webapp/trunk/src/main/java/com/mycompany/MemberRegistration.java 2010-08-01 17:30:30 UTC (rev 6873)
+++ archetypes/javaee6-webapp/trunk/src/main/java/com/mycompany/MemberRegistration.java 2010-08-01 21:22:52 UTC (rev 6874)
@@ -11,6 +11,8 @@
import org.slf4j.Logger;
// @javax.ejb.Stateful// Adding this annotation eliminates need for manual transaction demarcation
+
+//The @Model stereotype is a convenience mechanism to make this bean request-scoped and give it an EL name.
@Model
public class MemberRegistration
{
@@ -26,7 +28,7 @@
@Inject
private Event<Member> memberEventSrc;
-
+
private Member newMember;
@Produces
14 years, 6 months
Weld SVN: r6873 - core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx.
by weld-commits@lists.jboss.org
Author: aslak
Date: 2010-08-01 13:30:30 -0400 (Sun, 01 Aug 2010)
New Revision: 6873
Added:
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/AbstractHtmlUnit.java
Removed:
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/AbstractHtmlUnitTest.java
Modified:
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/TxEventTest.java
Log:
WELD-493 Renamed AbstractHTMLUnitTest, not a Test
Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/AbstractHtmlUnit.java (from rev 6870, core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/AbstractHtmlUnitTest.java)
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/AbstractHtmlUnit.java (rev 0)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/AbstractHtmlUnit.java 2010-08-01 17:30:30 UTC (rev 6873)
@@ -0,0 +1,64 @@
+/*
+ * 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.event.tx;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+public abstract class AbstractHtmlUnit
+{
+
+ public AbstractHtmlUnit()
+ {
+ super();
+ }
+
+ protected <T extends HtmlElement> T getFirstMatchingElement(HtmlPage page, Class<T> elementClass, String id)
+ {
+
+ Set<T> inputs = getElements(page.getBody(), elementClass);
+ for (T input : inputs)
+ {
+ if (input.getId().contains(id))
+ {
+ return input;
+ }
+ }
+ return null;
+ }
+
+ protected <T> Set<T> getElements(HtmlElement rootElement, Class<T> elementClass)
+ {
+ Set<T> result = new HashSet<T>();
+
+ for (HtmlElement element : rootElement.getAllHtmlChildElements())
+ {
+ result.addAll(getElements(element, elementClass));
+ }
+
+ if (elementClass.isInstance(rootElement))
+ {
+ result.add(elementClass.cast(rootElement));
+ }
+ return result;
+
+ }
+
+}
\ No newline at end of file
Deleted: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/AbstractHtmlUnitTest.java
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/AbstractHtmlUnitTest.java 2010-08-01 17:11:42 UTC (rev 6872)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/AbstractHtmlUnitTest.java 2010-08-01 17:30:30 UTC (rev 6873)
@@ -1,64 +0,0 @@
-/*
- * 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.event.tx;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-
-public abstract class AbstractHtmlUnitTest
-{
-
- public AbstractHtmlUnitTest()
- {
- super();
- }
-
- protected <T extends HtmlElement> T getFirstMatchingElement(HtmlPage page, Class<T> elementClass, String id)
- {
-
- Set<T> inputs = getElements(page.getBody(), elementClass);
- for (T input : inputs)
- {
- if (input.getId().contains(id))
- {
- return input;
- }
- }
- return null;
- }
-
- protected <T> Set<T> getElements(HtmlElement rootElement, Class<T> elementClass)
- {
- Set<T> result = new HashSet<T>();
-
- for (HtmlElement element : rootElement.getAllHtmlChildElements())
- {
- result.addAll(getElements(element, elementClass));
- }
-
- if (elementClass.isInstance(rootElement))
- {
- result.add(elementClass.cast(rootElement));
- }
- return result;
-
- }
-
-}
\ No newline at end of file
Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/TxEventTest.java
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/TxEventTest.java 2010-08-01 17:11:42 UTC (rev 6872)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/TxEventTest.java 2010-08-01 17:30:30 UTC (rev 6873)
@@ -36,7 +36,7 @@
@Category(Integration.class)
@RunWith(Arquillian.class)
@Run(RunModeType.AS_CLIENT)
-public class TxEventTest extends AbstractHtmlUnitTest
+public class TxEventTest extends AbstractHtmlUnit
{
@Deployment
public static WebArchive createDeployment()
14 years, 6 months
Weld SVN: r6872 - in core/trunk: tests/src/test/resources/org/jboss/weld/tests and 3 other directories.
by weld-commits@lists.jboss.org
Author: aslak
Date: 2010-08-01 13:11:42 -0400 (Sun, 01 Aug 2010)
New Revision: 6872
Added:
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/producer/field/named/
core/trunk/tests-arquillian/src/test/resources/org/jboss/weld/tests/producer/
Removed:
core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/
Modified:
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java
Log:
WELD-493 Converted NamedProducerTest to Arquillian
Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/producer/field/named (from rev 6868, core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named)
Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java 2010-08-01 16:19:26 UTC (rev 6868)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java 2010-08-01 17:11:42 UTC (rev 6872)
@@ -20,14 +20,18 @@
import java.util.HashSet;
import java.util.Set;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.impl.packaging.IntegrationTest;
-import org.jboss.testharness.impl.packaging.Resource;
-import org.jboss.testharness.impl.packaging.Resources;
-import org.jboss.testharness.impl.packaging.war.WarArtifactDescriptor;
-import org.jboss.weld.test.AbstractWeldTest;
-import org.testng.annotations.Test;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.api.Run;
+import org.jboss.arquillian.api.RunModeType;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.weld.tests.category.Integration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
@@ -41,19 +45,27 @@
* @author Pete Muir
*
*/
-@Artifact(addCurrentPackage=false)
-(a)Classes({User.class, NewUserAction.class, Employee.class, SaveAction.class})
-@IntegrationTest(runLocally=true)
-@Resources({
- @Resource(destination=WarArtifactDescriptor.WEB_XML_DESTINATION, source="web.xml"),
- @Resource(destination="view.xhtml", source="view.xhtml"),
- @Resource(destination="home.xhtml", source="home.xhtml"),
- @Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml")
-})
-public class NamedProducerTest extends AbstractWeldTest
+(a)Category(Integration.class)
+(a)RunWith(Arquillian.class)
+(a)Run(RunModeType.AS_CLIENT)
+public class NamedProducerTest
{
-
- @Test(description = "forum post")
+ @Deployment
+ public static WebArchive createDeployment()
+ {
+ return ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClasses(User.class, NewUserAction.class, Employee.class, SaveAction.class)
+ .addWebResource(NamedProducerTest.class.getPackage(), "web.xml", "web.xml")
+ .addWebResource(NamedProducerTest.class.getPackage(), "faces-config.xml", "faces-config.xml")
+ .addResource(NamedProducerTest.class.getPackage(), "view.xhtml", "view.xhtml")
+ .addResource(NamedProducerTest.class.getPackage(), "home.xhtml", "home.xhtml")
+ .addWebResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+ /*
+ * description = "forum post"
+ */
+ @Test
public void testNamedProducerWorks() throws Exception
{
WebClient client = new WebClient();
@@ -61,10 +73,13 @@
HtmlPage page = client.getPage(getPath("/view.jsf"));
// Check the page rendered ok
- assert getFirstMatchingElement(page, HtmlSubmitInput.class, "saveButton") != null;
+ Assert.assertNotNull(getFirstMatchingElement(page, HtmlSubmitInput.class, "saveButton"));
}
- @Test(description = "WELD-404")
+ /*
+ * description = "WELD-404"
+ */
+ @Test
public void testNamedProducerFieldLoosesValues() throws Exception
{
WebClient client = new WebClient();
@@ -74,13 +89,21 @@
HtmlSubmitInput saveButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "saveButton");
HtmlTextInput employeeFieldName = getFirstMatchingElement(page, HtmlTextInput.class, "employeeFieldName");
HtmlTextInput employeeMethodName = getFirstMatchingElement(page, HtmlTextInput.class, "employeeMethodName");
- assert employeeFieldName != null;
- assert employeeMethodName != null;
- assert saveButton != null;
+
+ Assert.assertNotNull(employeeFieldName);
+ Assert.assertNotNull(employeeMethodName);
+ Assert.assertNotNull(saveButton);
+
employeeFieldName.setValueAttribute("Pete");
employeeMethodName.setValueAttribute("Gavin");
saveButton.click();
}
+
+ protected String getPath(String page)
+ {
+ // TODO: this should be moved out and be handled by Arquillian
+ return "http://localhost:8080/test/" + page;
+ }
protected <T> Set<T> getElements(HtmlElement rootElement, Class<T> elementClass)
{
@@ -101,7 +124,6 @@
protected <T extends HtmlElement> T getFirstMatchingElement(HtmlPage page, Class<T> elementClass, String id)
{
-
Set<T> inputs = getElements(page.getBody(), elementClass);
for (T input : inputs)
{
@@ -112,5 +134,4 @@
}
return null;
}
-
-}
+}
\ No newline at end of file
Copied: core/trunk/tests-arquillian/src/test/resources/org/jboss/weld/tests/producer (from rev 6868, core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer)
14 years, 6 months
Weld SVN: r6871 - in core/trunk: tests/src/test/resources/org/jboss/weld/tests and 3 other directories.
by weld-commits@lists.jboss.org
Author: aslak
Date: 2010-08-01 13:01:26 -0400 (Sun, 01 Aug 2010)
New Revision: 6871
Added:
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/jsp/
core/trunk/tests-arquillian/src/test/resources/org/jboss/weld/tests/jsp/
Removed:
core/trunk/tests/src/test/java/org/jboss/weld/tests/jsp/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/jsp/
Modified:
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/jsp/JspTest.java
Log:
WELD-493 Converted JspTest to Arquillian
Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/jsp (from rev 6868, core/trunk/tests/src/test/java/org/jboss/weld/tests/jsp)
Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/jsp/JspTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/jsp/JspTest.java 2010-08-01 16:19:26 UTC (rev 6868)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/jsp/JspTest.java 2010-08-01 17:01:26 UTC (rev 6871)
@@ -32,14 +32,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import junit.framework.Assert;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.IntegrationTest;
-import org.jboss.testharness.impl.packaging.Resource;
-import org.jboss.testharness.impl.packaging.Resources;
-import org.jboss.testharness.impl.packaging.war.WebXml;
-import org.jboss.weld.test.AbstractWeldTest;
-import org.testng.annotations.Test;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.api.Run;
+import org.jboss.arquillian.api.RunModeType;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.weld.tests.category.Integration;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
@@ -48,31 +53,36 @@
* @author Nicklas Karlsson
* @author Dan Allen
*/
-@Artifact(addCurrentPackage = false)
-@IntegrationTest(runLocally = true)
-@Resources( {
- @Resource(destination = "index.jsp", source = "index.jsp"),
- @Resource(destination = "home.jspx", source = "home.jspx"),
- @Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml")
-})
-@WebXml("web.xml")
-public class JspTest extends AbstractWeldTest
+(a)Category(Integration.class)
+(a)RunWith(Arquillian.class)
+(a)Run(RunModeType.AS_CLIENT)
+public class JspTest
{
+ @Deployment
+ public static WebArchive createDeployment()
+ {
+ return ShrinkWrap.create(WebArchive.class, "test.war")
+ .addWebResource(JspTest.class.getPackage(), "web.xml", "web.xml")
+ .addWebResource(JspTest.class.getPackage(), "faces-config.xml", "faces-config.xml")
+ .addResource(JspTest.class.getPackage(), "index.jsp", "index.jsp")
+ .addResource(JspTest.class.getPackage(), "home.jspx", "home.jspx")
+ .addWebResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
- @Test(groups = { "contexts" })
+ @Test
public void testConversationPropagationToNonExistentConversationLeadsException() throws Exception
{
WebClient client = new WebClient();
client.setThrowExceptionOnFailingStatusCode(false);
Page page = client.getPage(getPath("/index.jsp"));
- assert page.getWebResponse().getStatusCode() == 200;
- assert page.getWebResponse().getRequestUrl().toString().contains("home.jsf");
+
+ Assert.assertEquals(200, page.getWebResponse().getStatusCode());
+ Assert.assertTrue(page.getWebResponse().getRequestUrl().toString().contains("home.jsf"));
}
- @Override
- protected String getPath(String viewId)
+ protected String getPath(String page)
{
- return getContextPath() + viewId;
+ // TODO: this should be moved out and be handled by Arquillian
+ return "http://localhost:8080/test/" + page;
}
-
}
\ No newline at end of file
Copied: core/trunk/tests-arquillian/src/test/resources/org/jboss/weld/tests/jsp (from rev 6868, core/trunk/tests/src/test/resources/org/jboss/weld/tests/jsp)
14 years, 6 months
Weld SVN: r6870 - in core/trunk: tests/src/test/resources/org/jboss/weld/tests and 4 other directories.
by weld-commits@lists.jboss.org
Author: aslak
Date: 2010-08-01 12:52:38 -0400 (Sun, 01 Aug 2010)
New Revision: 6870
Added:
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/
core/trunk/tests-arquillian/src/test/resources/org/jboss/weld/tests/event/
Removed:
core/trunk/tests/src/test/java/org/jboss/weld/tests/event/tx/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/event/
Modified:
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/AbstractHtmlUnitTest.java
core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/TxEventTest.java
Log:
WELD-493 Converted TxEventTest to Arquillian
Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java 2010-08-01 16:33:41 UTC (rev 6869)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java 2010-08-01 16:52:38 UTC (rev 6870)
@@ -29,8 +29,9 @@
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.weld.tests.contexts.errorpage.ErrorPageTest;
+import org.jboss.weld.tests.category.Integration;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import com.gargoylesoftware.htmlunit.WebClient;
@@ -45,14 +46,7 @@
* @author Pete Muir
*
*/
-//@Artifact(addCurrentPackage=false)
-//(a)Classes({Storm.class,SomeBean.class})
-//@IntegrationTest(runLocally=true)
-//@Resources({
-// @Resource(destination=WarArtifactDescriptor.WEB_XML_DESTINATION, source="web.xml"),
-// @Resource(destination="storm.jspx", source="storm.jsf"),
-// @Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml")
-//})
+(a)Category(Integration.class)
@RunWith(Arquillian.class)
@Run(RunModeType.AS_CLIENT)
public class InvalidateSessionTest
Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx (from rev 6868, core/trunk/tests/src/test/java/org/jboss/weld/tests/event/tx)
Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/AbstractHtmlUnitTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/event/tx/AbstractHtmlUnitTest.java 2010-08-01 16:19:26 UTC (rev 6868)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/AbstractHtmlUnitTest.java 2010-08-01 16:52:38 UTC (rev 6870)
@@ -19,12 +19,10 @@
import java.util.HashSet;
import java.util.Set;
-import org.jboss.weld.test.AbstractWeldTest;
-
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
-public abstract class AbstractHtmlUnitTest extends AbstractWeldTest
+public abstract class AbstractHtmlUnitTest
{
public AbstractHtmlUnitTest()
Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/TxEventTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/event/tx/TxEventTest.java 2010-08-01 16:19:26 UTC (rev 6868)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/event/tx/TxEventTest.java 2010-08-01 16:52:38 UTC (rev 6870)
@@ -17,33 +17,42 @@
package org.jboss.weld.tests.event.tx;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.impl.packaging.IntegrationTest;
-import org.jboss.testharness.impl.packaging.Resource;
-import org.jboss.testharness.impl.packaging.Resources;
-import org.jboss.testharness.impl.packaging.war.WarArtifactDescriptor;
-import org.testng.annotations.Test;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.api.Run;
+import org.jboss.arquillian.api.RunModeType;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.weld.tests.category.Integration;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
-@Artifact(addCurrentPackage=false)
-@IntegrationTest(runLocally=true)
-@Resources({
- @Resource(source="faces-config.xml", destination="WEB-INF/faces-config.xml"),
- @Resource(source="web.xml", destination=WarArtifactDescriptor.WEB_XML_DESTINATION),
- @Resource(source="home.xhtml", destination="home.xhtml")
-})
-@Classes({
- Foo.class,
- Updated.class
-})
+(a)Category(Integration.class)
+(a)RunWith(Arquillian.class)
+(a)Run(RunModeType.AS_CLIENT)
public class TxEventTest extends AbstractHtmlUnitTest
{
-
- @Test(description="WBRI-401")
+ @Deployment
+ public static WebArchive createDeployment()
+ {
+ return ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClasses(Foo.class, Updated.class)
+ .addWebResource(TxEventTest.class.getPackage(), "web.xml", "web.xml")
+ .addWebResource(TxEventTest.class.getPackage(), "faces-config.xml", "faces-config.xml")
+ .addResource(TxEventTest.class.getPackage(), "home.xhtml", "home.xhtml")
+ .addWebResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+ /*
+ * description = "WBRI-401"
+ */
+ @Test
public void testRequestContextLifecycle() throws Exception
{
WebClient webClient = new WebClient();
@@ -51,5 +60,10 @@
HtmlSubmitInput beginConversationButton = getFirstMatchingElement(home, HtmlSubmitInput.class, "SaveButton");
beginConversationButton.click();
}
-
+
+ protected String getPath(String page)
+ {
+ // TODO: this should be moved out and be handled by Arquillian
+ return "http://localhost:8080/test/" + page;
+ }
}
\ No newline at end of file
Copied: core/trunk/tests-arquillian/src/test/resources/org/jboss/weld/tests/event (from rev 6868, core/trunk/tests/src/test/resources/org/jboss/weld/tests/event)
14 years, 6 months