directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r638228 [15/20] - in /directory/sandbox/akarasulu/bigbang/apacheds: ./ apacheds-xbean-spring/src/site/ benchmarks/src/site/ bootstrap-extract/src/site/ bootstrap-partition/src/site/ bootstrap-plugin/src/main/java/org/apache/directory/server...
Date Tue, 18 Mar 2008 06:13:18 GMT
Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java?rev=638228&r1=638227&r2=638228&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java Mon Mar 17 23:12:41 2008
@@ -20,12 +20,13 @@
 package org.apache.directory.server.core.authz.support;
 
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.authn.LdapPrincipal;
 import org.apache.directory.server.core.changelog.ChangeLog;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerSearchResult;
 import org.apache.directory.server.core.interceptor.Interceptor;
 import org.apache.directory.server.core.interceptor.InterceptorChain;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
@@ -41,14 +42,11 @@
 import org.apache.directory.shared.ldap.aci.ProtectedItem;
 import org.apache.directory.shared.ldap.aci.UserClass;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
-import org.apache.directory.shared.ldap.ldif.Entry;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.SearchResult;
 import javax.naming.ldap.LdapContext;
 import java.io.File;
 import java.util.ArrayList;
@@ -60,6 +58,10 @@
 import java.util.NoSuchElementException;
 import java.util.Set;
 
+import org.junit.Test;
+import org.junit.BeforeClass;
+import static org.junit.Assert.assertEquals;
+
 
 /**
  * Tests {@link MaxImmSubFilter}.
@@ -67,7 +69,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class MaxImmSubFilterTest extends TestCase
+public class MaxImmSubFilterTest
 {
     private static final Collection<ACITuple> EMPTY_ACI_TUPLE_COLLECTION = Collections.unmodifiableCollection( new ArrayList<ACITuple>() );
     private static final Collection<UserClass> EMPTY_USER_CLASS_COLLECTION = Collections.unmodifiableCollection( new ArrayList<UserClass>() );
@@ -76,26 +78,25 @@
     private static final Set<MicroOperation> EMPTY_MICRO_OPERATION_SET = Collections.unmodifiableSet( new HashSet<MicroOperation>() );
 
     private static final LdapDN ROOTDSE_NAME = new LdapDN();
-    private static final LdapDN ENTRY_NAME;
-    private static final Collection<ProtectedItem> PROTECTED_ITEMS = new ArrayList<ProtectedItem>();
-    private static final Attributes ENTRY = new AttributesImpl();
+    private static LdapDN ENTRY_NAME;
+    private static Collection<ProtectedItem> PROTECTED_ITEMS = new ArrayList<ProtectedItem>();
+    private static ServerEntry ENTRY;
+    
+    /** A reference to the directory service */
+    private static DirectoryService service;
 
-    static
+    
+    @BeforeClass public static void setup() throws NamingException
     {
-        try
-        {
-            ENTRY_NAME = new LdapDN( "ou=test, ou=system" );
-        }
-        catch ( NamingException e )
-        {
-            throw new Error();
-        }
+        service = new DefaultDirectoryService();
 
+        ENTRY_NAME = new LdapDN( "ou=test, ou=system" );
         PROTECTED_ITEMS.add( new ProtectedItem.MaxImmSub( 2 ) );
+        ENTRY = new DefaultServerEntry( service.getRegistries(), ENTRY_NAME );
     }
 
 
-    public void testWrongScope() throws Exception
+    @Test public void testWrongScope() throws Exception
     {
         MaxImmSubFilter filter = new MaxImmSubFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
@@ -104,15 +105,15 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null, null,
             null, ENTRY_NAME, null, null, ENTRY, null, null ) );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
             null, null, ENTRY_NAME, null, null, ENTRY, null, null ) );
     }
 
 
-    public void testRootDSE() throws Exception
+    @Test public void testRootDSE() throws Exception
     {
         MaxImmSubFilter filter = new MaxImmSubFilter();
 
@@ -122,21 +123,21 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null,
             ROOTDSE_NAME, null, null, ENTRY, null, null ) );
     }
 
 
-    public void testZeroTuple() throws Exception
+    @Test public void testZeroTuple() throws Exception
     {
         MaxImmSubFilter filter = new MaxImmSubFilter();
 
-        Assert.assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ENTRY, null, null, null, null, null,
+        assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ENTRY, null, null, null, null, null,
             ENTRY_NAME, null, null, ENTRY, null, null ).size() );
     }
 
 
-    public void testDenialTuple() throws Exception
+    @Test public void testDenialTuple() throws Exception
     {
         MaxImmSubFilter filter = new MaxImmSubFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
@@ -145,22 +146,22 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null,
             ENTRY_NAME, null, null, ENTRY, null, null ) );
     }
 
 
-    public void testGrantTuple() throws Exception
+    @Test public void testGrantTuple() throws Exception
     {
         MaxImmSubFilter filter = new MaxImmSubFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
         tuples.add( new ACITuple( EMPTY_USER_CLASS_COLLECTION, AuthenticationLevel.NONE, 
             PROTECTED_ITEMS, EMPTY_MICRO_OPERATION_SET, true, 0 ) );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, new MockProxy( 1 ), null, null, null,
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ENTRY, new MockProxy( 1 ), null, null, null,
             null, ENTRY_NAME, null, null, ENTRY, null, null ).size() );
 
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, new MockProxy( 3 ), null, null, null,
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ENTRY, new MockProxy( 3 ), null, null, null,
             null, ENTRY_NAME, null, null, ENTRY, null, null ).size() );
     }
 
@@ -176,7 +177,7 @@
         }
 
 
-        public NamingEnumeration<SearchResult> search( SearchOperationContext opContext )
+        public NamingEnumeration<ServerSearchResult> search( SearchOperationContext opContext )
             throws NamingException
         {
             //noinspection unchecked
@@ -184,7 +185,7 @@
         }
 
 
-        public NamingEnumeration<SearchResult> search( SearchOperationContext opContext, Collection bypass ) throws NamingException
+        public NamingEnumeration<ServerSearchResult> search( SearchOperationContext opContext, Collection bypass ) throws NamingException
         {
             //noinspection unchecked
             return new BogusEnumeration( count );
@@ -388,13 +389,13 @@
         }
 
 
-        public List<Entry> getTestEntries()
+        public List<LdifEntry> getTestEntries()
         {
             return null;
         }
 
 
-        public void setTestEntries( List<? extends Entry> testEntries )
+        public void setTestEntries( List<? extends LdifEntry> testEntries )
         {
         }
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MaxValueCountFilterTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MaxValueCountFilterTest.java?rev=638228&r1=638227&r2=638228&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MaxValueCountFilterTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MaxValueCountFilterTest.java Mon Mar 17 23:12:41 2008
@@ -26,22 +26,27 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
+import javax.naming.NamingException;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
 
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.authz.support.MaxValueCountFilter;
 import org.apache.directory.server.core.authz.support.OperationScope;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.shared.ldap.aci.ACITuple;
 import org.apache.directory.shared.ldap.aci.MicroOperation;
 import org.apache.directory.shared.ldap.aci.ProtectedItem;
 import org.apache.directory.shared.ldap.aci.UserClass;
 import org.apache.directory.shared.ldap.aci.ProtectedItem.MaxValueCountItem;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -50,7 +55,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class MaxValueCountFilterTest extends TestCase
