directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1163013 [2/2] - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/ core-api/src/main/java/org/apache/directory/server/core/entry/ core-api/src/main/java/org/apache/directory/server/core/schema/ core-api/...
Date Mon, 29 Aug 2011 21:26:20 GMT
Modified: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java?rev=1163013&r1=1163012&r2=1163013&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java
(original)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/ServerSelectionRecordEncoderTest.java
Mon Aug 29 21:26:19 2011
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.directory.shared.util.Strings;
 import org.apache.mina.core.buffer.IoBuffer;
 
 
@@ -46,10 +47,10 @@ public class ServerSelectionRecordEncode
     protected Map<String, Object> getAttributes()
     {
         Map<String, Object> map = new HashMap<String, Object>();
-        map.put( DnsAttribute.SERVICE_PRIORITY.toLowerCase(), priority );
-        map.put( DnsAttribute.SERVICE_WEIGHT.toLowerCase(), weight );
-        map.put( DnsAttribute.SERVICE_PORT.toLowerCase(), port );
-        map.put( DnsAttribute.DOMAIN_NAME.toLowerCase(), srvName );
+        map.put( Strings.toLowerCase( DnsAttribute.SERVICE_PRIORITY ), priority );
+        map.put( Strings.toLowerCase( DnsAttribute.SERVICE_WEIGHT ), weight );
+        map.put( Strings.toLowerCase( DnsAttribute.SERVICE_PORT ), port );
+        map.put( Strings.toLowerCase( DnsAttribute.DOMAIN_NAME ), srvName );
         return map;
     }
 

Modified: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java?rev=1163013&r1=1163012&r2=1163013&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java
(original)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/StartOfAuthorityRecordEncoderTest.java
Mon Aug 29 21:26:19 2011
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.directory.shared.util.Strings;
 import org.apache.mina.core.buffer.IoBuffer;
 
 
@@ -50,13 +51,14 @@ public class StartOfAuthorityRecordEncod
     protected Map<String, Object> getAttributes()
     {
         Map<String, Object> map = new HashMap<String, Object>();
-        map.put( DnsAttribute.SOA_M_NAME.toLowerCase(), mName );
-        map.put( DnsAttribute.SOA_R_NAME.toLowerCase(), rName );
-        map.put( DnsAttribute.SOA_SERIAL.toLowerCase(), serial );
-        map.put( DnsAttribute.SOA_REFRESH.toLowerCase(), refresh );
-        map.put( DnsAttribute.SOA_RETRY.toLowerCase(), retry );
-        map.put( DnsAttribute.SOA_EXPIRE.toLowerCase(), expire );
-        map.put( DnsAttribute.SOA_MINIMUM.toLowerCase(), minimum );
+        map.put( Strings.toLowerCase( DnsAttribute.SOA_M_NAME ), mName );
+        map.put( Strings.toLowerCase( DnsAttribute.SOA_R_NAME ), rName );
+        map.put( Strings.toLowerCase( DnsAttribute.SOA_SERIAL ), serial );
+        map.put( Strings.toLowerCase( DnsAttribute.SOA_REFRESH ), refresh );
+        map.put( Strings.toLowerCase( DnsAttribute.SOA_RETRY ), retry );
+        map.put( Strings.toLowerCase( DnsAttribute.SOA_EXPIRE ), expire );
+        map.put( Strings.toLowerCase( DnsAttribute.SOA_MINIMUM ), minimum );
+        
         return map;
     }
 

Modified: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java?rev=1163013&r1=1163012&r2=1163013&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java
(original)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/TextRecordEncoderTest.java
Mon Aug 29 21:26:19 2011
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.directory.server.dns.store.DnsAttribute;
+import org.apache.directory.shared.util.Strings;
 import org.apache.mina.core.buffer.IoBuffer;
 
 
