From weld-commits at lists.jboss.org Tue Aug 3 08:13:02 2010 Content-Type: multipart/mixed; boundary="===============0659894857327390289==" MIME-Version: 1.0 From: weld-commits at lists.jboss.org To: weld-commits at lists.jboss.org Subject: [weld-commits] Weld SVN: r6877 - in core/trunk/tests/src/test: java/org/jboss/weld/tests/interceptors/invalidContract and 2 other directories. Date: Tue, 03 Aug 2010 08:13:02 -0400 Message-ID: <201008031213.o73CD29W021587@svn01.web.mwc.hst.phx2.redhat.com> --===============0659894857327390289== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/invalid= Contract/ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalid= Contract/Intercept.java core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalid= Contract/NoArgInterceptor.java core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalid= Contract/NoArgInterceptorInvalidContractTest.java core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalid= Contract/NotThrowingExceptionInterceptor.java core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalid= Contract/NotThrowingExceptionInterceptorInvalidContractTest.java core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalid= Contract/Service.java core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalid= Contract/ServiceImpl.java core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalid= Contract/VoidInterceptor.java core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invalid= Contract/VoidInterceptorInvalidContractTest.java core/trunk/tests/src/test/resources/org/jboss/weld/tests/interceptors/in= validContract/ core/trunk/tests/src/test/resources/org/jboss/weld/tests/interceptors/in= validContract/beans.xml Log: WELD-580 Added test cases for AroundInvoke interceptor contract Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/inv= alidContract/Intercept.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/Intercept.java (rev 0) +++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/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 Aslak Knutsen + * @version $Revision: $ + */ +(a)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/inv= alidContract/NoArgInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/NoArgInterceptor.java (rev 0) +++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/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 Aslak Knutsen + * @version $Revision: $ + */ +(a)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/inv= alidContract/NoArgInterceptorInvalidContractTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/NoArgInterceptorInvalidContractTest.java = (rev 0) +++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/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 In= terceptor = + * does not follow the defined contract. = + * = + * "Around-invoke methods have the following signature: = + * Object (InvocationContext) throws Exception" + * + * @author Aslak Knutsen + * @version $Revision: $ + */ +(a)ExpectedDeploymentException(DefinitionException.class) +(a)Artifact +(a)Classes({Intercept.class, Service.class, ServiceImpl.class, NoArgInterc= eptor.class}) +public class NoArgInterceptorInvalidContractTest extends AbstractWeldTest +{ + @Test(groups =3D "broken", description =3D "WELD-580") + public void shouldHaveThrownDefinitionException() throws Exception + { + } +} Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/inv= alidContract/NotThrowingExceptionInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/NotThrowingExceptionInterceptor.java (rev= 0) +++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/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 res= ult in DefinitionException + * + * @author Aslak Knutsen + * @version $Revision: $ + */ +(a)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/inv= alidContract/NotThrowingExceptionInterceptorInvalidContractTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/NotThrowingExceptionInterceptorInvalidContractTest.java = (rev 0) +++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/NotThrowingExceptionInterceptorInvalidContractTest.java 2010-08-0= 3 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 In= terceptor = + * does not follow the defined contract. = + * = + * "Around-invoke methods have the following signature: = + * Object (InvocationContext) throws Exception" + * + * @author Aslak Knutsen + * @version $Revision: $ + */ +(a)ExpectedDeploymentException(DefinitionException.class) +(a)Artifact +(a)Classes({Intercept.class, Service.class, ServiceImpl.class, NotThrowing= ExceptionInterceptor.class}) +public class NotThrowingExceptionInterceptorInvalidContractTest extends Ab= stractWeldTest +{ + @Test(groups =3D "broken", description =3D "WELD-580") + public void shouldHaveThrownDefinitionException() throws Exception + { + } +} Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/inv= alidContract/Service.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/Service.java (rev 0) +++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/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 Aslak Knutsen + * @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/inv= alidContract/ServiceImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/ServiceImpl.java (rev 0) +++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/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 Aslak Knutsen + * @version $Revision: $ + */ +(a)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/inv= alidContract/VoidInterceptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/VoidInterceptor.java (rev 0) +++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/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 resul= t in DefinitionException + * + * @author Aslak Knutsen + * @version $Revision: $ + */ +(a)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/inv= alidContract/VoidInterceptorInvalidContractTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/VoidInterceptorInvalidContractTest.java (= rev 0) +++ core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/invali= dContract/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 In= terceptor = + * does not follow the defined contract. = + * = + * "Around-invoke methods have the following signature: = + * Object (InvocationContext) throws Exception" + * + * @author Aslak Knutsen + * @version $Revision: $ + */ +(a)ExpectedDeploymentException(DefinitionException.class) +(a)Artifact +(a)Classes({Intercept.class, Service.class, ServiceImpl.class, VoidInterce= ptor.class}) +public class VoidInterceptorInvalidContractTest extends AbstractWeldTest +{ + @Test(groups =3D "broken", description =3D "WELD-580") + public void shouldHaveThrownDefinitionException() throws Exception + { + } +} Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/interceptor= s/invalidContract/beans.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/tests/src/test/resources/org/jboss/weld/tests/interceptors/i= nvalidContract/beans.xml (rev 0) +++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/interceptors/i= nvalidContract/beans.xml 2010-08-03 12:13:00 UTC (rev 6877) @@ -0,0 +1,5 @@ + + + org.jboss.weld.tests.interceptors.invalidContract.ServiceIntercep= tor + + \ No newline at end of file --===============0659894857327390289==--