directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1484389 [2/2] - in /directory: apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/ apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/prefs/ apacheds/trunk/core/src/main/java/org/apache/dir...
Date Mon, 20 May 2013 07:47:41 GMT
Modified: directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Base32.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Base32.java?rev=1484389&r1=1484388&r2=1484389&view=diff
==============================================================================
--- directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Base32.java (original)
+++ directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Base32.java Mon May 20 07:47:40 2013
@@ -1,159 +0,0 @@
-/*
- *  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.api.util;
-
-
-/**
- * decoding of base32 characters to raw bytes.
- * 
- * TODO: This class isn't used, remove it?
- * 
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public final class Base32
-{
-    /** The available characters */
-    private static final byte[] CHARS = new byte[]
-        {
-            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
-            'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
-            'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
-            'Y', 'Z', '2', '3', '4', '5', '6', '7' };
-
-
-    /**
-     * Private constructor.
-     */
-    private Base32()
-    {
-    }
-
-
-    /**
-     * Encodes a string to a Base64 encoded String.
-     *
-     * @param str the string
-     * @return the Base64 encoded string
-     */
-    public static String encode( String str )
-    {
-        if ( Strings.isEmpty( str ) )
-        {
-            return "";
-        }
-
-        byte[] data = Strings.getBytesUtf8( str );
-        int dataLength = data.length;
-        int newLength = ( ( dataLength << 3 ) / 5 ) + ( ( dataLength % 5 ) == 0 ? 0 : 1 );
-        newLength += ( ( newLength % 8 == 0 ) ? 0 : 8 - newLength % 8 );
-        byte[] out = new byte[newLength];
-
-        int roundLength = ( dataLength / 5 ) * 5;
-        int posOut = 0;
-        int posIn = 0;
-
-        if ( roundLength != 0 )
-        {
-            for ( posIn = 0; posIn < roundLength; posIn += 5 )
-            {
-                byte b0 = data[posIn];
-                byte b1 = data[posIn + 1];
-                byte b2 = data[posIn + 2];
-                byte b3 = data[posIn + 3];
-                byte b4 = data[posIn + 4];
-
-                out[posOut++] = CHARS[( b0 & 0xF8 ) >> 3];
-                out[posOut++] = CHARS[( ( b0 & 0x07 ) << 2 ) | ( ( b1 & 0xC0 ) >> 6 )];
-                out[posOut++] = CHARS[( b1 & 0x3E ) >> 1];
-                out[posOut++] = CHARS[( ( b1 & 0x01 ) << 4 ) | ( ( b2 & 0xF0 ) >> 4 )];
-                out[posOut++] = CHARS[( ( b2 & 0x0F ) << 1 ) | ( ( b3 & 0x80 ) >> 7 )];
-                out[posOut++] = CHARS[( b3 & 0x7C ) >> 2];
-                out[posOut++] = CHARS[( ( b3 & 0x03 ) << 3 ) | ( ( b4 & 0x70 ) >> 5 )];
-                out[posOut++] = CHARS[b4 & 0x1F];
-            }
-        }
-
-        int remaining = dataLength - roundLength;
-
-        switch ( remaining )
-        {
-            case 1:
-                byte b0 = data[posIn++];
-
-                out[posOut++] = CHARS[( b0 & 0xF8 ) >> 3];
-                out[posOut++] = CHARS[( ( b0 & 0x07 ) << 2 )];
-                out[posOut++] = '=';
-                out[posOut++] = '=';
-                out[posOut++] = '=';
-                out[posOut++] = '=';
-                out[posOut++] = '=';
-                out[posOut++] = '=';
-                break;
-
-            case 2:
-                b0 = data[posIn++];
-                byte b1 = data[posIn++];
-
-                out[posOut++] = CHARS[( b0 & 0xF8 ) >> 3];
-                out[posOut++] = CHARS[( ( b0 & 0x07 ) << 2 ) | ( ( b1 & 0xC0 ) >> 6 )];
-                out[posOut++] = CHARS[( b1 & 0x3E ) >> 1];
-                out[posOut++] = CHARS[( ( b1 & 0x01 ) << 4 )];
-                out[posOut++] = '=';
-                out[posOut++] = '=';
-                out[posOut++] = '=';
-                out[posOut++] = '=';
-                break;
-
-            case 3:
-                b0 = data[posIn++];
-                b1 = data[posIn++];
-                byte b2 = data[posIn++];
-
-                out[posOut++] = CHARS[( b0 & 0xF8 ) >> 3];
-                out[posOut++] = CHARS[( ( b0 & 0x07 ) << 2 ) | ( ( b1 & 0xC0 ) >> 6 )];
-                out[posOut++] = CHARS[( b1 & 0x3E ) >> 1];
-                out[posOut++] = CHARS[( ( b1 & 0x01 ) << 4 ) | ( ( b2 & 0xF0 ) >> 4 )];
-                out[posOut++] = CHARS[( ( b2 & 0x0F ) << 1 )];
-                out[posOut++] = '=';
-                out[posOut++] = '=';
-                out[posOut++] = '=';
-                break;
-
-            case 4:
-                b0 = data[posIn++];
-                b1 = data[posIn++];
-                b2 = data[posIn++];
-                byte b3 = data[posIn++];
-
-                out[posOut++] = CHARS[( b0 & 0xF8 ) >> 3];
-                out[posOut++] = CHARS[( ( b0 & 0x07 ) << 2 ) | ( ( b1 & 0xC0 ) >> 6 )];
-                out[posOut++] = CHARS[( b1 & 0x3E ) >> 1];
-                out[posOut++] = CHARS[( ( b1 & 0x01 ) << 4 ) | ( ( b2 & 0xF0 ) >> 4 )];
-                out[posOut++] = CHARS[( ( b2 & 0x0F ) << 1 ) | ( ( b3 & 0x80 ) >> 7 )];
-                out[posOut++] = CHARS[( b3 & 0x7C ) >> 2];
-                out[posOut++] = CHARS[( ( b3 & 0x03 ) << 3 )];
-                out[posOut++] = '=';
-                break;
-        }
-
-        return Strings.utf8ToString( out );
-    }
-}