+public class MaxValueCountFilterTest
 {
     private static final Collection<ACITuple> EMPTY_ACI_TUPLE_COLLECTION = Collections.unmodifiableCollection( new ArrayList<ACITuple>() );
     private static final Collection<UserClass> EMPTY_USER_CLASS_COLLECTION = Collections.unmodifiableCollection( new ArrayList<UserClass>() );
@@ -59,26 +64,38 @@
     private static final Set<MicroOperation> EMPTY_MICRO_OPERATION_SET = Collections.unmodifiableSet( new HashSet<MicroOperation>() );
 
     private static final Collection<ProtectedItem> PROTECTED_ITEMS = new ArrayList<ProtectedItem>();
-    private static final Attributes ENTRY = new AttributesImpl();
-    private static final Attributes FULL_ENTRY = new AttributesImpl();
+    private static ServerEntry ENTRY;
+    private static ServerEntry FULL_ENTRY;
 
     static
     {
         Collection<MaxValueCountItem> mvcItems = new ArrayList<MaxValueCountItem>();
-        mvcItems.add( new MaxValueCountItem( "testAttr", 2 ) );
+        mvcItems.add( new MaxValueCountItem( "cn", 2 ) );
         PROTECTED_ITEMS.add( new ProtectedItem.MaxValueCount( mvcItems ) );
+    }
 
-        ENTRY.put( "testAttr", "1" );
 
-        Attribute attr = new AttributeImpl( "testAttr" );
-        attr.add( "1" );
-        attr.add( "2" );
-        attr.add( "3" );
-        FULL_ENTRY.put( attr );
+    /** A reference to the directory service */
+    private static DirectoryService service;
+
+    
+    @BeforeClass public static void init() throws NamingException
+    {
+        service = new DefaultDirectoryService();
+    }
+    
+    @Before public void setup() throws NamingException
+    {
+        LdapDN entryName = new LdapDN( "ou=test, ou=system" );
+        ENTRY = new DefaultServerEntry( service.getRegistries(), entryName );
+        FULL_ENTRY = new DefaultServerEntry( service.getRegistries(), entryName );
+        
+        ENTRY.put( "cn", "1" );
+        FULL_ENTRY.put( "cn", "1", "2", "3" );
     }
 
 
-    public void testWrongScope() throws Exception
+    @Test public void testWrongScope() throws Exception
     {
         MaxValueCountFilter filter = new MaxValueCountFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
@@ -87,24 +104,24 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null, null,
             null, null, null, null, null, null, null ) );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null,
             null, null, null, null, null ) );
     }
 
 
-    public void testZeroTuple() throws Exception
+    @Test public void testZeroTuple() throws Exception
     {
         MaxValueCountFilter filter = new MaxValueCountFilter();
 
-        Assert.assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, 
+        assertEquals( 0, filter.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, 
             null, null, null, null, null, null, null, null, null, null, null ).size() );
     }
 
 
-    public void testDenialTuple() throws Exception
+    @Test public void testDenialTuple() throws Exception
     {
         MaxValueCountFilter filter = new MaxValueCountFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
@@ -113,24 +130,32 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
-            null, null, null, "testAttr", null, ENTRY, null, null ) );
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
-            null, null, null, "testAttr", null, FULL_ENTRY, null, null ) );
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
+            null, null, null, "cn", null, ENTRY, null, null ) );
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
+            null, null, null, "cn", null, FULL_ENTRY, null, null ) );
     }
 
 
-    public void testGrantTuple() throws Exception
+    @Test public void testGrantTuple() throws Exception
     {
         MaxValueCountFilter filter = new MaxValueCountFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
-        tuples.add( new ACITuple( EMPTY_USER_CLASS_COLLECTION, AuthenticationLevel.NONE, PROTECTED_ITEMS, 
-            EMPTY_MICRO_OPERATION_SET, true, 0 ) );
+        
+        // Test with this ACI :
+        // 
+        tuples.add( new ACITuple( 
+            EMPTY_USER_CLASS_COLLECTION, 
+            AuthenticationLevel.NONE, 
+            PROTECTED_ITEMS, 
+            EMPTY_MICRO_OPERATION_SET, 
+            true, 
+            0 ) );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
-            null, null, "testAttr", null, ENTRY, null, ENTRY ).size() );
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+            null, null, "cn", null, ENTRY, null, ENTRY ).size() );
 
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
-            null, null, "testAttr", null, FULL_ENTRY, null, FULL_ENTRY ).size() );
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+            null, null, "cn", null, FULL_ENTRY, null, FULL_ENTRY ).size() );
     }
 }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java?rev=638228&r1=638227&r2=638228&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java Mon Mar 17 23:12:41 2008
@@ -28,14 +28,17 @@
 
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
 
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.authz.support.OperationScope;
 import org.apache.directory.server.core.authz.support.RelatedProtectedItemFilter;
 import org.apache.directory.server.core.authz.support.RelatedUserClassFilter;
+import org.apache.directory.server.core.entry.DefaultServerAttribute;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerAttribute;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.event.ExpressionEvaluator;
 import org.apache.directory.server.core.subtree.RefinementEvaluator;
 import org.apache.directory.server.core.subtree.RefinementLeafEvaluator;
@@ -48,10 +51,15 @@
 import org.apache.directory.shared.ldap.aci.ProtectedItem.MaxValueCountItem;
 import org.apache.directory.shared.ldap.aci.ProtectedItem.RestrictedByItem;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+
 
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
 
 /**
  * Tests {@link RelatedUserClassFilter}.
@@ -59,158 +67,178 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class RelatedProtectedItemFilterTest extends TestCase
+public class RelatedProtectedItemFilterTest
 {
     private static final Collection<UserClass> EMPTY_USER_CLASS_COLLECTION = Collections.unmodifiableCollection( new ArrayList<UserClass>() );
     private static final Collection<ACITuple> EMPTY_ACI_TUPLE_COLLECTION = Collections.unmodifiableCollection( new ArrayList<ACITuple>() );
     private static final Set<MicroOperation> EMPTY_MICRO_OPERATION_SET = Collections.unmodifiableSet( new HashSet<MicroOperation>() );
 
-    private static final LdapDN GROUP_NAME;
-    private static final LdapDN USER_NAME;
-    private static final Set<LdapDN> USER_NAMES = new HashSet<LdapDN>();
-    private static final Set<LdapDN> GROUP_NAMES = new HashSet<LdapDN>();
+    private static LdapDN GROUP_NAME;
+    private static LdapDN USER_NAME;
+    private static Set<LdapDN> USER_NAMES = new HashSet<LdapDN>();
+    private static Set<LdapDN> GROUP_NAMES = new HashSet<LdapDN>();
 
     private static final AttributeTypeRegistry ATTR_TYPE_REGISTRY_A = new DummyAttributeTypeRegistry( false );
     private static final AttributeTypeRegistry ATTR_TYPE_REGISTRY_B = new DummyAttributeTypeRegistry( true );
-    private static final OidRegistry OID_REGISTRY = new DummyOidRegistry();
+    private static OidRegistry OID_REGISTRY;
+
+    private static RelatedProtectedItemFilter filterA;
+    private static RelatedProtectedItemFilter filterB;
 
-    private static final RelatedProtectedItemFilter filterA;
-    private static final RelatedProtectedItemFilter filterB;
+    /** A reference to the directory service */
+    private static DirectoryService service;
+    
+    /** The CN attribute Type */
+    private static AttributeType CN_AT;
 
