directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1073538 - in /directory/shared/branches/akarasulu/ldap-extras/codec/src: main/java/org/apache/directory/shared/ldap/extras/extended/ main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/ test/java/org/apache/directory/shared...
Date Tue, 22 Feb 2011 23:07:11 GMT
Author: akarasulu
Date: Tue Feb 22 23:07:11 2011
New Revision: 1073538

URL: http://svn.apache.org/viewvc?rev=1073538&view=rev
Log:
DIRSHARED-86: fixing some test problems

Modified:
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureRequestImpl.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedure.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationRequestTest.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureTest.java

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureRequestImpl.java?rev=1073538&r1=1073537&r2=1073538&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureRequestImpl.java
(original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureRequestImpl.java
Tue Feb 22 23:07:11 2011
@@ -23,6 +23,9 @@ package org.apache.directory.shared.ldap
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.directory.shared.asn1.ber.tlv.IntegerDecoder;
+import org.apache.directory.shared.asn1.ber.tlv.IntegerDecoderException;
+import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.model.message.AbstractExtendedRequest;
 import org.apache.directory.shared.util.exception.NotImplementedException;
@@ -192,6 +195,24 @@ public class StoredProcedureRequestImpl 
     /**
      * {@inheritDoc}
      */
+    public Object getParameterTypeString( int index )
+    {
+        if ( ! language.equals( "java" ) )
+        {
+            Object obj = parameters.get( index ).getType();
+            if ( obj instanceof byte[] )
+            {
+                return Strings.utf8ToString( ( byte [] ) obj );
+            }
+        }
+
+        return getJavaParameterType( index );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     public Class<?> getJavaParameterType( int index )
     {
         throw new NotImplementedException( I18n.err( I18n.ERR_04175 ) );
@@ -215,6 +236,42 @@ public class StoredProcedureRequestImpl 
     /**
      * {@inheritDoc}
      */
+    public Object getParameterValueString( int index )
+    {
+        if ( ! language.equals( "java" ) )
+        {
+            Object obj = parameters.get( index ).getValue();
+            if ( obj instanceof byte[] )
+            {
+                String str = Strings.utf8ToString( ( byte [] ) obj );
+                String type = ( String ) getParameterTypeString( index );
+                
+                if ( type.equals( "int" ) )
+                {
+                    try
+                    {
+                        return IntegerDecoder.parse( new Value( (byte[]) obj ) );
+                    }
+                    catch ( IntegerDecoderException e )
+                    {
+                        throw new RuntimeException( "Failed to decode INTEGER: " + 
+                            Strings.dumpBytes( ( byte[] ) obj ), e );
+                    }
+                }
+                else 
+                {
+                    return str;
+                }
+            }
+        }
+
+        return getJavaParameterValue( index );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     public Object getJavaParameterValue( int index )
     {
         throw new NotImplementedException( I18n.err( I18n.ERR_04176 ) );

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedure.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedure.java?rev=1073538&r1=1073537&r2=1073538&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedure.java
(original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedure.java
Tue Feb 22 23:07:11 2011
@@ -98,6 +98,18 @@ public class StoredProcedure extends Abs
         byte[] value;
 
 
+        public String getTypeString()
+        {
+            return Strings.utf8ToString( type );
+        }
+        
+        
+        public String getValueString()
+        {
+            return Strings.utf8ToString( value );
+        }
+        
+        
         public byte[] getType()
         {
             if ( type == null )
@@ -362,6 +374,12 @@ public class StoredProcedure extends Abs
     }
 
 
+    public Object getParameterTypeString( int index )
+    {
+        return request.getParameterTypeString( index );
+    }
+
+
     public Class<?> getJavaParameterType( int index )
     {
         return request.getJavaParameterType( index );
@@ -374,6 +392,12 @@ public class StoredProcedure extends Abs
     }
 
 
+    public Object getParameterValueString( int index )
+    {
+        return request.getParameterValueString( index );
+    }
+
+
     public Object getJavaParameterValue( int index )
     {
         return request.getJavaParameterValue( index );

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationRequestTest.java?rev=1073538&r1=1073537&r2=1073538&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationRequestTest.java
(original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationRequestTest.java
Tue Feb 22 23:07:11 2011
@@ -93,7 +93,7 @@ public class CertGenerationRequestTest
         bb.put( new byte[]
             { 0x04, 0x03, 'R', 'S', 'A' } );
 
-        String decodedPdu = Strings.dumpBytes(bb.array());
+        String decodedPdu = Strings.dumpBytes( bb.array() );
         bb.flip();
 
         CertGenerationContainer container = new CertGenerationContainer();
@@ -114,7 +114,7 @@ public class CertGenerationRequestTest
         assertEquals( dn, req.getSubjectDN() );
         assertEquals( keyAlgo, req.getKeyAlgorithm() );
 
-        assertEquals( bufLen, req.computeLength() );
+        assertEquals( bufLen, req.getCertGenerationObject().computeLength() );
 
         try
         {

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureTest.java?rev=1073538&r1=1073537&r2=1073538&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureTest.java
(original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureTest.java
Tue Feb 22 23:07:11 2011
@@ -78,7 +78,7 @@ public class StoredProcedureTest
         stream.flip();
 
         // Allocate a StoredProcedure Container
-        Asn1Container storedProcedureContainer = new StoredProcedureContainer();
+        StoredProcedureContainer storedProcedureContainer = new StoredProcedureContainer();
 
         // Decode a StoredProcedure message
         try
@@ -91,7 +91,7 @@ public class StoredProcedureTest
             fail( de.getMessage() );
         }
 
-        StoredProcedure storedProcedure = ( ( StoredProcedureContainer ) storedProcedureContainer
).getStoredProcedure();
+        StoredProcedure storedProcedure = storedProcedureContainer.getStoredProcedure();
 
         assertEquals("Java", storedProcedure.getLanguage());
         
@@ -99,14 +99,14 @@ public class StoredProcedureTest
 
         assertEquals( 3, storedProcedure.size() );
 
-        assertEquals( "int", storedProcedure.getParameterType( 0 ) );
-        assertEquals( 1, storedProcedure.getParameterValue( 0 ) );
+        assertEquals( "int", storedProcedure.getParameterTypeString( 0 ) );
+        assertEquals( 1, storedProcedure.getParameterValueString( 0 ) );
 
-        assertEquals( "boolean", storedProcedure.getParameterType( 1 ) );
-        assertEquals( "true", storedProcedure.getParameterValue( 1 ) );
+        assertEquals( "boolean", storedProcedure.getParameterTypeString( 1 ) );
+        assertEquals( "true", storedProcedure.getParameterValueString( 1 ) );
 
-        assertEquals( "String", storedProcedure.getParameterType( 2 ) );
-        assertEquals( "parameter3", storedProcedure.getParameterValue( 2 ) );
+        assertEquals( "String", storedProcedure.getParameterTypeString( 2 ) );
+        assertEquals( "parameter3", storedProcedure.getParameterValueString( 2 ) );
 
         // Check the encoding
         try
@@ -222,8 +222,8 @@ public class StoredProcedureTest
 
         assertEquals( 1, storedProcedure.size() );
 
-        assertEquals( "int", storedProcedure.getParameterType( 0 ) );
-        assertEquals( 1, storedProcedure.getParameterValue( 0 ) );
+        assertEquals( "int", storedProcedure.getParameterTypeString( 0 ) );
+        assertEquals( 1, storedProcedure.getParameterValueString( 0 ) );
 
         // Check the encoding
         try



Mime
View raw message