Modified: directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/ByteBuffer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/ByteBuffer.java?rev=1484389&r1=1484388&r2=1484389&view=diff
==============================================================================
--- directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/ByteBuffer.java (original)
+++ directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/ByteBuffer.java Mon May 20 07:47:40 2013
@@ -35,8 +35,10 @@ public class ByteBuffer
 
     /** the initial size of the buffer in number of bytes: also increment for allocations */
     private final int initialSize;
+
     /** the position into the buffer */
     private int pos = 0;
+
     /** the bytes of the buffer */
     private byte[] buf;
 
@@ -53,6 +55,7 @@ public class ByteBuffer
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_04354 ) );
         }
+
         this.initialSize = initialSize;
         this.buf = new byte[initialSize];
     }
@@ -76,9 +79,9 @@ public class ByteBuffer
     }
 
 
-    public final byte get( int ii )
+    public final byte get( int i )
     {
-        return buf[ii];
+        return buf[i];
     }
 
 
@@ -109,24 +112,27 @@ public class ByteBuffer
      */
     public final void append( byte[] bytes )
     {
-        for ( byte b : bytes )
+        if ( pos + bytes.length > buf.length )
         {
-            append( b );
+            growBuffer( bytes.length );
         }
+
+        System.arraycopy( bytes, 0, buf, pos, bytes.length );
+        pos += bytes.length;
     }
 
 
     /**
      * Appends a byte to this buffer.
      */
-    public final void append( byte bite )
+    public final void append( byte b )
     {
         if ( pos >= buf.length )
         {
             growBuffer();
         }
 
-        buf[pos] = bite;
+        buf[pos] = b;
         pos++;
     }
 
@@ -147,6 +153,23 @@ public class ByteBuffer
     }
 
 
+    private void growBuffer( int size )
+    {
+        if ( size > initialSize )
+        {
+            byte[] copy = new byte[buf.length + size];
+            System.arraycopy( buf, 0, copy, 0, pos );
+            this.buf = copy;
+        }
+        else
+        {
+            byte[] copy = new byte[buf.length + initialSize];
+            System.arraycopy( buf, 0, copy, 0, pos );
+            this.buf = copy;
+        }
+    }
+
+
     private void growBuffer()
     {
         byte[] copy = new byte[buf.length + initialSize];

Modified: directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Hex.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Hex.java?rev=1484389&r1=1484388&r2=1484389&view=diff
==============================================================================
--- directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Hex.java (original)
+++ directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Hex.java Mon May 20 07:47:40 2013
@@ -38,103 +38,15 @@ public class Hex
     public static final byte[] HEX_VALUE =
         {
             -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00 -> 0F
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1, // 10 -> 1F
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1, // 20 -> 2F
-            0,
-            1,
-            2,
-            3,
-            4,
-            5,
-            6,
-            7,
-            8,
-            9,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1, // 30 -> 3F ( 0, 1,2, 3, 4,5, 6, 7, 8, 9 )
-            -1,
-            10,
-            11,
-            12,
-            13,
-            14,
-            15,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1, // 40 -> 4F ( A, B, C, D, E, F )
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1, // 50 -> 5F
-            -1,
-            10,
-            11,
-            12,
-            13,
-            14,
-            15,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1,
-            -1 // 60 -> 6F ( a, b, c, d, e, f )
+            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10 -> 1F
+            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 20 -> 2F
+             0,  1,  2,  3,  4,  5,  6,  7,  8,  9, -1, -1, -1, -1, -1, -1, // 30 -> 3F ( 0, 1,2, 3, 4,5, 6, 7, 8, 9 )
+            -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 40 -> 4F ( A, B, C, D, E, F )
+            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 50 -> 5F
+            -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 60 -> 6F ( a, b, c, d, e, f )
+            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 70 -> 7F
     };
+    
     /** Used to build output as Hex */
     public static final char[] HEX_CHAR =
         { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };

Modified: directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/IteratorNamingEnumeration.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/IteratorNamingEnumeration.java?rev=1484389&r1=1484388&r2=1484389&view=diff
==============================================================================
--- directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/IteratorNamingEnumeration.java (original)
+++ directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/IteratorNamingEnumeration.java Mon May 20 07:47:40 2013
@@ -1,102 +0,0 @@
-/*
- *  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.api.util;
-
-
-import java.util.Iterator;
-import javax.naming.NamingEnumeration;
-
-
-/**
- * A NamingEnumeration over an Iterator.
- * 
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class IteratorNamingEnumeration<T> implements NamingEnumeration<T>
-{
-    /** the iterator to wrap as in the enumeration */
-    private Iterator<T> iterator;
-
-
-    /**
-     * Creates a NamingEnumeration over an Iterator.
-     * 
-     * @param iterator
-     *            the Iterator the NamingEnumeration is based on.
-     */
-    public IteratorNamingEnumeration( Iterator<T> iterator )
-    {
-        this.iterator = iterator;
-    }
-
-
-    // --------------------------------------------------------------------
-    // Enumeration Interface Method Implementations
-    // --------------------------------------------------------------------
-
-    /**
-     * @see java.util.Enumeration#hasMoreElements()
-     */
-    public boolean hasMoreElements()
-    {
-        return iterator.hasNext();
-    }
-
-
-    /**
-     * @see java.util.Enumeration#nextElement()
-     */
-    public T nextElement()
-    {
-        return iterator.next();
-    }
-
-
-    // --------------------------------------------------------------------
-    // NamingEnumeration Interface Method Implementations
-    // --------------------------------------------------------------------
-
-    /**
-     * @see javax.naming.NamingEnumeration#close()
-     */
-    public void close()
-    {
-        // Does nothing!
-    }
-
-
-    /**
-     * @see javax.naming.NamingEnumeration#hasMore()
-     */
-    public boolean hasMore()
-    {
-        return iterator.hasNext();
-    }
-
-
-    /**
-     * @see javax.naming.NamingEnumeration#next()
-     */
-    public T next()
-    {
-        return iterator.next();
-    }
-}

