[jboss-cvs] JBossAS SVN: r100311 - in projects/interceptors/trunk: jboss-interceptor/src/main/java/org/jboss/interceptor/model and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 2 21:23:19 EST 2010


Author: marius.bogoevici
Date: 2010-02-02 21:23:18 -0500 (Tue, 02 Feb 2010)
New Revision: 100311

Added:
   projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTestCase.java
   projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java
Removed:
   projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTest.java
   projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTest.java
Modified:
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionModelBuilder.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionType.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionTypeRegistry.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java
   projects/interceptors/trunk/pom.xml
Log:
minor changes and enabling tests

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionModelBuilder.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionModelBuilder.java	2010-02-03 02:02:35 UTC (rev 100310)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionModelBuilder.java	2010-02-03 02:23:18 UTC (rev 100311)
@@ -104,11 +104,11 @@
          this.interceptionTypes = interceptionType;
       }
 
-      public void with(I... clazzes)
+      public void with(I... interceptors)
       {
          for (InterceptionType interceptionType: interceptionTypes)
          {
-            InterceptionModelBuilder.this.interceptionModel.appendInterceptors(interceptionType, method, clazzes);
+            InterceptionModelBuilder.this.interceptionModel.appendInterceptors(interceptionType, method, interceptors);
          }
       }
    }

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionType.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionType.java	2010-02-03 02:02:35 UTC (rev 100310)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionType.java	2010-02-03 02:23:18 UTC (rev 100311)
@@ -44,7 +44,7 @@
       return lifecycleCallback;
    }
 
-   public String getAnnotationClassName()
+   public String annotationClassName()
    {
       return annotationClassName;
    }

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionTypeRegistry.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionTypeRegistry.java	2010-02-03 02:02:35 UTC (rev 100310)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptionTypeRegistry.java	2010-02-03 02:23:18 UTC (rev 100311)
@@ -36,8 +36,6 @@
    private static final Logger LOG = LoggerFactory.getLogger(InterceptionTypeRegistry.class);
    private static Map<InterceptionType, Class<? extends Annotation>> interceptionAnnotationClasses;
 
-   public static Class<? extends Annotation> TIMEOUT_ANNOTATION_CLASS = null;
-
    static
    {
       interceptionAnnotationClasses = new HashMap<InterceptionType, Class<? extends Annotation>>();
@@ -46,20 +44,13 @@
       {
          try
          {
-            interceptionAnnotationClasses.put(interceptionType, (Class<? extends Annotation>) ReflectionUtils.classForName(interceptionType.getAnnotationClassName()));
+            interceptionAnnotationClasses.put(interceptionType, (Class<? extends Annotation>) ReflectionUtils.classForName(interceptionType.annotationClassName()));
          } catch (Exception e)
          {
-            LOG.warn("Class '" + interceptionType.getAnnotationClassName() + "' not found, interception based on it is not enabled" );
+            LOG.warn("Class '" + interceptionType.annotationClassName() + "' not found, interception based on it is not enabled" );
          }
       }
-
-      try
-      {
-         TIMEOUT_ANNOTATION_CLASS = (Class<? extends Annotation>) ReflectionUtils.classForName("javax.ejb.Timeout");
-      } catch (ClassNotFoundException e)
-      {
-         // no-op
-      }
+      
    }
 
    public static Collection<InterceptionType> getSupportedInterceptionTypes()
@@ -69,7 +60,7 @@
 
    public static boolean supportsTimeoutMethods()
    {
-      return TIMEOUT_ANNOTATION_CLASS != null;
+      return interceptionAnnotationClasses.containsKey(InterceptionType.AROUND_TIMEOUT);
    }
 
    public static Class<? extends Annotation> getAnnotationClass(InterceptionType interceptionType)

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java	2010-02-03 02:02:35 UTC (rev 100310)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java	2010-02-03 02:23:18 UTC (rev 100311)
@@ -78,7 +78,7 @@
          {
             return thisMethod.invoke(getTargetInstance(), args);
          }
-         if (InterceptionTypeRegistry.supportsTimeoutMethods() && thisMethod.isAnnotationPresent(InterceptionTypeRegistry.TIMEOUT_ANNOTATION_CLASS))
+         if (InterceptionTypeRegistry.supportsTimeoutMethods() && thisMethod.isAnnotationPresent(InterceptionTypeRegistry.getAnnotationClass(InterceptionType.AROUND_TIMEOUT)))
          {
             return executeInterception(thisMethod, args, InterceptionType.AROUND_TIMEOUT);
          }

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java	2010-02-03 02:02:35 UTC (rev 100310)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java	2010-02-03 02:23:18 UTC (rev 100311)
@@ -19,7 +19,6 @@
 
 import org.jboss.interceptor.model.InterceptionType;
 import org.jboss.interceptor.model.InterceptionTypeRegistry;