-    static
+    /** The SN attribute Type */
+    private static AttributeType SN_AT;
+
+    
+    @BeforeClass public static void setup() throws NamingException
     {
-        try
-        {
-            GROUP_NAME = new LdapDN( "ou=test,ou=groups,ou=system" );
-            USER_NAME = new LdapDN( "ou=test, ou=users, ou=system" );
+        service = new DefaultDirectoryService();
+        OID_REGISTRY = service.getRegistries().getOidRegistry();
 
-            filterA = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
-                OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_A ), OID_REGISTRY, ATTR_TYPE_REGISTRY_A );
+        GROUP_NAME = new LdapDN( "ou=test,ou=groups,ou=system" );
+        USER_NAME = new LdapDN( "ou=test, ou=users, ou=system" );
 
-            filterB = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
-                OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_B ), OID_REGISTRY, ATTR_TYPE_REGISTRY_B );
-        }
-        catch ( NamingException e )
-        {
-            throw new Error();
-        }
+        filterA = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
+            OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_A ), OID_REGISTRY, ATTR_TYPE_REGISTRY_A );
+
+        filterB = new RelatedProtectedItemFilter( new RefinementEvaluator( new RefinementLeafEvaluator(
+            OID_REGISTRY ) ), new ExpressionEvaluator( OID_REGISTRY, ATTR_TYPE_REGISTRY_B ), OID_REGISTRY, ATTR_TYPE_REGISTRY_B );
 
         USER_NAMES.add( USER_NAME );
         GROUP_NAMES.add( GROUP_NAME );
+        CN_AT = service.getRegistries().getAttributeTypeRegistry().lookup( "cn" );
+        SN_AT = service.getRegistries().getAttributeTypeRegistry().lookup( "sn" );
     }
 
+    
+    private Collection<Attribute> convert( Collection<ServerAttribute> attributes )
+    {
+        Set<Attribute> jndiAttributes = new HashSet<Attribute>();
+        
+        for ( ServerAttribute attribute:attributes )
+        {
+            jndiAttributes.add( ServerEntryUtils.toAttributeImpl( attribute ) );
+        }
+        
+        return jndiAttributes;
+    }
 
-    public void testZeroTuple() throws Exception
+    @Test public void testZeroTuple() throws Exception
     {
-        Assert.assertEquals( 0, filterA.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
+        assertEquals( 0, filterA.filter( null, EMPTY_ACI_TUPLE_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
             null, null, null, null, null, null, null, null, null ).size() );
     }
 
 
-    public void testEntry() throws Exception
+    @Test public void testEntry() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( ProtectedItem.ENTRY );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, null, null,
             AuthenticationLevel.NONE, null, "ou", null, null, null, null ).size() );
     }
 
 
-    public void testAllUserAttributeTypes() throws Exception
+    @Test public void testAllUserAttributeTypes() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "userAttr", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
 
         tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "userAttr", null, null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
     }
 
 
-    public void testAllUserAttributeTypesAndValues() throws Exception
+    @Test public void testAllUserAttributeTypesAndValues() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES_AND_VALUES );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "userAttr", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
 
         tuples = getTuples( ProtectedItem.ALL_USER_ATTRIBUTE_TYPES_AND_VALUES );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "userAttr", null, null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
     }
 
 
-    public void testAllAttributeValues() throws Exception
+    @Test public void testAllAttributeValues() throws Exception
     {
         Collection<String> attrTypes = new ArrayList<String>();
-        attrTypes.add( "attrA" );
+        attrTypes.add( "cn" );
         Collection<ACITuple> tuples = getTuples( new ProtectedItem.AllAttributeValues( attrTypes ) );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
 
         tuples = getTuples( new ProtectedItem.AllAttributeValues( attrTypes ) );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME, null,
-            null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
 
-        Assert.assertEquals( 0, filterB.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME, null,
-            null, null, "attrB", null, null, null, null ).size() );
+        assertEquals( 0, filterB.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME, null,
+            null, null, "sn", null, null, null, null ).size() );
     }
 
 
-    public void testAttributeType() throws Exception
+    @Test public void testAttributeType() throws Exception
     {
         Collection<String> attrTypes = new ArrayList<String>();
-        attrTypes.add( "attrA" );
+        attrTypes.add( "cn" );
         Collection<ACITuple> tuples = getTuples( new ProtectedItem.AttributeType( attrTypes ) );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
 
         tuples = getTuples( new ProtectedItem.AttributeType( attrTypes ) );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
 
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "attrB", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "sn", null, null, null, null ).size() );
     }
 
 
-    public void testAttributeValue() throws Exception
+    @Test public void testAttributeValue() throws Exception
     {
-        Collection<Attribute> attributes = new ArrayList<Attribute>();
-        attributes.add( new AttributeImpl( "attrA", "valueA" ) );
-        Collection<ACITuple> tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
+        Collection<ServerAttribute> attributes = new ArrayList<ServerAttribute>();
+        attributes.add( new DefaultServerAttribute( "cn", CN_AT, "valueA" ) );
+        Collection<ACITuple> tuples = getTuples( new ProtectedItem.AttributeValue( convert( attributes ) ) );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, null, null, null ).size() );
-        tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
+        tuples = getTuples( new ProtectedItem.AttributeValue( convert( attributes )  ) );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
 
-        tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
+        tuples = getTuples( new ProtectedItem.AttributeValue( convert( attributes )  ) );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrA", "valueA", null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "cn", new ClientStringValue( "valueA" ), null, null, null ).size() );
 
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrA", "valueB", null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "cn", new ClientStringValue( "valueB" ), null, null, null ).size() );
 
-        tuples = getTuples( new ProtectedItem.AttributeValue( attributes ) );
+        tuples = getTuples( new ProtectedItem.AttributeValue( convert( attributes )  ) );
 
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrB", "valueA", null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "sn", new ClientStringValue( "valueA" ), null, null, null ).size() );
     }
 
 
@@ -220,106 +248,107 @@
     }
 
 
-    public void testMaxImmSub() throws Exception
+    @Test public void testMaxImmSub() throws Exception
     {
         Collection<ACITuple> tuples = getTuples( new ProtectedItem.MaxImmSub( 2 ) );
 
-        // Should always retain ruples.
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, null, null, null ).size() );
+        // Should always retain tuples.
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
     }
 
 