Modified: directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/JoinIterator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/JoinIterator.java?rev=1484389&r1=1484388&r2=1484389&view=diff
==============================================================================
--- directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/JoinIterator.java (original)
+++ directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/JoinIterator.java Mon May 20 07:47:40 2013
@@ -1,98 +0,0 @@
-/*
- *  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.api.util;
-
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.apache.directory.api.i18n.I18n;
-
-
-/**
- * An Iterator that joins the results of many iterators.
- * 
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class JoinIterator implements Iterator<Object>
-{
-    /** the iterators whose results are joined */
-    private final Iterator<?>[] iterators;
-
-    private int index;
-
-
-    /**
-     * Creates an Iterator that joins other Iterators.
-     * 
-     * @param iterators
-     *            the Iterators whose results are joined
-     * @throws IllegalArgumentException
-     *             if a null array argument, or one with less than 2 elements is
-     *             used
-     */
-    public JoinIterator( Iterator<?>[] iterators )
-    {
-        if ( iterators == null || iterators.length < 2 )
-        {
-            throw new IllegalArgumentException( I18n.err( I18n.ERR_04397 ) );
-        }
-
-        this.iterators = new Iterator[iterators.length];
-        System.arraycopy( iterators, 0, this.iterators, 0, iterators.length );
-        this.index = 0;
-    }
-
-
-    public void remove()
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
-    public boolean hasNext()
-    {
-        for ( /** nada */
-        ; index < iterators.length; index++ )
-        {
-            if ( iterators[index].hasNext() )
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-
-    public Object next()
-    {
-        for ( /** nada */
-        ; index < iterators.length; index++ )
-        {
-            if ( iterators[index].hasNext() )
-            {
-                return iterators[index].next();
-            }
-        }
-
-        throw new NoSuchElementException();
-    }
-}

Modified: directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/PreferencesDictionary.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/PreferencesDictionary.java?rev=1484389&r1=1484388&r2=1484389&view=diff
==============================================================================
--- directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/PreferencesDictionary.java (original)
+++ directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/PreferencesDictionary.java Mon May 20 07:47:40 2013
@@ -1,169 +0,0 @@
-/*
- *  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.api.util;
-
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.prefs.Preferences;
-import java.util.prefs.BackingStoreException;
-
-import org.apache.directory.api.i18n.I18n;
-
-
-/**
- * A wrapper around Preferences to access it as a Dictionary.
- * 
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class PreferencesDictionary extends Dictionary<String, String>
-{
-    /** the underlying wrapped preferences object */
-    private final Preferences prefs;
-
-
-    // ------------------------------------------------------------------------
-    // C O N S T R U C T O R
-    // ------------------------------------------------------------------------
-
-    public PreferencesDictionary( Preferences prefs )
-    {
-        this.prefs = prefs;
-    }
-
-
-    // ------------------------------------------------------------------------
-    // E X T R A M E T H O D S
-    // ------------------------------------------------------------------------
-
-    /**
-     * Gets the Preferences used as the backing store for this Dictionary.
-     * 
-     * @return the underlying Preferences object
-     */
-    public Preferences getPreferences()
-    {
-        return prefs;
-    }
-
-
-    // ------------------------------------------------------------------------
-    // D I C T I O N A R Y M E T H O D S
-    // ------------------------------------------------------------------------
-
-    public int size()
-    {
-        try
-        {
-            return prefs.keys().length;
-        }
-        catch ( BackingStoreException e )
-        {
-            throw new RuntimeException( I18n.err( I18n.ERR_04423 ), e );
-        }
-    }
-
-
-    public boolean isEmpty()
-    {
-        try
-        {
-            return prefs.keys().length == 0;
-        }
-        catch ( BackingStoreException e )
-        {
-            throw new RuntimeException( I18n.err( I18n.ERR_04423 ), e );
-        }
-    }
-
-
-    @SuppressWarnings("unchecked")
-    public Enumeration<String> elements()
-    {
-        try
-        {
-            return new ArrayEnumeration( prefs.keys() )
-            {
-                public String nextElement()
-                {
-                    String key = ( String ) super.nextElement();
-
-                    return prefs.get( key, null );
-                }
-            };
-        }
-        catch ( BackingStoreException e )
-        {
-            throw new RuntimeException( I18n.err( I18n.ERR_04423 ), e );
-        }
-    }
-
-
-    @SuppressWarnings("unchecked")
-    public Enumeration<String> keys()
-    {
-        try
-        {
-            return new ArrayEnumeration( prefs.keys() );
-        }
-        catch ( BackingStoreException e )
-        {
-            throw new RuntimeException( I18n.err( I18n.ERR_04423 ), e );
-        }
-    }
-
-
-    public String get( Object key )
-    {
-        if ( key instanceof String )
-        {
-            return prefs.get( ( String ) key, null );
-        }
-
-        return prefs.get( key.toString(), null );
-    }
-
-
-    public String remove( Object key )
-    {
-        String retval = get( key );
-
-        if ( key instanceof String )
-        {
-            prefs.remove( ( String ) key );
-        }
-        else
-        {
-            prefs.remove( key.toString() );
-        }
-
-        return retval;
-    }
-
-
-    public String put( String key, String value )
-    {
-        String retval = get( key );
-
-        prefs.put( key, value );
-
-        return retval;
-    }
-}

