You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/07/03 01:19:19 UTC

svn commit: r1688926 - /directory/studio/trunk/plugins/openldap.config.editor/src/test/java/org/apache/directory/studio/openldap/config/wrappers/DbIndexWrapperTest.java

Author: elecharny
Date: Thu Jul  2 23:19:18 2015
New Revision: 1688926

URL: http://svn.apache.org/r1688926
Log:
Added a test for the DbIndexWrapper class

Added:
    directory/studio/trunk/plugins/openldap.config.editor/src/test/java/org/apache/directory/studio/openldap/config/wrappers/DbIndexWrapperTest.java

Added: directory/studio/trunk/plugins/openldap.config.editor/src/test/java/org/apache/directory/studio/openldap/config/wrappers/DbIndexWrapperTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/test/java/org/apache/directory/studio/openldap/config/wrappers/DbIndexWrapperTest.java?rev=1688926&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/test/java/org/apache/directory/studio/openldap/config/wrappers/DbIndexWrapperTest.java (added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/test/java/org/apache/directory/studio/openldap/config/wrappers/DbIndexWrapperTest.java Thu Jul  2 23:19:18 2015
@@ -0,0 +1,76 @@
+/*
+ *  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.studio.openldap.config.wrappers;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+import org.apache.directory.studio.openldap.config.editor.wrappers.DbIndexWrapper;
+import org.apache.directory.studio.openldap.common.ui.model.IndexTypeEnum;
+import org.junit.Test;
+
+/**
+ * A test for the DbIndexWrapper class
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DbIndexWrapperTest
+{
+    @Test
+    public void testClone()
+    {
+        DbIndexWrapper index1 = new DbIndexWrapper( "cn,sn,objectClass eq,sub,approx" );
+        
+        DbIndexWrapper index2 = index1.clone();
+        
+        index1.getAttributes().clear();
+        
+        assertFalse( index1.getAttributes().contains( "cn" ) );
+        assertTrue( index2.getAttributes().contains( "cn" ) );
+    }
+
+    @Test
+    public void testConstructor()
+    {
+        DbIndexWrapper index1 = new DbIndexWrapper( "cn,sn,objectClass,cn eq,sub,aprox,eq" );
+        
+        assertEquals( 3, index1.getAttributes().size() );
+        assertEquals( 2, index1.getIndexTypes().size() );
+        assertTrue( index1.getIndexTypes().contains( IndexTypeEnum.EQ ) );
+        assertTrue( index1.getIndexTypes().contains( IndexTypeEnum.SUB ) );
+        assertFalse( index1.getIndexTypes().contains( IndexTypeEnum.APPROX ) );
+        
+        assertEquals( "cn,objectclass,sn eq,sub", index1.toString() );
+    }
+
+    @Test
+    public void testCompare()
+    {
+        DbIndexWrapper index = new DbIndexWrapper( "cn,sn,objectClass,cn eq,sub,aprox,eq" );
+        DbIndexWrapper index2 = new DbIndexWrapper( "cn,sn,objectClass,a eq,sub,aprox,eq" );
+        DbIndexWrapper index3 = new DbIndexWrapper( "cn,sn,objectClass,z eq,sub,aprox,eq" );
+        DbIndexWrapper index4 = new DbIndexWrapper( "sn,objectClass,cn eq" );
+        
+        assertTrue( index.compareTo( index2 ) > 0 );
+        assertTrue( index.compareTo( index3 ) < 0 );
+        assertTrue( index.compareTo( index4 ) == 0 );
+    }
+}