-    public void testMaxValueCount() throws Exception
+    @Test public void testMaxValueCount() throws Exception
     {
         Collection<MaxValueCountItem> mvcItems = new ArrayList<MaxValueCountItem>();
-        mvcItems.add( new MaxValueCountItem( "attrA", 3 ) );
+        mvcItems.add( new MaxValueCountItem( "cn", 3 ) );
         Collection<ACITuple> tuples = getTuples( new ProtectedItem.MaxValueCount( mvcItems ) );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
         tuples = getTuples( new ProtectedItem.MaxValueCount( mvcItems ) );
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
 
         tuples = getTuples( new ProtectedItem.MaxValueCount( mvcItems ) );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "cn", null, null, null, null ).size() );
 
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrB", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "sn", null, null, null, null ).size() );
     }
 
 
     /* this test requires a real registry with real values or the dummy registry
      * needs to be altered to contain some usable mock data.  This is a result of
      * using the registry now in this operation.    
+     *
     public void testRangeOfValues() throws Exception
     {
-        Attributes entry = new AttributesImpl( true );
-        entry.put( "attrA", "valueA" );
-        Collection tuples = getTuples( new ProtectedItem.RangeOfValues( new PresenceNode( "attrA" ) ) );
+        ServerEntry entry = new DefaultServerEntry( service.getRegistries(), USER_NAME );
+        entry.put( "cn", "valueA" );
+        Collection<ACITuple> tuples = getTuples( new ProtectedItem.RangeOfValues( new PresenceNode( "cn" ) ) );
 
         Assert.assertEquals( 1, filterA.filter( tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null,
             new LdapDN( "ou=testEntry" ), null, null, entry, null ).size() );
 
-        entry.remove( "attrA" );
-        Assert.assertEquals( 0, filterA.filter( tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+        entry.remove( "cn" );
+        Assert.assertEquals( 0, filterA.filter( service.getRegistries(), tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
             null, null, new LdapDN( "ou=testEntry" ), null, null, entry, null ).size() );
     }
     */
 
 
-    public void testRestrictedBy() throws Exception
+    @Test public void testRestrictedBy() throws Exception
     {
         Collection<RestrictedByItem> rbItems = new ArrayList<RestrictedByItem>();
-        rbItems.add( new RestrictedByItem( "attrA", "attrB" ) );
+        rbItems.add( new RestrictedByItem( "cn", "sn" ) );
         Collection<ACITuple> tuples = getTuples( new ProtectedItem.RestrictedBy( rbItems ) );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, null, null, null ).size() );
         tuples = getTuples( new ProtectedItem.RestrictedBy( rbItems ) );
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
-            null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, USER_NAME, null,
+            null, null, "cn", null, null, null, null ).size() );
 
         tuples = getTuples( new ProtectedItem.RestrictedBy( rbItems ) );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrA", null, null, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "cn", null, null, null, null ).size() );
 
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrB", null, null, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "sn", null, null, null, null ).size() );
     }
 
 
-    public void testSelfValue() throws Exception
+    @Test public void testSelfValue() throws Exception
     {
         Collection<String> attrTypes = new ArrayList<String>();
-        attrTypes.add( "attrA" );
+        attrTypes.add( "cn" );
         Collection<ACITuple> tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
 
-        Attributes entry = new AttributesImpl();
-        entry.put( "attrA", USER_NAME.toNormName() );
+        ServerEntry entry = new DefaultServerEntry( service.getRegistries(), USER_NAME );
+        entry.put( "cn", USER_NAME.toNormName() );
 
         // Test wrong scope
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
-            "attrA", null, entry, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ENTRY, null, null, USER_NAME, null, null, null,
+            "cn", null, entry, null, null ).size() );
 
         tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
 
-        Assert.assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrA", null, entry, null, null ).size() );
+        assertEquals( 1, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "cn", null, entry, null, null ).size() );
 
-        entry.remove( "attrA" );
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrA", null, entry, null, null ).size() );
+        entry.remove( "cn" );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "cn", null, entry, null, null ).size() );
 
         tuples = getTuples( new ProtectedItem.SelfValue( attrTypes ) );
-        Assert.assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
-            null, null, null, "attrB", null, entry, null, null ).size() );
+        assertEquals( 0, filterA.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, USER_NAME,
+            null, null, null, "sn", null, entry, null, null ).size() );
     }
 
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java?rev=638228&r1=638227&r2=638228&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java Mon Mar 17 23:12:41 2008
@@ -26,22 +26,27 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import javax.naming.NamingException;
 
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.authz.support.OperationScope;
 import org.apache.directory.server.core.authz.support.RestrictedByFilter;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.shared.ldap.aci.ACITuple;
 import org.apache.directory.shared.ldap.aci.MicroOperation;
 import org.apache.directory.shared.ldap.aci.ProtectedItem;
 import org.apache.directory.shared.ldap.aci.UserClass;
 import org.apache.directory.shared.ldap.aci.ProtectedItem.RestrictedByItem;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -50,7 +55,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class RestrictedByFilterTest extends TestCase
+public class RestrictedByFilterTest
 {
     private static final Collection<UserClass> UC_EMPTY_COLLECTION = Collections.unmodifiableCollection( new ArrayList<UserClass>() );
     private static final Collection<ACITuple> AT_EMPTY_COLLECTION = Collections.unmodifiableCollection( new ArrayList<ACITuple>() );
@@ -58,23 +63,33 @@
     private static final Set<MicroOperation> MO_EMPTY_SET = Collections.unmodifiableSet( new HashSet<MicroOperation>() );
 
     private static final Collection<ProtectedItem> PROTECTED_ITEMS = new ArrayList<ProtectedItem>();
-    private static final Attributes ENTRY = new AttributesImpl();
+    private static ServerEntry ENTRY;
 
     static
     {
         Collection<RestrictedByItem> mvcItems = new ArrayList<RestrictedByItem>();
-        mvcItems.add( new RestrictedByItem( "choice", "option" ) );
+        mvcItems.add( new RestrictedByItem( "sn", "cn" ) );
         PROTECTED_ITEMS.add( new ProtectedItem.RestrictedBy( mvcItems ) );
+    }
+
+
+    /** A reference to the directory service */
+    private static DirectoryService service;
+
+    
+    @BeforeClass public static void setup() throws NamingException
+    {
+        service = new DefaultDirectoryService();
 
-        Attribute attr = new AttributeImpl( "option" );
-        attr.add( "1" );
-        attr.add( "2" );
+        LdapDN entryName = new LdapDN( "ou=test, ou=system" );
+        PROTECTED_ITEMS.add( new ProtectedItem.MaxImmSub( 2 ) );
+        ENTRY = new DefaultServerEntry( service.getRegistries(), entryName );
 
-        ENTRY.put( attr );
+        ENTRY.put( "cn", "1", "2" );
     }
 
 
-    public void testWrongScope() throws Exception
+    @Test public void testWrongScope() throws Exception
     {
         RestrictedByFilter filter = new RestrictedByFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
@@ -82,24 +97,24 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE, null, null, null, null,
             null, null, null, null, null, null, null ) );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ENTRY, null, null, null, null, null, null,
             null, null, null, null, null ) );
     }
 
 