Modified: directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/PropertiesUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/PropertiesUtils.java?rev=1484389&r1=1484388&r2=1484389&view=diff
==============================================================================
--- directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/PropertiesUtils.java (original)
+++ directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/PropertiesUtils.java Mon May 20 07:47:40 2013
@@ -1,618 +0,0 @@
-/*
- *  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.api.util;
-
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Properties;
-
-import org.apache.directory.api.util.exception.NotImplementedException;
-
-
-/**
- * A utility class used for accessing, finding, merging and macro expanding
- * properties, on disk, via URLS or as resources.
- * 
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public final class PropertiesUtils
-{
-    /** default properties file extension */
-    private static final String DOTPROPERTIES = ".properties";
-
-
-    /**
-     * Private constructor
-     */
-    private PropertiesUtils()
-    {
-    }
-
-
-    // ------------------------------------------------------------------------
-    // Utilities for discovering Properties
-    // ------------------------------------------------------------------------
-
-    /**
-     * Loads a properties object in a properties file if it exists relative to
-     * the filename ${user.home}. If the file ${user.home}/[filename] does not
-     * exist then one last attempt to find the file is made if filename does not
-     * have a .properties extension. If so and
-     * ${user.home}/[filename].properties exists then it is loaded.
-     * 
-     * @param filename
-     *            the properties file name with or without an extension
-     * @return the user properties object
-     */
-    public static Properties findUserProperties( String filename )
-    {
-        return findProperties( new File( System.getProperty( "user.home" ) ), filename );
-    }
-
-
-    /**
-     * Create a new properties object and load the properties file if it exists
-     * relative to [dir]/[filename] or [dir]/[filename].properties.
-     * 
-     * @param dir
-     *            the base directory
-     * @param filename
-     *            the full fine name or the base name w/o the extension
-     * @return the loaded properties object
-     */
-    public static Properties findProperties( File dir, String filename )
-    {
-        final File asis = new File( dir, filename );
-
-        if ( asis.exists() )
-        {
-            return getProperties( asis );
-        }
-
-        if ( filename.endsWith( DOTPROPERTIES ) )
-        {
-            String noExt = filename.substring( 0, filename.length() - 11 );
-            if ( new File( dir, noExt ).exists() )
-            {
-                return getProperties( new File( dir, noExt ) );
-            }
-
-            return new Properties();
-        }
-
-        File withExt = new File( dir, filename + DOTPROPERTIES );
-        if ( withExt.exists() )
-        {
-            return getProperties( withExt );
-        }
-
-        return new Properties();
-    }
-
-
-    /**
-     * Load a properties from a resource relative to a supplied class. First an
-     * attempt is made to locate a property file colocated with the class with
-     * the name [class].properties. If this cannot be found or errors result an
-     * empty Properties file is returned.
-     * 
-     * @param ref
-     *            a class to use for relative path references
-     * @return the static properties
-     */
-    // This will suppress PMD.EmptyCatchBlock warnings in this method
-    @SuppressWarnings("PMD.EmptyCatchBlock")
-    public static Properties getStaticProperties( Class<?> ref )
-    {
-        final Properties properties = new Properties();
-        final String address = ref.toString().replace( '.', '/' );
-        final String path = address + ".properties";
-        InputStream input = ref.getResourceAsStream( path );
-
-        if ( null != input )
-        {
-            try
-            {
-                properties.load( input );
-            }
-            catch ( IOException e )
-            {
-                return properties;
-            }
-            finally
-            {
-                if ( input != null )
-                {
-                    try
-                    {
-                        input.close();
-                    }
-                    catch ( IOException e )
-                    {
-                        // Empty catch, we can't more than trying to close
-                    }
-                }
-            }
-        }
-
-        return properties;
-    }
-
-
-    /**
-     * Load properties from a resource relative to a supplied class and path.
-     * 
-     * @param ref
-     *            a class to use for relative path references
-     * @param path
-     *            the relative path to the resoruce
-     * @return the static properties
-     */
-    // This will suppress PMD.EmptyCatchBlock warnings in this method
-    @SuppressWarnings("PMD.EmptyCatchBlock")
-    public static Properties getStaticProperties( Class<?> ref, String path )
-    {
-        Properties properties = new Properties();
-        InputStream input = ref.getResourceAsStream( path );
-
-        if ( input == null )
-        {
-            return properties;
-        }
-
-        try
-        {
-            properties.load( input );
-        }
-        catch ( IOException e )
-        {
-            return properties;
-        }
-        finally
-        {
-            if ( input != null )
-            {
-                try
-                {
-                    input.close();
-                }
-                catch ( IOException e )
-                {
-                    // Empty catch, we can't more than trying to close
-                }
-            }
-        }
-
-        return properties;
-    }
-
-
-    /**
-     * Creates a properties object and loads the properties in the file
-     * otherwise and empty property object will be returned.
-     * 
-     * @param file
-     *            the properties file
-     * @return the properties object
-     */
-    public static Properties getProperties( File file )
-    {
-        Properties properties = new Properties();
-
-        if ( null == file )
-        {
-            return properties;
-        }
-
-        if ( file.exists() )
-        {
-            try
-            {
-                final FileInputStream fis = new FileInputStream( file );
-                try
-                {
-                    properties.load( fis );
-                }
-                finally
-                {
-                    fis.close();
-                }
-            }
-            catch ( IOException e )
-            {
-                return properties;
-            }
-        }
-
-        return properties;
-    }
-
-
-    /**
-     * Loads a properties file as a CL resource if it exists and returns an
-     * empty Properties object otherwise.
-     * 
-     * @param classloader
-     *            the loader to use for the resources
-     * @param path
-     *            the path to the resource
-     * @return the loaded or new Properties
-     */
-    // This will suppress PMD.EmptyCatchBlock warnings in this method
-    @SuppressWarnings("PMD.EmptyCatchBlock")
-    public static Properties getProperties( ClassLoader classloader, String path )
-    {
-        Properties properties = new Properties();
-        InputStream input = classloader.getResourceAsStream( path );
-
-        if ( input != null )
-        {
-            try
-            {
-                properties.load( input );
-            }
-            catch ( IOException e )
-            {
-                return properties;
-            }
-            finally
-            {
-                if ( input != null )
-                {
-                    try
-                    {
-                        input.close();
-                    }
-                    catch ( IOException e )
-                    {
-                        // Empty catch, we can't more than trying to close
-                    }
-                }
-            }
-        }
-
-        return properties;
-    }
-
-
-    /**
-     * Loads a properties file as a class resource if it exists and returns an
-     * empty Properties object otherwise.
-     * 
-     * @param clazz
-     *            the class to use for resolving the resources
-     * @param path
-     *            the relative path to the resource
-     * @return the loaded or new Properties
-     */
-    // This will suppress PMD.EmptyCatchBlock warnings in this method
-    @SuppressWarnings("PMD.EmptyCatchBlock")
-    public static Properties getProperties( Class<?> clazz, String path )
-    {
-        Properties properties = new Properties();
-        InputStream input = clazz.getResourceAsStream( path );
-
-        if ( input != null )
-        {
-            try
-            {
-                properties.load( input );
-            }
-            catch ( IOException e )
-            {
-                return properties;
-            }
-            finally
-            {
-                if ( input != null )
-                {
-                    try
-                    {
-                        input.close();
-                    }
-                    catch ( IOException e )
-                    {
-                        // Empty catch, we can't more than trying to close
-                    }
-                }
-            }
-        }
-
-        return properties;
-    }
-
-
-    // ------------------------------------------------------------------------
-    // Utilities for operating on or setting Properties values
-    // ------------------------------------------------------------------------
-
-    /**
-     * Expands out a set of property key macros in the following format
-     * ${foo.bar} where foo.bar is a property key, by dereferencing the value of
-     * the key using the original source Properties and other optional
-     * Properties. If the original expanded Properties contain the value for the
-     * macro key, foo.bar, then dereferencing stops by using the value in the
-     * expanded Properties: the other optional Properties are NOT used at all.
-     * If the original expanded Properties do NOT contain the value for the
-     * macro key, then the optional Properties are used in order. The first of
-     * the optionals to contain the value for the macro key (foo.bar) shorts the
-     * search. Hence the first optional Properties in the array to contain a
-     * value for the macro key (foo.bar) is used to set the expanded value. If a
-     * macro cannot be expanded because it's key was not defined within the
-     * expanded Properties or one of the optional Properties then it is left as
-     * is.
-     * 
-     * @param expanded
-     *            the Properties to perform the macro expansion upon
-     * @param optionals
-     *            null or an optional set of Properties to use for dereferencing
-     *            macro keys (foo.bar)
-     */
-    public static void macroExpand( Properties expanded, Properties[] optionals )
-    {
-        // Handle null optionals
-        if ( null == optionals )
-        {
-            optionals = new Properties[0];
-        }
-
-        Enumeration<?> list = expanded.propertyNames();
-
-        while ( list.hasMoreElements() )
-        {
-            String key = ( String ) list.nextElement();
-            String macro = expanded.getProperty( key );
-
-            int n = macro.indexOf( "${" );
-            if ( n < 0 )
-            {
-                continue;
-            }
-
-            int m = macro.indexOf( "}", n + 2 );
-            if ( m < 0 )
-            {
-                continue;
-            }
-
-            final String symbol = macro.substring( n + 2, m );
-
-            if ( expanded.containsKey( symbol ) )
-            {
-                final String value = expanded.getProperty( symbol );
-                final String head = macro.substring( 0, n );
-                final String tail = macro.substring( m + 1 );
-                final String resolved = head + value + tail;
-                expanded.put( key, resolved );
-                continue;
-            }
-
-            /*
-             * Check if the macro key exists within the array of optional
-             * Properties. Set expanded value to first Properties with the key
-             * and break out of the loop.
-             */
-            for ( int ii = 0; ii < optionals.length; ii++ )
-            {
-                if ( optionals[ii].containsKey( symbol ) )
-                {
-                    final String value = optionals[ii].getProperty( symbol );
-                    final String head = macro.substring( 0, n );
-                    final String tail = macro.substring( m + 1 );
-                    final String resolved = head + value + tail;
-                    expanded.put( key, resolved );
-                    break;
-                }
-            }
-        }
-    }
-
-
-    /**
-     * Discovers a value within a set of Properties either halting on the first
-     * time the property is discovered or continuing on to take the last value
-     * found for the property key.
-     * 
-     * @param key
-     *            a property key
-     * @param sources
-     *            a set of source Properties
-     * @param haltOnDiscovery
-     *            true if we stop on finding a value, false otherwise
-     * @return the value found or null
-     */
-    public static String discover( String key, Properties[] sources, boolean haltOnDiscovery )
-    {
-        String retval = null;
-
-        for ( int ii = 0; ii < sources.length; ii++ )
-        {
-            if ( sources[ii].containsKey( key ) )
-            {
-                retval = sources[ii].getProperty( key );
-
-                if ( haltOnDiscovery )
-                {
-                    break;
-                }
-            }
-        }
-
-        return retval;
-    }
-
-
-    /**
-     * Merges a set of properties from source Properties into a target
-     * properties instance containing keys. This method does not allow null
-     * overrides.
-     * 
-     * @param keys
-     *            the keys to discover values for
-     * @param sources
-     *            the sources to search
-     * @param haltOnDiscovery
-     *            true to halt on first find or false to continue to last find
-     */
-    public static void discover( Properties keys, Properties[] sources, boolean haltOnDiscovery )
-    {
-        if ( null == sources || null == keys )
-        {
-            return;
-        }
-
-        /*
-         * H A N D L E S I N G L E V A L U E D K E Y S
-         */
-        for ( Object key : keys.keySet() )
-        {
-            String value = discover( ( String ) key, sources, haltOnDiscovery );
-
-            if ( value != null )
-            {
-                keys.setProperty( ( String ) key, value );
-            }
-        }
-    }
-
-
-    // ------------------------------------------------------------------------
-    // Various Property Accessors
-    // ------------------------------------------------------------------------
-
-    /**
-     * Gets a String property as a boolean returning a defualt if the key is not
-     * present. In any case, true, on, 1 and yes strings return true and
-     * everything else returns
-     * 
-     * @param props
-     *            the properties to get the value from
-     * @param key
-     *            the property key
-     * @param defaultValue
-     *            the default value to return if key is not present
-     * @return true defaultValue if property does not exist, else return true if
-     *         the String value is one of 'true', 'on', '1', 'yes', otherwise
-     *         false is returned
-     */
-    public static boolean get( Properties props, String key, boolean defaultValue )
-    {
-        if ( props == null || !props.containsKey( key ) || props.getProperty( key ) == null )
-        {
-            return defaultValue;
-        }
-
-        String val = Strings.toLowerCase( Strings.trim( props.getProperty( key ) ) );
-        return val.equals( "true" ) || val.equals( "on" ) || val.equals( "1" ) || val.equals( "yes" );
-    }
-
-
-    /**
-     * Gets a property or entry value from a hashtable and tries to transform
-     * whatever the value may be to an primitive integer.
-     * 
-     * @param ht
-     *            the hashtable to access for the value
-     * @param key
-     *            the key to use when accessing the ht
-     * @param defval
-     *            the default value to use if the key is not contained in ht or
-     *            if the value cannot be represented as a primitive integer.
-     * @return the primitive integer representation of a hashtable value
-     */
-    public static int get( Hashtable<String, Object> ht, Object key, int defval )
-    {
-        if ( ht == null || !ht.containsKey( key ) || ht.get( key ) == null )
-        {
-            return defval;
-        }
-
-        Object obj = ht.get( key );
-
-        if ( obj instanceof Byte )
-        {
-            return ( ( Byte ) obj ).intValue();
-        }
-        if ( obj instanceof Short )
-        {
-            return ( ( Short ) obj ).intValue();
-        }
-        if ( obj instanceof Integer )
-        {
-            return ( ( Integer ) obj ).intValue();
-        }
-        if ( obj instanceof Long )
-        {
-            return ( ( Long ) obj ).intValue();
-        }
-        if ( obj instanceof String )
-        {
-            try
-            {
-                return Integer.parseInt( ( String ) obj );
-            }
-            catch ( NumberFormatException ne )
-            {
-                ne.printStackTrace();
-                return defval;
-            }
-        }
-
-        return defval;
-    }
-
-
-    public static long get( Properties props, String key, long defaultValue )
-    {
-        if ( props == null || !props.containsKey( key ) || props.getProperty( key ) == null )
-        {
-            return defaultValue;
-        }
-
-        throw new NotImplementedException();
-    }
-
-
-    public static byte get( Properties props, String key, byte defaultValue )
-    {
-        if ( props == null || !props.containsKey( key ) || props.getProperty( key ) == null )
-        {
-            return defaultValue;
-        }
-
-        throw new NotImplementedException();
-    }
-
-
-    public static char get( Properties props, String key, char defaultValue )
-    {
-        if ( props == null || !props.containsKey( key ) || props.getProperty( key ) == null )
-        {
-            return defaultValue;
-        }
-
-        throw new NotImplementedException();
-    }
-}

