directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 10129 - in incubator/directory/rms/trunk/je/src/test/org/apache/rms/je: . permissions sequence
Date Tue, 20 Apr 2004 18:01:38 GMT
Author: akarasulu
Date: Tue Apr 20 11:01:37 2004
New Revision: 10129

Added:
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/JeUtilsTest.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permissions/
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permissions/BitPermissionMapTupleBindingTest.java
      - copied, changed from rev 10044, incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/PermMapTupleBindingTest.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/sequence/
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/sequence/JeSequenceDaoTest.java
      - copied, changed from rev 10044, incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/JeSequenceDaoTest.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/sequence/JeSequenceFactoryTest.java
      - copied, changed from rev 10045, incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/JeSequenceFactoryTest.java
Removed:
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/JeSequenceDaoTest.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/JeSequenceFactoryTest.java
   incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/PermMapTupleBindingTest.java
Log:
Commit changes ...

o moved unit tests to their new packages mirroring src files
o added extra unit tests for JeUtils 



Added: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/JeUtilsTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/JeUtilsTest.java	Tue Apr 20
11:01:37 2004
@@ -0,0 +1,137 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.rms.je ;
+
+
+import com.sleepycat.je.Cursor ;
+import com.sleepycat.je.LockMode ;
+import com.sleepycat.je.OperationStatus ;
+
+import com.sleepycat.bind.EntryBinding ;
+import com.sleepycat.bind.tuple.TupleBinding ;
+
+
+/**
+ * Tests the JeUtils class methods.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JeUtilsTest extends AbstractJeTest
+{
+    Cursor cursor ;
+    EntryBinding intBinding =
+            TupleBinding.getPrimitiveBinding( Integer.class ) ;
+    EntryBinding charBinding =
+            TupleBinding.getPrimitiveBinding( Character.class ) ;
+
+
+    /**
+     * Sets up the example database in the javadoc of the JeUtils class and
+     * opens a cursor to the newly created database.
+     *
+     * @throws Exception if there are failures
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp() ;
+
+        intBinding.objectToEntry( new Integer( 1 ), key ) ;
+        charBinding.objectToEntry( new Character( 'a' ), value ) ;
+        db.put( null, key, value ) ;
+
+        intBinding.objectToEntry( new Integer( 2 ), key ) ;
+        charBinding.objectToEntry( new Character( 'b' ), value ) ;
+        db.put( null, key, value ) ;
+
+        intBinding.objectToEntry( new Integer( 2 ), key ) ;
+        charBinding.objectToEntry( new Character( 'c' ), value ) ;
+        db.put( null, key, value ) ;
+
+        intBinding.objectToEntry( new Integer( 3 ), key ) ;
+        charBinding.objectToEntry( new Character( 'd' ), value ) ;
+        db.put( null, key, value ) ;
+
+        intBinding.objectToEntry( new Integer( 3 ), key ) ;
+        charBinding.objectToEntry( new Character( 'e' ), value ) ;
+        db.put( null, key, value ) ;
+
+        cursor = db.openCursor( null, null ) ;
+    }
+
+
+    /**
+     * Closes the created cursor and clears it out to null before the super
+     * method is called.
+     *
+     * @throws Exception if there are failures
+     */
+    protected void tearDown() throws Exception
+    {
+        cursor.close() ;
+        cursor = null ;
+        super.tearDown() ;
+    }
+
+
+    /**
+     * Tests the getSearchLastDuplicate() method in the case where the key
+     * is not found.
+     *
+     * @throws Exception if there are failures
+     */
+    public void testGetSearchLastDuplicateNotFound() throws Exception
+    {
+        intBinding.objectToEntry( new Integer( 12 ), key ) ;
+        OperationStatus status = JeUtils.getSearchLastDuplicate(
+                cursor, key, value, LockMode.DEFAULT ) ;
+        assertEquals( OperationStatus.NOTFOUND, status ) ;
+    }
+
+
+    /**
+     * Tests the getSearchLastDuplicate() method for the trivial case.
+     *
+     * @throws Exception if there are failures
+     */
+    public void testGetSearchLastDuplicate() throws Exception
+    {
+        intBinding.objectToEntry( new Integer( 2 ), key ) ;
+        OperationStatus status = JeUtils.getSearchLastDuplicate(
+                cursor, key, value, LockMode.DEFAULT ) ;
+        assertEquals( OperationStatus.SUCCESS, status ) ;
+        Character ch = ( Character ) charBinding.entryToObject( value ) ;
+        assertEquals( new Character( 'c' ), ch  ) ;
+    }
+
+
+    /**
+     * Tests the getSearchLastDuplicate() method for the case where the
+     * last value of the last key is requested.
+     *
+     * @throws Exception if there are failures
+     */
+    public void testGetSearchLastDuplicateLastKey() throws Exception
+    {
+        intBinding.objectToEntry( new Integer( 3 ), key ) ;
+        OperationStatus status = JeUtils.getSearchLastDuplicate(
+                cursor, key, value, LockMode.DEFAULT ) ;
+        assertEquals( OperationStatus.SUCCESS, status ) ;
+        Character ch = ( Character ) charBinding.entryToObject( value ) ;
+        assertEquals( new Character( 'e' ), ch  ) ;
+    }
+}
\ No newline at end of file

