You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/01/06 19:27:19 UTC
svn commit: r896599 [4/30] - in /directory/apacheds/trunk: ./ avl-partition/
avl-partition/src/ avl-partition/src/main/ avl-partition/src/main/java/
avl-partition/src/main/java/org/ avl-partition/src/main/java/org/apache/
avl-partition/src/main/java/or...
Modified: directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java (original)
+++ directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java Wed Jan 6 18:26:43 2010
@@ -19,6 +19,16 @@
*/
package org.apache.directory.server.core.entry;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
@@ -32,19 +42,6 @@
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.NoSuchAttributeException;
-import org.apache.directory.server.schema.bootstrap.ApacheSchema;
-import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
-import org.apache.directory.server.schema.bootstrap.CoreSchema;
-import org.apache.directory.server.schema.bootstrap.CosineSchema;
-import org.apache.directory.server.schema.bootstrap.InetorgpersonSchema;
-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.OidRegistry;
-import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.Entry;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
@@ -55,16 +52,13 @@
import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
import org.apache.directory.shared.ldap.util.StringTools;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
import org.junit.BeforeClass;
import org.junit.Test;
@@ -81,10 +75,8 @@
private static final byte[] BYTES2 = new byte[]{ 'b' };
private static final byte[] BYTES3 = new byte[]{ 'c' };
- private static BootstrapSchemaLoader loader;
- private static Registries registries;
- private static AttributeTypeRegistry atr;
- private static OidRegistry oidRegistry;
+ private static LdifSchemaLoader loader;
+ private static SchemaManager schemaManager;
private static AttributeType atObjectClass;
private static AttributeType atCN;
@@ -104,29 +96,37 @@
@BeforeClass
public static void setup() throws Exception
{
- loader = new BootstrapSchemaLoader();
- oidRegistry = new DefaultOidRegistry();
- registries = new DefaultRegistries( "bootstrap", loader, oidRegistry );
-
- // load essential bootstrap schemas
- Set<Schema> bootstrapSchemas = new HashSet<Schema>();
- bootstrapSchemas.add( new ApachemetaSchema() );
- bootstrapSchemas.add( new ApacheSchema() );
- bootstrapSchemas.add( new CoreSchema() );
- bootstrapSchemas.add( new SystemSchema() );
- bootstrapSchemas.add( new InetorgpersonSchema() );
- bootstrapSchemas.add( new CosineSchema() );
- loader.loadWithDependencies( bootstrapSchemas, registries );
-
- atr = registries.getAttributeTypeRegistry();
-
- atObjectClass = registries.getAttributeTypeRegistry().lookup( "objectClass" );
- atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
- atC = registries.getAttributeTypeRegistry().lookup( "c" );
- atL = registries.getAttributeTypeRegistry().lookup( "l" );
- atOC = registries.getAttributeTypeRegistry().lookup( "objectClass" );
- atSN = registries.getAttributeTypeRegistry().lookup( "sn" );
- atPwd = registries.getAttributeTypeRegistry().lookup( "userpassword" );
+ String workingDirectory = System.getProperty( "workingDirectory" );
+
+ if ( workingDirectory == null )
+ {
+ String path = DefaultServerEntryTest.class.getResource( "" ).getPath();
+ int targetPos = path.indexOf( "target" );
+ workingDirectory = path.substring( 0, targetPos + 6 );
+ }
+
+ File schemaRepository = new File( workingDirectory, "schema" );
+ SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
+ extractor.extractOrCopy( true );
+ loader = new LdifSchemaLoader( schemaRepository );
+
+ schemaManager = new DefaultSchemaManager( loader );
+ schemaManager.loadAllEnabled();
+
+ List<Throwable> errors = schemaManager.getErrors();
+
+ if ( errors.size() != 0 )
+ {
+ fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+ }
+
+ atObjectClass = schemaManager.lookupAttributeTypeRegistry( "objectClass" );
+ atCN = schemaManager.lookupAttributeTypeRegistry( "cn" );
+ atC = schemaManager.lookupAttributeTypeRegistry( "c" );
+ atL = schemaManager.lookupAttributeTypeRegistry( "l" );
+ atOC = schemaManager.lookupAttributeTypeRegistry( "objectClass" );
+ atSN = schemaManager.lookupAttributeTypeRegistry( "sn" );
+ atPwd = schemaManager.lookupAttributeTypeRegistry( "userpassword" );
EXAMPLE_DN = new LdapDN( "dc=example,dc=com" );
}
@@ -154,7 +154,7 @@
@Test
public void testDefaultServerEntryRegistries() throws Exception
{
- Entry entry = new DefaultServerEntry( registries );
+ Entry entry = new DefaultServerEntry( schemaManager );
assertNotNull( entry );
assertEquals( LdapDN.EMPTY_LDAPDN, entry.getDn() );
assertEquals( 0, entry.size() );
@@ -167,7 +167,7 @@
@Test
public void testDefaultServerEntryRegistriesDN() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertNotNull( entry );
assertEquals( EXAMPLE_DN, entry.getDn() );
assertEquals( 0, entry.size() );
@@ -180,7 +180,7 @@
@Test
public void testDefaultServerEntryRegistriesDNAttributeTypeArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN, atOC, atPwd, atCN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN, atOC, atPwd, atCN );
assertNotNull( entry );
assertEquals( EXAMPLE_DN, entry.getDn() );
assertEquals( 3, entry.size() );
@@ -196,7 +196,7 @@
@Test
public void testDefaultServerEntryRegistriesDNAttributeTypeUpId() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN, atOC, " OBJECTCLASS " );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN, atOC, " OBJECTCLASS " );
assertNotNull( entry );
assertEquals( EXAMPLE_DN, entry.getDn() );
assertEquals( 1, entry.size() );
@@ -212,7 +212,7 @@
@Test
public void testDefaultServerEntryRegistriesDNUpIdArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN, " OBJECTCLASS ", " Cn " );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN, " OBJECTCLASS ", " Cn " );
assertNotNull( entry );
assertEquals( EXAMPLE_DN, entry.getDn() );
assertEquals( 2, entry.size() );
@@ -234,7 +234,7 @@
@Test
public void testAddEntryAttribute() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
EntryAttribute oc = new DefaultServerAttribute( atObjectClass, "top", "person" );
EntryAttribute cn = new DefaultServerAttribute( atCN, "test1", "test2" );
@@ -273,7 +273,7 @@
@Test
public void testAddStringByteArrayArray() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
entry.add( "userPassword", (byte[])null );
assertEquals( 1, entry.size() );
@@ -317,7 +317,7 @@
@Test
public void testAddStringStringArray() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
entry.add( "cn", (String)null );
assertEquals( 1, entry.size() );
@@ -362,7 +362,7 @@
@Test
public void testAddStringValueArray() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
Value<String> value = new ServerStringValue( atCN, (String)null );
entry.add( "cn", value );
@@ -415,7 +415,7 @@
@Test
public void testAddAttributeTypeByteArrayArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
entry.add( atPwd, BYTES1, BYTES2 );
assertEquals( 1, entry.size() );
@@ -438,7 +438,7 @@
@Test
public void testAddAttributeTypeStringArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
entry.add( atC, "us", "fr" );
assertEquals( 1, entry.size() );
@@ -466,7 +466,7 @@
@Test
public void testAddAttributeTypeValueArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
Value<String> strValue1 = new ServerStringValue( atCN, "test1" );
Value<String> strValue2 = new ServerStringValue( atCN, "test2" );
@@ -512,7 +512,7 @@
@Test
public void testAddStringAttributeTypeByteArrayArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
entry.add( "UserPassword", atPwd, BYTES1, BYTES2 );
assertEquals( 1, entry.size() );
@@ -549,7 +549,7 @@
@Test
public void testAddStringAttributeTypeStringArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
entry.add( "CommonName", atCN, "test1", "test2" );
assertEquals( 1, entry.size() );
@@ -584,7 +584,7 @@
@Test
public void testAddStringAttributeTypeValueArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
Value<String> strValue1 = new ServerStringValue( atCN, "test1" );
Value<String> strValue2 = new ServerStringValue( atCN, "test2" );
@@ -642,7 +642,7 @@
@Test public void testAddAtStringElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
// Test a simple addition
entry.add( atCN, "test1" );
@@ -691,9 +691,9 @@
@Test public void testAddAtBytesElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
+ AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
byte[] test1 = StringTools.getBytesUtf8( "test1" );
byte[] test2 = StringTools.getBytesUtf8( "test2" );
@@ -748,9 +748,9 @@
@Test public void testAddAtServerValueElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
+ AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
byte[] b1 = StringTools.getBytesUtf8( "test1" );
byte[] b2 = StringTools.getBytesUtf8( "test2" );
@@ -853,7 +853,7 @@
@Test public void testAddUpIdStringElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
// Test a simple addition
entry.add( "CN", "test1" );
@@ -905,9 +905,9 @@
@Test public void testAddUpIdBytesElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
+ AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
byte[] test1 = StringTools.getBytesUtf8( "test1" );
byte[] test2 = StringTools.getBytesUtf8( "test2" );
@@ -962,9 +962,9 @@
@Test public void testAddUpIdServerValueElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- ServerEntry entry = new DefaultServerEntry( registries, dn );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
+ AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
byte[] b1 = StringTools.getBytesUtf8( "test1" );
byte[] b2 = StringTools.getBytesUtf8( "test2" );
@@ -1073,7 +1073,7 @@
@Test public void testAddUpIdAtStringElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
// Test a simple addition
entry.add( "cn", atCN, "test1" );
@@ -1122,9 +1122,9 @@
@Test public void testAddUpIdAtBytesElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
+ AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
byte[] test1 = StringTools.getBytesUtf8( "test1" );
byte[] test2 = StringTools.getBytesUtf8( "test2" );
@@ -1179,9 +1179,9 @@
@Test public void testAddUpIdAtServerValueElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- ServerEntry entry = new DefaultServerEntry( registries, dn );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
+ AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
byte[] b1 = StringTools.getBytesUtf8( "test1" );
byte[] b2 = StringTools.getBytesUtf8( "test2" );
@@ -1290,7 +1290,7 @@
@Test
public void testClear() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertEquals( 0, entry.size() );
assertNull( entry.get( "ObjectClass" ) );
@@ -1314,7 +1314,7 @@
@Test
public void testClone() throws Exception
{
- Entry entry1 = new DefaultServerEntry( registries );
+ Entry entry1 = new DefaultServerEntry( schemaManager );
Entry entry2 = entry1.clone();
@@ -1351,7 +1351,7 @@
@Test
public void testContainsAttributeTypeByteArrayArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertFalse( entry.contains( (AttributeType )null, BYTES1 ) );
assertFalse( entry.contains( atPwd, BYTES1 ) );
@@ -1374,7 +1374,7 @@
@Test
public void testContainsAttributeTypeStringArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertFalse( entry.contains( (AttributeType )null, "test" ) );
assertFalse( entry.contains( atCN, "test" ) );
@@ -1397,7 +1397,7 @@
@Test
public void testContainsAttributeTypeValuesArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
Value<String> strValue1 = new ServerStringValue( atCN, "test1" );
Value<String> strValue2 = new ServerStringValue( atCN, "test2" );
@@ -1432,7 +1432,7 @@
@Test
public void testContainsEntryAttributeArray() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
EntryAttribute attrOC = new DefaultServerAttribute( atOC, "top", "person" );
EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", "test2" );
@@ -1462,7 +1462,7 @@
@Test
public void testContainsStringByteArrayArray() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertFalse( entry.contains( (String)null, BYTES3 ) );
assertFalse( entry.containsAttribute( "objectClass" ) );
@@ -1486,7 +1486,7 @@
@Test
public void testContainsStringStringArray() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertFalse( entry.contains( (String)null, "test" ) );
assertFalse( entry.containsAttribute( "objectClass" ) );
@@ -1510,7 +1510,7 @@
@Test
public void testContainsStringValueArray() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertFalse( entry.contains( (String)null, "test" ) );
assertFalse( entry.containsAttribute( "objectClass" ) );
@@ -1545,7 +1545,7 @@
@Test
public void testContainsAttributeAttributeType() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertFalse( entry.containsAttribute( atOC ) );
@@ -1576,7 +1576,7 @@
@Test
public void testContainsAttributeString() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertFalse( entry.containsAttribute( "objectClass" ) );
@@ -1605,8 +1605,8 @@
@Test
public void testEqualsObject() throws Exception
{
- Entry entry1 = new DefaultServerEntry( registries );
- Entry entry2 = new DefaultServerEntry( registries );
+ Entry entry1 = new DefaultServerEntry( schemaManager );
+ Entry entry2 = new DefaultServerEntry( schemaManager );
assertEquals( entry1, entry2 );
@@ -1653,7 +1653,7 @@
@Test
public void testGetAttributeTypes() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertEquals( 0, entry.getAttributeTypes().size() );
@@ -1681,7 +1681,7 @@
@Test
public void testGetAttributeType() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertNull( entry.get( atCN ) );
assertNull( entry.get( (AttributeType)null ) );
@@ -1708,7 +1708,7 @@
@Test
public void testGetString() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertNull( entry.get( "cn" ) );
assertNull( entry.get( "badId" ) );
@@ -1737,7 +1737,7 @@
@Test
public void testGetDn() throws InvalidNameException
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertEquals( EXAMPLE_DN, entry.getDn() );
@@ -1754,8 +1754,8 @@
@Test
public void testHashCode() throws InvalidNameException, Exception
{
- Entry entry1 = new DefaultServerEntry( registries, EXAMPLE_DN );
- Entry entry2 = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry1 = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
+ Entry entry2 = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertEquals( entry1.hashCode(), entry2.hashCode() );
@@ -1776,7 +1776,7 @@
assertEquals( entry1.hashCode(), entry2.hashCode() );
- Entry entry3 = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry3 = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
entry3.add( attrOC, attrSN, attrCN, attrPWD );
assertEquals( entry1.hashCode(), entry3.hashCode() );
@@ -1789,7 +1789,7 @@
@Test
public void testHasObjectClassEntryAttribute() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
EntryAttribute attrOC = new DefaultServerAttribute( atOC, "top", "person" );
@@ -1818,7 +1818,7 @@
@Test
public void testHasObjectClassString() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertFalse( entry.containsAttribute( "objectClass" ) );
assertFalse( entry.hasObjectClass( "top" ) );
@@ -1872,7 +1872,7 @@
@Test
public void testIterator() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
EntryAttribute attrOC = new DefaultServerAttribute( atOC, "top", "person" );
EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", "test2" );
@@ -1913,7 +1913,7 @@
@Test
public void testPutAttributeTypeByteArrayArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
try
{
@@ -1954,7 +1954,7 @@
@Test
public void testPutAttributeTypeStringArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
try
{
@@ -1995,7 +1995,7 @@
@Test
public void testPutAttributeTypeValueArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
Value<String> strValue1 = new ServerStringValue( atCN, "test1" );
Value<String> strValue2 = new ServerStringValue( atCN, "test2" );
@@ -2043,7 +2043,7 @@
@Test
public void testPutEntryAttribute() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
EntryAttribute oc = new DefaultServerAttribute( atObjectClass, "top", "person" );
EntryAttribute cn = new DefaultServerAttribute( atCN, "test1", "test2" );
@@ -2093,7 +2093,7 @@
@Test
public void testPutStringAttributeTypeByteArrayArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
try
{
@@ -2168,7 +2168,7 @@
@Test
public void testPutStringAttributeTypeStringArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
try
{
@@ -2242,7 +2242,7 @@
@Test
public void testPutStringAttributeTypeValueArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
Value<String> strValue1 = new ServerStringValue( atCN, "test1" );
Value<String> strValue2 = new ServerStringValue( atCN, "test2" );
@@ -2323,7 +2323,7 @@
@Test
public void testPutStringByteArrayArray()
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
try
{
@@ -2391,7 +2391,7 @@
@Test
public void testPutStringStringArray()
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
try
{
@@ -2461,7 +2461,7 @@
@Test
public void testPutStringValueArray()
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
Value<String> strValue1 = new ServerStringValue( atCN, "test1" );
Value<String> strValue2 = new ServerStringValue( atCN, "test2" );
@@ -2542,7 +2542,7 @@
@Test public void tesPutServerAttributeElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
// first test a null SA addition. It should be allowed.
try
@@ -2556,9 +2556,9 @@
}
// Adding some serverAttributes
- //AttributeType atCo = registries.getAttributeTypeRegistry().lookup( "countryName" );
- AttributeType atGN = registries.getAttributeTypeRegistry().lookup( "givenname" );
- AttributeType atStreet = registries.getAttributeTypeRegistry().lookup( "2.5.4.9" );
+ //AttributeType atCo = registries.lookupAttributeTypeRegistry( "countryName" );
+ AttributeType atGN = schemaManager.lookupAttributeTypeRegistry( "givenname" );
+ AttributeType atStreet = schemaManager.lookupAttributeTypeRegistry( "2.5.4.9" );
ServerAttribute sa = new DefaultServerAttribute( atL, "france" );
entry.put( sa );
@@ -2597,7 +2597,7 @@
assertEquals( "testStreet", entry.get( atStreet ).get().getString() );
// test an ObjectClass replacement
- AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
+ AttributeType OBJECT_CLASS_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT );
ServerAttribute oc = new DefaultServerAttribute( "OBJECTCLASS", OBJECT_CLASS_AT, "person", "inetorgperson" );
List<EntryAttribute> oldOc = entry.put( oc );
@@ -2622,7 +2622,7 @@
@Test public void tesPutAtStringElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
// Test an empty AT
entry.put( atCN, (String)null );
@@ -2642,7 +2642,7 @@
}
// Add a single value
- atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
+ atCN = schemaManager.lookupAttributeTypeRegistry( "cn" );
entry.put( atCN, "test" );
assertEquals( 1, entry.size() );
@@ -2679,7 +2679,7 @@
@Test public void tesPutAtByteElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
// Test an empty AT
entry.put( atPwd, (byte[])null );
@@ -2704,7 +2704,7 @@
byte[] test3 = StringTools.getBytesUtf8( "test3" );
// Add a single value
- atPwd = registries.getAttributeTypeRegistry().lookup( "userPassword" );
+ atPwd = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
entry.put( atPwd, password );
assertEquals( 1, entry.size() );
@@ -2741,7 +2741,7 @@
@Test public void tesPutAtSVs() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
// Adding a null value to an attribute
entry.put( atCN, (Value<?>)null );
@@ -2761,7 +2761,7 @@
}
// Add a single value
- atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
+ atCN = schemaManager.lookupAttributeTypeRegistry( "cn" );
Value<?> ssv = new ServerStringValue( atCN, "test" );
entry.put( atCN, ssv );
@@ -2803,7 +2803,7 @@
@Test public void tesPutUpIdStringElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
// Adding a null value should be possible
entry.put( "cn", (String)null );
@@ -2824,7 +2824,7 @@
}
// Add a single value
- atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
+ atCN = schemaManager.lookupAttributeTypeRegistry( "cn" );
entry.put( "cn", "test" );
assertEquals( 1, entry.size() );
@@ -2865,9 +2865,9 @@
@Test public void tesPutUpIdBytesElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
+ AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
// Adding a null value should be possible
entry.put( "userPassword", (byte[])null );
@@ -2928,7 +2928,7 @@
@Test public void tesPutUpIDAtStringElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
// Test that we get an error when the ID or AT are null
try
@@ -2991,9 +2991,9 @@
@Test public void tesPutUpIDAtBytesElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
+ AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
// Test that we get an error when the ID or AT are null
try
@@ -3074,7 +3074,7 @@
@Test public void tesPutUpIDAtSVElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
// Test that we get an error when the ID or AT are null
try
@@ -3152,7 +3152,7 @@
@Test public void tesPutUpIDSVElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
// Test that we get an error when the ID or AT are null
try
@@ -3198,7 +3198,7 @@
@Test
public void testRemoveAttributeTypeByteArrayArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
EntryAttribute attrPWD = new DefaultServerAttribute( atPwd, BYTES1, (byte[])null, BYTES2 );
@@ -3227,7 +3227,7 @@
@Test
public void testRemoveAttributeTypeStringArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", (String)null, "test2" );
@@ -3256,7 +3256,7 @@
@Test
public void testRemoveAttributeTypeValueArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
Value<String> strValue1 = new ServerStringValue( atCN, "test1" );
Value<String> strValue2 = new ServerStringValue( atCN, "test2" );
@@ -3292,7 +3292,7 @@
@Test
public void testRemoveEntryAttribute() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
EntryAttribute attrOC = new DefaultServerAttribute( atOC, "top", "person" );
EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", "test2" );
@@ -3324,7 +3324,7 @@
@Test
public void testRemoveAttributesAttributeTypeArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
EntryAttribute attrOC = new DefaultServerAttribute( atOC, "top", "person" );
EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", "test2" );
@@ -3352,7 +3352,7 @@
@Test
public void testRemoveAttributesStringArray() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
EntryAttribute attrOC = new DefaultServerAttribute( atOC, "top", "person" );
EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", "test2" );
@@ -3383,7 +3383,7 @@
@Test
public void testRemoveStringByteArrayArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
EntryAttribute attrPWD = new DefaultServerAttribute( atPwd, BYTES1, (byte[])null, BYTES2 );
@@ -3416,7 +3416,7 @@
@Test
public void testRemoveStringStringArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", (String)null, "test2" );
@@ -3449,7 +3449,7 @@
@Test
public void testRemoveStringValueArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
Value<String> strValue1 = new ServerStringValue( atCN, "test1" );
Value<String> strValue2 = new ServerStringValue( atCN, "test2" );
@@ -3485,9 +3485,9 @@
@Test public void testRemoveUpIdElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- AttributeType atPassword = registries.getAttributeTypeRegistry().lookup( "userPassword" );
+ AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
byte[] b1 = StringTools.getBytesUtf8( "test1" );
byte[] b2 = StringTools.getBytesUtf8( "test2" );
@@ -3517,7 +3517,7 @@
assertNotNull( entry.get( atCN ) );
assertNotNull( entry.get( atPassword ) );
- AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
+ AttributeType OBJECT_CLASS_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT );
entry.removeAttributes( "cN", "UsErPaSsWoRd" );
assertEquals( 0, entry.size() );
@@ -3544,7 +3544,7 @@
@Test public void testSetATElipsis() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- ServerEntry entry = new DefaultServerEntry( registries, dn );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
List<EntryAttribute> result = null;
@@ -3562,8 +3562,8 @@
assertEquals( "sn", ((ServerAttribute)sa).getAttributeType().getName() );
// Add two AT now
- AttributeType atGN = registries.getAttributeTypeRegistry().lookup( "givenname" );
- AttributeType atStreet = registries.getAttributeTypeRegistry().lookup( "2.5.4.9" );
+ AttributeType atGN = schemaManager.lookupAttributeTypeRegistry( "givenname" );
+ AttributeType atStreet = schemaManager.lookupAttributeTypeRegistry( "2.5.4.9" );
result = entry.set( atL, atC, atGN, atStreet );
assertNull( result );
@@ -3597,14 +3597,14 @@
assertEquals( "test", entry.get( "sn" ).get().getString() );
// Now add a new SN empty AT : it should replace the existing one.
- AttributeType atSNEmpty = registries.getAttributeTypeRegistry().lookup( "sn" );
+ AttributeType atSNEmpty = schemaManager.lookupAttributeTypeRegistry( "sn" );
sa = entry.set( atSNEmpty ).get( 0 );
assertEquals( "test", sa.get().getString() );
assertNotNull( entry.get( "sn" ) );
assertNull( entry.get( "sn" ).get() );
// Last, not least, put an ObjectClass AT
- AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
+ AttributeType OBJECT_CLASS_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT );
entry.set( OBJECT_CLASS_AT );
@@ -3623,7 +3623,7 @@
@Test public void testSetUpID() throws Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
// First check that this method fails if we pass a null or empty ID
List<EntryAttribute> result = entry.set( (String)null );
@@ -3646,8 +3646,8 @@
assertEquals( "sn", sa.getId() );
// Add different upIds now
- AttributeType atGN = registries.getAttributeTypeRegistry().lookup( "givenname" );
- AttributeType atStreet = registries.getAttributeTypeRegistry().lookup( "2.5.4.9" );
+ AttributeType atGN = schemaManager.lookupAttributeTypeRegistry( "givenname" );
+ AttributeType atStreet = schemaManager.lookupAttributeTypeRegistry( "2.5.4.9" );
entry.set( "L" );
entry.set( "CountryName" );
@@ -3688,7 +3688,7 @@
assertEquals( "test", entry.get( "sn" ).get().getString() );
// Now add a new SN empty AT : it should replace the existing one.
- AttributeType atSNEmpty = registries.getAttributeTypeRegistry().lookup( "sn" );
+ AttributeType atSNEmpty = schemaManager.lookupAttributeTypeRegistry( "sn" );
sa = entry.set( atSNEmpty ).get( 0 );
assertEquals( "test", sa.get().getString() );
assertNotNull( entry.get( "sn" ) );
@@ -3702,7 +3702,7 @@
@Test
public void testSetAttributeTypeArray() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
entry.add( "ObjectClass", "top", "person" );
entry.add( "cn", "test1", "test2" );
@@ -3732,7 +3732,7 @@
@Test
public void testSetStringArray() throws Exception
{
- Entry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
entry.add( "ObjectClass", "top", "person" );
entry.add( "cn", "test1", "test2" );
@@ -3762,7 +3762,7 @@
@Test
public void testSetDn()
{
- Entry entry = new DefaultServerEntry( registries );
+ Entry entry = new DefaultServerEntry( schemaManager );
assertEquals( LdapDN.EMPTY_LDAPDN, entry.getDn() );
@@ -3777,12 +3777,12 @@
@Test
public void testSize() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertEquals( 0, entry.size() );
- entry.add( "ObjectClass", atr.lookup( "ObjectClass" ), "top", "person" );
- entry.add( "CN", atr.lookup( "Cn" ), "test" );
- entry.add( "SN", atr.lookup( "Sn" ), "Test" );
+ entry.add( "ObjectClass", schemaManager.lookupAttributeTypeRegistry( "ObjectClass" ), "top", "person" );
+ entry.add( "CN", schemaManager.lookupAttributeTypeRegistry( "Cn" ), "test" );
+ entry.add( "SN", schemaManager.lookupAttributeTypeRegistry( "Sn" ), "Test" );
assertEquals( 3, entry.size() );
@@ -3797,12 +3797,12 @@
@Test public void testToBasicAttributes() throws InvalidNameException, Exception
{
LdapDN dn = new LdapDN( "cn=test" );
- DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
+ AttributeType OBJECT_CLASS_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT );
entry.put( "objectClass", OBJECT_CLASS_AT, "top", "person", "inetOrgPerson", "organizationalPerson" );
- entry.put( "cn", registries.getAttributeTypeRegistry().lookup( "cn" ), "test" );
+ entry.put( "cn", schemaManager.lookupAttributeTypeRegistry( "cn" ), "test" );
Attributes attributes = ServerEntryUtils.toBasicAttributes( entry );
@@ -3833,7 +3833,7 @@
@Test
public void testToString() throws Exception
{
- ServerEntry entry = new DefaultServerEntry( registries, EXAMPLE_DN );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
assertEquals( "ServerEntry\n dn[]: dc=example,dc=com\n", entry.toString() );
@@ -3869,11 +3869,11 @@
@Test
public void testCopyConstructorServerEntry() throws NamingException
{
- Entry serverEntry = new DefaultServerEntry( registries );
+ Entry serverEntry = new DefaultServerEntry( schemaManager );
serverEntry.add( "cn", "test1", "test2" );
serverEntry.add( "objectClass", "top", "person" );
- Entry copyEntry = new DefaultServerEntry( registries, serverEntry );
+ Entry copyEntry = new DefaultServerEntry( schemaManager, serverEntry );
assertEquals( copyEntry, serverEntry );
assertTrue( copyEntry.contains( "objectClass", "top", "person" ) );
@@ -3898,7 +3898,7 @@
clientEntry.add( "cn", "test1", "test2" );
clientEntry.add( "objectClass", "top", "person" );
- Entry copyEntry = new DefaultServerEntry( registries, clientEntry );
+ Entry copyEntry = new DefaultServerEntry( schemaManager, clientEntry );
assertTrue( copyEntry instanceof ServerEntry );
assertTrue( copyEntry.contains( "objectClass", "top", "person" ) );
@@ -3918,7 +3918,7 @@
public void testToClientEntry() throws NamingException
{
LdapDN dn = new LdapDN( "ou=system" );
- ServerEntry serverEntry = new DefaultServerEntry( registries );
+ ServerEntry serverEntry = new DefaultServerEntry( schemaManager );
serverEntry.setDn( dn );
serverEntry.add( "cn", "test1", "test2" );
serverEntry.add( "objectClass", "top", "person" );
Modified: directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java (original)
+++ directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java Wed Jan 6 18:26:43 2010
@@ -20,6 +20,13 @@
package org.apache.directory.server.core.entry;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -32,18 +39,12 @@
import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.LdapSyntax;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
import org.apache.directory.shared.ldap.schema.Normalizer;
import org.apache.directory.shared.ldap.schema.comparators.ByteArrayComparator;
-import org.apache.directory.shared.ldap.schema.syntaxes.AcceptAllSyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.OctetStringSyntaxChecker;
import org.apache.directory.shared.ldap.util.StringTools;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
import org.junit.Before;
import org.junit.Test;
@@ -63,9 +64,9 @@
*/
public class ServerBinaryValueTest
{
- private TestServerEntryUtils.S s;
- private TestServerEntryUtils.AT at;
- private TestServerEntryUtils.MR mr;
+ private LdapSyntax s;
+ private AttributeType at;
+ private MatchingRule mr;
private static final byte[] BYTES1 = new byte[]{0x01, 0x02, 0x03, 0x04};
private static final byte[] BYTES2 = new byte[]{(byte)0x81, (byte)0x82, (byte)0x83, (byte)0x84};
@@ -76,12 +77,13 @@
*/
@Before public void initAT()
{
- s = new TestServerEntryUtils.S( "1.1.1.1", false );
- s.setSyntaxChecker( new AcceptAllSyntaxChecker( "1.1.1.1" ) );
- mr = new TestServerEntryUtils.MR( "1.1.2.1" );
- mr.syntax = s;
- mr.comparator = new ByteArrayComparator();
- mr.normalizer = new Normalizer()
+ s = TestServerEntryUtils.syntaxFactory( "1.1.1.1", false );
+ s.setSyntaxChecker( new OctetStringSyntaxChecker() );
+ mr = TestServerEntryUtils.matchingRuleFactory( "1.1.2.1" );
+ mr.setSyntax( s );
+
+ mr.setLdapComparator( new ByteArrayComparator( "1.1.1" ) );
+ mr.setNormalizer( new Normalizer( "1.1.1" )
{
private static final long serialVersionUID = 1L;
@@ -110,11 +112,12 @@
{
throw new IllegalStateException( "expected byte[] to normalize" );
}
- };
- at = new TestServerEntryUtils.AT( "1.1.3.1" );
+ });
+
+ at = new AttributeType( "1.1.3.1" );
at.setEquality( mr );
at.setOrdering( mr );
- at.setSubstr( mr );
+ at.setSubstring( mr );
at.setSyntax( s );
}
@@ -210,7 +213,7 @@
}
// create a AT without any syntax
- AttributeType attribute = new TestServerEntryUtils.AT( "1.1.3.1" );
+ AttributeType attribute = new AttributeType( "1.1.3.1" );
try
{
Modified: directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java (original)
+++ directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java Wed Jan 6 18:26:43 2010
@@ -20,30 +20,26 @@
package org.apache.directory.server.core.entry;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.File;
import java.util.HashMap;
-import java.util.HashSet;
+import java.util.List;
import java.util.Map;
-import java.util.Set;
-import org.apache.directory.server.schema.bootstrap.ApacheSchema;
-import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
-import org.apache.directory.server.schema.bootstrap.CoreSchema;
-import org.apache.directory.server.schema.bootstrap.CosineSchema;
-import org.apache.directory.server.schema.bootstrap.InetorgpersonSchema;
-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.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
import org.apache.directory.shared.ldap.schema.normalizers.DeepTrimToLowerNormalizer;
import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
import org.apache.directory.shared.ldap.util.StringTools;
-
-import static org.junit.Assert.assertEquals;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -56,9 +52,8 @@
*/
public class ServerEntrySerializerTest
{
- private static BootstrapSchemaLoader loader;
- private static Registries registries;
- private static OidRegistry oidRegistry;
+ private static LdifSchemaLoader loader;
+ private static SchemaManager schemaManager;
private static Map<String, OidNormalizer> oids;
private static Map<String, OidNormalizer> oidOids;
@@ -68,49 +63,67 @@
@BeforeClass
public static void setup() throws Exception
{
- loader = new BootstrapSchemaLoader();
- oidRegistry = new DefaultOidRegistry();
- registries = new DefaultRegistries( "bootstrap", loader, oidRegistry );
-
- // load essential bootstrap schemas
- Set<Schema> bootstrapSchemas = new HashSet<Schema>();
- bootstrapSchemas.add( new ApachemetaSchema() );
- bootstrapSchemas.add( new ApacheSchema() );
- bootstrapSchemas.add( new CoreSchema() );
- bootstrapSchemas.add( new SystemSchema() );
- bootstrapSchemas.add( new InetorgpersonSchema() );
- bootstrapSchemas.add( new CosineSchema() );
- loader.loadWithDependencies( bootstrapSchemas, registries );
+ String workingDirectory = System.getProperty( "workingDirectory" );
+
+ if ( workingDirectory == null )
+ {
+ String path = ServerEntrySerializerTest.class.getResource( "" ).getPath();
+ int targetPos = path.indexOf( "target" );
+ workingDirectory = path.substring( 0, targetPos + 6 );
+ }
+
+ File schemaRepository = new File( workingDirectory, "schema" );
+ SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
+ extractor.extractOrCopy( true );
+ loader = new LdifSchemaLoader( schemaRepository );
+
+ schemaManager = new DefaultSchemaManager( loader );
+ schemaManager.loadAllEnabled();
+
+ List<Throwable> errors = schemaManager.getErrors();
+
+ if ( errors.size() != 0 )
+ {
+ fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+ }
oids = new HashMap<String, OidNormalizer>();
- oids.put( "dc", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
- oids.put( "domaincomponent", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
- oids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
- oids.put( "ou", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
- oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
- oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-
+ // DC normalizer
+ OidNormalizer dcOidNormalizer = new OidNormalizer( "dc",
+ new DeepTrimToLowerNormalizer( SchemaConstants.DOMAIN_COMPONENT_AT_OID ) );
+
+ oids.put( "dc", dcOidNormalizer );
+ oids.put( "domaincomponent", dcOidNormalizer );
+ oids.put( "0.9.2342.19200300.100.1.25", dcOidNormalizer );
+
+ // OU normalizer
+ OidNormalizer ouOidNormalizer = new OidNormalizer( "ou",
+ new DeepTrimToLowerNormalizer( SchemaConstants.OU_AT_OID ) );
+
+ oids.put( "ou", ouOidNormalizer );
+ oids.put( "organizationalUnitName",ouOidNormalizer );
+ oids.put( "2.5.4.11", ouOidNormalizer );
// Another map where we store OIDs instead of names.
oidOids = new HashMap<String, OidNormalizer>();
- oidOids.put( "dc", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
- oidOids.put( "domaincomponent", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
- oidOids.put( "0.9.2342.19200300.100.1.25",
- new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
- oidOids.put( "ou", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
- oidOids.put( "organizationalUnitName", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
- oidOids.put( "2.5.4.11", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
+ oidOids.put( "dc", dcOidNormalizer );
+ oidOids.put( "domaincomponent", dcOidNormalizer );
+ oidOids.put( "0.9.2342.19200300.100.1.25", dcOidNormalizer );
+
+ oidOids.put( "ou", ouOidNormalizer );
+ oidOids.put( "organizationalUnitName",ouOidNormalizer );
+ oidOids.put( "2.5.4.11", ouOidNormalizer );
}
@Test public void testSerializeEmtpyServerEntry() throws Exception
{
LdapDN dn = LdapDN.EMPTY_LDAPDN;
- ServerEntry entry = new DefaultServerEntry( registries, dn );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- ServerEntrySerializer ses = new ServerEntrySerializer( registries );
+ ServerEntrySerializer ses = new ServerEntrySerializer( schemaManager );
byte[] data = ses.serialize( entry );
@@ -125,9 +138,9 @@
LdapDN dn = new LdapDN( "cn=text, dc=example, dc=com" );
dn.normalize( oids );
- ServerEntry entry = new DefaultServerEntry( registries, dn );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- ServerEntrySerializer ses = new ServerEntrySerializer( registries );
+ ServerEntrySerializer ses = new ServerEntrySerializer( schemaManager );
byte[] data = ses.serialize( entry );
@@ -142,10 +155,10 @@
LdapDN dn = new LdapDN( "cn=text, dc=example, dc=com" );
dn.normalize( oids );
- ServerEntry entry = new DefaultServerEntry( registries, dn );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
entry.add( "objectClass", "top", "person", "inetOrgPerson", "organizationalPerson" );
- ServerEntrySerializer ses = new ServerEntrySerializer( registries );
+ ServerEntrySerializer ses = new ServerEntrySerializer( schemaManager );
byte[] data = ses.serialize( entry );
@@ -160,13 +173,13 @@
LdapDN dn = new LdapDN( "cn=text, dc=example, dc=com" );
dn.normalize( oids );
- ServerEntry entry = new DefaultServerEntry( registries, dn );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
entry.add( "objectClass", "top", "person", "inetOrgPerson", "organizationalPerson" );
entry.add( "cn", "text", "test" );
entry.add( "SN", (String)null );
entry.add( "userPassword", StringTools.getBytesUtf8( "password" ) );
- ServerEntrySerializer ses = new ServerEntrySerializer( registries );
+ ServerEntrySerializer ses = new ServerEntrySerializer( schemaManager );
byte[] data = ses.serialize( entry );
@@ -181,13 +194,13 @@
LdapDN dn = new LdapDN( "" );
dn.normalize( oids );
- ServerEntry entry = new DefaultServerEntry( registries, dn );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
entry.add( "objectClass", "top", "person", "inetOrgPerson", "organizationalPerson" );
entry.add( "cn", "text", "test" );
entry.add( "SN", (String)null );
entry.add( "userPassword", StringTools.getBytesUtf8( "password" ) );
- ServerEntrySerializer ses = new ServerEntrySerializer( registries );
+ ServerEntrySerializer ses = new ServerEntrySerializer( schemaManager );
byte[] data = ses.serialize( entry );
@@ -202,9 +215,9 @@
LdapDN dn = new LdapDN( "" );
dn.normalize( oids );
- ServerEntry entry = new DefaultServerEntry( registries, dn );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- ServerEntrySerializer ses = new ServerEntrySerializer( registries );
+ ServerEntrySerializer ses = new ServerEntrySerializer( schemaManager );
byte[] data = ses.serialize( entry );
@@ -219,10 +232,10 @@
LdapDN dn = new LdapDN( "" );
dn.normalize( oids );
- ServerEntry entry = new DefaultServerEntry( registries, dn );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- ServerEntrySerializer ses = new ServerEntrySerializer( registries );
- EntryAttribute oc = new DefaultServerAttribute( "ObjectClass", registries.getAttributeTypeRegistry().lookup( "objectclass" ) );
+ ServerEntrySerializer ses = new ServerEntrySerializer( schemaManager );
+ EntryAttribute oc = new DefaultServerAttribute( "ObjectClass", schemaManager.lookupAttributeTypeRegistry( "objectclass" ) );
entry.add( oc );
byte[] data = ses.serialize( entry );
@@ -238,9 +251,9 @@
LdapDN dn = new LdapDN( "" );
dn.normalize( oids );
- ServerEntry entry = new DefaultServerEntry( registries, dn );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- ServerEntrySerializer ses = new ServerEntrySerializer( registries );
+ ServerEntrySerializer ses = new ServerEntrySerializer( schemaManager );
entry.add( "ObjectClass", "top", "person" );
byte[] data = ses.serialize( entry );
@@ -256,9 +269,9 @@
LdapDN dn = new LdapDN( "" );
dn.normalize( oids );
- ServerEntry entry = new DefaultServerEntry( registries, dn );
+ ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
- ServerEntrySerializer ses = new ServerEntrySerializer( registries );
+ ServerEntrySerializer ses = new ServerEntrySerializer( schemaManager );
entry.add( "userPassword", StringTools.getBytesUtf8( "secret" ) );
byte[] data = ses.serialize( entry );
Modified: directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java (original)
+++ directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java Wed Jan 6 18:26:43 2010
@@ -19,28 +19,23 @@
*/
package org.apache.directory.server.core.entry;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.List;
import javax.naming.NamingException;
-import org.apache.directory.server.schema.bootstrap.ApacheSchema;
-import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
-import org.apache.directory.server.schema.bootstrap.CoreSchema;
-import org.apache.directory.server.schema.bootstrap.CosineSchema;
-import org.apache.directory.server.schema.bootstrap.InetorgpersonSchema;
-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.entry.EntryAttribute;
import org.apache.directory.shared.ldap.entry.Modification;
import org.apache.directory.shared.ldap.entry.ModificationOperation;
@@ -48,13 +43,12 @@
import org.apache.directory.shared.ldap.entry.client.ClientModification;
import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
import org.apache.directory.shared.ldap.schema.AttributeType;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
-
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -67,9 +61,8 @@
*/
public class ServerModificationTest
{
- private static BootstrapSchemaLoader loader;
- private static Registries registries;
- private static OidRegistry oidRegistry;
+ private static LdifSchemaLoader loader;
+ private static SchemaManager schemaManager;
private static AttributeType atCN;
// A SINGLE-VALUE attribute
@@ -127,7 +120,7 @@
oIn = new ObjectInputStream( in );
ServerModification value = new ServerModification();
- value.deserialize( oIn, registries.getAttributeTypeRegistry() );
+ value.deserialize( oIn, schemaManager );
return value;
}
@@ -158,22 +151,32 @@
@BeforeClass
public static void setup() throws Exception
{
- loader = new BootstrapSchemaLoader();
- oidRegistry = new DefaultOidRegistry();
- registries = new DefaultRegistries( "bootstrap", loader, oidRegistry );
-
- // load essential bootstrap schemas
- Set<Schema> bootstrapSchemas = new HashSet<Schema>();
- bootstrapSchemas.add( new ApachemetaSchema() );
- bootstrapSchemas.add( new ApacheSchema() );
- bootstrapSchemas.add( new CoreSchema() );
- bootstrapSchemas.add( new SystemSchema() );
- bootstrapSchemas.add( new InetorgpersonSchema() );
- bootstrapSchemas.add( new CosineSchema() );
- loader.loadWithDependencies( bootstrapSchemas, registries );
+ String workingDirectory = System.getProperty( "workingDirectory" );
+
+ if ( workingDirectory == null )
+ {
+ String path = ServerModificationTest.class.getResource( "" ).getPath();
+ int targetPos = path.indexOf( "target" );
+ workingDirectory = path.substring( 0, targetPos + 6 );
+ }
+
+ File schemaRepository = new File( workingDirectory, "schema" );
+ SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
+ extractor.extractOrCopy( true );
+ loader = new LdifSchemaLoader( schemaRepository );
- atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
- atC = registries.getAttributeTypeRegistry().lookup( "c" );
+ schemaManager = new DefaultSchemaManager( loader );
+ schemaManager.loadAllEnabled();
+
+ List<Throwable> errors = schemaManager.getErrors();
+
+ if ( errors.size() != 0 )
+ {
+ fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+ }
+
+ atCN = schemaManager.lookupAttributeTypeRegistry( "cn" );
+ atC = schemaManager.lookupAttributeTypeRegistry( "c" );
}
@@ -209,7 +212,7 @@
attribute.add( "test1", "test2" );
Modification serverModification = new ServerModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
- Modification copy = new ServerModification( registries, serverModification );
+ Modification copy = new ServerModification( schemaManager, serverModification );
assertTrue( copy instanceof ServerModification );
assertEquals( copy, serverModification );
@@ -234,7 +237,7 @@
attribute.add( "test1", "test2" );
Modification clientModification = new ClientModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
- Modification copy = new ServerModification( registries, clientModification );
+ Modification copy = new ServerModification( schemaManager, clientModification );
assertTrue( copy instanceof ServerModification );
assertFalse( copy instanceof ClientModification );
Modified: directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java (original)
+++ directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java Wed Jan 6 18:26:43 2010
@@ -20,6 +20,13 @@
package org.apache.directory.server.core.entry;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -32,27 +39,18 @@
import java.util.List;
import javax.naming.NamingException;
-import javax.naming.directory.InvalidAttributeValueException;
import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.LdapComparator;
import org.apache.directory.shared.ldap.schema.SyntaxChecker;
+import org.apache.directory.shared.ldap.schema.comparators.StringComparator;
import org.apache.directory.shared.ldap.schema.normalizers.DeepTrimToLowerNormalizer;
import org.apache.directory.shared.ldap.schema.normalizers.NoOpNormalizer;
-import org.apache.directory.shared.ldap.schema.syntaxes.AcceptAllSyntaxChecker;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
+import org.apache.directory.shared.ldap.schema.syntaxCheckers.OctetStringSyntaxChecker;
import org.junit.Before;
import org.junit.Test;
-import jdbm.helper.StringComparator;
-
/**
* Tests that the ServerStringValue class works properly as expected.
@@ -81,15 +79,15 @@
@Before public void initAT()
{
s = new TestServerEntryUtils.S( "1.1.1.1", false );
- s.setSyntaxChecker( new AcceptAllSyntaxChecker( "1.1.1.1" ) );
+ s.setSyntaxChecker( new OctetStringSyntaxChecker() );
mr = new TestServerEntryUtils.MR( "1.1.2.1" );
- mr.syntax = s;
- mr.comparator = new StringComparator();
- mr.normalizer = new DeepTrimToLowerNormalizer();
+ mr.setSyntax( s );
+ mr.setLdapComparator( new StringComparator( "1.1.2.1" ) );
+ mr.setNormalizer( new DeepTrimToLowerNormalizer( "1.1.2.1" ) );
at = new TestServerEntryUtils.AT( "1.1.3.1" );
at.setEquality( mr );
at.setOrdering( mr );
- at.setSubstr( mr );
+ at.setSubstring( mr );
at.setSyntax( s );
}
@@ -443,8 +441,9 @@
*/
@Test public void testConstrainedString()
{
- s.setSyntaxChecker( new SyntaxChecker() {
- public String getSyntaxOid() { return "1.1.1.1"; }
+ s.setSyntaxChecker( new SyntaxChecker( "1.1.1.1" ) {
+ private static final long serialVersionUID = 0L;
+
public boolean isValidSyntax( Object value )
{
if ( value instanceof String )
@@ -454,13 +453,13 @@
}
return false;
}
- public void assertSyntax( Object value ) throws NamingException
- { if ( ! isValidSyntax( value ) ) {throw new InvalidAttributeValueException(); }}
});
- mr.syntax = s;
- mr.comparator = new Comparator<String>()
+ mr.setSyntax( s );
+ mr.setLdapComparator( new LdapComparator<String>( mr.getOid() )
{
+ private static final long serialVersionUID = 0L;
+
public int compare( String o1, String o2 )
{
if ( o1 == null )
@@ -496,8 +495,9 @@
if ( val.equals( "HIGH" ) ) { return 2; }
throw new IllegalArgumentException( "Not a valid value" );
}
- };
- mr.normalizer = new NoOpNormalizer();
+ } );
+
+ mr.setNormalizer( new NoOpNormalizer( mr.getOid() ) );
at.setEquality( mr );
at.setSyntax( s );
@@ -655,14 +655,7 @@
return 1;
}
- try
- {
- return mr.getComparator().compare( n1, n2 );
- }
- catch ( NamingException ne )
- {
- throw new IllegalStateException( "Normalization and comparison should succeed!", ne );
- }
+ return mr.getLdapComparator().compare( n1, n2 );
}
};
Modified: directory/apacheds/trunk/core-integ/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/pom.xml?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/pom.xml (original)
+++ directory/apacheds/trunk/core-integ/pom.xml Wed Jan 6 18:26:43 2010
@@ -54,17 +54,34 @@
<dependency>
<groupId>org.apache.directory.server</groupId>
- <artifactId>apacheds-schema-extras</artifactId>
+ <artifactId>apacheds-jdbm-partition</artifactId>
<version>${pom.version}</version>
- <scope>test</scope>
+ <!--scope>test</scope-->
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
- <artifactId>apacheds-bootstrap-partition</artifactId>
+ <artifactId>apacheds-avl-partition</artifactId>
<version>${pom.version}</version>
- <scope>test</scope>
- </dependency>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-ldif-partition</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-test-framework</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-avl-partition</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
</dependencies>
<profiles>
Modified: directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java (original)
+++ directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java Wed Jan 6 18:26:43 2010
@@ -22,7 +22,6 @@
import java.io.File;
import java.io.IOException;
import java.util.List;
-import java.util.Map;
import javax.naming.InvalidNameException;
import javax.naming.NamingException;
@@ -34,10 +33,13 @@
import org.apache.commons.io.FileUtils;
import org.apache.directory.server.constants.ServerDNConstants;
+import org.apache.directory.server.core.CoreSession;
import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.server.core.LdapPrincipal;
import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.jndi.ServerLdapContext;
import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
import org.apache.directory.shared.ldap.ldif.ChangeType;
@@ -45,13 +47,10 @@
import org.apache.directory.shared.ldap.ldif.LdifReader;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.registries.Schema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.directory.server.core.CoreSession;
-import org.apache.directory.server.core.jndi.ServerLdapContext;
-import org.apache.directory.server.schema.bootstrap.Schema;
-
/**
* Integration test utility methods.
@@ -109,7 +108,7 @@
if ( entry.isChangeAdd() )
{
service.getAdminSession().add(
- new DefaultServerEntry( service.getRegistries(), entry.getEntry() ) );
+ new DefaultServerEntry( service.getSchemaManager(), entry.getEntry() ) );
}
else if ( entry.isChangeModify() )
{
@@ -124,6 +123,9 @@
throw new NamingException( message );
}
}
+
+ // And close the reader
+ reader.close();
}
@@ -142,7 +144,7 @@
}
LdapDN userDn = new LdapDN( principalDn );
- userDn.normalize( service.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+ userDn.normalize( service.getSchemaManager().getNormalizerMapping() );
LdapPrincipal principal = new LdapPrincipal( userDn, AuthenticationLevel.SIMPLE );
if ( dn == null )
@@ -165,7 +167,7 @@
}
LdapDN userDn = new LdapDN( principalDn );
- userDn.normalize( service.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+ userDn.normalize( service.getSchemaManager().getNormalizerMapping() );
LdapPrincipal principal = new LdapPrincipal( userDn, AuthenticationLevel.SIMPLE );
if ( dn == null )
@@ -186,7 +188,7 @@
public static LdapContext getSchemaContext( DirectoryService service ) throws Exception
{
- return getContext( ServerDNConstants.ADMIN_SYSTEM_DN, service, ServerDNConstants.OU_SCHEMA_DN );
+ return getContext( ServerDNConstants.ADMIN_SYSTEM_DN, service, SchemaConstants.OU_SCHEMA );
}
@@ -205,7 +207,7 @@
{
case( ChangeType.ADD_ORDINAL ):
session.add(
- new DefaultServerEntry( service.getRegistries(), entry.getEntry() ) );
+ new DefaultServerEntry( service.getSchemaManager(), entry.getEntry() ) );
break;
case( ChangeType.DELETE_ORDINAL ):
@@ -271,7 +273,7 @@
attr = new DefaultClientAttribute( "ou", "Engineering", "People" );
ldif.addAttribute( attr );
- String uid = ( String ) dn.getRdn().getValue();
+ String uid = ( String ) dn.getRdn().getNormValue();
ldif.putAttribute( "uid", uid );
ldif.putAttribute( "l", "Bogusville" );
@@ -291,10 +293,6 @@
// -----------------------------------------------------------------------
// Enable/Disable Schema Tests
// -----------------------------------------------------------------------
- public static Map<String, Schema> getLoadedSchemas( DirectoryService service )
- {
- return service.getRegistries().getLoadedSchemas();
- }
public static void enableSchema( DirectoryService service, String schemaName ) throws Exception
@@ -322,23 +320,35 @@
/**
- * A helper method which tells if a schema is disabled
+ * A helper method which tells if a schema is disabled.
*/
public static boolean isDisabled( DirectoryService service, String schemaName )
{
- Schema schema = getLoadedSchemas(service ).get( schemaName );
+ Schema schema = service.getSchemaManager().getLoadedSchema( schemaName );
+
+ return ( schema == null ) || schema.isDisabled();
+ }
+
+
+ /**
+ * A helper method which tells if a schema is loaded.
+ */
+ public static boolean isLoaded( DirectoryService service, String schemaName )
+ {
+ Schema schema = service.getSchemaManager().getLoadedSchema( schemaName );
- return ( schema == null ) || ( schema.isDisabled() );
+ return ( schema != null );
}
/**
- * A helper method which tells if a schema is enabled
+ * A helper method which tells if a schema is enabled. A shema must be
+ * loaded and enabled.
*/
public static boolean isEnabled( DirectoryService service, String schemaName )
{
- Schema schema = getLoadedSchemas( service ).get( schemaName );
+ Schema schema = service.getSchemaManager().getLoadedSchema( schemaName );
- return ( schema != null ) && ( !schema.isDisabled() );
+ return ( schema != null ) && schema.isEnabled();
}
}
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java Wed Jan 6 18:26:43 2010
@@ -20,24 +20,12 @@
package org.apache.directory.server.core.authn;
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.integ.CiRunner;
-import org.apache.directory.server.core.jndi.ServerLdapContext;
-
-import static org.apache.directory.server.core.integ.IntegrationUtils.getUserAddLdif;
import static org.apache.directory.server.core.integ.IntegrationUtils.apply;
-
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.ArrayUtils;
-import org.apache.directory.shared.ldap.util.StringTools;
-
-import static org.junit.Assert.assertTrue;
+import static org.apache.directory.server.core.integ.IntegrationUtils.getUserAddLdif;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
@@ -46,6 +34,15 @@
import javax.naming.directory.ModificationItem;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.core.jndi.ServerLdapContext;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.ArrayUtils;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
/**
* A set of simple tests to make sure simple authentication is working as it
@@ -54,12 +51,9 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-@RunWith( CiRunner.class )
-public class SimpleAuthenticationIT
+@RunWith( FrameworkRunner.class )
+public class SimpleAuthenticationIT extends AbstractLdapTestUnit
{
- public static DirectoryService service;
-
-
/**
* Checks all attributes of the admin account entry minus the userPassword
* attribute.