Modified: directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/ArrayEnumerationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/ArrayEnumerationTest.java?rev=1484389&r1=1484388&r2=1484389&view=diff
==============================================================================
--- directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/ArrayEnumerationTest.java (original)
+++ directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/ArrayEnumerationTest.java Mon May 20 07:47:40 2013
@@ -1,169 +0,0 @@
-/*
- *  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.api.util;
-
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.NoSuchElementException;
-
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
-
-import org.apache.directory.api.util.ArrayEnumeration;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-
-/**
- * Tests the ArrayEnumeration class.
- * 
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-@RunWith(ConcurrentJunitRunner.class)
-@Concurrency()
-public class ArrayEnumerationTest
-{
-    @Test
-    public void testAll()
-    {
-        // test with null array
-
-        Object[] array = null;
-
-        ArrayEnumeration list = new ArrayEnumeration( array );
-
-        assertFalse( list.hasMoreElements() );
-
-        try
-        {
-            list.nextElement();
-
-            fail( "should never get here due to a NoSuchElementException" );
-        }
-        catch ( NoSuchElementException e )
-        {
-        }
-
-        // test with empty array
-
-        array = new Object[0];
-
-        list = new ArrayEnumeration( array );
-
-        assertFalse( list.hasMoreElements() );
-
-        assertFalse( list.hasMoreElements() );
-
-        try
-        {
-            list.nextElement();
-
-            fail( "should never get here due to a NoSuchElementException" );
-        }
-        catch ( NoSuchElementException e )
-        {
-        }
-
-        // test with one object
-
-        array = new Object[]
-            { new Object() };
-
-        list = new ArrayEnumeration( array );
-
-        assertTrue( list.hasMoreElements() );
-
-        assertNotNull( list.nextElement() );
-
-        assertFalse( list.hasMoreElements() );
-
-        try
-        {
-            list.nextElement();
-
-            fail( "should never get here due to a NoSuchElementException" );
-        }
-        catch ( NoSuchElementException e )
-        {
-        }
-
-        // test with two objects
-
-        array = new Object[]
-            { new Object(), new Object() };
-
-        list = new ArrayEnumeration( array );
-
-        assertTrue( list.hasMoreElements() );
-
-        assertNotNull( list.nextElement() );
-
-        assertTrue( list.hasMoreElements() );
-
-        assertNotNull( list.nextElement() );
-
-        assertFalse( list.hasMoreElements() );
-
-        try
-        {
-            list.nextElement();
-
-            fail( "should never get here due to a NoSuchElementException" );
-        }
-        catch ( NoSuchElementException e )
-        {
-        }
-
-        // test with three elements
-
-        array = new Object[]
-            { new Object(), new Object(), new Object() };
-
-        list = new ArrayEnumeration( array );
-
-        assertTrue( list.hasMoreElements() );
-
-        assertNotNull( list.nextElement() );
-
-        assertTrue( list.hasMoreElements() );
-
-        assertNotNull( list.nextElement() );
-
-        assertTrue( list.hasMoreElements() );
-
-        assertNotNull( list.nextElement() );
-
-        assertFalse( list.hasMoreElements() );
-
-        try
-        {
-            list.nextElement();
-
-            fail( "should never get here due to a NoSuchElementException" );
-        }
-        catch ( NoSuchElementException e )
-        {
-        }
-    }
-}

Modified: directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/ArrayNamingEnumerationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/ArrayNamingEnumerationTest.java?rev=1484389&r1=1484388&r2=1484389&view=diff
==============================================================================
--- directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/ArrayNamingEnumerationTest.java (original)
+++ directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/ArrayNamingEnumerationTest.java Mon May 20 07:47:40 2013
@@ -1,137 +0,0 @@
-/*
- *  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.api.util;
-
-
-import java.util.NoSuchElementException;
-
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
-
-import org.apache.directory.api.util.ArrayNamingEnumeration;
-import org.apache.directory.api.util.StringConstants;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
-/**
- * Tests the {@link ArrayNamingEnumeration} class.
- * 
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-@RunWith(ConcurrentJunitRunner.class)
-@Concurrency()
-public class ArrayNamingEnumerationTest
-{
-    /**
-     * Tests ArrayNamingEnumeration using an null array.
-     */
-    @Test
-    public void testUsingNullArray()
-    {
-        ArrayNamingEnumeration<Object> list = new ArrayNamingEnumeration<Object>( null );
-        assertFalse( list.hasMore() );
-
-        try
-        {
-            list.next();
-            fail( "should blow exception before getting here" );
-        }
-        catch ( NoSuchElementException e )
-        {
-            assertNotNull( e );
-        }
-    }
-
-
-    /**
-     * Tests ArrayNamingEnumeration using an array with length = 0.
-     */
-    @Test
-    public void testUsingEmptyArray()
-    {
-        ArrayNamingEnumeration<String> list = new ArrayNamingEnumeration<String>( StringConstants.EMPTY_STRINGS );
-        assertFalse( list.hasMore() );
-
-        try
-        {
-            list.next();
-            fail( "should blow exception before getting here" );
-        }
-        catch ( NoSuchElementException e )
-        {
-            assertNotNull( e );
-        }
-    }
-
-
-    /**
-     * Tests ArrayNamingEnumeration using an array with length = 1.
-     */
-    @Test
-    public void testUsingSingleElementArray()
-    {
-        ArrayNamingEnumeration<String> list = new ArrayNamingEnumeration<String>( new String[]
-            { "foo" } );
-        assertTrue( list.hasMore() );
-        assertEquals( "foo", list.next() );
-
-        try
-        {
-            list.next();
-            fail( "should blow exception before getting here" );
-        }
-        catch ( NoSuchElementException e )
-        {
-            assertNotNull( e );
-        }
-    }
-
-
-    /**
-     * Tests ArrayNamingEnumeration using an array with length = 2.
-     */
-    @Test
-    public void testUsingTwoElementArray()
-    {
-        ArrayNamingEnumeration<String> list = new ArrayNamingEnumeration<String>( new String[]
-            { "foo", "bar" } );
-        assertTrue( list.hasMore() );
-        assertEquals( "foo", list.next() );
-        assertTrue( list.hasMore() );
-        assertEquals( "bar", list.next() );
-
-        try
-        {
-            list.next();
-            fail( "should blow exception before getting here" );
-        }
-        catch ( NoSuchElementException e )
-        {
-            assertNotNull( e );
-        }
-    }
-}