@@ -42,7 +43,7 @@ public class TextRecordEncoderTest exten
     protected Map<String, Object> getAttributes()
     {
         Map<String, Object> map = new HashMap<String, Object>();
-        map.put( DnsAttribute.CHARACTER_STRING.toLowerCase(), characterString );
+        map.put( Strings.toLowerCase( DnsAttribute.CHARACTER_STRING ), characterString );
         return map;
     }
 

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java?rev=1163013&r1=1163012&r2=1163013&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java
Mon Aug 29 21:26:19 2011
@@ -30,6 +30,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.model.message.SearchScope;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.util.Strings;
 
 
 /**
@@ -133,9 +134,9 @@ public class SyncreplConfiguration imple
     {
         attributes = new HashSet<String>();
         attributes.add( SchemaConstants.ALL_USER_ATTRIBUTES );
-        attributes.add( SchemaConstants.ENTRY_UUID_AT.toLowerCase() );
-        attributes.add( SchemaConstants.ENTRY_CSN_AT.toLowerCase() );
-        attributes.add( SchemaConstants.REF_AT.toLowerCase() );
+        attributes.add( Strings.toLowerCase( SchemaConstants.ENTRY_UUID_AT ) );
+        attributes.add( Strings.toLowerCase( SchemaConstants.ENTRY_CSN_AT ) );
+        attributes.add( Strings.toLowerCase( SchemaConstants.REF_AT ) );
     }
 
 
@@ -318,7 +319,7 @@ public class SyncreplConfiguration imple
         {
             at = at.trim();
 
-            if ( !attributes.contains( at.toLowerCase() ) )
+            if ( !attributes.contains( Strings.toLowerCase( at ) ) )
             {
                 attributes.add( at );
             }

Added: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/IndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/IndexTest.java?rev=1163013&view=auto
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/IndexTest.java
(added)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/IndexTest.java
Mon Aug 29 21:26:19 2011
@@ -0,0 +1,150 @@
+/*
+ *   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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
+import org.apache.directory.server.xdbm.Index;
+import org.apache.directory.server.xdbm.IndexCursor;
+import org.apache.directory.server.xdbm.impl.avl.AvlIndex;
+import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.schema.AttributeType;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schemaextractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.exception.Exceptions;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+
+
+public class IndexTest
+{
+    private static File dbFileDir;
+    private static SchemaManager schemaManager;
+    
+    private JdbmIndex<String, Entry> jdbmIndex;
+    private AvlIndex<String, Entry> avlIndex;
+
+
+    @BeforeClass
+    public static void init() throws Exception
+    {
+        String workingDirectory = System.getProperty( "workingDirectory" );
+
+        if ( workingDirectory == null )
+        {
+            String path = IndexTest.class.getResource( "" ).getPath();
+            int targetPos = path.indexOf( "target" );
+            workingDirectory = path.substring( 0, targetPos + 6 );
+        }
+
+        File schemaRepository = new File( workingDirectory, "schema" );
+        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory
) );
+        extractor.extractOrCopy( true );
+        LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+        schemaManager = new DefaultSchemaManager( loader );
+
+        boolean loaded = schemaManager.loadAllEnabled();
+
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors())
);
+        }
+    }
+
+
+    @Before
+    public void setup() throws Exception
+    {
+
+        File tmpIndexFile = File.createTempFile( IndexTest.class.getSimpleName(), "db" );
+        tmpIndexFile.deleteOnExit();
+        dbFileDir = new File( tmpIndexFile.getParentFile(), IndexTest.class.getSimpleName()
);
+        dbFileDir.mkdirs();
+        
+        AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OU_AT
);
+
+        jdbmIndex = new JdbmIndex<String, Entry>();
+        jdbmIndex.setWkDirPath( dbFileDir.toURI() );
+        jdbmIndex.init( schemaManager, attributeType );
+        
+        avlIndex = new AvlIndex<String, Entry>();
+        avlIndex.init( schemaManager, attributeType );
+    }
+
+    @Test
+    public void testAvlIndex() throws Exception
+    {
+        doTest( avlIndex );
+    }
+
+    @Test
+    public void testJdbmIndex() throws Exception
+    {
+        doTest( jdbmIndex );
+    }
+    
+    private void doTest(Index<String, Entry, Long> idx) throws Exception
+    {
+        String alphabet = "abcdefghijklmnopqrstuvwxyz";
+
+        for ( long i = 0L; i < 26L; i++ )
+        {
+            String val = alphabet.substring( (int)i, (int)(i+1) );
+            idx.add( val, i + 1 );
+        }
+
+        assertEquals( 26, idx.count() );
+        
+        IndexCursor<String, Entry, Long> cursor1 = idx.forwardCursor();
+        cursor1.beforeFirst();
+
+        assertHasNext(cursor1, 1L);
+        assertHasNext(cursor1, 2L);
+        
+        idx.drop( "c", 3L );
+
+        for ( long i = 4L; i < 27L; i++ )
+        {
+            assertHasNext(cursor1, i);
+        }
+        
+        assertFalse(cursor1.next());
+    }
+
+    private void assertHasNext( IndexCursor<String, Entry, Long> cursor1, long expectedId
) throws Exception
+    {
+        assertTrue(cursor1.next());
+        //System.out.println(cursor1.get());
+        assertEquals(expectedId, cursor1.get().getId().longValue());
+    }
+}

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareIT.java?rev=1163013&r1=1163012&r2=1163013&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareIT.java
Mon Aug 29 21:26:19 2011
@@ -33,6 +33,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.integ.ServerIntegrationUtils;
+import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -96,7 +97,7 @@ public class MatchingRuleCompareIT exten
         ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
 
         String[] values =
-            { PERSON_SN, PERSON_SN.toUpperCase(), PERSON_SN.toLowerCase(), PERSON_SN + "X"
};
+            { PERSON_SN, PERSON_SN.toUpperCase(), Strings.toLowerCase( PERSON_SN ), PERSON_SN
+ "X" };
         boolean[] expected =
             { true, true, true, false };
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsUpdateCertificateIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsUpdateCertificateIT.java?rev=1163013&r1=1163012&r2=1163013&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsUpdateCertificateIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsUpdateCertificateIT.java
Mon Aug 29 21:26:19 2011
@@ -49,6 +49,7 @@ import org.apache.directory.server.opera
 import org.apache.directory.shared.ldap.model.constants.SupportedSaslMechanisms;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.util.Strings;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -152,8 +153,10 @@ public class LdapsUpdateCertificateIT ex
         String subjectDN = lastReceivedServerCertificates[0].getSubjectDN().getName();
         // converting the values to lowercase is required cause the certificate is
         // having attribute names in capital letters e.c the above newIssuerDN will be present
as CN=new_issuer_dn
-        assertEquals( "Expected the new certificate with the new issuer", newIssuerDN.toLowerCase(),
issuerDN.toLowerCase() );
-        assertEquals( "Expected the new certificate with the new subject", newSubjectDN.toLowerCase(),
subjectDN.toLowerCase() );
+        assertEquals( "Expected the new certificate with the new issuer", 
+            Strings.toLowerCase( newIssuerDN ), Strings.toLowerCase( issuerDN ) );
+        assertEquals( "Expected the new certificate with the new subject", 
+            Strings.toLowerCase( newSubjectDN ), Strings.toLowerCase( subjectDN ) );
     }
 
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsUpdateCertificateIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsUpdateCertificateIT.java?rev=1163013&r1=1163012&r2=1163013&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsUpdateCertificateIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsUpdateCertificateIT.java
Mon Aug 29 21:26:19 2011
@@ -53,6 +53,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.ldap.handlers.extended.StartTlsHandler;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.util.Strings;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
@@ -208,7 +209,7 @@ public class StartTlsUpdateCertificateIT
         assertEquals( 1, lastReceivedServerCertificates.length );
         String issuerDN = lastReceivedServerCertificates[0].getIssuerDN().getName();
         String subjectDN = lastReceivedServerCertificates[0].getSubjectDN().getName();
-        assertEquals( "Expected the new certificate with the new issuer", newIssuerDN.toLowerCase(),
issuerDN.toLowerCase() );
-        assertEquals( "Expected the new certificate with the new subject", newSubjectDN.toLowerCase(),
subjectDN.toLowerCase() );
+        assertEquals( "Expected the new certificate with the new issuer", Strings.toLowerCase(
newIssuerDN ), Strings.toLowerCase( issuerDN ) );
+        assertEquals( "Expected the new certificate with the new subject", Strings.toLowerCase(
newSubjectDN ), Strings.toLowerCase( subjectDN ) );
     }
 }

Modified: directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java?rev=1163013&r1=1163012&r2=1163013&view=diff
==============================================================================
--- directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
(original)
+++ directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
Mon Aug 29 21:26:19 2011
@@ -425,7 +425,7 @@ public class ApacheDS
             {
                 public boolean accept( File pathname )
                 {
-                    boolean isLdif = pathname.getName().toLowerCase().endsWith( ".ldif" );
+                    boolean isLdif = Strings.toLowerCase( pathname.getName() ).endsWith(
".ldif" );
                     return pathname.isFile() && pathname.canRead() && isLdif;
                 }
             } );

Modified: directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java?rev=1163013&r1=1163012&r2=1163013&view=diff
==============================================================================
--- directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java
(original)
+++ directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java
Mon Aug 29 21:26:19 2011
@@ -102,6 +102,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.message.SearchScope;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.bouncycastle.util.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -127,7 +128,7 @@ public class ServiceBuilder
                 return true;
             }
 
-            return file.getName().toLowerCase().endsWith( ".ldif" );
+            return Strings.toLowerCase( file.getName() ).endsWith( ".ldif" );
         }
     };
     



Mime
View raw message