-import org.jboss.interceptor.model.InterceptionModel;
 import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
 import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
 import org.jboss.interceptor.proxy.LifecycleMixin;
@@ -39,8 +38,6 @@
 import java.util.Collections;
 import java.util.concurrent.Callable;
 
-import javassist.util.proxy.ProxyObject;
-
 /**
  * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
  */
@@ -234,7 +231,7 @@
    {
       return "Method " + method.getName() + " defined on class " + method.getDeclaringClass().getName()
             + " will not be used for interception, since it is not defined according to the specification. It is annotated with @"
-            + interceptionType.getAnnotationClassName() + ", but ";
+            + interceptionType.annotationClassName() + ", but ";
    }
 
    public static <T> T proxifyInstance(T instance, Class<?> superClass, List<InterceptorRegistry<Class<?>, ?>> interceptorRegistries, List<InterceptionHandlerFactory<?>> interceptionHandlerFactory)

Deleted: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTest.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTest.java	2010-02-03 02:02:35 UTC (rev 100310)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTest.java	2010-02-03 02:23:18 UTC (rev 100311)
@@ -1,150 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
- * contributors by the @authors tag. See the copyright.txt in the
- * distribution for a full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.interceptors.metadata;
-
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import org.jboss.interceptor.model.InterceptorClassMetadata;
-import org.jboss.interceptor.model.InterceptionType;
-import org.jboss.interceptor.model.InterceptorMetadataException;
-import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
-import org.jboss.interceptor.InterceptorException;
-
-import java.lang.reflect.Method;
-import java.util.List;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public class InterceptorClassMetadataTest
-{
-
-   @Test
-   public void testInterceptorWithAllMethods()
-   {
-      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(InterceptorWithAllMethods.class);
-
-      List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
-      assertEquals(true, postConstructMethods.size() == 1);
-      assertEquals(postConstructMethods.get(0).getName(), "doPostConstruct");
-
-      List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
-      assertEquals(true, preDestroyMethods.size() == 1);
-      assertEquals(preDestroyMethods.get(0).getName(), "doPreDestroy");
-
-      List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
-      assertEquals(true, aroundInvokeMethods.size() == 1);
-      assertEquals(aroundInvokeMethods.get(0).getName(), "doAroundInvoke");
-
-      List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
-      assertEquals(true, postActivateMethods.size() == 1);
-      assertEquals(postActivateMethods.get(0).getName(), "doPostActivate");
-
-
-      List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
-      assertEquals(true, prePassivateMethods.size() == 1);
-      assertEquals(prePassivateMethods.get(0).getName(), "doPrePassivate");
-
-   }
-
-   @Test
-   public void testInterceptorWithSomeMethods()
-   {
-      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(InterceptorWithSomeMethods.class);
-
-      List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
-      assertEquals(true, postConstructMethods.size() == 0);
-
-      List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
-      assertEquals(true, preDestroyMethods.size() == 1);
-      assertEquals(preDestroyMethods.get(0).getName(), "doPreDestroy");
-
-      List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
-      assertEquals(true, aroundInvokeMethods.size() == 1);
-      assertEquals(aroundInvokeMethods.get(0).getName(), "doAroundInvoke");
-
-      List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
-      assertEquals(true, postActivateMethods.size() == 1);
-      assertEquals(postActivateMethods.get(0).getName(), "doPostActivate");
-
-
-      List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
-      assertEquals(true, prePassivateMethods.size() == 0);
-
-   }
-
-   @Test
-   public void testSimpleInheritance()
-   {
-      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(SimpleInheritanceChildInterceptor.class);
-
-      List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
-      assertEquals(1, postConstructMethods.size());
-      assertEquals(postConstructMethods.get(0).getName(), "doPostConstruct");
-
-      List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
-      assertEquals(true, preDestroyMethods.size() == 0);
-
-      List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
-      assertEquals(true, aroundInvokeMethods.size() == 1);
-      assertEquals(aroundInvokeMethods.get(0).getName(), "doAroundInvoke");
-
-      List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
-      assertEquals(true, postActivateMethods.size() == 0);
-
-      List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
-      assertEquals(true, prePassivateMethods.size() == 0);
-
-   }
-
-   @Test
-   public void testInheritanceWithAndWithoutOverriding()
-   {
-      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(OverrideChildInterceptor.class);
-
-      List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
-      assertEquals(true, postConstructMethods.size() == 1);
-      assertEquals(postConstructMethods.get(0).getName(), "methodOverriddenAndUsedAsInterceptor");
-
-      List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
-      assertEquals(true, preDestroyMethods.size() == 0);
-
-      List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
-      assertEquals(true, aroundInvokeMethods.size() == 2);
-      assertEquals(aroundInvokeMethods.get(0).getName(), "methodDefinedOnParentAndUsedAsInterceptor");
-      assertEquals(aroundInvokeMethods.get(1).getName(), "methodDefinedOnChildAndUsedAsInterceptor");
-
-      List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
-      assertEquals(true, postActivateMethods.size() == 0);
-
-
-      List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
-      assertEquals(true, prePassivateMethods.size() == 0);
-
-   }
-
-   @Test(expected = InterceptorMetadataException.class)
-   public void testDuplicateAnnotations()
-   {
-      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(InterceptorWithDuplicateAnnotations.class);
-
-   }
-
-
-
-}