Modified: directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/Base32Test.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/Base32Test.java?rev=1484389&r1=1484388&r2=1484389&view=diff
==============================================================================
--- directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/Base32Test.java (original)
+++ directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/Base32Test.java Mon May 20 07:47:40 2013
@@ -1,54 +0,0 @@
-/*
- *  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.api.util;
-
-
-import static org.junit.Assert.assertEquals;
-
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
-
-import org.apache.directory.api.util.Base32;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-
-@RunWith(ConcurrentJunitRunner.class)
-@Concurrency()
-public class Base32Test
-{
-    @Test
-    public void testEncode()
-    {
-        String[] data = new String[]
-            { "", "a", "ab", "abc", "abcd", "abcde", "abcdef" };
-        String[] expected = new String[]
-            { "", "ME======", "MFRA====", "MFRGG===", "MFRGGZA=", "MFRGGZDF", "MFRGGZDFMY======" };
-
-        for ( int i = 0; i < data.length; i++ )
-        {
-            String in = data[i];
-
-            String res = Base32.encode( in );
-
-            assertEquals( expected[i], res );
-        }
-    }
-}

Modified: directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/JoinIteratorTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/JoinIteratorTest.java?rev=1484389&r1=1484388&r2=1484389&view=diff
==============================================================================
--- directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/JoinIteratorTest.java (original)
+++ directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/JoinIteratorTest.java Mon May 20 07:47:40 2013
@@ -1,123 +0,0 @@
-/*
- *  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.api.util;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
-
-import org.apache.directory.api.util.JoinIterator;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-
-/**
- * Document this class.
- * 
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-@RunWith(ConcurrentJunitRunner.class)
-@Concurrency()
-public class JoinIteratorTest
-{
-    @Test
-    public void testNullArgument()
-    {
-        try
-        {
-            new JoinIterator( null );
-            fail( "Should not be able to create a JoinIterator with null args" );
-        }
-        catch ( IllegalArgumentException e )
-        {
-            assertNotNull( e );
-        }
-    }
-
-
-    @Test
-    public void testSingleArgument()
-    {
-        Iterator<?>[] iterators = new Iterator<?>[]
-            { Collections.singleton( "foo" ).iterator() };
-
-        try
-        {
-            new JoinIterator( iterators );
-            fail( "Should not be able to create a JoinIterator with a single Iterator" );
-        }
-        catch ( IllegalArgumentException e )
-        {
-            assertNotNull( e );
-        }
-    }
-
-
-    @Test
-    public void testTwoArguments()
-    {
-        Iterator<?>[] iterators = new Iterator<?>[]
-            { Collections.singleton( "foo" ).iterator(), Collections.singleton( "bar" ).iterator() };
-
-        JoinIterator iterator = new JoinIterator( iterators );
-        assertTrue( "iterator should have an element", iterator.hasNext() );
-        assertEquals( "foo", iterator.next() );
-        assertTrue( "iterator should have an element", iterator.hasNext() );
-        assertEquals( "bar", iterator.next() );
-        assertFalse( "iterator should NOT have an element", iterator.hasNext() );
-    }
-
-
-    @Test
-    public void testSeveralArguments()
-    {
-        List<String> multivalued = new ArrayList<String>();
-        multivalued.add( "foo1" );
-        multivalued.add( "foo2" );
-
-        Iterator<?>[] iterators = new Iterator<?>[]
-            { Collections.singleton( "foo0" ).iterator(), multivalued.iterator(),
-                Collections.singleton( "bar0" ).iterator(), Collections.singleton( "bar1" ).iterator() };
-
-        JoinIterator iterator = new JoinIterator( iterators );
-        assertTrue( "iterator should have an element", iterator.hasNext() );
-        assertEquals( "foo0", iterator.next() );
-        assertTrue( "iterator should have an element", iterator.hasNext() );
-        assertEquals( "foo1", iterator.next() );
-        assertTrue( "iterator should have an element", iterator.hasNext() );
-        assertEquals( "foo2", iterator.next() );
-        assertTrue( "iterator should have an element", iterator.hasNext() );
-        assertEquals( "bar0", iterator.next() );
-        assertTrue( "iterator should have an element", iterator.hasNext() );
-        assertEquals( "bar1", iterator.next() );
-        assertFalse( "iterator should NOT have an element", iterator.hasNext() );
-    }
-}



Mime
View raw message