-    public void testZeroTuple() throws Exception
+    @Test public void testZeroTuple() throws Exception
     {
         RestrictedByFilter filter = new RestrictedByFilter();
 
-        Assert.assertEquals( 0, filter.filter( null, AT_EMPTY_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
+        assertEquals( 0, filter.filter( null, AT_EMPTY_COLLECTION, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null,
             null, null, null, null, null, null, null, null, null ).size() );
     }
 
 
-    public void testDenialTuple() throws Exception
+    @Test public void testDenialTuple() throws Exception
     {
         RestrictedByFilter filter = new RestrictedByFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
@@ -107,24 +122,24 @@
 
         tuples = Collections.unmodifiableCollection( tuples );
 
-        Assert.assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
+        assertEquals( tuples, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null,
             null, null, null, "testAttr", null, ENTRY, null, null ) );
     }
 
 
-    public void testGrantTuple() throws Exception
+    @Test public void testGrantTuple() throws Exception
     {
         RestrictedByFilter filter = new RestrictedByFilter();
         Collection<ACITuple> tuples = new ArrayList<ACITuple>();
         tuples.add( new ACITuple( UC_EMPTY_COLLECTION, AuthenticationLevel.NONE, PROTECTED_ITEMS, MO_EMPTY_SET, true, 0 ) );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
-            null, null, "choice", "1", ENTRY, null, null ).size() );
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+            null, null, "sn", new ClientStringValue( "1" ), ENTRY, null, null ).size() );
 
-        Assert.assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
-            null, null, "choice", "2", ENTRY, null, null ).size() );
+        assertEquals( 1, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+            null, null, "sn", new ClientStringValue( "2" ), ENTRY, null, null ).size() );
 
-        Assert.assertEquals( 0, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
-            null, null, "choice", "3", ENTRY, null, null ).size() );
+        assertEquals( 0, filter.filter( null, tuples, OperationScope.ATTRIBUTE_TYPE_AND_VALUE, null, null, null, null,
+            null, null, "sn", new ClientStringValue( "3" ), ENTRY, null, null ).size() );
     }
 }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java?rev=638228&r1=638227&r2=638228&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java Mon Mar 17 23:12:41 2008
@@ -22,7 +22,7 @@
 import junit.framework.TestCase;
 import org.apache.directory.server.core.authn.LdapPrincipal;
 import org.apache.directory.shared.ldap.ldif.ChangeType;
-import org.apache.directory.shared.ldap.ldif.Entry;
+import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
@@ -58,13 +58,13 @@
     {
         assertEquals( "first revision is always 0", 0, store.getCurrentRevision() );
 
-        Entry forward = new Entry();
+        LdifEntry forward = new LdifEntry();
         forward.setDn( "ou=system" );
         forward.setChangeType( ChangeType.Add );
         forward.putAttribute( "objectClass", "organizationalUnit" );
         forward.putAttribute( "ou", "system" );
 
-        Entry reverse = LdifUtils.reverseAdd( new LdapDN( forward.getDn() ) );
+        LdifEntry reverse = LdifUtils.reverseAdd( new LdapDN( forward.getDn() ) );
         assertEquals( 1, store.log( new LdapPrincipal(), forward, reverse ) );
         assertEquals( 1, store.getCurrentRevision() );
     }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java?rev=638228&r1=638227&r2=638228&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java Mon Mar 17 23:12:41 2008
@@ -35,7 +35,7 @@
 import org.apache.directory.server.core.schema.SchemaOperationControl;
 import org.apache.directory.server.core.schema.SchemaService;
 import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.shared.ldap.ldif.Entry;
+import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
 import javax.naming.Context;
@@ -443,13 +443,13 @@
         }
 
 
-        public List<Entry> getTestEntries()
+        public List<LdifEntry> getTestEntries()
         {
             return null;
         }
 
 
-        public void setTestEntries( List<? extends Entry> testEntries )
+        public void setTestEntries( List<? extends LdifEntry> testEntries )
         {
         }
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/interceptor/MockInterceptor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/interceptor/MockInterceptor.java?rev=638228&r1=638227&r2=638228&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/interceptor/MockInterceptor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/interceptor/MockInterceptor.java Mon Mar 17 23:12:41 2008
@@ -22,6 +22,7 @@
 
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerSearchResult;
 import org.apache.directory.server.core.interceptor.context.AddContextPartitionOperationContext;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
@@ -45,8 +46,6 @@
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.SearchResult;
 import java.util.Iterator;
 
 
@@ -164,14 +163,14 @@
     }
 
 
-    public NamingEnumeration<SearchResult> search( NextInterceptor next, SearchOperationContext opContext ) throws NamingException
+    public NamingEnumeration<ServerSearchResult> search( NextInterceptor next, SearchOperationContext opContext ) throws NamingException
     {
         test.interceptors.add( this );
         return next.search( opContext );
     }
 
 
