directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r718202 - in /directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/util: ./ TestCodeEnhancer.java
Date Mon, 17 Nov 2008 09:02:37 GMT
Author: kayyagari
Date: Mon Nov 17 01:02:35 2008
New Revision: 718202

URL: http://svn.apache.org/viewvc?rev=718202&view=rev
Log:
tesat case for code enhancer

Added:
    directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/util/
    directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/util/TestCodeEnhancer.java

Added: directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/util/TestCodeEnhancer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/util/TestCodeEnhancer.java?rev=718202&view=auto
==============================================================================
--- directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/util/TestCodeEnhancer.java
(added)
+++ directory/sandbox/kayyagari/apacheds-olm/src/test/java/org/apache/directory/olm/util/TestCodeEnhancer.java
Mon Nov 17 01:02:35 2008
@@ -0,0 +1,132 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.apache.directory.olm.util;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import net.sf.cglib.transform.impl.InterceptFieldEnabled;
+
+import org.apache.directory.olm.SingleValueAttribute;
+import org.junit.Before;
+import org.junit.Test;
+import org.objectweb.asm.ClassReader;
+
+
+/**
+ * 
+ * TestCodeEnhancer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class TestCodeEnhancer
+{
+    
+    File classFile;
+
+    @Before
+    public void enhanceClassFile() throws Exception
+    {
+        CodeEnhancer ce = new CodeEnhancer();
+        
+        String fileName = TestAttributeImpl.class.getName().replace( ".", "/" ) + ".class";
+        
+        fileName = TestCodeEnhancer.class.getClassLoader().getSystemResource( fileName ).getPath();
+        
+        classFile = new File( fileName );
+        ce.enhance( classFile );
+    }
+    
+    
+    @Test
+    public void testFieldInterceptor() throws Exception
+    {
+        ClassReader reader = new ClassReader( new FileInputStream( classFile ) );
+        String[] interfaces = reader.getInterfaces();
+        
+        String expected = InterceptFieldEnabled.class.getName().replace( ".", "/" );
+        
+        for( String s : interfaces )
+        {
+            if( s.equals( expected ) )
+            {
+                assertTrue( true );
+                return;
+            }
+        }
+        
+        fail( "The class was not enhanced" );
+    }
+    
+
+    class TestAttributeImpl implements SingleValueAttribute
+    {
+
+        public String getName()
+        {
+            return null;
+        }
+
+        public Object getValue()
+        {
+            return null;
+        }
+
+        public Class getJavaType()
+        {
+            return null;
+        }
+
+        public String getOid()
+        {
+            return null;
+        }
+
+        public String getSyntax()
+        {
+            return null;
+        }
+
+        public boolean isCollective()
+        {
+            return false;
+        }
+
+        public boolean isNoUserModification()
+        {
+            return false;
+        }
+
+        public boolean isObsolete()
+        {
+            return false;
+        }
+
+        public boolean isSingleValue()
+        {
+            return false;
+        }
+        
+    }
+}



Mime
View raw message