directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r348726 - in /directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs: JNDIClassLoaderTest.java JavaStoredProcTest.java LdapClassLoaderTest.java
Date Thu, 24 Nov 2005 13:21:36 GMT
Author: ersiner
Date: Thu Nov 24 05:21:29 2005
New Revision: 348726

URL: http://svn.apache.org/viewcvs?rev=348726&view=rev
Log:
Added test case for new ldap stored proc runner.


Added:
    directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/JavaStoredProcTest.java
    directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/LdapClassLoaderTest.java
      - copied, changed from r348696, directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/JNDIClassLoaderTest.java
Removed:
    directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/JNDIClassLoaderTest.java

Added: directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/JavaStoredProcTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/JavaStoredProcTest.java?rev=348726&view=auto
==============================================================================
--- directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/JavaStoredProcTest.java
(added)
+++ directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/JavaStoredProcTest.java
Thu Nov 24 05:21:29 2005
@@ -0,0 +1,77 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   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.apache.ldap.server.storedprocs;
+
+
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+
+import org.apache.ldap.common.util.Base64;
+import org.apache.ldap.server.jndi.ServerLdapContext;
+import org.apache.ldap.server.unit.AbstractAdminTestCase;
+
+
+/**
+ * Test case for JavaStoredProcedure.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$ $Date$
+ */
+public class JavaStoredProcTest extends AbstractAdminTestCase
+{
+	private static final String HELLOWORLD_CLASS_BASE64 = 
+		"yv66vgAAADEAHQoABgAPCQAQABEIABIKABMAFAcAFQcAFgEABjxpbml0PgEAAygpV" +
+		"gEABENvZGUBAA9MaW5lTnVtYmVyVGFibGUBAARtYWluAQAWKFtMamF2YS9sYW5nL1N0cmluZzsp" +
+        "VgEAClNvdXJjZUZpbGUBAA9IZWxsb1dvcmxkLmphdmEMAAcACAcAFwwAGAAZAQAMSGVsbG8gV29" +
+        "ybGQhBwAaDAAbABwBAApIZWxsb1dvcmxkAQAQamF2YS9sYW5nL09iamVjdAEAEGphdmEvbGFuZy" +
+        "9TeXN0ZW0BAANvdXQBABVMamF2YS9pby9QcmludFN0cmVhbTsBABNqYXZhL2lvL1ByaW50U3RyZ" +
+        "WFtAQAHcHJpbnRsbgEAFShMamF2YS9sYW5nL1N0cmluZzspVgAhAAUABgAAAAAAAgABAAcACAAB" +
+        "AAkAAAAdAAEAAQAAAAUqtwABsQAAAAEACgAAAAYAAQAAAAEACQALAAwAAQAJAAAAJQACAAEAAAA" +
+        "JsgACEgO2AASxAAAAAQAKAAAACgACAAAABQAIAAYAAQANAAAAAgAO";
+	private static final byte[] HELLOWORLD_CLASS_BYTES = Base64.decode( HELLOWORLD_CLASS_BASE64.toCharArray()
);
+	
+    public void testLoadingClass() throws Exception
+    {
+        // set up
+        Attributes attributes = new BasicAttributes( "objectClass", "top", true );
+        attributes.get( "objectClass" ).add( "javaClass" );
+        attributes.put( "fqcn", "HelloWorld" );
+        attributes.put( "byteCode", HELLOWORLD_CLASS_BYTES );
+        sysRoot.createSubcontext( "fqcn=HelloWorld", attributes );
+        assertNotNull( sysRoot.lookup( "fqcn=HelloWorld" ) );
+
+        
+        StoredProcedure sp = new JavaStoredProcedure(
+                ( ServerLdapContext ) ( sysRoot.lookup( "" ) ), 
+                "HelloWorld.main",
+                new Class[] { String[].class }
+                );
+        
+        sp.call( new Object[] { new String[] {} } );
+        
+//        // load the class
+//        LdapClassLoader loader = new LdapClassLoader( ( ServerLdapContext ) ( sysRoot.lookup(
"" ) ) );
+//        Class clazz = loader.loadClass( "HelloWorld" );
+//        assertEquals( clazz.getName(), "HelloWorld" );
+//               
+//        // call a static method over loaded class via reflection
+//        Method m = clazz.getMethod("main", new Class[] { (new String[] {}).getClass() });
+//        m.invoke( null, new Object[] { new String[] {} } );
+    }
+}

Copied: directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/LdapClassLoaderTest.java
(from r348696, directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/JNDIClassLoaderTest.java)
URL: http://svn.apache.org/viewcvs/directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/LdapClassLoaderTest.java?p2=directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/LdapClassLoaderTest.java&p1=directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/JNDIClassLoaderTest.java&r1=348696&r2=348726&rev=348726&view=diff
==============================================================================
--- directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/JNDIClassLoaderTest.java
(original)
+++ directory/sandbox/ersiner/apacheds-with-storedprocs/core-unit/src/test/java/org/apache/ldap/server/storedprocs/LdapClassLoaderTest.java
Thu Nov 24 05:21:29 2005
@@ -30,11 +30,12 @@
 
 
 /**
+ * Test case for LdapClassLoader.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class JNDIClassLoaderTest extends AbstractAdminTestCase
+public class LdapClassLoaderTest extends AbstractAdminTestCase
 {
 	private static final String HELLOWORLD_CLASS_BASE64 = 
 		"yv66vgAAADEAHQoABgAPCQAQABEIABIKABMAFAcAFQcAFgEABjxpbml0PgEAAygpV" +
@@ -58,8 +59,8 @@
         assertNotNull( sysRoot.lookup( "fqcn=HelloWorld" ) );
 
         // load the class
-        JNDIClassLoader loader = new JNDIClassLoader( ( ServerLdapContext ) ( sysRoot.lookup(
"" ) ) );
-        Class clazz = loader.findClass( "HelloWorld" );
+        LdapClassLoader loader = new LdapClassLoader( ( ServerLdapContext ) ( sysRoot.lookup(
"" ) ) );
+        Class clazz = loader.loadClass( "HelloWorld" );
         assertEquals( clazz.getName(), "HelloWorld" );
                
         // call a static method over loaded class via reflection



Mime
View raw message