Copied: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTestCase.java (from rev 100027, projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTest.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTestCase.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTestCase.java	2010-02-03 02:23:18 UTC (rev 100311)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptors.metadata;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import org.jboss.interceptor.model.InterceptorClassMetadata;
+import org.jboss.interceptor.model.InterceptionType;
+import org.jboss.interceptor.model.InterceptorMetadataException;
+import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
+import org.jboss.interceptor.InterceptorException;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class InterceptorClassMetadataTestCase
+{
+
+   @Test
+   public void testInterceptorWithAllMethods()
+   {
+      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(InterceptorWithAllMethods.class);
+
+      List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+      assertEquals(true, postConstructMethods.size() == 1);
+      assertEquals(postConstructMethods.get(0).getName(), "doPostConstruct");
+
+      List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+      assertEquals(true, preDestroyMethods.size() == 1);
+      assertEquals(preDestroyMethods.get(0).getName(), "doPreDestroy");
+
+      List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+      assertEquals(true, aroundInvokeMethods.size() == 1);
+      assertEquals(aroundInvokeMethods.get(0).getName(), "doAroundInvoke");
+
+      List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+      assertEquals(true, postActivateMethods.size() == 1);
+      assertEquals(postActivateMethods.get(0).getName(), "doPostActivate");
+
+
+      List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+      assertEquals(true, prePassivateMethods.size() == 1);
+      assertEquals(prePassivateMethods.get(0).getName(), "doPrePassivate");
+
+   }
+
+   @Test
+   public void testInterceptorWithSomeMethods()
+   {
+      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(InterceptorWithSomeMethods.class);
+
+      List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+      assertEquals(true, postConstructMethods.size() == 0);
+
+      List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+      assertEquals(true, preDestroyMethods.size() == 1);
+      assertEquals(preDestroyMethods.get(0).getName(), "doPreDestroy");
+
+      List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+      assertEquals(true, aroundInvokeMethods.size() == 1);
+      assertEquals(aroundInvokeMethods.get(0).getName(), "doAroundInvoke");
+
+      List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+      assertEquals(true, postActivateMethods.size() == 1);
+      assertEquals(postActivateMethods.get(0).getName(), "doPostActivate");
+
+
+      List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+      assertEquals(true, prePassivateMethods.size() == 0);
+
+   }
+
+   @Test
+   public void testSimpleInheritance()
+   {
+      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(SimpleInheritanceChildInterceptor.class);
+
+      List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+      assertEquals(1, postConstructMethods.size());
+      assertEquals(postConstructMethods.get(0).getName(), "doPostConstruct");
+
+      List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+      assertEquals(true, preDestroyMethods.size() == 0);
+
+      List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+      assertEquals(true, aroundInvokeMethods.size() == 1);
+      assertEquals(aroundInvokeMethods.get(0).getName(), "doAroundInvoke");
+
+      List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+      assertEquals(true, postActivateMethods.size() == 0);
+
+      List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+      assertEquals(true, prePassivateMethods.size() == 0);
+
+   }
+
+   @Test
+   public void testInheritanceWithAndWithoutOverriding()
+   {
+      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(OverrideChildInterceptor.class);
+
+      List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+      assertEquals(true, postConstructMethods.size() == 1);
+      assertEquals(postConstructMethods.get(0).getName(), "methodOverriddenAndUsedAsInterceptor");
+
+      List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+      assertEquals(true, preDestroyMethods.size() == 0);
+
+      List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+      assertEquals(true, aroundInvokeMethods.size() == 2);
+      assertEquals(aroundInvokeMethods.get(0).getName(), "methodDefinedOnParentAndUsedAsInterceptor");
+      assertEquals(aroundInvokeMethods.get(1).getName(), "methodDefinedOnChildAndUsedAsInterceptor");
+
+      List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+      assertEquals(true, postActivateMethods.size() == 0);
+
+
+      List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+      assertEquals(true, prePassivateMethods.size() == 0);
+
+   }
+
+   @Test(expected = InterceptorMetadataException.class)
+   public void testDuplicateAnnotations()
+   {
+      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(InterceptorWithDuplicateAnnotations.class);
+
+   }
+
+
+
+}

Deleted: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTest.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTest.java	2010-02-03 02:02:35 UTC (rev 100310)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTest.java	2010-02-03 02:23:18 UTC (rev 100311)
@@ -1,381 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
- * contributors by the @authors tag. See the copyright.txt in the
- * distribution for a full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.interceptors.proxy;
-
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ByteArrayInputStream;
-import java.lang.reflect.Array;
-
-import org.jboss.interceptor.model.InterceptionModelBuilder;
-import org.jboss.interceptor.model.InterceptionModel;
-import org.jboss.interceptor.proxy.DirectClassInterceptionHandlerFactory;
-import org.jboss.interceptor.registry.InterceptorRegistry;
-import org.jboss.interceptor.util.InterceptionUtils;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public class InterceptionTest
-{
-   private static final String TEAM_NAME = "Ajax Amsterdam";
-
-   private String[] expectedLoggedValues = {
-         "org.jboss.interceptors.proxy.FirstInterceptor_postConstruct",
-         "org.jboss.interceptors.proxy.Team_postConstruct",
-         "org.jboss.interceptors.proxy.FootballTeam_postConstruct",
-         "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeBefore",
-         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeBefore",
-         "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeBefore",
-         "org.jboss.interceptors.proxy.FootballTeam_getName",
-         "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.SecondInterceptor_preDestroy"
-   };
-
-   private String[] expectedLoggedValuesWithGlobalsIgnored = {
-         "org.jboss.interceptors.proxy.FirstInterceptor_postConstruct",
-         "org.jboss.interceptors.proxy.Team_postConstruct",
-         "org.jboss.interceptors.proxy.FootballTeam_postConstruct",
-         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeBefore",
-         "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeBefore",
-         "org.jboss.interceptors.proxy.FootballTeam_getName",
-         "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.SecondInterceptor_preDestroy"
-   };
-
-   private String[] expectedLoggedValuesOnSerialization = {
-         "org.jboss.interceptors.proxy.FirstInterceptor_postConstruct",
-         "org.jboss.interceptors.proxy.Team_postConstruct",
-         "org.jboss.interceptors.proxy.FootballTeam_postConstruct",
-         "org.jboss.interceptors.proxy.FootballTeam_prePassivating",
-         "org.jboss.interceptors.proxy.FootballTeam_postActivating",
-         "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeBefore",
-         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeBefore",
-         "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeBefore",
-         "org.jboss.interceptors.proxy.FootballTeam_getName",
-         "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeAfter",
-   };
-
-   private String[] expectedLoggedValuesWhenRaw = {
-         "org.jboss.interceptors.proxy.FootballTeam_getName",
-   };
-
-
-
-   private InterceptionModel<Class<?>, Class<?>> interceptionModel;
-   private InterceptorRegistry<Class<?>, Class<?>> interceptorRegistry;
-
-   public void resetLogAndSetupClassesForMethod() throws Exception
-   {
-      InterceptorTestLogger.reset();
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(FirstInterceptor.class, SecondInterceptor.class);
-      builder.interceptPostConstruct().with(FirstInterceptor.class);
-      builder.interceptPreDestroy().with(SecondInterceptor.class);
-      interceptionModel = builder.build();
-      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-   }
-
-   public void resetLogAndSetupClassesGlobally() throws Exception
-   {
-      InterceptorTestLogger.reset();
-
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-
-      builder.interceptAll().with(FirstInterceptor.class, SecondInterceptor.class);
-      interceptionModel = builder.build();
-      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-   }
-
-   public void resetLogAndSetupClassesMixed() throws Exception
-   {
-      InterceptorTestLogger.reset();
-
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-      builder.interceptAll().with(FirstInterceptor.class);
-      builder.interceptPreDestroy().with(SecondInterceptor.class);
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(SecondInterceptor.class);
-      interceptionModel = builder.build();
-      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-   }
-
-   public void resetLogAndSetupClassesWithGlobalsIgnored() throws Exception
-   {
-      InterceptorTestLogger.reset();
-
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-      builder.interceptAll().with(FirstInterceptor.class);
-      builder.interceptPreDestroy().with(SecondInterceptor.class);
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(SecondInterceptor.class);
-      builder.ignoreGlobalInterceptors(FootballTeam.class.getMethod("getName"));
-      interceptionModel = builder.build();
-      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-   }
-
-
-   @Test
-   public void testInterceptionWithMethodRegisteredInterceptors() throws Exception
-   {
-      resetLogAndSetupClassesForMethod();
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      InterceptionUtils.executePostConstruct(proxy);
-      Assert.assertEquals(TEAM_NAME, proxy.getName());
-      InterceptionUtils.executePredestroy(proxy);
-      Object[] logValues = InterceptorTestLogger.getLog().toArray();
-      Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValues, logValues);
-      assertRawObject(proxy);
-   }
-
-   @Test
-   public void testInterceptionWithGlobalInterceptors() throws Exception
-   {
-      resetLogAndSetupClassesGlobally();
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      InterceptionUtils.executePostConstruct(proxy);
-      Assert.assertEquals(TEAM_NAME, proxy.getName());
-      InterceptionUtils.executePredestroy(proxy);
-      assertRawObject(proxy);
-   }
-
-   @Test
-   public void testInterceptionWithMixedInterceptors() throws Exception
-   {
-      resetLogAndSetupClassesMixed();
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      InterceptionUtils.executePostConstruct(proxy);
-      Assert.assertEquals(TEAM_NAME, proxy.getName());
-      InterceptionUtils.executePredestroy(proxy);
-      Object[] logValues = InterceptorTestLogger.getLog().toArray();
-      Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValues, logValues);
-      assertRawObject(proxy);
-   }
-
-   @Test
-   public void testInterceptionWithGlobalsIgnored() throws Exception
-   {
-      resetLogAndSetupClassesWithGlobalsIgnored();
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      InterceptionUtils.executePostConstruct(proxy);
-      Assert.assertEquals(TEAM_NAME, proxy.getName());
-      InterceptionUtils.executePredestroy(proxy);
-      Object[] logValues = InterceptorTestLogger.getLog().toArray();
-      Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValuesWithGlobalsIgnored, logValues);
-      assertRawObject(proxy);
-   }
-
-
-   @Test
-   public void testInterceptionWithSerializedProxy() throws Exception
-   {
-      resetLogAndSetupClassesForMethod();
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      InterceptionUtils.executePostConstruct(proxy);
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      new ObjectOutputStream(baos).writeObject(proxy);
-      proxy = (FootballTeam) new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())).readObject();
-      Assert.assertEquals(TEAM_NAME, proxy.getName());
-      Object[] logValues = InterceptorTestLogger.getLog().toArray();
-      Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValuesOnSerialization, logValues);
-      assertRawObject(proxy);
-   }
-
-
-   @Test
-   public void testMethodParameterOverriding() throws Exception
-   {
-      InterceptorTestLogger.reset();
-
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo", String.class)).with(ParameterOverridingInterceptor.class);
-      interceptionModel = builder.build();
-      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      Assert.assertEquals(42, proxy.echo("1"));
-   }
-
-   @Test
-   public void testMethodParameterOverridingWithPrimitive() throws Exception
-   {
-      InterceptorTestLogger.reset();
-
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithInteger.class);
-      interceptionModel = builder.build();
-      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      Assert.assertEquals(42, proxy.echoInt(1));
-   }
-
-   @Test(expected = IllegalArgumentException.class)
-   public void testMethodParameterOverridingWithObject() throws Exception
-   {
-      InterceptorTestLogger.reset();
-
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithInteger.class);
-      interceptionModel = builder.build();
-      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      Assert.assertEquals(new Long(42), proxy.echoLongAsObject(1l));
-   }
-
-   @Test
-   public void testMethodParameterOverridingWithObjectSucceed() throws Exception
-   {
-      InterceptorTestLogger.reset();
-
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithLong.class);
-      interceptionModel = builder.build();
-      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      Assert.assertEquals(new Long(42), proxy.echoLongAsObject(1l));
-   }
-
-   @Test
-   public void testMethodParameterOverridingWithPrimitiveWidening() throws Exception
-   {
-      InterceptorTestLogger.reset();
-
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLong", long.class)).with(ParameterOverridingInterceptorWithInteger.class);
-      interceptionModel = builder.build();
-      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      Assert.assertEquals(42, proxy.echoLong(1));
-   }
-
-   @Test(expected = IllegalArgumentException.class)
-   public void testMethodParameterOverridingWithPrimitiveNarrowing() throws Exception
-   {
-      InterceptorTestLogger.reset();
-
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithLong.class);
-      interceptionModel = builder.build();
-      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      Assert.assertEquals(42, proxy.echoInt(1));
-   }
-
-   @Test
-   public void testMethodParameterOverridingWithArray() throws Exception
-   {
-      InterceptorTestLogger.reset();
-
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoObjectArray", Object[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
-      interceptionModel = builder.build();
-      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      Assert.assertEquals(new Long[]{42l}, proxy.echoObjectArray(new Object[]{}));
-   }
-
-   @Test(expected = IllegalArgumentException.class)
-   public void testMethodParameterOverridingWithArrayOnString() throws Exception
-   {
-      InterceptorTestLogger.reset();
-
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoStringArray", String[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
-      interceptionModel = builder.build();
-      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      Assert.assertEquals(new Long[]{42l}, proxy.echoStringArray(new String[]{}));
-   }
-
-   @Test
-   public void testMethodParameterOverridingWithSubclass() throws Exception
-   {
-      InterceptorTestLogger.reset();
-
-
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo2", ValueBearer.class)).with(ParameterOverridingInterceptor2.class);
-      interceptionModel = builder.build();
-      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
-      Assert.assertEquals(42, proxy.echo2(new ValueBearerImpl(1)));
-   }
-
-
-   public void assertRawObject(FootballTeam proxy)
-   {
-      InterceptorTestLogger.reset();
-      FootballTeam rawInstance = InterceptionUtils.getRawInstance(proxy);
-      Assert.assertEquals(TEAM_NAME, rawInstance.getName());
-      Object[] logValues = InterceptorTestLogger.getLog().toArray();
-      Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValuesWhenRaw, logValues);
-   }
-
-   private String iterateAndDisplay(Object[] logValues)
-   {
-      StringBuffer buffer = new StringBuffer();
-      for (Object logValue : logValues)
-      {
-         buffer.append(logValue.toString()).append("\n");
-      }
-      return buffer.toString();
-   }
-
-
-}

