directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r349801 - in /directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs: StoredProcedureTests.java codec/StoredProcedureDecoder.java
Date Tue, 29 Nov 2005 19:45:18 GMT
Author: ersiner
Date: Tue Nov 29 11:45:01 2005
New Revision: 349801

URL: http://svn.apache.org/viewcvs?rev=349801&view=rev
Log:
Adding files that I missed in previous commits.

(Using IDE support for version control is a good thing!)

Added:
    directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/StoredProcedureTests.java
    directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureDecoder.java

Added: directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/StoredProcedureTests.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/StoredProcedureTests.java?rev=349801&view=auto
==============================================================================
--- directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/StoredProcedureTests.java
(added)
+++ directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/StoredProcedureTests.java
Tue Nov 29 11:45:01 2005
@@ -0,0 +1,147 @@
+/*
+ *   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 java.lang.reflect.InvocationTargetException;
+import java.nio.ByteBuffer;
+
+import javax.naming.NamingException;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1.codec.util.StringUtils;
+import org.apache.asn1new.ber.Asn1Decoder;
+import org.apache.asn1new.ber.containers.IAsn1Container;
+import org.apache.ldap.server.storedprocs.codec.StoredProcedureContainer;
+import org.apache.ldap.server.storedprocs.codec.StoredProcedureDecoder;
+
+
+public class StoredProcedureTests extends TestCase
+{
+    public void testDecodeStoredProcedure() throws NamingException
+    {
+        Asn1Decoder storedProcedureDecoder = new StoredProcedureDecoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x3E );
+
+        stream.put(
+            new byte[]
+            {
+                0x30, 0x3C, 		
+				  0x04, 0x04, 'J', 'a', 'v', 'a', 	
+				  0x04, 0x07, 'e', 'x', 'e', 'c', 'u', 't', 'e',		
+				  0x30, 0x2B, 
+					0x04, 0x03, 'i', 'n', 't',
+					0x04, 0x01, 0x01,
+					
+					0x04, 0x07, 'b', 'o', 'o', 'l', 'e', 'a', 'n',
+					0x04, 0x04, 't', 'r', 'u', 'e',
+					
+					0x04, 0x06, 'S', 't', 'r', 'i', 'n', 'g',
+					0x04, 0x0A, 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', '3'
+            } );
+
+        // String decodedPdu = StringUtils.dumpBytes( stream.array() );
+        stream.flip();
+
+        // Allocate a StoredProcedure Container
+        IAsn1Container storedProcedureContainer = new StoredProcedureContainer();
+
+        // Decode a StoredProcedure message
+        try
+        {
+            storedProcedureDecoder.decode( stream, storedProcedureContainer );
+        }
+        catch (DecoderException de)
+        {
+            de.printStackTrace();
+            Assert.fail( de.getMessage() );
+        }
+
+        StoredProcedurePojo pojo = ( ( StoredProcedureContainer ) storedProcedureContainer
)
+                .getStoredProcedurePojo();
+
+        // Check the decoded message
+        Assert.assertEquals( "execute", StringUtils
+                .toUtf8( pojo.getProcedure() ) );
+
+        Assert.assertNotNull( pojo.getParameters() );
+        Assert.assertEquals( 3, pojo.getParameters().size() );
+
+        ParameterPojo param = ( ParameterPojo ) pojo.getParameters().get( 0 );
+
+        Assert.assertEquals( "int", StringUtils.toUtf8( param.getType() ) );
+        Assert.assertEquals( 1, param.getValue()[0] );
+
+        param = ( ParameterPojo ) pojo.getParameters().get( 1 );
+
+        Assert.assertEquals( "boolean", StringUtils.toUtf8( param.getType() ) );
+        Assert.assertEquals( "true", StringUtils.toUtf8( param.getValue() ) );
+
+        param = ( ParameterPojo ) pojo.getParameters().get( 2 );
+
+        Assert.assertEquals( "String", StringUtils.toUtf8( param.getType() ) );
+        Assert.assertEquals( "parameter3", StringUtils
+                .toUtf8( param.getValue() ) );
+        
+        // Unrelated Stuff...
+        try
+        {
+            System.out.println(((Class.forName( "java.lang.String" ).getConstructor( new
Class[] { String.class } )).newInstance(new Object[]{ "ersin" })).toString());
+        }
+        catch (IllegalArgumentException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch (InstantiationException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch (IllegalAccessException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch (InvocationTargetException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch (SecurityException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch (NoSuchMethodException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch (ClassNotFoundException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+}

Added: directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureDecoder.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureDecoder.java?rev=349801&view=auto
==============================================================================
--- directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureDecoder.java
(added)
+++ directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/codec/StoredProcedureDecoder.java
Tue Nov 29 11:45:01 2005
@@ -0,0 +1,37 @@
+/*
+ *   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.codec;
+
+import org.apache.asn1new.ber.Asn1Decoder;
+
+/**
+ * The Ldap decoder. This class does the initialisation of the object's pools.
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoredProcedureDecoder extends Asn1Decoder {
+    
+    /**
+     * Standard LdapDecoder constructor. 
+     *
+     */
+    public StoredProcedureDecoder()
+    {
+    }
+}
+



Mime
View raw message