Copied: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permissions/BitPermissionMapTupleBindingTest.java
(from rev 10044, incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/PermMapTupleBindingTest.java)
==============================================================================
--- incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/PermMapTupleBindingTest.java
(original)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/permissions/BitPermissionMapTupleBindingTest.java
Tue Apr 20 11:01:37 2004
@@ -14,12 +14,11 @@
  *   limitations under the License.
  *
  */
-package org.apache.rms.je ;
+package org.apache.rms.je.permissions ;
 
 
 import org.apache.rms.je.AbstractJeTest ;
 import org.apache.rms.DefaultBitPermission ;
-import org.apache.rms.je.PermMapTupleBinding ;
 
 import org.apache.commons.collections.Factory ;
 import org.apache.commons.collections.list.LazyList ;
@@ -39,7 +38,7 @@
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class PermMapTupleBindingTest extends AbstractJeTest
+public class BitPermissionMapTupleBindingTest extends AbstractJeTest
 {
     /** A factory that always returns null */
     private final static Factory NULL_FACTORY = new Factory()
@@ -51,7 +50,7 @@
     public void testObjectToEntryNoData() throws IOException, DatabaseException
     {
         List perms = LazyList.decorate( new ArrayList(), NULL_FACTORY ) ;
-        PermMapTupleBinding binding = new PermMapTupleBinding() ;
+        BitPermissionMapTupleBinding binding = new BitPermissionMapTupleBinding() ;
         DatabaseEntry key = new DatabaseEntry() ;
         DatabaseEntry value = new DatabaseEntry() ;
         key.setData( "app1".getBytes( "UTF-8" ) ) ;
@@ -77,7 +76,8 @@
             perms.add( ii, new DefaultBitPermission( perm, ii, app ) ) ;
         }
 
-        PermMapTupleBinding binding = new PermMapTupleBinding() ;
+        BitPermissionMapTupleBinding binding =
+                new BitPermissionMapTupleBinding() ;
         DatabaseEntry key = new DatabaseEntry() ;
         DatabaseEntry value = new DatabaseEntry() ;
         key.setData( "app1".getBytes( "UTF-8" ) ) ;
@@ -111,7 +111,8 @@
             perms.add( ii, new DefaultBitPermission( perm, ii, app ) ) ;
         }
 
-        PermMapTupleBinding binding = new PermMapTupleBinding() ;
+        BitPermissionMapTupleBinding binding =
+                new BitPermissionMapTupleBinding() ;
         DatabaseEntry key = new DatabaseEntry() ;
         DatabaseEntry value = new DatabaseEntry() ;
         key.setData( "app1".getBytes( "UTF-8" ) ) ;

Copied: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/sequence/JeSequenceDaoTest.java
(from rev 10044, incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/JeSequenceDaoTest.java)
==============================================================================
--- incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/JeSequenceDaoTest.java	(original)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/sequence/JeSequenceDaoTest.java
Tue Apr 20 11:01:37 2004
@@ -14,9 +14,11 @@
  *   limitations under the License.
  *
  */
-package org.apache.rms.je ;
+package org.apache.rms.je.sequence ;
 
 import org.apache.rms.RmsException ;
+import org.apache.rms.je.sequence.JeSequenceDao;
+import org.apache.rms.je.AbstractJeTest;
 
 
 /**

Copied: incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/sequence/JeSequenceFactoryTest.java
(from rev 10045, incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/JeSequenceFactoryTest.java)
==============================================================================
--- incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/JeSequenceFactoryTest.java
(original)
+++ incubator/directory/rms/trunk/je/src/test/org/apache/rms/je/sequence/JeSequenceFactoryTest.java
Tue Apr 20 11:01:37 2004
@@ -14,11 +14,11 @@
  *   limitations under the License.
  *
  */
-package org.apache.rms.je ;
+package org.apache.rms.je.sequence ;
 
-
-import junit.framework.TestCase;
-import org.apache.rms.je.JeSequenceFactory;
+import org.apache.rms.je.sequence.JeSequenceDao;
+import org.apache.rms.je.sequence.JeSequenceFactory;
+import org.apache.rms.je.AbstractJeTest;
 
 
 /**

Mime
View raw message