Copied: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java (from rev 100109, projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTest.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java	2010-02-03 02:23:18 UTC (rev 100311)
@@ -0,0 +1,381 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptors.proxy;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ByteArrayInputStream;
+import java.lang.reflect.Array;
+
+import org.jboss.interceptor.model.InterceptionModelBuilder;
+import org.jboss.interceptor.model.InterceptionModel;
+import org.jboss.interceptor.proxy.DirectClassInterceptionHandlerFactory;
+import org.jboss.interceptor.registry.InterceptorRegistry;
+import org.jboss.interceptor.util.InterceptionUtils;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class InterceptionTestCase
+{
+   private static final String TEAM_NAME = "Ajax Amsterdam";
+
+   private String[] expectedLoggedValues = {
+         "org.jboss.interceptors.proxy.FirstInterceptor_postConstruct",
+         "org.jboss.interceptors.proxy.Team_postConstruct",
+         "org.jboss.interceptors.proxy.FootballTeam_postConstruct",
+         "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeBefore",
+         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeBefore",
+         "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeBefore",
+         "org.jboss.interceptors.proxy.FootballTeam_getName",
+         "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeAfter",
+         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeAfter",
+         "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeAfter",
+         "org.jboss.interceptors.proxy.SecondInterceptor_preDestroy"
+   };
+
+   private String[] expectedLoggedValuesWithGlobalsIgnored = {
+         "org.jboss.interceptors.proxy.FirstInterceptor_postConstruct",
+         "org.jboss.interceptors.proxy.Team_postConstruct",
+         "org.jboss.interceptors.proxy.FootballTeam_postConstruct",
+         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeBefore",
+         "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeBefore",
+         "org.jboss.interceptors.proxy.FootballTeam_getName",
+         "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeAfter",
+         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeAfter",
+         "org.jboss.interceptors.proxy.SecondInterceptor_preDestroy"
+   };
+
+   private String[] expectedLoggedValuesOnSerialization = {
+         "org.jboss.interceptors.proxy.FirstInterceptor_postConstruct",
+         "org.jboss.interceptors.proxy.Team_postConstruct",
+         "org.jboss.interceptors.proxy.FootballTeam_postConstruct",
+         "org.jboss.interceptors.proxy.FootballTeam_prePassivating",
+         "org.jboss.interceptors.proxy.FootballTeam_postActivating",
+         "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeBefore",
+         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeBefore",
+         "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeBefore",
+         "org.jboss.interceptors.proxy.FootballTeam_getName",
+         "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeAfter",
+         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeAfter",
+         "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeAfter",
+   };
+
+   private String[] expectedLoggedValuesWhenRaw = {
+         "org.jboss.interceptors.proxy.FootballTeam_getName",
+   };
+
+
+
+   private InterceptionModel<Class<?>, Class<?>> interceptionModel;
+   private InterceptorRegistry<Class<?>, Class<?>> interceptorRegistry;
+
+   public void resetLogAndSetupClassesForMethod() throws Exception
+   {
+      InterceptorTestLogger.reset();
+      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(FirstInterceptor.class, SecondInterceptor.class);
+      builder.interceptPostConstruct().with(FirstInterceptor.class);
+      builder.interceptPreDestroy().with(SecondInterceptor.class);
+      interceptionModel = builder.build();
+      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
+      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+
+   }
+
+   public void resetLogAndSetupClassesGlobally() throws Exception
+   {
+      InterceptorTestLogger.reset();
+
+      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+
+      builder.interceptAll().with(FirstInterceptor.class, SecondInterceptor.class);
+      interceptionModel = builder.build();
+      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
+      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+
+   }
+
+   public void resetLogAndSetupClassesMixed() throws Exception
+   {
+      InterceptorTestLogger.reset();
+
+      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      builder.interceptAll().with(FirstInterceptor.class);
+      builder.interceptPreDestroy().with(SecondInterceptor.class);
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(SecondInterceptor.class);
+      interceptionModel = builder.build();
+      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
+      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+
+   }
+
+   public void resetLogAndSetupClassesWithGlobalsIgnored() throws Exception
+   {
+      InterceptorTestLogger.reset();
+
+      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      builder.interceptAll().with(FirstInterceptor.class);
+      builder.interceptPreDestroy().with(SecondInterceptor.class);
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(SecondInterceptor.class);
+      builder.ignoreGlobalInterceptors(FootballTeam.class.getMethod("getName"));
+      interceptionModel = builder.build();
+      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
+      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+
+   }
+
+
+   @Test
+   public void testInterceptionWithMethodRegisteredInterceptors() throws Exception
+   {
+      resetLogAndSetupClassesForMethod();
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      InterceptionUtils.executePostConstruct(proxy);
+      Assert.assertEquals(TEAM_NAME, proxy.getName());
+      InterceptionUtils.executePredestroy(proxy);
+      Object[] logValues = InterceptorTestLogger.getLog().toArray();
+      Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValues, logValues);
+      assertRawObject(proxy);
+   }
+
+   @Test
+   public void testInterceptionWithGlobalInterceptors() throws Exception
+   {
+      resetLogAndSetupClassesGlobally();
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      InterceptionUtils.executePostConstruct(proxy);
+      Assert.assertEquals(TEAM_NAME, proxy.getName());
+      InterceptionUtils.executePredestroy(proxy);
+      assertRawObject(proxy);
+   }
+
+   @Test
+   public void testInterceptionWithMixedInterceptors() throws Exception
+   {
+      resetLogAndSetupClassesMixed();
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      InterceptionUtils.executePostConstruct(proxy);
+      Assert.assertEquals(TEAM_NAME, proxy.getName());
+      InterceptionUtils.executePredestroy(proxy);
+      Object[] logValues = InterceptorTestLogger.getLog().toArray();
+      Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValues, logValues);
+      assertRawObject(proxy);
+   }
+
+   @Test
+   public void testInterceptionWithGlobalsIgnored() throws Exception
+   {
+      resetLogAndSetupClassesWithGlobalsIgnored();
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      InterceptionUtils.executePostConstruct(proxy);
+      Assert.assertEquals(TEAM_NAME, proxy.getName());
+      InterceptionUtils.executePredestroy(proxy);
+      Object[] logValues = InterceptorTestLogger.getLog().toArray();
+      Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValuesWithGlobalsIgnored, logValues);
+      assertRawObject(proxy);
+   }
+
+
+   @Test
+   public void testInterceptionWithSerializedProxy() throws Exception
+   {
+      resetLogAndSetupClassesForMethod();
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      InterceptionUtils.executePostConstruct(proxy);
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      new ObjectOutputStream(baos).writeObject(proxy);
+      proxy = (FootballTeam) new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())).readObject();
+      Assert.assertEquals(TEAM_NAME, proxy.getName());
+      Object[] logValues = InterceptorTestLogger.getLog().toArray();
+      Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValuesOnSerialization, logValues);
+      assertRawObject(proxy);
+   }
+
+
+   @Test
+   public void testMethodParameterOverriding() throws Exception
+   {
+      InterceptorTestLogger.reset();
+
+      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo", String.class)).with(ParameterOverridingInterceptor.class);
+      interceptionModel = builder.build();
+      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
+      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      Assert.assertEquals(42, proxy.echo("1"));
+   }
+
+   @Test
+   public void testMethodParameterOverridingWithPrimitive() throws Exception
+   {
+      InterceptorTestLogger.reset();
+
+      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithInteger.class);
+      interceptionModel = builder.build();
+      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
+      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      Assert.assertEquals(42, proxy.echoInt(1));
+   }
+
+   @Test(expected = IllegalArgumentException.class)
+   public void testMethodParameterOverridingWithObject() throws Exception
+   {
+      InterceptorTestLogger.reset();
+
+      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithInteger.class);
+      interceptionModel = builder.build();
+      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
+      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      Assert.assertEquals(new Long(42), proxy.echoLongAsObject(1l));
+   }
+
+   @Test
+   public void testMethodParameterOverridingWithObjectSucceed() throws Exception
+   {
+      InterceptorTestLogger.reset();
+
+      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithLong.class);
+      interceptionModel = builder.build();
+      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
+      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      Assert.assertEquals(new Long(42), proxy.echoLongAsObject(1l));
+   }
+
+   @Test
+   public void testMethodParameterOverridingWithPrimitiveWidening() throws Exception
+   {
+      InterceptorTestLogger.reset();
+
+      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLong", long.class)).with(ParameterOverridingInterceptorWithInteger.class);
+      interceptionModel = builder.build();
+      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
+      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      Assert.assertEquals(42, proxy.echoLong(1));
+   }
+
+   @Test(expected = IllegalArgumentException.class)
+   public void testMethodParameterOverridingWithPrimitiveNarrowing() throws Exception
+   {
+      InterceptorTestLogger.reset();
+
+      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithLong.class);
+      interceptionModel = builder.build();
+      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
+      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      Assert.assertEquals(42, proxy.echoInt(1));
+   }
+
+   @Test
+   public void testMethodParameterOverridingWithArray() throws Exception
+   {
+      InterceptorTestLogger.reset();
+
+      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoObjectArray", Object[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
+      interceptionModel = builder.build();
+      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
+      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      Assert.assertEquals(new Long[]{42l}, proxy.echoObjectArray(new Object[]{}));
+   }
+
+   @Test(expected = IllegalArgumentException.class)
+   public void testMethodParameterOverridingWithArrayOnString() throws Exception
+   {
+      InterceptorTestLogger.reset();
+
+      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoStringArray", String[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
+      interceptionModel = builder.build();
+      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
+      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      Assert.assertEquals(new Long[]{42l}, proxy.echoStringArray(new String[]{}));
+   }
+
+   @Test
+   public void testMethodParameterOverridingWithSubclass() throws Exception
+   {
+      InterceptorTestLogger.reset();
+
+
+      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo2", ValueBearer.class)).with(ParameterOverridingInterceptor2.class);
+      interceptionModel = builder.build();
+      this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
+      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+
+      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      Assert.assertEquals(42, proxy.echo2(new ValueBearerImpl(1)));
+   }
+
+
+   public void assertRawObject(FootballTeam proxy)
+   {
+      InterceptorTestLogger.reset();
+      FootballTeam rawInstance = InterceptionUtils.getRawInstance(proxy);
+      Assert.assertEquals(TEAM_NAME, rawInstance.getName());
+      Object[] logValues = InterceptorTestLogger.getLog().toArray();
+      Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValuesWhenRaw, logValues);
+   }
+
+   private String iterateAndDisplay(Object[] logValues)
+   {
+      StringBuffer buffer = new StringBuffer();
+      for (Object logValue : logValues)
+      {
+         buffer.append(logValue.toString()).append("\n");
+      }
+      return buffer.toString();
+   }
+
+
+}

Modified: projects/interceptors/trunk/pom.xml
===================================================================
--- projects/interceptors/trunk/pom.xml	2010-02-03 02:02:35 UTC (rev 100310)
+++ projects/interceptors/trunk/pom.xml	2010-02-03 02:23:18 UTC (rev 100311)
@@ -75,8 +75,8 @@
             <redirectTestOutputToFile>true</redirectTestOutputToFile>
             <!--testFailureIgnore>true</testFailureIgnore-->
             <includes>
-              <include>org/jboss/interceptor/**/*TestCase.java</include>
-              <include>org/jboss/interceptor/**/*Test.java</include>              
+              <include>org/jboss/interceptors/**/*TestCase.java</include>
+              <include>org/jboss/interceptors/**/*Test.java</include>              
             </includes>
           </configuration>
         </plugin>




More information about the jboss-cvs-commits mailing list