-    public Attributes lookup( NextInterceptor next, LookupOperationContext opContext ) throws NamingException
+    public ServerEntry lookup( NextInterceptor next, LookupOperationContext opContext ) throws NamingException
     {
         test.interceptors.add( this );
         return next.lookup( opContext );

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java?rev=638228&r1=638227&r2=638228&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java Mon Mar 17 23:12:41 2008
@@ -20,7 +20,6 @@
 package org.apache.directory.server.core.schema;
 
 
-import junit.framework.TestCase;
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
@@ -40,6 +39,13 @@
 import org.apache.directory.server.schema.registries.DefaultRegistries;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 
 import javax.naming.NamingException;
 import java.io.File;
@@ -56,24 +62,24 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class PartitionSchemaLoaderTest extends TestCase
+public class PartitionSchemaLoaderTest
 {
-    private Registries registries;
-    private DirectoryService directoryService;
-    private JdbmPartition schemaPartition;
+    private static Registries registries;
+    private static DirectoryService directoryService;
+    private static JdbmPartition schemaPartition;
 
 
-    public void setUp() throws Exception
+    @BeforeClass public static void setUp() throws Exception
     {
-        super.setUp();
-
         // setup working directory
         directoryService = new DefaultDirectoryService();
         File workingDirectory = new File( System.getProperty( "workingDirectory", System.getProperty( "user.dir" ) ) );
+        
         if ( ! workingDirectory.exists() )
         {
             workingDirectory.mkdirs();
         }
+        
         directoryService.setWorkingDirectory( workingDirectory );
         
         // --------------------------------------------------------------------
@@ -147,7 +153,7 @@
     }
     
     
-    public void testGetSchemas() throws NamingException
+    @Test public void testGetSchemas() throws NamingException
     {
         PartitionSchemaLoader loader = new PartitionSchemaLoader( schemaPartition, registries );
         Map<String,Schema> schemas = loader.getSchemas();
@@ -266,7 +272,7 @@
     }
     
     
-    public void testGetSchemaNames() throws NamingException
+    @Test public void testGetSchemaNames() throws NamingException
     {
         PartitionSchemaLoader loader = new PartitionSchemaLoader( schemaPartition, registries );
         Set<String> schemaNames = loader.getSchemaNames();

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java?rev=638228&r1=638227&r2=638228&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java Mon Mar 17 23:12:41 2008
@@ -27,22 +27,29 @@
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
 
+import org.apache.directory.server.core.entry.DefaultServerAttribute;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerAttribute;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.schema.SchemaChecker;
 import org.apache.directory.server.schema.bootstrap.ApacheSchema;
 import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
 import org.apache.directory.server.schema.bootstrap.CoreSchema;
 import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.bootstrap.SystemSchema;
+import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.DefaultOidRegistry;
 import org.apache.directory.server.schema.registries.DefaultRegistries;
 import org.apache.directory.server.schema.registries.ObjectClassRegistry;
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
 import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 import java.util.Collections;
@@ -83,7 +90,8 @@
         schemas.add( new CoreSchema() );
         loader.loadWithDependencies( schemas,registries );
 
-        java.util.List errors = registries.checkRefInteg();
+        List<Throwable> errors = registries.checkRefInteg();
+        
         if ( !errors.isEmpty() )
         {
             NamingException e = new NamingException();
@@ -151,7 +159,7 @@
     /**
      * Test case to check the schema checker operates correctly when modify
      * operations remove objectClasses.
-     */
+     *
     public void testPreventStructuralClassRemovalOnModifyRemove() throws Exception
     {
         LdapDN name = new LdapDN( "uid=akarasulu,ou=users,dc=example,dc=com" );
@@ -220,14 +228,16 @@
     {
         int mod = DirContext.REMOVE_ATTRIBUTE;
         LdapDN name = new LdapDN( "ou=user,dc=example,dc=com" );
-        Attributes attributes = new AttributesImpl( true );
+        ServerEntry attributes = new DefaultServerEntry( registries, name );
         attributes.put( "cn", "does not matter" );
 
         // postive test which should pass
         SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, registries.getOidRegistry() );
 
         // test should fail since we are removing the ou attribute
-        attributes.put( new AttributeImpl( "ou" ) );
+        AttributeType OU_AT = registries.getAttributeTypeRegistry().lookup( "ou" );
+        attributes.put( new DefaultServerAttribute( "ou", OU_AT ) );
+
         try
         {
             SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, registries.getOidRegistry() );
@@ -240,12 +250,14 @@
 
         // test success using more than one attribute for the Rdn but not modifying rdn attribute
         name = new LdapDN( "ou=users+cn=system users,dc=example,dc=com" );
-        attributes = new AttributesImpl( true );
+        attributes = new DefaultServerEntry( registries, name );
         attributes.put( "sn", "does not matter" );
         SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, registries.getOidRegistry() );
 
         // test for failure when modifying Rdn attribute in multi attribute Rdn
-        attributes.put( new AttributeImpl( "cn" ) );
+        AttributeType CN_AT = registries.getAttributeTypeRegistry().lookup( "cn" );
+        attributes.put( new DefaultServerAttribute( "cn", CN_AT ) );
+        
         try
         {
             SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, registries.getOidRegistry() );
@@ -258,12 +270,12 @@
 
         // should succeed since the value being deleted from the rdn attribute is
         // is not used when composing the Rdn
-        attributes = new AttributesImpl( true );
+        attributes = new DefaultServerEntry( registries, name );
         attributes.put( "ou", "container" );
         SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, attributes, registries.getOidRegistry() );
 
         // now let's make it fail again just by providing the right value for ou (users)
-        attributes = new AttributesImpl( true );
+        attributes = new DefaultServerEntry( registries, name );
         attributes.put( "ou", "users" );
         try
         {
@@ -285,14 +297,15 @@
     {
         int mod = DirContext.REPLACE_ATTRIBUTE;
         LdapDN name = new LdapDN( "ou=user,dc=example,dc=com" );
-        Attributes attributes = new AttributesImpl( true );
+        ServerEntry attributes = new DefaultServerEntry( registries, name );
         attributes.put( "cn", "does not matter" );
 
         // postive test which should pass
         SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, registries.getOidRegistry() );
 
         // test should fail since we are removing the ou attribute
-        attributes.put( new AttributeImpl( "ou" ) );
+        attributes.put( "ou", (String)null );
+        
         try
         {
             SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, registries.getOidRegistry() );
@@ -305,12 +318,13 @@
 
         // test success using more than one attribute for the Rdn but not modifying rdn attribute
         name = new LdapDN( "ou=users+cn=system users,dc=example,dc=com" );
-        attributes = new AttributesImpl( true );
+        attributes = new DefaultServerEntry( registries, name );
         attributes.put( "sn", "does not matter" );
         SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, registries.getOidRegistry() );
 
         // test for failure when modifying Rdn attribute in multi attribute Rdn
-        attributes.put( new AttributeImpl( "cn" ) );
+        attributes.put("cn", (String)null );
+        
         try
         {
             SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, registries.getOidRegistry() );
@@ -323,13 +337,13 @@
 
         // should succeed since the values being replaced from the rdn attribute is
         // is includes the old Rdn attribute value
-        attributes = new AttributesImpl( true );
+        attributes = new DefaultServerEntry( registries, name );
         attributes.put( "ou", "container" );
         attributes.put( "ou", "users" );
         SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes, registries.getOidRegistry() );
 
         // now let's make it fail by not including the old value for ou (users)
-        attributes = new AttributesImpl( true );
+        attributes = new DefaultServerEntry( registries, name );
         attributes.put( "ou", "container" );
         try
         {
@@ -354,20 +368,22 @@
     public void testPreventStructuralClassRemovalOnModifyReplaceAttribute() throws Exception
     {
         ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();
+        AttributeType OBJECT_CLASS = registries.getAttributeTypeRegistry().lookup( "objectClass" );
+        AttributeType CN_AT = registries.getAttributeTypeRegistry().lookup( "cn" );
 
         // this should pass
         LdapDN name = new LdapDN( "uid=akarasulu,ou=users,dc=example,dc=com" );
-        int mod = DirContext.REPLACE_ATTRIBUTE;
-        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, new AttributeImpl( "cn" ) );
+        ModificationOperation mod = ModificationOperation.REPLACE_ATTRIBUTE;
+        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, new DefaultServerAttribute( "cn", CN_AT ) );
 
         // this should succeed since person is still in replaced set and is structural
-        Attribute objectClassesReplaced = new AttributeImpl( "objectClass" );
+        ServerAttribute objectClassesReplaced = new DefaultServerAttribute( "objectClass", OBJECT_CLASS );
         objectClassesReplaced.add( "top" );
         objectClassesReplaced.add( "person" );
         SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, objectClassesReplaced );
 
         // this should fail since only top is left
-        objectClassesReplaced = new AttributeImpl( "objectClass" );
+        objectClassesReplaced = new DefaultServerAttribute( "objectClass", OBJECT_CLASS );
         objectClassesReplaced.add( "top" );
         try
         {
@@ -381,7 +397,7 @@
 
         // this should fail since the modify operation tries to delete all
         // objectClass attribute values
-        objectClassesReplaced = new AttributeImpl( "objectClass" );
+        objectClassesReplaced = new DefaultServerAttribute( "objectClass", OBJECT_CLASS );
         try
         {
             SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, objectClassesReplaced );
@@ -400,29 +416,35 @@
      */
     public void testPreventStructuralClassRemovalOnModifyRemoveAttribute() throws Exception
     {
+        AttributeTypeRegistry atReg = registries.getAttributeTypeRegistry();
         LdapDN name = new LdapDN( "uid=akarasulu,ou=users,dc=example,dc=com" );
-        int mod = DirContext.REMOVE_ATTRIBUTE;
-        Attribute entryObjectClasses = new AttributeImpl( "objectClass" );
-        entryObjectClasses.add( "top" );
-        entryObjectClasses.add( "person" );
-        entryObjectClasses.add( "organizationalPerson" );
+        ModificationOperation mod = ModificationOperation.REMOVE_ATTRIBUTE;
+        AttributeType ocAt = atReg.lookup( "objectClass" );
+        
+        ServerAttribute entryObjectClasses = new DefaultServerAttribute( "objectClass", ocAt );
+        entryObjectClasses.add( "top", "person", "organizationalPerson" );
 
         ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();
 
         // this should pass
-        SchemaChecker.preventStructuralClassRemovalOnModifyRemove( ocRegistry, name, mod, new AttributeImpl( "cn" ),
+        SchemaChecker.preventStructuralClassRemovalOnModifyRemove( 
+            ocRegistry, 
+            name, 
+            mod, 
+            new DefaultServerAttribute( "cn", atReg.lookup( "cn" ) ),
             entryObjectClasses );
 
         // this should succeed since person is left and is structural
-        Attribute objectClassesRemoved = new AttributeImpl( "objectClass" );
+        ServerAttribute objectClassesRemoved = new DefaultServerAttribute( 
+            "objectClass", ocAt );
         objectClassesRemoved.add( "person" );
         SchemaChecker.preventStructuralClassRemovalOnModifyRemove( ocRegistry, name, mod, objectClassesRemoved,
             entryObjectClasses );
 
         // this should fail since only top is left
-        objectClassesRemoved = new AttributeImpl( "objectClass" );
-        objectClassesRemoved.add( "person" );
-        objectClassesRemoved.add( "organizationalPerson" );
+        objectClassesRemoved = new DefaultServerAttribute( "objectClass", ocAt );
+        objectClassesRemoved.add( "person", "organizationalPerson" );
+        
         try
         {
             SchemaChecker.preventStructuralClassRemovalOnModifyRemove( ocRegistry, name, mod, objectClassesRemoved,
@@ -436,7 +458,8 @@
 
         // this should fail since the modify operation tries to delete all
         // objectClass attribute values
-        objectClassesRemoved = new AttributeImpl( "objectClass" );
+        objectClassesRemoved = new DefaultServerAttribute( "objectClass", ocAt );
+
         try
         {
             SchemaChecker.preventStructuralClassRemovalOnModifyRemove( ocRegistry, name, mod, objectClassesRemoved,
@@ -457,17 +480,21 @@
     public void testPreventRdnChangeOnModifyRemoveAttribute() throws Exception
     {
         OidRegistry registry = new MockOidRegistry();
-        int mod = DirContext.REMOVE_ATTRIBUTE;
+        ModificationOperation mod = ModificationOperation.REMOVE_ATTRIBUTE;
         LdapDN name = new LdapDN( "ou=user,dc=example,dc=com" );
+        AttributeType cnAt = registries.getAttributeTypeRegistry().lookup( "cn" );
+        AttributeType ouAt = registries.getAttributeTypeRegistry().lookup( "ou" );
+        AttributeType snAt = registries.getAttributeTypeRegistry().lookup( "sn" );
 
         // postive test which should pass
         SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, 
-            new AttributeImpl( "cn", "does not matter" ), registry );
+            new DefaultServerAttribute( "cn", cnAt, "does not matter" ), registry );
 
         // test should fail since we are removing the ou attribute
         try
         {
-            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, new AttributeImpl( "ou" ), registry );
+            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, 
+                new DefaultServerAttribute( "ou", ouAt ), registry );
             fail( "should never get here due to a LdapSchemaViolationException being thrown" );
         }
         catch ( LdapSchemaViolationException e )
@@ -478,12 +505,13 @@
         // test success using more than one attribute for the Rdn but not modifying rdn attribute
         name = new LdapDN( "ou=users+cn=system users,dc=example,dc=com" );
         SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, 
-            new AttributeImpl( "sn", "does not matter" ), registry );
+            new DefaultServerAttribute( "sn", snAt, "does not matter" ), registry );
 
         // test for failure when modifying Rdn attribute in multi attribute Rdn
         try
         {
-            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, new AttributeImpl( "cn" ), registry );
+            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, 
+                new DefaultServerAttribute( "cn", cnAt ), registry );
             fail( "should never get here due to a LdapSchemaViolationException being thrown" );
         }
         catch ( LdapSchemaViolationException e )
@@ -493,12 +521,14 @@
 
         // should succeed since the value being deleted from the rdn attribute is
         // is not used when composing the Rdn
-        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, new AttributeImpl( "ou", "container" ), registry );
+        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, 
+            new DefaultServerAttribute( "ou", ouAt, "container" ), registry );
 
         // now let's make it fail again just by providing the right value for ou (users)
         try
         {
-            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, new AttributeImpl( "ou", "users" ), registry );
+            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, 
+                new DefaultServerAttribute( "ou", ouAt, "users" ), registry );
             fail( "should never get here due to a LdapSchemaViolationException being thrown" );
         }
         catch ( LdapSchemaViolationException e )

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java?rev=638228&r1=638227&r2=638228&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java Mon Mar 17 23:12:41 2008
@@ -20,30 +20,29 @@
 package org.apache.directory.server.core.subtree;
 
 
