openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1427084 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/proxy/asm/ test/java/org/apache/webbeans/newtests/interceptors/factory/ test/java/org/apache/webbeans/newtests/interceptors/factory/beans/
Date Mon, 31 Dec 2012 11:17:32 GMT
Author: struberg
Date: Mon Dec 31 11:17:31 2012
New Revision: 1427084

URL: http://svn.apache.org/viewvc?rev=1427084&view=rev
Log:
OWB-344 add test class for non-intercepted methods

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/MethodInterceptedClass.java
      - copied, changed from r1427033, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/asm/InterceptorDecoratorProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/asm/InterceptorDecoratorProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/asm/InterceptorDecoratorProxyFactory.java?rev=1427084&r1=1427083&r2=1427084&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/asm/InterceptorDecoratorProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/asm/InterceptorDecoratorProxyFactory.java
Mon Dec 31 11:17:31 2012
@@ -30,6 +30,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.proxy.ProxyGenerationException;
 import org.objectweb.asm.ClassWriter;
 import org.objectweb.asm.MethodVisitor;
@@ -55,6 +56,16 @@ public class InterceptorDecoratorProxyFa
     /** the name of the field which stores the proxied instance */
     public static final String FIELD_PROXIED_INSTANCE = "owbIntDecProxiedInstance";
 
+    //X TODO add caching of created proxy classes. This is needed to prevent class loading
clashes.
+    //X a generated proxy cannot easily get redefined later!
+
+    private WebBeansContext webBeansContext;
+
+    public InterceptorDecoratorProxyFactory(WebBeansContext webBeansContext)
+    {
+        this.webBeansContext = webBeansContext;
+    }
+
     public <T> T createProxyInstance(Class<T> proxyClass, T instance)
             throws ProxyGenerationException
     {

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java?rev=1427084&r1=1427083&r2=1427084&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/InterceptorDecoratorProxyFactoryTest.java
Mon Dec 31 11:17:31 2012
@@ -19,7 +19,10 @@
 package org.apache.webbeans.newtests.interceptors.factory;
 
 import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collection;
 
+import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.newtests.interceptors.factory.beans.ClassInterceptedClass;
 import org.apache.webbeans.proxy.asm.InterceptorDecoratorProxyFactory;
 
@@ -30,13 +33,16 @@ import org.junit.Test;
 /**
  * Test the {@link org.apache.webbeans.proxy.asm.InterceptorDecoratorProxyFactory}
  */
-public class InterceptorDecoratorProxyFactoryTest
+public class InterceptorDecoratorProxyFactoryTest extends AbstractUnitTest
 {
 
     @Test
     public void textSimpleProxyCreation() throws Exception
     {
-        InterceptorDecoratorProxyFactory pf = new InterceptorDecoratorProxyFactory();
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        startContainer(beanClasses, null);
+
+        InterceptorDecoratorProxyFactory pf = new InterceptorDecoratorProxyFactory(getWebBeansContext());
 
         ClassLoader classLoader = this.getClass().getClassLoader();
 
@@ -58,5 +64,8 @@ public class InterceptorDecoratorProxyFa
         proxy.setMeaningOfLife(42);
 
         Assert.assertEquals(42, proxy.getMeaningOfLife());
+
+
+        shutDownContainer();
     }
 }

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/MethodInterceptedClass.java
(from r1427033, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/MethodInterceptedClass.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/MethodInterceptedClass.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java&r1=1427033&r2=1427084&rev=1427084&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/ClassInterceptedClass.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/factory/beans/MethodInterceptedClass.java
Mon Dec 31 11:17:31 2012
@@ -21,20 +21,21 @@ package org.apache.webbeans.newtests.int
 import org.apache.webbeans.test.component.intercept.webbeans.bindings.Transactional;
 
 /**
- * A simple class which is not intercepted
+ * A simple class which is not intercepted but has some
+ * methods which are.
  */
-@Transactional
-public class ClassInterceptedClass
+public class MethodInterceptedClass
 {
     private boolean defaultCtInvoked = false;
 
     private int meaningOfLife;
 
-    public ClassInterceptedClass()
+    public MethodInterceptedClass()
     {
         defaultCtInvoked = true;
     }
 
+    @Transactional
     public int getMeaningOfLife()
     {
         System.out.println("answering the question about life, the universe and everything!");
@@ -42,9 +43,14 @@ public class ClassInterceptedClass
         return meaningOfLife;
     }
 
+    @Transactional
     public void setMeaningOfLife(int meaningOfLife)
     {
         this.meaningOfLife = meaningOfLife;
     }
 
+    public int nonTransactionalGetter()
+    {
+        return meaningOfLife + 2;
+    }
 }



Mime
View raw message