[weld-commits] Weld SVN: r6877 - in core/trunk/tests/src/test: java/org/jboss/weld/tests/interceptors/invalidContract and 2 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Tue Aug 3 08:13:02 EDT 2010


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 at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at InterceptorBinding
+ at Target({ElementType.TYPE, ElementType.METHOD})
+ at 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 at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at 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 at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at ExpectedDeploymentException(DefinitionException.class)
+ at Artifact
+ at 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 at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at 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 at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at ExpectedDeploymentException(DefinitionException.class)
+ at Artifact
+ at 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 at 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 at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at 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 at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at 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 at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at ExpectedDeploymentException(DefinitionException.class)
+ at Artifact
+ at 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



More information about the weld-commits mailing list