commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bali...@apache.org
Subject cvs commit: jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore TestEnhancer.java
Date Tue, 30 Apr 2002 18:04:35 GMT
baliuka     02/04/30 11:04:35

  Modified:    simplestore/src/java/org/apache/commons/simplestore/tools
                        Enhancer.java
               simplestore/src/test/org/apache/commons/simplestore
                        TestEnhancer.java
  Log:
  Fixed bug
  
  Revision  Changes    Path
  1.24      +6 -9      jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/tools/Enhancer.java
  
  Index: Enhancer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/tools/Enhancer.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Enhancer.java	29 Apr 2002 18:01:59 -0000	1.23
  +++ Enhancer.java	30 Apr 2002 18:04:35 -0000	1.24
  @@ -135,7 +135,7 @@
    * </pre>
    *@author     Juozas Baliuka <a href="mailto:baliuka@mwm.lt">
    *      baliuka@mwm.lt</a>
  - *@version    $Id: Enhancer.java,v 1.23 2002/04/29 18:01:59 baliuka Exp $
  + *@version    $Id: Enhancer.java,v 1.24 2002/04/30 18:04:35 baliuka Exp $
    */
   public class Enhancer implements org.apache.bcel.Constants ,
   Constants{
  @@ -237,33 +237,29 @@
               cls = Object.class;
           }
           
  -        StringBuffer key = new StringBuffer(cls.getName() + ";");
  +        StringBuffer keyBuff = new StringBuffer(cls.getName() + ";");
           if(interfaces != null){
               for(int i = 0; i< interfaces.length; i++ ){
  -                key.append(interfaces[i].getName() + ";");
  +                keyBuff.append(interfaces[i].getName() + ";");
               }
           }
  -        
  +       String key = keyBuff.toString(); 
           
           java.util.Map map = (java.util.Map) cache.get(loader);
           if ( map == null ) {
  -            map = new java.util.HashMap();
  +            map = new java.util.Hashtable();
               cache.put(loader, map);
           }
  -        
           Class result = (Class) map.get(key);
           
           
           
           if (result == null) {
  -            
                  String class_name = cls.getName() + CLASS_SUFIX;
                   if (class_name.startsWith("java")) {
                       class_name = CLASS_PREFIX + class_name;
                   }
                  class_name += index++;
  -            
  -            
               java.util.HashMap methods = new java.util.HashMap();
               JavaClass clazz = enhance(cls, class_name, interfaces, methods);
               byte b[] = clazz.getBytes();
  @@ -283,6 +279,7 @@
                   String name = (String) i.next();
                   result.getField(name).set(null, methods.get(name));
               }
  +           
               map.put(key, result);
           }
           return result
  
  
  
  1.15      +13 -8     jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestEnhancer.java
  
  Index: TestEnhancer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestEnhancer.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TestEnhancer.java	1 Apr 2002 17:08:09 -0000	1.14
  +++ TestEnhancer.java	30 Apr 2002 18:04:35 -0000	1.15
  @@ -64,7 +64,7 @@
   /**
    *@author     Juozas Baliuka <a href="mailto:baliuka@mwm.lt">
    *      baliuka@mwm.lt</a>
  - *@version    $Id: TestEnhancer.java,v 1.14 2002/04/01 17:08:09 baliuka Exp $
  + *@version    $Id: TestEnhancer.java,v 1.15 2002/04/30 18:04:35 baliuka Exp $
    */
   public class TestEnhancer  extends TestCase {
       
  @@ -85,12 +85,8 @@
     
       public void testEnhance()throws Throwable{
            
  -        
  -        java.util.Vector vector = (java.util.Vector)Enhancer.enhance(
  -        java.util.Vector.class,
  -        new Class[]{java.util.List.class},
  -        
  -        new MethodInterceptor(){
  +        MethodInterceptor interceptor =
  +         new MethodInterceptor(){
                           
               public Object beforeInvoke( Object obj,java.lang.reflect.Method method,
               Object args[] )
  @@ -113,7 +109,16 @@
               return retValFromSuper;//return the same as supper
           }
           
  -    });
  +    };
  +        
  +        java.util.Vector vector = (java.util.Vector)Enhancer.enhance(
  +        java.util.Vector.class,
  +        new Class[]{java.util.List.class},interceptor );
  +         java.util.Vector vector2 = (java.util.Vector)Enhancer.enhance(
  +        java.util.Vector.class,
  +        new Class[]{java.util.List.class},interceptor );
  +        
  +       assertTrue("Cache failed",vector.getClass() == vector2.getClass()); 
       //TODO : Add meanigful asserts
       
       String value = "VALUE";
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message