-import junit.framework.TestCase;
-
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
 
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.entry.DefaultServerAttribute;
+import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.subtree.RefinementEvaluator;
 import org.apache.directory.server.core.subtree.RefinementLeafEvaluator;
-import org.apache.directory.server.schema.bootstrap.ApacheSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
-import org.apache.directory.server.schema.bootstrap.CoreSchema;
-import org.apache.directory.server.schema.bootstrap.Schema;
-import org.apache.directory.server.schema.bootstrap.SystemSchema;
-import org.apache.directory.server.schema.registries.DefaultOidRegistry;
-import org.apache.directory.server.schema.registries.DefaultRegistries;
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.FilterParser;
 import org.apache.directory.shared.ldap.filter.NotNode;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-
-import java.util.Set;
-import java.util.HashSet;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 
 /**
@@ -52,28 +51,32 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class RefinementEvaluatorTest extends TestCase
+public class RefinementEvaluatorTest
 {
     /** the registries */
-    private Registries registries;
+    private static Registries registries;
+    
     /** the refinement evaluator to test */
-    private RefinementEvaluator evaluator;
+    private static RefinementEvaluator evaluator;
+
+    /** The ObjectClass AttributeType */
+    private static AttributeType OBJECT_CLASS;
+
+    /** The CN AttributeType */
+    private static AttributeType CN;
 
+    /** A reference to the directory service */
+    private static DirectoryService service;
 
+    
     /**
      * Initializes the global registries.
      * @throws javax.naming.NamingException if there is a failure loading the schema
      */
-    private void init() throws NamingException
+    @BeforeClass public static void init() throws NamingException
     {
-        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-        DefaultRegistries bsRegistries = new DefaultRegistries( "bootstrap", loader, new DefaultOidRegistry() );
-        Set<Schema> schemas = new HashSet<Schema>();
-        schemas.add( new SystemSchema() );
-        schemas.add( new ApacheSchema() );
-        schemas.add( new CoreSchema() );
-        loader.loadWithDependencies( schemas, bsRegistries );
-        registries = bsRegistries;
+        service = new DefaultDirectoryService();
+        registries = service.getRegistries();
     }
 
 
@@ -81,34 +84,35 @@
      * Initializes registries and creates the leaf evalutator
      * @throws Exception if there are schema initialization problems
      */
