directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r414589 - in /directory/trunks/apacheds: server-tools/src/main/java/org/apache/directory/server/tools/ server-unit/src/test/java/org/apache/directory/server/
Date Thu, 15 Jun 2006 14:08:32 GMT
Author: akarasulu
Date: Thu Jun 15 07:08:32 2006
New Revision: 414589

URL: http://svn.apache.org/viewvc?rev=414589&view=rev
Log:
adding hello world stored procedure and a test case to try it out

Added:
    directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/HelloWorldProcedure.java
    directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/StoredProcedureTest.java
Modified:
    directory/trunks/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/StoredProcedureCommand.java

Modified: directory/trunks/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/StoredProcedureCommand.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/StoredProcedureCommand.java?rev=414589&r1=414588&r2=414589&view=diff
==============================================================================
--- directory/trunks/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/StoredProcedureCommand.java
(original)
+++ directory/trunks/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/StoredProcedureCommand.java
Thu Jun 15 07:08:32 2006
@@ -78,7 +78,7 @@
         }
 
         String language = "java";
-        String procedure = "hello";
+        String procedure = "HelloWorldProcedure.sayHello";
         StoredProcedureRequest req = new StoredProcedureRequest( 0, procedure, language );
         ctx.extendedOperation( req );
         ctx.close();

Added: directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/HelloWorldProcedure.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/HelloWorldProcedure.java?rev=414589&view=auto
==============================================================================
--- directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/HelloWorldProcedure.java
(added)
+++ directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/HelloWorldProcedure.java
Thu Jun 15 07:08:32 2006
@@ -0,0 +1,10 @@
+package org.apache.directory.server;
+
+
+public class HelloWorldProcedure
+{
+    public void sayHello()
+    {
+        System.out.println( "Hello World!" );
+    }
+}

Added: directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/StoredProcedureTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/StoredProcedureTest.java?rev=414589&view=auto
==============================================================================
--- directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/StoredProcedureTest.java
(added)
+++ directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/StoredProcedureTest.java
Thu Jun 15 07:08:32 2006
@@ -0,0 +1,97 @@
+/*
+ *   Copyright 2004 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.directory.server;
+
+
+import javax.naming.directory.*;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+import javax.naming.NamingException;
+
+import org.apache.directory.server.unit.AbstractServerTest;
+import org.apache.directory.shared.ldap.message.extended.StoredProcedureRequest;
+import org.apache.directory.shared.ldap.message.extended.StoredProcedureResponse;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Hashtable;
+
+
+/**
+ * Test case to verify DIREVE-216.  Starts up the server binds via SUN JNDI provider
+ * to perform add modify operations on entries.
+ * 
+ * @author szoerner
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 379013 $
+ */
+public class StoredProcedureTest extends AbstractServerTest
+{
+    private LdapContext ctx = null;
+
+
+    /**
+     * Create an entry for a person.
+     */
+    public void setUp() throws Exception
+    {
+        super.setUp();
+
+        Hashtable env = new Hashtable();
+        env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
+        env.put( "java.naming.provider.url", "ldap://localhost:" + port + "/ou=system" );
+        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
+        env.put( "java.naming.security.credentials", "secret" );
+        env.put( "java.naming.security.authentication", "simple" );
+        ctx = new InitialLdapContext( env, null );
+
+        URL url = getClass().getResource( "HelloWorldProcedure.class" );
+        InputStream in = getClass().getResourceAsStream( "HelloWorldProcedure.class" );
+        File file = new File( url.getFile() );
+        int size = ( int ) file.length();
+        byte[] buf = new byte[size];
+        in.read( buf );
+        in.close();
+        
+        // set up
+        Attributes attributes = new BasicAttributes( "objectClass", "top", true );
+        attributes.get( "objectClass" ).add( "javaClass" );
+        attributes.put( "fullyQualifiedClassName", HelloWorldProcedure.class.getName() );
+        attributes.put( "byteCode", buf );
+        ctx.createSubcontext( "fullyQualifiedClassName=" + HelloWorldProcedure.class.getName(),
attributes );
+    }
+
+
+    public void tearDown() throws Exception
+    {
+        ctx.close();
+        ctx = null;
+    }
+
+
+    /**
+     */
+    public void testExecuteProcedure() throws NamingException
+    {
+        String language = "java";
+        String procedure = "org.apache.directory.server.HelloWorldProcedure.sayHello";
+        StoredProcedureRequest req = new StoredProcedureRequest( 0, procedure, language );
+        StoredProcedureResponse resp = ( StoredProcedureResponse ) ctx.extendedOperation(
req );
+        assertNotNull( resp );
+    }
+}



Mime
View raw message