Author: elecharny
Date: Thu Dec 10 01:34:11 2009
New Revision: 889052
URL: http://svn.apache.org/viewvc?rev=889052&view=rev
Log:
Ignored the two added tests atm, because after a second thought, I'm not sure these are problematic
use cases...
Modified:
directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java
Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java?rev=889052&r1=889051&r2=889052&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java
(original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerAddTest.java
Thu Dec 10 01:34:11 2009
@@ -19,7 +19,6 @@
*/
package org.apache.directory.server.schema;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -47,86 +46,70 @@
import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
-
/**
* A test class for SchemaManager, testig the addition of a SchemaObject.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class SchemaManagerAddTest
-{
+public class SchemaManagerAddTest {
// A directory in which the ldif files will be stored
private static String workingDirectory;
// The schema repository
- private static File schemaRepository;
-
+ private static File schemaRepository;
@BeforeClass
- public static void setup() throws Exception
- {
- workingDirectory = System.getProperty( "workingDirectory" );
-
- if ( workingDirectory == null )
- {
- String path = SchemaManagerAddTest.class.getResource( "" ).getPath();
- int targetPos = path.indexOf( "target" );
- workingDirectory = path.substring( 0, targetPos + 6 );
+ public static void setup() throws Exception {
+ workingDirectory = System.getProperty("workingDirectory");
+
+ if (workingDirectory == null) {
+ String path = SchemaManagerAddTest.class.getResource("").getPath();
+ int targetPos = path.indexOf("target");
+ workingDirectory = path.substring(0, targetPos + 6);
}
- schemaRepository = new File( workingDirectory, "schema" );
+ schemaRepository = new File(workingDirectory, "schema");
// Cleanup the target directory
- FileUtils.deleteDirectory( schemaRepository );
+ FileUtils.deleteDirectory(schemaRepository);
- SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory
) );
+ SchemaLdifExtractor extractor = new SchemaLdifExtractor(new File(workingDirectory));
extractor.extractOrCopy();
}
-
@AfterClass
- public static void cleanup() throws IOException
- {
+ public static void cleanup() throws IOException {
// Cleanup the target directory
- FileUtils.deleteDirectory( schemaRepository );
+ FileUtils.deleteDirectory(schemaRepository);
}
-
- private SchemaManager loadSystem() throws Exception
- {
- LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
- SchemaManager schemaManager = new DefaultSchemaManager( loader );
+ private SchemaManager loadSystem() throws Exception {
+ LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
+ SchemaManager schemaManager = new DefaultSchemaManager(loader);
String schemaName = "system";
- schemaManager.loadWithDeps( schemaName );
+ schemaManager.loadWithDeps(schemaName);
return schemaManager;
}
-
- private boolean isATPresent( SchemaManager schemaManager, String oid )
- {
- try
- {
- AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( oid
);
+ private boolean isATPresent(SchemaManager schemaManager, String oid) {
+ try {
+ AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry(oid);
return attributeType != null;
- }
- catch ( NoSuchAttributeException nsae )
- {
+ } catch (NoSuchAttributeException nsae) {
return false;
- }
- catch ( NamingException ne )
- {
+ } catch (NamingException ne) {
return false;
}
}
-
//=========================================================================
// For each test, we will check many different things.
// If the test is successful, we want to know if the SchemaObject
@@ -141,309 +124,289 @@
* Try to inject an AttributeType without any superior nor Syntax : it's invalid
*/
@Test
- public void testAddAttributeTypeNoSupNoSyntaxNoSuperior() throws Exception
- {
+ public void testAddAttributeTypeNoSupNoSyntaxNoSuperior() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "1.1.0" );
- attributeType.setEqualityOid( "2.5.13.1" );
- attributeType.setOrderingOid( null );
- attributeType.setSubstringOid( null );
+ AttributeType attributeType = new AttributeType("1.1.0");
+ attributeType.setEqualityOid("2.5.13.1");
+ attributeType.setOrderingOid(null);
+ attributeType.setSubstringOid(null);
// It should fail
- assertFalse( schemaManager.add( attributeType ) );
+ assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
- assertEquals( 1, errors.size() );
- Throwable error = errors.get( 0 );
+ assertEquals(1, errors.size());
+ Throwable error = errors.get(0);
- assertTrue( error instanceof LdapSchemaViolationException );
+ assertTrue(error instanceof LdapSchemaViolationException);
- assertFalse( isATPresent( schemaManager, "1.1.0" ) );
- assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+ assertFalse(isATPresent(schemaManager, "1.1.0"));
+ assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
}
-
/**
* Try to inject an AttributeType which is Collective, and userApplication AT
*/
@Test
- public void testAddAttributeTypeNoSupCollectiveUser() throws Exception
- {
+ public void testAddAttributeTypeNoSupCollectiveUser() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "1.1.0" );
- attributeType.setEqualityOid( "2.5.13.1" );
- attributeType.setOrderingOid( null );
- attributeType.setSubstringOid( null );
- attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
- attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
- attributeType.setCollective( true );
+ AttributeType attributeType = new AttributeType("1.1.0");
+ attributeType.setEqualityOid("2.5.13.1");
+ attributeType.setOrderingOid(null);
+ attributeType.setSubstringOid(null);
+ attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
+ attributeType.setUsage(UsageEnum.USER_APPLICATIONS);
+ attributeType.setCollective(true);
// It should not fail
- assertTrue( schemaManager.add( attributeType ) );
+ assertTrue(schemaManager.add(attributeType));
- assertTrue( isATPresent( schemaManager, "1.1.0" ) );
- assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize + 1, schemaManager.getOidRegistry().size() );
+ assertTrue(isATPresent(schemaManager, "1.1.0"));
+ assertEquals(atrSize + 1, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize + 1, schemaManager.getOidRegistry().size());
}
-
/**
* Try to inject an AttributeType which is Collective, but an operational AT
*/
@Test
- public void testAddAttributeTypeNoSupCollectiveOperational() throws Exception
- {
+ public void testAddAttributeTypeNoSupCollectiveOperational() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "1.1.0" );
- attributeType.setEqualityOid( "2.5.13.1" );
- attributeType.setOrderingOid( null );
- attributeType.setSubstringOid( null );
- attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
- attributeType.setUsage( UsageEnum.DIRECTORY_OPERATION );
- attributeType.setCollective( true );
+ AttributeType attributeType = new AttributeType("1.1.0");
+ attributeType.setEqualityOid("2.5.13.1");
+ attributeType.setOrderingOid(null);
+ attributeType.setSubstringOid(null);
+ attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
+ attributeType.setUsage(UsageEnum.DIRECTORY_OPERATION);
+ attributeType.setCollective(true);
// It should fail
- assertFalse( schemaManager.add( attributeType ) );
+ assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
- assertEquals( 1, errors.size() );
- Throwable error = errors.get( 0 );
+ assertEquals(1, errors.size());
+ Throwable error = errors.get(0);
- assertTrue( error instanceof LdapSchemaViolationException );
+ assertTrue(error instanceof LdapSchemaViolationException);
- assertFalse( isATPresent( schemaManager, "1.1.0" ) );
- assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+ assertFalse(isATPresent(schemaManager, "1.1.0"));
+ assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
}
-
/**
* Try to inject an AttributeType which is a NO-USER-MODIFICATION and userApplication
*/
@Test
- public void testAddAttributeTypeNoSupNoUserModificationUserAplication() throws Exception
- {
+ public void testAddAttributeTypeNoSupNoUserModificationUserAplication() throws Exception
{
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "1.1.0" );
- attributeType.setEqualityOid( "2.5.13.1" );
- attributeType.setOrderingOid( null );
- attributeType.setSubstringOid( null );
- attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
- attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
- attributeType.setUserModifiable( false );
+ AttributeType attributeType = new AttributeType("1.1.0");
+ attributeType.setEqualityOid("2.5.13.1");
+ attributeType.setOrderingOid(null);
+ attributeType.setSubstringOid(null);
+ attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
+ attributeType.setUsage(UsageEnum.USER_APPLICATIONS);
+ attributeType.setUserModifiable(false);
// It should fail
- assertFalse( schemaManager.add( attributeType ) );
+ assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
- assertEquals( 1, errors.size() );
- Throwable error = errors.get( 0 );
+ assertEquals(1, errors.size());
+ Throwable error = errors.get(0);
- assertTrue( error instanceof LdapSchemaViolationException );
+ assertTrue(error instanceof LdapSchemaViolationException);
- assertFalse( isATPresent( schemaManager, "1.1.0" ) );
- assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+ assertFalse(isATPresent(schemaManager, "1.1.0"));
+ assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
}
-
/**
* Try to inject an AttributeType which is a NO-USER-MODIFICATION and is operational
*/
@Test
- public void testAddAttributeTypeNoSupNoUserModificationOpAttr() throws Exception
- {
+ public void testAddAttributeTypeNoSupNoUserModificationOpAttr() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "1.1.0" );
- attributeType.setEqualityOid( "2.5.13.1" );
- attributeType.setOrderingOid( null );
- attributeType.setSubstringOid( null );
- attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
- attributeType.setUsage( UsageEnum.DISTRIBUTED_OPERATION );
- attributeType.setUserModifiable( false );
+ AttributeType attributeType = new AttributeType("1.1.0");
+ attributeType.setEqualityOid("2.5.13.1");
+ attributeType.setOrderingOid(null);
+ attributeType.setSubstringOid(null);
+ attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
+ attributeType.setUsage(UsageEnum.DISTRIBUTED_OPERATION);
+ attributeType.setUserModifiable(false);
// It should not fail
- assertTrue( schemaManager.add( attributeType ) );
+ assertTrue(schemaManager.add(attributeType));
- assertTrue( isATPresent( schemaManager, "1.1.0" ) );
- assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize + 1, schemaManager.getOidRegistry().size() );
+ assertTrue(isATPresent(schemaManager, "1.1.0"));
+ assertEquals(atrSize + 1, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize + 1, schemaManager.getOidRegistry().size());
}
-
/**
* Try to inject an AttributeType with an invalid EQUALITY MR
*/
@Test
- public void testAddAttributeTypeNoSupInvalidEqualityMR() throws Exception
- {
+ public void testAddAttributeTypeNoSupInvalidEqualityMR() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "1.1.0" );
- attributeType.setEqualityOid( "0.0" );
- attributeType.setOrderingOid( null );
- attributeType.setSubstringOid( null );
- attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
- attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
+ AttributeType attributeType = new AttributeType("1.1.0");
+ attributeType.setEqualityOid("0.0");
+ attributeType.setOrderingOid(null);
+ attributeType.setSubstringOid(null);
+ attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
+ attributeType.setUsage(UsageEnum.USER_APPLICATIONS);
// It should fail
- assertFalse( schemaManager.add( attributeType ) );
+ assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
- assertEquals( 1, errors.size() );
- Throwable error = errors.get( 0 );
+ assertEquals(1, errors.size());
+ Throwable error = errors.get(0);
- assertTrue( error instanceof LdapSchemaViolationException );
+ assertTrue(error instanceof LdapSchemaViolationException);
- assertFalse( isATPresent( schemaManager, "1.1.0" ) );
- assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+ assertFalse(isATPresent(schemaManager, "1.1.0"));
+ assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
}
-
/**
* Try to inject an AttributeType with an invalid ORDERING MR
*/
@Test
- public void testAddAttributeTypeNoSupInvalidOrderingMR() throws Exception
- {
+ public void testAddAttributeTypeNoSupInvalidOrderingMR() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "1.1.0" );
- attributeType.setEqualityOid( null );
- attributeType.setOrderingOid( "0.0" );
- attributeType.setSubstringOid( null );
- attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
- attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
+ AttributeType attributeType = new AttributeType("1.1.0");
+ attributeType.setEqualityOid(null);
+ attributeType.setOrderingOid("0.0");
+ attributeType.setSubstringOid(null);
+ attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
+ attributeType.setUsage(UsageEnum.USER_APPLICATIONS);
// It should fail
- assertFalse( schemaManager.add( attributeType ) );
+ assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
- assertEquals( 1, errors.size() );
- Throwable error = errors.get( 0 );
+ assertEquals(1, errors.size());
+ Throwable error = errors.get(0);
- assertTrue( error instanceof LdapSchemaViolationException );
+ assertTrue(error instanceof LdapSchemaViolationException);
- assertFalse( isATPresent( schemaManager, "1.1.0" ) );
- assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+ assertFalse(isATPresent(schemaManager, "1.1.0"));
+ assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
}
-
/**
* Try to inject an AttributeType with an invalid SUBSTR MR
*/
@Test
- public void testAddAttributeTypeNoSupInvalidSubstringMR() throws Exception
- {
+ public void testAddAttributeTypeNoSupInvalidSubstringMR() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "1.1.0" );
- attributeType.setEqualityOid( null );
- attributeType.setOrderingOid( null );
- attributeType.setSubstringOid( "0.0" );
- attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
- attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
+ AttributeType attributeType = new AttributeType("1.1.0");
+ attributeType.setEqualityOid(null);
+ attributeType.setOrderingOid(null);
+ attributeType.setSubstringOid("0.0");
+ attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
+ attributeType.setUsage(UsageEnum.USER_APPLICATIONS);
// It should fail
- assertFalse( schemaManager.add( attributeType ) );
+ assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
- assertEquals( 1, errors.size() );
- Throwable error = errors.get( 0 );
+ assertEquals(1, errors.size());
+ Throwable error = errors.get(0);
- assertTrue( error instanceof LdapSchemaViolationException );
+ assertTrue(error instanceof LdapSchemaViolationException);
- assertFalse( isATPresent( schemaManager, "1.1.0" ) );
- assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+ assertFalse(isATPresent(schemaManager, "1.1.0"));
+ assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
}
-
/**
* Try to inject an AttributeType with valid MRs
*/
@Test
- public void testAddAttributeTypeNoSupValidMR() throws Exception
- {
+ public void testAddAttributeTypeNoSupValidMR() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "1.1.0" );
- attributeType.setEqualityOid( "2.5.13.1" );
- attributeType.setOrderingOid( "2.5.13.1" );
- attributeType.setSubstringOid( "2.5.13.1" );
- attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
- attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
+ AttributeType attributeType = new AttributeType("1.1.0");
+ attributeType.setEqualityOid("2.5.13.1");
+ attributeType.setOrderingOid("2.5.13.1");
+ attributeType.setSubstringOid("2.5.13.1");
+ attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
+ attributeType.setUsage(UsageEnum.USER_APPLICATIONS);
// It should not fail
- assertTrue( schemaManager.add( attributeType ) );
+ assertTrue(schemaManager.add(attributeType));
- assertTrue( isATPresent( schemaManager, "1.1.0" ) );
- assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize + 1, schemaManager.getOidRegistry().size() );
+ assertTrue(isATPresent(schemaManager, "1.1.0"));
+ assertEquals(atrSize + 1, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize + 1, schemaManager.getOidRegistry().size());
}
-
/**
* Try to inject an AttributeType which already exist
*/
@Test
- public void testAddAttributeTypeAlreadyExist() throws Exception
- {
+ public void testAddAttributeTypeAlreadyExist() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "2.5.18.4" );
- attributeType.setEqualityOid( "2.5.13.1" );
- attributeType.setOrderingOid( "2.5.13.1" );
- attributeType.setSubstringOid( "2.5.13.1" );
+ AttributeType attributeType = new AttributeType("2.5.18.4");
+ attributeType.setEqualityOid("2.5.13.1");
+ attributeType.setOrderingOid("2.5.13.1");
+ attributeType.setSubstringOid("2.5.13.1");
// It should fail
- assertFalse( schemaManager.add( attributeType ) );
+ assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
- assertEquals( 1, errors.size() );
- Throwable error = errors.get( 0 );
+ assertEquals(1, errors.size());
+ Throwable error = errors.get(0);
- assertTrue( error instanceof LdapSchemaViolationException );
+ assertTrue(error instanceof LdapSchemaViolationException);
// The AT must be there
- assertTrue( isATPresent( schemaManager, "2.5.18.4" ) );
+ assertTrue(isATPresent(schemaManager, "2.5.18.4"));
// Check that it hasen't changed
- AttributeType original = schemaManager.lookupAttributeTypeRegistry( "2.5.18.4" );
- assertEquals( "distinguishedNameMatch", original.getEqualityOid() );
- assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+ AttributeType original = schemaManager.lookupAttributeTypeRegistry("2.5.18.4");
+ assertEquals("distinguishedNameMatch", original.getEqualityOid());
+ assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
}
-
//-------------------------------------------------------------------------
// Then, with a superior
//-------------------------------------------------------------------------
@@ -452,298 +415,275 @@
* take its superior' syntax and MR
*/
@Test
- public void testAddAttributeTypeSupNoSyntaxNoSuperior() throws Exception
- {
+ public void testAddAttributeTypeSupNoSyntaxNoSuperior() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "1.1.0" );
- attributeType.setEqualityOid( null );
- attributeType.setOrderingOid( null );
- attributeType.setSubstringOid( null );
- attributeType.setSuperiorOid( "2.5.18.4" );
- attributeType.setUsage( UsageEnum.DIRECTORY_OPERATION );
+ AttributeType attributeType = new AttributeType("1.1.0");
+ attributeType.setEqualityOid(null);
+ attributeType.setOrderingOid(null);
+ attributeType.setSubstringOid(null);
+ attributeType.setSuperiorOid("2.5.18.4");
+ attributeType.setUsage(UsageEnum.DIRECTORY_OPERATION);
// It should not fail
- assertTrue( schemaManager.add( attributeType ) );
+ assertTrue(schemaManager.add(attributeType));
- AttributeType result = schemaManager.lookupAttributeTypeRegistry( "1.1.0" );
+ AttributeType result = schemaManager.lookupAttributeTypeRegistry("1.1.0");
- assertEquals( "1.3.6.1.4.1.1466.115.121.1.12", result.getSyntaxOid() );
- assertEquals( "2.5.13.1", result.getEqualityOid() );
- assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize + 1, schemaManager.getOidRegistry().size() );
+ assertEquals("1.3.6.1.4.1.1466.115.121.1.12", result.getSyntaxOid());
+ assertEquals("2.5.13.1", result.getEqualityOid());
+ assertEquals(atrSize + 1, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize + 1, schemaManager.getOidRegistry().size());
}
-
/**
* Try to inject an AttributeType with a superior and different USAGE
*/
@Test
- public void testAddAttributeTypeSupDifferentUsage() throws Exception
- {
+ public void testAddAttributeTypeSupDifferentUsage() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "1.1.0" );
- attributeType.setEqualityOid( null );
- attributeType.setOrderingOid( null );
- attributeType.setSubstringOid( null );
- attributeType.setSuperiorOid( "2.5.18.4" );
- attributeType.setUsage( UsageEnum.DISTRIBUTED_OPERATION );
+ AttributeType attributeType = new AttributeType("1.1.0");
+ attributeType.setEqualityOid(null);
+ attributeType.setOrderingOid(null);
+ attributeType.setSubstringOid(null);
+ attributeType.setSuperiorOid("2.5.18.4");
+ attributeType.setUsage(UsageEnum.DISTRIBUTED_OPERATION);
// It should fail
- assertFalse( schemaManager.add( attributeType ) );
+ assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
- assertEquals( 1, errors.size() );
- Throwable error = errors.get( 0 );
+ assertEquals(1, errors.size());
+ Throwable error = errors.get(0);
- assertTrue( error instanceof LdapSchemaViolationException );
+ assertTrue(error instanceof LdapSchemaViolationException);
- assertFalse( isATPresent( schemaManager, "1.1.0" ) );
- assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+ assertFalse(isATPresent(schemaManager, "1.1.0"));
+ assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
}
-
/**
* Try to inject an AttributeType with itself as a superior
*/
@Test
- public void testAddAttributeTypeSupWithOwnSup() throws Exception
- {
+ public void testAddAttributeTypeSupWithOwnSup() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "1.1.0" );
- attributeType.setEqualityOid( null );
- attributeType.setOrderingOid( null );
- attributeType.setSubstringOid( null );
- attributeType.setSuperiorOid( "1.1.0" );
- attributeType.setUsage( UsageEnum.DISTRIBUTED_OPERATION );
+ AttributeType attributeType = new AttributeType("1.1.0");
+ attributeType.setEqualityOid(null);
+ attributeType.setOrderingOid(null);
+ attributeType.setSubstringOid(null);
+ attributeType.setSuperiorOid("1.1.0");
+ attributeType.setUsage(UsageEnum.DISTRIBUTED_OPERATION);
// It should fail
- assertFalse( schemaManager.add( attributeType ) );
+ assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
- assertEquals( 1, errors.size() );
- Throwable error = errors.get( 0 );
+ assertEquals(1, errors.size());
+ Throwable error = errors.get(0);
- assertTrue( error instanceof LdapSchemaViolationException );
+ assertTrue(error instanceof LdapSchemaViolationException);
- assertFalse( isATPresent( schemaManager, "1.1.0" ) );
- assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+ assertFalse(isATPresent(schemaManager, "1.1.0"));
+ assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
}
-
/**
* Try to inject an AttributeType with a bad superior
*/
@Test
- public void testAddAttributeTypeSupBadSup() throws Exception
- {
+ public void testAddAttributeTypeSupBadSup() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
- AttributeType attributeType = new AttributeType( "1.1.0" );
- attributeType.setEqualityOid( null );
- attributeType.setOrderingOid( null );
- attributeType.setSubstringOid( null );
- attributeType.setSuperiorOid( "0.0" );
- attributeType.setUsage( UsageEnum.DISTRIBUTED_OPERATION );
+ AttributeType attributeType = new AttributeType("1.1.0");
+ attributeType.setEqualityOid(null);
+ attributeType.setOrderingOid(null);
+ attributeType.setSubstringOid(null);
+ attributeType.setSuperiorOid("0.0");
+ attributeType.setUsage(UsageEnum.DISTRIBUTED_OPERATION);
// It should fail
- assertFalse( schemaManager.add( attributeType ) );
+ assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
- assertEquals( 1, errors.size() );
- Throwable error = errors.get( 0 );
+ assertEquals(1, errors.size());
+ Throwable error = errors.get(0);
- assertTrue( error instanceof LdapSchemaViolationException );
+ assertTrue(error instanceof LdapSchemaViolationException);
- assertFalse( isATPresent( schemaManager, "1.1.0" ) );
- assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+ assertFalse(isATPresent(schemaManager, "1.1.0"));
+ assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
}
-
//=========================================================================
// Comparator addition tests
//-------------------------------------------------------------------------
@Test
- public void testAddNewComparator() throws Exception
- {
+ public void testAddNewComparator() throws Exception {
SchemaManager schemaManager = loadSystem();
int ctrSize = schemaManager.getComparatorRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
String oid = "0.0.0";
- LdapComparator<?> lc = new BooleanComparator( oid );
+ LdapComparator<?> lc = new BooleanComparator(oid);
- assertTrue( schemaManager.add( lc ) );
+ assertTrue(schemaManager.add(lc));
List<Throwable> errors = schemaManager.getErrors();
- assertEquals( 0, errors.size() );
+ assertEquals(0, errors.size());
- assertEquals( ctrSize + 1, schemaManager.getComparatorRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+ assertEquals(ctrSize + 1, schemaManager.getComparatorRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
- try
- {
- LdapComparator<?> added = schemaManager.lookupComparatorRegistry( oid );
+ try {
+ LdapComparator<?> added = schemaManager.lookupComparatorRegistry(oid);
- assertNotNull( added );
- }
- catch ( NamingException ne )
- {
+ assertNotNull(added);
+ } catch (NamingException ne) {
fail();
}
}
-
//@Test
- public void testAddAlreadyExistingComparator() throws Exception
- {
+ public void testAddAlreadyExistingComparator() throws Exception {
SchemaManager schemaManager = loadSystem();
int ctrSize = schemaManager.getComparatorRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
String oid = "0.0.0";
- LdapComparator<?> lc = new BooleanComparator( oid );
+ LdapComparator<?> lc = new BooleanComparator(oid);
- assertTrue( schemaManager.add( lc ) );
+ assertTrue(schemaManager.add(lc));
- try
- {
- LdapComparator<?> added = schemaManager.lookupComparatorRegistry( oid );
+ try {
+ LdapComparator<?> added = schemaManager.lookupComparatorRegistry(oid);
- assertNotNull( added );
- }
- catch ( NamingException ne )
- {
+ assertNotNull(added);
+ } catch (NamingException ne) {
fail();
}
List<Throwable> errors = schemaManager.getErrors();
- assertEquals( 0, errors.size() );
- assertEquals( ctrSize + 1, schemaManager.getComparatorRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+ assertEquals(0, errors.size());
+ assertEquals(ctrSize + 1, schemaManager.getComparatorRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
- lc = new CsnComparator( oid );
+ lc = new CsnComparator(oid);
- assertFalse( schemaManager.add( lc ) );
+ assertFalse(schemaManager.add(lc));
errors = schemaManager.getErrors();
- assertEquals( 1, errors.size() );
+ assertEquals(1, errors.size());
- assertEquals( ctrSize + 1, schemaManager.getComparatorRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+ assertEquals(ctrSize + 1, schemaManager.getComparatorRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
- try
- {
- LdapComparator<?> added = schemaManager.lookupComparatorRegistry( oid );
+ try {
+ LdapComparator<?> added = schemaManager.lookupComparatorRegistry(oid);
- assertNotNull( added );
- }
- catch ( NamingException ne )
- {
+ assertNotNull(added);
+ } catch (NamingException ne) {
fail();
}
}
-
+ /**
+ * Test that we can't add two comparators with the same class code.
+ *
+ * This is a questionable test, as there is no real reason why it could
+ * be a problem.
+ */
+ @Ignore
@Test
- public void testAddAnotherComparatorWithSameClass() throws Exception
- {
+ public void testAddAnotherComparatorWithSameClass() throws Exception {
SchemaManager schemaManager = loadSystem();
int ctrSize = schemaManager.getComparatorRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
String oid = "0.0.0";
- LdapComparator<?> lc = new BooleanComparator( oid );
+ LdapComparator<?> lc = new BooleanComparator(oid);
// using java.sql.ResultSet cause it is very unlikely to get loaded
// in ADS
- lc.setFqcn( "java.sql.ResultSet" );
+ lc.setFqcn("java.sql.ResultSet");
- assertTrue( schemaManager.add( lc ) );
+ assertTrue(schemaManager.add(lc));
List<Throwable> errors = schemaManager.getErrors();
errors = schemaManager.getErrors();
- assertEquals( 0, errors.size() );
+ assertEquals(0, errors.size());
+
+ lc = new BooleanComparator("0.0.1");
+ lc.setFqcn("java.sql.ResultSet");
- lc = new BooleanComparator( "0.0.1" );
- lc.setFqcn( "java.sql.ResultSet" );
-
// FIXME this has to fail cause the java.sql.ResultSet class was already used in
the above lc
- assertFalse( schemaManager.add( lc ) );
-
+ assertFalse(schemaManager.add(lc));
+
errors = schemaManager.getErrors();
errors = schemaManager.getErrors();
- assertEquals( 1, errors.size() );
-
- assertEquals( ctrSize + 1, schemaManager.getComparatorRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
-
- try
- {
- LdapComparator<?> added = schemaManager.lookupComparatorRegistry( oid );
+ assertEquals(1, errors.size());
- assertNotNull( added );
- }
- catch ( NamingException ne )
- {
+ assertEquals(ctrSize + 1, schemaManager.getComparatorRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
+
+ try {
+ LdapComparator<?> added = schemaManager.lookupComparatorRegistry(oid);
+
+ assertNotNull(added);
+ } catch (NamingException ne) {
fail();
}
}
-
+ @Ignore
+ // Definitively not an issue.
@Test
- public void testAddNewComparatorWithDuplicateName() throws Exception
- {
+ public void testAddNewComparatorWithDuplicateName() throws Exception {
SchemaManager schemaManager = loadSystem();
int ctrSize = schemaManager.getComparatorRegistry().size();
int goidSize = schemaManager.getOidRegistry().size();
List<String> names = new ArrayList<String>();
- names.add( "name" );
- names.add( "name" );
-
+ names.add("name");
+ names.add("name");
+
String oid = "0.0.0";
- LdapComparator<?> lc = new BooleanComparator( oid );
- lc.setNames( names );
+ LdapComparator<?> lc = new BooleanComparator(oid);
+ lc.setNames(names);
// FIXME this should fail cause the same name was set twice
- assertTrue( schemaManager.add( lc ) );
+ assertTrue(schemaManager.add(lc));
List<Throwable> errors = schemaManager.getErrors();
errors = schemaManager.getErrors();
- assertEquals( 1, errors.size() );
-
-
- assertEquals( ctrSize + 1, schemaManager.getComparatorRegistry().size() );
- assertEquals( goidSize, schemaManager.getOidRegistry().size() );
-
- try
- {
- LdapComparator<?> added = schemaManager.lookupComparatorRegistry( oid );
+ assertEquals(1, errors.size());
- assertNotNull( added );
- }
- catch ( NamingException ne )
- {
+ assertEquals(ctrSize + 1, schemaManager.getComparatorRegistry().size());
+ assertEquals(goidSize, schemaManager.getOidRegistry().size());
+
+ try {
+ LdapComparator<?> added = schemaManager.lookupComparatorRegistry(oid);
+
+ assertNotNull(added);
+ } catch (NamingException ne) {
fail();
}
}
-
//=========================================================================
// DITContentRule addition tests
//-------------------------------------------------------------------------
|