-    protected void setUp() throws Exception
+    @Before public void setUp() throws Exception
     {
-        init();
         OidRegistry registry = registries.getOidRegistry();
         RefinementLeafEvaluator leafEvaluator = new RefinementLeafEvaluator( registry );
         evaluator = new RefinementEvaluator( leafEvaluator );
+        
+        OBJECT_CLASS = registries.getAttributeTypeRegistry().lookup( "objectClass" );
+        CN = registries.getAttributeTypeRegistry().lookup( "cn" );
     }
 
 
     /**
      * Sets evaluator and registries to null.
      */
-    protected void tearDown()
+    @After public void tearDown()
     {
         evaluator = null;
-        registries = null;
     }
 
 
     /**
      * Test cases for various bad combinations of arguments
-     * @throws Exception if something goes wrongg
+     * @throws Exception if something goes wrong
      */
-    public void testForBadArguments() throws Exception
+    @Test public void testForBadArguments() throws Exception
     {
         try
         {
-            assertFalse( evaluator.evaluate( null, new AttributeImpl( "objectClass" ) ) );
+            assertFalse( evaluator.evaluate( null, new DefaultServerAttribute( "objectClass", OBJECT_CLASS ) ) );
             fail( "should never get here due to an IAE" );
         }
         catch ( IllegalArgumentException iae )
@@ -126,7 +130,7 @@
 
         try
         {
-            assertFalse( evaluator.evaluate( new EqualityNode( "", "" ), new AttributeImpl( "blah" ) ) );
+            assertFalse( evaluator.evaluate( new EqualityNode( "", "" ), new DefaultServerAttribute( "cn", CN ) ) );
             fail( "should never get here due to an IAE" );
         }
         catch ( IllegalArgumentException iae )
@@ -135,102 +139,104 @@
     }
 
 
-    public void testMatchByName() throws Exception
+    @Test public void testMatchByName() throws Exception
     {
-        Attribute objectClasses = null;
+        ServerAttribute objectClasses = null;
 
         // positive test
-        objectClasses = new AttributeImpl( "objectClass", "person" );
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "person" );
         assertTrue( evaluator.evaluate( new EqualityNode( "objectClass", "person" ), objectClasses ) );
 
-        objectClasses = new AttributeImpl( "objectClass" );
-        objectClasses.add( "person" );
-        objectClasses.add( "blah" );
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "person", "blah" );
         assertTrue( evaluator.evaluate( new EqualityNode( "objectClass", "person" ), objectClasses ) );
 
         // negative tests
-        objectClasses = new AttributeImpl( "objectClass", "person" );
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "person" );
         assertFalse( evaluator.evaluate( new EqualityNode( "objectClass", "blah" ), objectClasses ) );
 
-        objectClasses = new AttributeImpl( "objectClass", "blah" );
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "blah" );
         assertFalse( evaluator.evaluate( new EqualityNode( "objectClass", "person" ), objectClasses ) );
     }
 
 
-    public void testMatchByOID() throws Exception
+    @Test public void testMatchByOID() throws Exception
     {
-        Attribute objectClasses = null;
-
+        ServerAttribute objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "person" );
+        
         // positive test
-        objectClasses = new AttributeImpl( "objectClass", "person" );
         assertTrue( evaluator.evaluate( new EqualityNode( "objectClass", "2.5.6.6" ), objectClasses ) );
 
-        objectClasses = new AttributeImpl( "objectClass" );
-        objectClasses.add( "person" );
-        objectClasses.add( "blah" );
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "person", "blah" );
         assertTrue( evaluator.evaluate( new EqualityNode( "objectClass", "2.5.6.6" ), objectClasses ) );
 
         // negative tests
-        objectClasses = new AttributeImpl( "objectClass", "person" );
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "person" );
         assertFalse( evaluator.evaluate( new EqualityNode( "objectClass", "2.5.6.5" ), objectClasses ) );
 
-        objectClasses = new AttributeImpl( "objectClass", "blah" );
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "blah" );
         assertFalse( evaluator.evaluate( new EqualityNode( "objectClass", "2.5.6.5" ), objectClasses ) );
     }
 
 
-    public void testComplexOrRefinement() throws Exception
+    @Test public void testComplexOrRefinement() throws Exception
     {
         ExprNode refinement = null;
-        Attribute objectClasses = new AttributeImpl( "objectClass", "person" );
+        ServerAttribute objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "person" );
         String refStr = "(|(objectClass=person)(objectClass=organizationalUnit))";
         
         refinement = FilterParser.parse( refStr );
 
         assertTrue( evaluator.evaluate( refinement, objectClasses ) );
-        objectClasses = new AttributeImpl( "objectClass", "organizationalUnit" );
+        
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "organizationalUnit" );
         assertTrue( evaluator.evaluate( refinement, objectClasses ) );
-        objectClasses = new AttributeImpl( "objectClass", "domain" );
+        
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "domain" );
         assertFalse( evaluator.evaluate( refinement, objectClasses ) );
     }
 
 
-    public void testComplexAndRefinement() throws Exception
+    @Test public void testComplexAndRefinement() throws Exception
     {
         ExprNode refinement = null;
-        Attribute objectClasses = new AttributeImpl( "objectClass", "person" );
+        ServerAttribute objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "person" );
         objectClasses.add( "organizationalUnit" );
         String refStr = "(&(objectClass=person)(objectClass=organizationalUnit))";
         
         refinement = FilterParser.parse( refStr );
 
         assertTrue( evaluator.evaluate( refinement, objectClasses ) );
-        objectClasses = new AttributeImpl( "objectClass", "organizationalUnit" );
+        
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "organizationalUnit" );
         assertFalse( evaluator.evaluate( refinement, objectClasses ) );
-        objectClasses = new AttributeImpl( "objectClass", "person" );
+        
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "person" );
         assertFalse( evaluator.evaluate( refinement, objectClasses ) );
-        objectClasses = new AttributeImpl( "objectClass", "domain" );
+        
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "domain" );
         assertFalse( evaluator.evaluate( refinement, objectClasses ) );
     }
 
 
-    public void testComplexNotRefinement() throws Exception
+    @Test public void testComplexNotRefinement() throws Exception
     {
         ExprNode refinement = null;
-        Attribute objectClasses = new AttributeImpl( "objectClass", "person" );
+        ServerAttribute objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "person" );
         String refStr = "(!(objectClass=person))";
 
         refinement = FilterParser.parse( refStr );
 
         assertFalse( evaluator.evaluate( refinement, objectClasses ) );
-        objectClasses = new AttributeImpl( "objectClass", "organizationalUnit" );
+        
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "organizationalUnit" );
         assertTrue( evaluator.evaluate( refinement, objectClasses ) );
-        objectClasses = new AttributeImpl( "objectClass", "domain" );
+        
+        objectClasses = new DefaultServerAttribute( "objectClass", OBJECT_CLASS, "domain" );
         assertTrue( evaluator.evaluate( refinement, objectClasses ) );
 
         try
         {
-            assertFalse( evaluator.evaluate( new NotNode(), new AttributeImpl( "objectClass" ) ) );
+            assertFalse( evaluator.evaluate( new NotNode(), new DefaultServerAttribute( "objectClass", OBJECT_CLASS ) ) );
             fail( "should never get here due to an IAE" );
         }
         catch ( IllegalArgumentException iae )



Mime
View raw message