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/08/06 16:28:52 UTC
svn commit: r982989 [2/3] - in
/directory/apacheds/branches/apacheds-codec-merge: all/ core-annotations/
core-api/ core-avl/ core-constants/ core-integ/
core-integ/src/test/java/org/apache/directory/server/core/collective/
core-integ/src/test/java/org/...
Modified: directory/apacheds/branches/apacheds-codec-merge/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-codec-merge/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java?rev=982989&r1=982988&r2=982989&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-codec-merge/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java (original)
+++ directory/apacheds/branches/apacheds-codec-merge/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaNormalizerHandlerIT.java Fri Aug 6 14:28:50 2010
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.directory.server.core.schema;
@@ -42,7 +42,7 @@ import org.apache.directory.server.core.
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
-//import org.apache.directory.shared.ldap.exception.LdapUnwillingToPerformException;
+import org.apache.directory.shared.ldap.jndi.JndiUtils;
import org.apache.directory.shared.ldap.ldif.LdifUtils;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.DN;
@@ -84,91 +84,91 @@ public class MetaNormalizerHandlerIT ext
@Test
public void testAddNormalizerToEnabledSchema() throws Exception
{
- Attributes attrs = LdifUtils.createAttributes(
+ Attributes attrs = LdifUtils.createAttributes(
"objectClass: top",
"objectClass: metaTop",
"objectClass: metaNormalizer",
"m-fqcn", NoOpNormalizer.class.getName(),
"m-oid", OID,
"m-description: A test normalizer" );
-
+
DN dn = getNormalizerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
assertTrue( schemaManager.getNormalizerRegistry().contains( OID ) );
assertEquals( schemaManager.getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
Class<?> clazz = schemaManager.getNormalizerRegistry().lookup( OID ).getClass();
assertEquals( clazz, NoOpNormalizer.class );
assertTrue( isOnDisk( dn ) );
}
-
-
+
+
@Test
public void testAddNormalizerToDisabledSchema() throws Exception
{
- Attributes attrs = LdifUtils.createAttributes(
+ Attributes attrs = LdifUtils.createAttributes(
"objectClass: top",
"objectClass: metaTop",
"objectClass: metaNormalizer",
"m-fqcn", NoOpNormalizer.class.getName(),
"m-oid", OID,
"m-description: A test normalizer" );
-
+
// nis is by default inactive
DN dn = getNormalizerContainer( "nis" );
dn = dn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-
- assertFalse( "adding new normalizer to disabled schema should not register it into the registries",
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
+ assertFalse( "adding new normalizer to disabled schema should not register it into the registries",
schemaManager.getNormalizerRegistry().contains( OID ) );
assertTrue( isOnDisk( dn ) );
}
-
-
+
+
@Test
public void testAddNormalizerToUnloadedSchema() throws Exception
{
- Attributes attrs = LdifUtils.createAttributes(
+ Attributes attrs = LdifUtils.createAttributes(
"objectClass: top",
"objectClass: metaTop",
"objectClass: metaNormalizer",
"m-fqcn", NoOpNormalizer.class.getName(),
"m-oid", OID,
"m-description: A test normalizer" );
-
+
// nis is by default inactive
DN dn = getNormalizerContainer( "notloaded" );
dn = dn.add( "m-oid" + "=" + OID );
try
{
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
fail( "Should not be there" );
}
catch( NameNotFoundException nnfe )
{
// Expected result.
}
-
- assertFalse( "adding new normalizer to disabled schema should not register it into the registries",
+
+ assertFalse( "adding new normalizer to disabled schema should not register it into the registries",
schemaManager.getNormalizerRegistry().contains( OID ) );
assertFalse( isOnDisk( dn ) );
}
-
-
+
+
@Test
public void testAddNormalizerWithByteCodeToEnabledSchema() throws Exception
{
InputStream in = getClass().getResourceAsStream( "DummyNormalizer.bytecode" );
ByteArrayOutputStream out = new ByteArrayOutputStream();
-
+
while ( in.available() > 0 )
{
out.write( in.read() );
}
-
- Attributes attrs = LdifUtils.createAttributes(
+
+ Attributes attrs = LdifUtils.createAttributes(
"objectClass: top",
"objectClass: metaTop",
"objectClass: metaNormalizer",
@@ -176,31 +176,31 @@ public class MetaNormalizerHandlerIT ext
"m-bytecode", out.toByteArray(),
"m-oid", OID,
"m-description: A test normalizer" );
-
+
DN dn = getNormalizerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
assertTrue( schemaManager.getNormalizerRegistry().contains( OID ) );
assertEquals( schemaManager.getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
Class<?> clazz = schemaManager.getNormalizerRegistry().lookup( OID ).getClass();
assertEquals( clazz.getName(), "org.apache.directory.shared.ldap.schema.normalizers.DummyNormalizer" );
assertTrue( isOnDisk( dn ) );
}
-
-
+
+
@Test
public void testAddNormalizerWithByteCodeToDisabledSchema() throws Exception
{
InputStream in = getClass().getResourceAsStream( "DummyNormalizer.bytecode" );
ByteArrayOutputStream out = new ByteArrayOutputStream();
-
+
while ( in.available() > 0 )
{
out.write( in.read() );
}
-
- Attributes attrs = LdifUtils.createAttributes(
+
+ Attributes attrs = LdifUtils.createAttributes(
"objectClass: top",
"objectClass: metaTop",
"objectClass: metaNormalizer",
@@ -208,30 +208,30 @@ public class MetaNormalizerHandlerIT ext
"m-bytecode", out.toByteArray(),
"m-oid", OID,
"m-description: A test normalizer" );
-
+
DN dn = getNormalizerContainer( "nis" );
dn = dn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
assertFalse( schemaManager.getNormalizerRegistry().contains( OID ) );
assertTrue( isOnDisk( dn ) );
}
-
-
+
+
@Test
public void testDeleteNormalizerFromEnabledSchema() throws Exception
{
DN dn = getNormalizerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
testAddNormalizerToEnabledSchema();
-
- assertTrue( "normalizer should be removed from the registry after being deleted",
+
+ assertTrue( "normalizer should be removed from the registry after being deleted",
schemaManager.getNormalizerRegistry().contains( OID ) );
assertTrue( isOnDisk( dn ) );
-
- getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
- assertFalse( "normalizer should be removed from the registry after being deleted",
+ getSchemaContext( service ).destroySubcontext( JndiUtils.toName( dn ) );
+
+ assertFalse( "normalizer should be removed from the registry after being deleted",
schemaManager.getNormalizerRegistry().contains( OID ) );
try
@@ -254,13 +254,13 @@ public class MetaNormalizerHandlerIT ext
dn = dn.add( "m-oid" + "=" + OID );
testAddNormalizerToEnabledSchema();
- assertTrue( "normalizer should be removed from the registry after being deleted",
+ assertTrue( "normalizer should be removed from the registry after being deleted",
schemaManager.getNormalizerRegistry().contains( OID ) );
assertTrue( isOnDisk( dn ) );
-
- getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
- assertFalse( "normalizer should be removed from the registry after being deleted",
+ getSchemaContext( service ).destroySubcontext( JndiUtils.toName( dn ) );
+
+ assertFalse( "normalizer should be removed from the registry after being deleted",
schemaManager.getNormalizerRegistry().contains( OID ) );
try
@@ -283,12 +283,12 @@ public class MetaNormalizerHandlerIT ext
DN dn = getNormalizerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
testAddNormalizerToEnabledSchema();
-
+
DN newdn = getNormalizerContainer( "apachemeta" );
newdn = newdn.add( "m-oid" + "=" + NEW_OID );
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
- assertFalse( "old normalizer OID should be removed from the registry after being renamed",
+ assertFalse( "old normalizer OID should be removed from the registry after being renamed",
schemaManager.getNormalizerRegistry().contains( OID ) );
//noinspection EmptyCatchBlock
@@ -312,19 +312,19 @@ public class MetaNormalizerHandlerIT ext
public void testMoveNormalizer() throws Exception
{
testAddNormalizerToEnabledSchema();
-
+
DN dn = getNormalizerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
DN newdn = getNormalizerContainer( "apache" );
newdn = newdn.add( "m-oid" + "=" + OID );
-
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
- assertTrue( "normalizer OID should still be present",
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+
+ assertTrue( "normalizer OID should still be present",
schemaManager.getNormalizerRegistry().contains( OID ) );
-
- assertEquals( "normalizer schema should be set to apache not apachemeta",
+
+ assertEquals( "normalizer schema should be set to apache not apachemeta",
schemaManager.getNormalizerRegistry().getSchemaName( OID ), "apache" );
Class<?> clazz = schemaManager.getNormalizerRegistry().lookup( OID ).getClass();
@@ -337,77 +337,77 @@ public class MetaNormalizerHandlerIT ext
public void testMoveNormalizerAndChangeRdn() throws Exception
{
testAddNormalizerToEnabledSchema();
-
+
DN dn = getNormalizerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
DN newdn = getNormalizerContainer( "apache" );
newdn = newdn.add( "m-oid" + "=" + NEW_OID );
-
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
- assertFalse( "old normalizer OID should NOT be present",
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+
+ assertFalse( "old normalizer OID should NOT be present",
schemaManager.getNormalizerRegistry().contains( OID ) );
-
- assertTrue( "new normalizer OID should be present",
+
+ assertTrue( "new normalizer OID should be present",
schemaManager.getNormalizerRegistry().contains( NEW_OID ) );
-
- assertEquals( "normalizer with new oid should have schema set to apache NOT apachemeta",
+
+ assertEquals( "normalizer with new oid should have schema set to apache NOT apachemeta",
schemaManager.getNormalizerRegistry().getSchemaName( NEW_OID ), "apache" );
Class<?> clazz = schemaManager.getNormalizerRegistry().lookup( NEW_OID ).getClass();
assertEquals( clazz, NoOpNormalizer.class );
}
-
+
@Test
@Ignore
public void testModifyNormalizerWithModificationItems() throws Exception
{
testAddNormalizerToEnabledSchema();
-
+
DN dn = getNormalizerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
-
+
ModificationItem[] mods = new ModificationItem[1];
Attribute attr = new BasicAttribute( "m-fqcn", DeepTrimNormalizer.class.getName() );
mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
- getSchemaContext( service ).modifyAttributes( DN.toName( dn ), mods );
+ getSchemaContext( service ).modifyAttributes( JndiUtils.toName( dn ), mods );
- assertTrue( "normalizer OID should still be present",
+ assertTrue( "normalizer OID should still be present",
schemaManager.getNormalizerRegistry().contains( OID ) );
-
- assertEquals( "normalizer schema should be set to apachemeta",
+
+ assertEquals( "normalizer schema should be set to apachemeta",
schemaManager.getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
Class<?> clazz = schemaManager.getNormalizerRegistry().lookup( OID ).getClass();
assertEquals( clazz, DeepTrimNormalizer.class );
}
-
+
@Test
@Ignore
public void testModifyNormalizerWithAttributes() throws Exception
{
testAddNormalizerToEnabledSchema();
-
+
DN dn = getNormalizerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
-
+
Attributes mods = new BasicAttributes( true );
mods.put( "m-fqcn", DeepTrimNormalizer.class.getName() );
- getSchemaContext( service ).modifyAttributes( DN.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
+ getSchemaContext( service ).modifyAttributes( JndiUtils.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
- assertTrue( "normalizer OID should still be present",
+ assertTrue( "normalizer OID should still be present",
schemaManager.getNormalizerRegistry().contains( OID ) );
-
- assertEquals( "normalizer schema should be set to apachemeta",
+
+ assertEquals( "normalizer schema should be set to apachemeta",
schemaManager.getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
Class<?> clazz = schemaManager.getNormalizerRegistry().lookup( OID ).getClass();
assertEquals( clazz, DeepTrimNormalizer.class );
}
-
+
// ----------------------------------------------------------------------
// Test move, rename, and delete when a MR exists and uses the Normalizer
@@ -422,9 +422,9 @@ public class MetaNormalizerHandlerIT ext
testAddNormalizerToEnabledSchema();
assertTrue( isOnDisk( nDn ) );
assertTrue( service.getSchemaManager().getNormalizerRegistry().contains( OID ) );
-
+
// Create a MR using this Normalizer
- Attributes attrs = LdifUtils.createAttributes(
+ Attributes attrs = LdifUtils.createAttributes(
"objectClass: top",
"objectClass: metaTop",
"objectClass: metaMatchingRule",
@@ -440,7 +440,7 @@ public class MetaNormalizerHandlerIT ext
assertFalse( service.getSchemaManager().getMatchingRuleRegistry().contains( OID ) );
// MatchingRule Addition
- getSchemaContext( service ).createSubcontext( DN.toName( mrDn ), attrs );
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( mrDn ), attrs );
// Post-checks
assertTrue( isOnDisk( mrDn ) );
@@ -448,7 +448,7 @@ public class MetaNormalizerHandlerIT ext
try
{
- getSchemaContext( service ).destroySubcontext( DN.toName( nDn ) );
+ getSchemaContext( service ).destroySubcontext( JndiUtils.toName( nDn ) );
fail( "should not be able to delete a Normalizer in use" );
}
catch ( OperationNotSupportedException e )
@@ -458,31 +458,31 @@ public class MetaNormalizerHandlerIT ext
assertTrue( "Normalizer should still be in the registry after delete failure", schemaManager
.getNormalizerRegistry().contains( OID ) );
}
-
-
+
+
@Test
@Ignore
public void testMoveNormalizerWhenInUse() throws Exception
{
testAddNormalizerToEnabledSchema();
schemaManager.getMatchingRuleRegistry().register( new DummyMR() );
-
+
DN dn = getNormalizerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
DN newdn = getNormalizerContainer( "apache" );
newdn = newdn.add( "m-oid" + "=" + OID );
-
+
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
fail( "should not be able to move a normalizer in use" );
}
- catch( OperationNotSupportedException e )
+ catch( OperationNotSupportedException e )
{
}
- assertTrue( "normalizer should still be in the registry after move failure",
+ assertTrue( "normalizer should still be in the registry after move failure",
schemaManager.getNormalizerRegistry().contains( OID ) );
schemaManager.getMatchingRuleRegistry().unregister( OID );
schemaManager.getGlobalOidRegistry().unregister( OID );
@@ -495,29 +495,29 @@ public class MetaNormalizerHandlerIT ext
{
testAddNormalizerToEnabledSchema();
schemaManager.getMatchingRuleRegistry().register( new DummyMR() );
-
+
DN dn = getNormalizerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
DN newdn = getNormalizerContainer( "apache" );
newdn = newdn.add( "m-oid" + "=" + NEW_OID );
-
+
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
fail( "should not be able to move a normalizer in use" );
}
- catch( OperationNotSupportedException e )
+ catch( OperationNotSupportedException e )
{
}
- assertTrue( "normalizer should still be in the registry after move failure",
+ assertTrue( "normalizer should still be in the registry after move failure",
schemaManager.getNormalizerRegistry().contains( OID ) );
schemaManager.getMatchingRuleRegistry().unregister( OID );
schemaManager.getGlobalOidRegistry().unregister( OID );
}
-
+
@Test
@Ignore
public void testRenameNormalizerWhenInUse() throws Exception
@@ -526,20 +526,20 @@ public class MetaNormalizerHandlerIT ext
dn = dn.add( "m-oid" + "=" + OID );
testAddNormalizerToEnabledSchema();
schemaManager.getMatchingRuleRegistry().register( new DummyMR() );
-
+
DN newdn = getNormalizerContainer( "apachemeta" );
newdn = newdn.add( "m-oid" + "=" + NEW_OID );
-
+
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
fail( "should not be able to rename a normalizer in use" );
}
- catch( OperationNotSupportedException e )
+ catch( OperationNotSupportedException e )
{
}
- assertTrue( "normalizer should still be in the registry after rename failure",
+ assertTrue( "normalizer should still be in the registry after rename failure",
schemaManager.getNormalizerRegistry().contains( OID ) );
schemaManager.getMatchingRuleRegistry().unregister( OID );
schemaManager.getGlobalOidRegistry().unregister( OID );
@@ -556,24 +556,24 @@ public class MetaNormalizerHandlerIT ext
public void testMoveNormalizerToTop() throws Exception
{
testAddNormalizerToEnabledSchema();
-
+
DN dn = getNormalizerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
DN top = new DN();
top = top.add( "m-oid" + "=" + OID );
-
+
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( top ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( top ) );
fail( "should not be able to move a normalizer up to ou=schema" );
}
- catch( LdapInvalidDnException e )
+ catch( LdapInvalidDnException e )
{
assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
}
- assertTrue( "normalizer should still be in the registry after move failure",
+ assertTrue( "normalizer should still be in the registry after move failure",
schemaManager.getNormalizerRegistry().contains( OID ) );
}
@@ -583,24 +583,24 @@ public class MetaNormalizerHandlerIT ext
public void testMoveNormalizerToComparatorContainer() throws Exception
{
testAddNormalizerToEnabledSchema();
-
+
DN dn = getNormalizerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
DN newdn = new DN( "ou=comparators,cn=apachemeta" );
newdn = newdn.add( "m-oid" + "=" + OID );
-
+
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
fail( "should not be able to move a normalizer into comparators container" );
}
- catch( LdapInvalidDnException e )
+ catch( LdapInvalidDnException e )
{
assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
}
- assertTrue( "normalizer should still be in the registry after move failure",
+ assertTrue( "normalizer should still be in the registry after move failure",
schemaManager.getNormalizerRegistry().contains( OID ) );
}
@@ -610,17 +610,17 @@ public class MetaNormalizerHandlerIT ext
public void testMoveNormalizerToDisabledSchema() throws Exception
{
testAddNormalizerToEnabledSchema();
-
+
DN dn = getNormalizerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
// nis is inactive by default
DN newdn = getNormalizerContainer( "nis" );
newdn = newdn.add( "m-oid" + "=" + OID );
-
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
- assertFalse( "normalizer OID should no longer be present",
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+
+ assertFalse( "normalizer OID should no longer be present",
schemaManager.getNormalizerRegistry().contains( OID ) );
}
@@ -630,23 +630,23 @@ public class MetaNormalizerHandlerIT ext
public void testMoveNormalizerToEnabledSchema() throws Exception
{
testAddNormalizerToDisabledSchema();
-
+
// nis is inactive by default
DN dn = getNormalizerContainer( "nis" );
dn = dn.add( "m-oid" + "=" + OID );
- assertFalse( "normalizer OID should NOT be present when added to disabled nis schema",
+ assertFalse( "normalizer OID should NOT be present when added to disabled nis schema",
schemaManager.getNormalizerRegistry().contains( OID ) );
DN newdn = getNormalizerContainer( "apachemeta" );
newdn = newdn.add( "m-oid" + "=" + OID );
-
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
- assertTrue( "normalizer OID should be present when moved to enabled schema",
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+
+ assertTrue( "normalizer OID should be present when moved to enabled schema",
schemaManager.getNormalizerRegistry().contains( OID ) );
-
- assertEquals( "normalizer should be in apachemeta schema after move",
+
+ assertEquals( "normalizer should be in apachemeta schema after move",
schemaManager.getNormalizerRegistry().getSchemaName( OID ), "apachemeta" );
}
Modified: directory/apacheds/branches/apacheds-codec-merge/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-codec-merge/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java?rev=982989&r1=982988&r2=982989&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-codec-merge/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java (original)
+++ directory/apacheds/branches/apacheds-codec-merge/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerIT.java Fri Aug 6 14:28:50 2010
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.directory.server.core.schema;
@@ -39,6 +39,7 @@ import javax.naming.directory.Modificati
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.jndi.JndiUtils;
import org.apache.directory.shared.ldap.ldif.LdifUtils;
import org.apache.directory.shared.ldap.name.DN;
import org.apache.directory.shared.ldap.schema.ObjectClass;
@@ -63,7 +64,7 @@ public class MetaObjectClassHandlerIT ex
private static final String DESCRIPTION0 = "A test objectClass";
private static final String DESCRIPTION1 = "An alternate description";
-
+
private static final String OID = "1.3.6.1.4.1.18060.0.4.0.3.100000";
private static final String NEW_OID = "1.3.6.1.4.1.18060.0.4.0.3.100001";
private static final String DEPENDEE_OID = "1.3.6.1.4.1.18060.0.4.0.3.100002";
@@ -73,11 +74,11 @@ public class MetaObjectClassHandlerIT ex
{
return service.getSchemaManager().getObjectClassRegistry();
}
-
-
+
+
private DN addObjectClass() throws Exception
{
- Attributes attrs = LdifUtils.createAttributes(
+ Attributes attrs = LdifUtils.createAttributes(
"objectClass: top",
"objectClass: metaTop",
"objectClass: metaObjectClass",
@@ -87,15 +88,15 @@ public class MetaObjectClassHandlerIT ex
"m-typeObjectClass: AUXILIARY",
"m-must: cn",
"m-may: ou" );
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
return dn;
}
-
+
// ----------------------------------------------------------------------
// Test all core methods with normal operational pathways
// ----------------------------------------------------------------------
@@ -103,19 +104,19 @@ public class MetaObjectClassHandlerIT ex
public void testAddObjectClassToEnabledSchema() throws Exception
{
DN dn = addObjectClass();
-
+
assertTrue( getObjectClassRegistry().contains( OID ) );
assertEquals( getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
assertTrue( isOnDisk( dn ) );
}
-
-
+
+
@Test
public void testAddObjectClassToDisabledSchema() throws Exception
{
DN dn = addObjectClassToDisabledSchema();
-
- assertFalse( "adding new objectClass to disabled schema should not register it into the registries",
+
+ assertFalse( "adding new objectClass to disabled schema should not register it into the registries",
getObjectClassRegistry().contains( OID ) );
assertTrue( isOnDisk( dn ) );
}
@@ -124,7 +125,7 @@ public class MetaObjectClassHandlerIT ex
@Test
public void testAddObjectClassToUnloadedSchema() throws Exception
{
- Attributes attrs = LdifUtils.createAttributes(
+ Attributes attrs = LdifUtils.createAttributes(
"objectClass: top",
"objectClass: metaTop",
"objectClass: metaObjectClass",
@@ -137,18 +138,18 @@ public class MetaObjectClassHandlerIT ex
DN dn = getObjectClassContainer( "notloaded" );
dn = dn.add( "m-oid" + "=" + OID );
-
+
try
{
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
fail( "Should not be there" );
}
catch( NameNotFoundException nnfe )
{
// Excpected result
}
-
- assertFalse( "adding new objectClass to disabled schema should not register it into the registries",
+
+ assertFalse( "adding new objectClass to disabled schema should not register it into the registries",
getObjectClassRegistry().contains( OID ) );
assertFalse( isOnDisk( dn ) );
}
@@ -161,13 +162,13 @@ public class MetaObjectClassHandlerIT ex
dn = dn.add( "m-oid" + "=" + OID );
addObjectClass();
- assertTrue( "objectClass should be removed from the registry after being deleted",
+ assertTrue( "objectClass should be removed from the registry after being deleted",
getObjectClassRegistry().contains( OID ) );
assertTrue( isOnDisk( dn ) );
- getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
+ getSchemaContext( service ).destroySubcontext( JndiUtils.toName( dn ) );
- assertFalse( "objectClass should be removed from the registry after being deleted",
+ assertFalse( "objectClass should be removed from the registry after being deleted",
getObjectClassRegistry().contains( OID ) );
try
@@ -182,21 +183,21 @@ public class MetaObjectClassHandlerIT ex
assertFalse( isOnDisk( dn ) );
}
-
+
@Test
public void testDeleteObjectClassFromDisabledSchema() throws Exception
{
DN dn = getObjectClassContainer( "nis" );
dn = dn.add( "m-oid" + "=" + OID );
addObjectClassToDisabledSchema();
-
- assertFalse( "objectClass should be removed from the registry after being deleted",
+
+ assertFalse( "objectClass should be removed from the registry after being deleted",
getObjectClassRegistry().contains( OID ) );
assertTrue( isOnDisk( dn ) );
-
- getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
- assertFalse( "objectClass should be removed from the registry after being deleted",
+ getSchemaContext( service ).destroySubcontext( JndiUtils.toName( dn ) );
+
+ assertFalse( "objectClass should be removed from the registry after being deleted",
getObjectClassRegistry().contains( OID ) );
try
@@ -207,10 +208,10 @@ public class MetaObjectClassHandlerIT ex
catch( LdapException e )
{
}
-
+
assertFalse( isOnDisk( dn ) );
}
-
+
@Test
@Ignore
@@ -219,12 +220,12 @@ public class MetaObjectClassHandlerIT ex
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
addObjectClass();
-
+
DN newdn = getObjectClassContainer( "apachemeta" );
newdn = newdn.add( "m-oid" + "=" + NEW_OID );
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
- assertFalse( "old objectClass OID should be removed from the registry after being renamed",
+ assertFalse( "old objectClass OID should be removed from the registry after being renamed",
getObjectClassRegistry().contains( OID ) );
//noinspection EmptyCatchBlock
@@ -246,19 +247,19 @@ public class MetaObjectClassHandlerIT ex
public void testMoveObjectClass() throws Exception
{
addObjectClass();
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
DN newdn = getObjectClassContainer( "apache" );
newdn = newdn.add( "m-oid" + "=" + OID );
-
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
- assertTrue( "objectClass OID should still be present",
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+
+ assertTrue( "objectClass OID should still be present",
getObjectClassRegistry().contains( OID ) );
-
- assertEquals( "objectClass schema should be set to apache not apachemeta",
+
+ assertEquals( "objectClass schema should be set to apache not apachemeta",
getObjectClassRegistry().getSchemaName( OID ), "apache" );
}
@@ -268,87 +269,87 @@ public class MetaObjectClassHandlerIT ex
public void testMoveObjectClassAndChangeRdn() throws Exception
{
addObjectClass();
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
DN newdn = getObjectClassContainer( "apache" );
newdn = newdn.add( "m-oid" + "=" + NEW_OID );
-
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
- assertFalse( "old objectClass OID should NOT be present",
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+
+ assertFalse( "old objectClass OID should NOT be present",
getObjectClassRegistry().contains( OID ) );
-
- assertTrue( "new objectClass OID should be present",
+
+ assertTrue( "new objectClass OID should be present",
getObjectClassRegistry().contains( NEW_OID ) );
-
- assertEquals( "objectClass with new oid should have schema set to apache NOT apachemeta",
+
+ assertEquals( "objectClass with new oid should have schema set to apache NOT apachemeta",
getObjectClassRegistry().getSchemaName( NEW_OID ), "apache" );
}
-
+
@Test
@Ignore
public void testModifyObjectClassWithModificationItems() throws Exception
{
addObjectClass();
-
+
ObjectClass oc = getObjectClassRegistry().lookup( OID );
assertEquals( oc.getDescription(), DESCRIPTION0 );
assertEquals( oc.getName(), NAME );
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
-
+
ModificationItem[] mods = new ModificationItem[2];
Attribute attr = new BasicAttribute( "m-description", DESCRIPTION1 );
mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
attr = new BasicAttribute( "m-name", NEW_NAME );
mods[1] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
- getSchemaContext( service ).modifyAttributes( DN.toName( dn ), mods );
+ getSchemaContext( service ).modifyAttributes( JndiUtils.toName( dn ), mods );
- assertTrue( "objectClass OID should still be present",
+ assertTrue( "objectClass OID should still be present",
getObjectClassRegistry().contains( OID ) );
-
- assertEquals( "objectClass schema should be set to apachemeta",
+
+ assertEquals( "objectClass schema should be set to apachemeta",
getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
-
+
oc = getObjectClassRegistry().lookup( OID );
assertEquals( oc.getDescription(), DESCRIPTION1 );
assertEquals( oc.getName(), NEW_NAME );
}
-
+
@Test
@Ignore
public void testModifyObjectClassWithAttributes() throws Exception
{
addObjectClass();
-
+
ObjectClass oc = getObjectClassRegistry().lookup( OID );
assertEquals( oc.getDescription(), DESCRIPTION0 );
assertEquals( oc.getName(), NAME );
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
-
+
Attributes mods = new BasicAttributes( true );
mods.put( "m-description", DESCRIPTION1 );
mods.put( "m-name", NEW_NAME );
- getSchemaContext( service ).modifyAttributes( DN.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
+ getSchemaContext( service ).modifyAttributes( JndiUtils.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
- assertTrue( "objectClass OID should still be present",
+ assertTrue( "objectClass OID should still be present",
getObjectClassRegistry().contains( OID ) );
-
- assertEquals( "objectClass schema should be set to apachemeta",
+
+ assertEquals( "objectClass schema should be set to apachemeta",
getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
oc = getObjectClassRegistry().lookup( OID );
assertEquals( oc.getDescription(), DESCRIPTION1 );
assertEquals( oc.getName(), NEW_NAME );
}
-
+
// ----------------------------------------------------------------------
// Test move, rename, and delete when a OC exists and uses the OC as sup
@@ -367,16 +368,16 @@ public class MetaObjectClassHandlerIT ex
attrs.put( "m-must", "cn" );
attrs.put( "m-may", "ou" );
attrs.put( "m-supObjectClass", OID );
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + DEPENDEE_OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
assertTrue( getObjectClassRegistry().contains( DEPENDEE_OID ) );
assertEquals( getObjectClassRegistry().getSchemaName( DEPENDEE_OID ), "apachemeta" );
}
-
+
@Test
public void testDeleteObjectClassWhenInUse() throws Exception
{
@@ -384,44 +385,44 @@ public class MetaObjectClassHandlerIT ex
dn = dn.add( "m-oid" + "=" + OID );
addObjectClass();
addDependeeObjectClass();
-
+
try
{
- getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
+ getSchemaContext( service ).destroySubcontext( JndiUtils.toName( dn ) );
fail( "should not be able to delete a objectClass in use" );
}
- catch( OperationNotSupportedException e )
+ catch( OperationNotSupportedException e )
{
}
- assertTrue( "objectClass should still be in the registry after delete failure",
+ assertTrue( "objectClass should still be in the registry after delete failure",
getObjectClassRegistry().contains( OID ) );
}
-
-
+
+
@Test
@Ignore
public void testMoveObjectClassWhenInUse() throws Exception
{
addObjectClass();
addDependeeObjectClass();
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
DN newdn = getObjectClassContainer( "apache" );
newdn = newdn.add( "m-oid" + "=" + OID );
-
+
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
fail( "should not be able to move a objectClass in use" );
}
- catch( OperationNotSupportedException e )
+ catch( OperationNotSupportedException e )
{
}
- assertTrue( "objectClass should still be in the registry after move failure",
+ assertTrue( "objectClass should still be in the registry after move failure",
getObjectClassRegistry().contains( OID ) );
}
@@ -432,27 +433,27 @@ public class MetaObjectClassHandlerIT ex
{
addObjectClass();
addDependeeObjectClass();
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
DN newdn = getObjectClassContainer( "apache" );
newdn = newdn.add( "m-oid" + "=" + NEW_OID );
-
+
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
fail( "should not be able to move an objectClass in use" );
}
- catch( OperationNotSupportedException e )
+ catch( OperationNotSupportedException e )
{
}
- assertTrue( "ObjectClass should still be in the registry after move failure",
+ assertTrue( "ObjectClass should still be in the registry after move failure",
getObjectClassRegistry().contains( OID ) );
}
-
+
@Test
@Ignore
public void testRenameObjectClassWhenInUse() throws Exception
@@ -461,20 +462,20 @@ public class MetaObjectClassHandlerIT ex
dn = dn.add( "m-oid" + "=" + OID );
addObjectClass();
addDependeeObjectClass();
-
+
DN newdn = getObjectClassContainer( "apachemeta" );
newdn = newdn.add( "m-oid" + "=" + NEW_OID );
-
+
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
fail( "should not be able to rename an objectClass in use" );
}
- catch( OperationNotSupportedException e )
+ catch( OperationNotSupportedException e )
{
}
- assertTrue( "objectClass should still be in the registry after rename failure",
+ assertTrue( "objectClass should still be in the registry after rename failure",
getObjectClassRegistry().contains( OID ) );
}
@@ -487,23 +488,23 @@ public class MetaObjectClassHandlerIT ex
public void testMoveObjectClassToTop() throws Exception
{
addObjectClass();
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
DN top = new DN();
top.add( "m-oid" + "=" + OID );
-
+
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( top ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( top ) );
fail( "should not be able to move a objectClass up to ou=schema" );
}
- catch( InvalidNameException e )
+ catch( InvalidNameException e )
{
}
- assertTrue( "objectClass should still be in the registry after move failure",
+ assertTrue( "objectClass should still be in the registry after move failure",
getObjectClassRegistry().contains( OID ) );
}
@@ -513,30 +514,30 @@ public class MetaObjectClassHandlerIT ex
public void testMoveObjectClassToComparatorContainer() throws Exception
{
addObjectClass();
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
DN newdn = new DN( "ou=comparators,cn=apachemeta" );
newdn = newdn.add( "m-oid" + "=" + OID );
-
+
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
fail( "should not be able to move a objectClass into comparators container" );
}
- catch( InvalidNameException e )
+ catch( InvalidNameException e )
{
}
- assertTrue( "objectClass should still be in the registry after move failure",
+ assertTrue( "objectClass should still be in the registry after move failure",
getObjectClassRegistry().contains( OID ) );
}
-
+
private DN addObjectClassToDisabledSchema() throws Exception
{
- Attributes attrs = LdifUtils.createAttributes(
+ Attributes attrs = LdifUtils.createAttributes(
"objectClass: top",
"objectClass: metaTop",
"objectClass: metaObjectClass",
@@ -549,28 +550,28 @@ public class MetaObjectClassHandlerIT ex
DN dn = getObjectClassContainer( "nis" );
dn = dn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
return dn;
}
-
-
+
+
@Test
@Ignore
public void testMoveObjectClassToDisabledSchema() throws Exception
{
addObjectClass();
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
// nis is inactive by default
DN newdn = getObjectClassContainer( "nis" );
newdn = newdn.add( "m-oid" + "=" + OID );
-
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
- assertFalse( "objectClass OID should no longer be present",
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+
+ assertFalse( "objectClass OID should no longer be present",
getObjectClassRegistry().contains( OID ) );
}
@@ -580,26 +581,26 @@ public class MetaObjectClassHandlerIT ex
public void testMoveObjectClassToEnabledSchema() throws Exception
{
addObjectClassToDisabledSchema();
-
+
// nis is inactive by default
DN dn = getObjectClassContainer( "nis" );
dn = dn.add( "m-oid" + "=" + OID );
- assertFalse( "objectClass OID should NOT be present when added to disabled nis schema",
+ assertFalse( "objectClass OID should NOT be present when added to disabled nis schema",
getObjectClassRegistry().contains( OID ) );
DN newdn = getObjectClassContainer( "apachemeta" );
newdn = newdn.add( "m-oid" + "=" + OID );
-
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
- assertTrue( "objectClass OID should be present when moved to enabled schema",
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+
+ assertTrue( "objectClass OID should be present when moved to enabled schema",
getObjectClassRegistry().contains( OID ) );
-
- assertEquals( "objectClass should be in apachemeta schema after move",
+
+ assertEquals( "objectClass should be in apachemeta schema after move",
getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
}
-
+
// ----------------------------------------------------------------------
// Let's test the Abstract, Auiliary and Structural inheritence enforcement
// ----------------------------------------------------------------------
@@ -614,7 +615,7 @@ public class MetaObjectClassHandlerIT ex
oc.add( "metaTop" );
oc.add( "metaObjectClass" );
attrs.put( oc );
-
+
attrs.put( "m-oid", OID );
attrs.put( "m-name", "abstractOCtest");
attrs.put( "m-description", "An abstract oC inheriting from top" );
@@ -622,16 +623,16 @@ public class MetaObjectClassHandlerIT ex
attrs.put( "m-supObjectClass", "top" );
attrs.put( "m-must", "cn" );
attrs.put( "m-may", "ou" );
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
assertTrue( getObjectClassRegistry().contains( OID ) );
assertEquals( getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
}
-
+
/**
* Check that we can't create an ABSTRACT OC which inherit from an AUXILIARY OC
*/
@@ -643,25 +644,25 @@ public class MetaObjectClassHandlerIT ex
oc.add( "metaTop" );
oc.add( "metaObjectClass" );
attrs.put( oc );
-
+
attrs.put( "m-oid", OID );
attrs.put( "m-name", "abstractOCtest");
attrs.put( "m-description", "An abstract oC inheriting from top" );
attrs.put( "m-typeObjectClass", "ABSTRACT" );
attrs.put( "m-must", "cn" );
attrs.put( "m-may", "ou" );
-
+
Attribute sup = new BasicAttribute( "m-supObjectClass" );
sup.add( "top" );
sup.add( "javaSerializedObject");
attrs.put( sup );
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
-
+
try
{
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
fail();
}
catch ( NamingException ne )
@@ -669,8 +670,8 @@ public class MetaObjectClassHandlerIT ex
assertTrue( true );
}
}
-
-
+
+
/**
* Check that we can't create an ABSTRACT OC which inherit from an STRUCTURAL OC
*/
@@ -682,25 +683,25 @@ public class MetaObjectClassHandlerIT ex
oc.add( "metaTop" );
oc.add( "metaObjectClass" );
attrs.put( oc );
-
+
attrs.put( "m-oid", OID );
attrs.put( "m-name", "abstractOCtest");
attrs.put( "m-description", "An abstract oC inheriting from top" );
attrs.put( "m-typeObjectClass", "ABSTRACT" );
attrs.put( "m-must", "cn" );
attrs.put( "m-may", "ou" );
-
+
Attribute sup = new BasicAttribute( "m-supObjectClass" );
sup.add( "top" );
sup.add( "person");
attrs.put( sup );
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
-
+
try
{
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
fail();
}
catch ( NamingException ne )
@@ -708,8 +709,8 @@ public class MetaObjectClassHandlerIT ex
assertTrue( true );
}
}
-
-
+
+
/**
* Check that we can create an AUXILIARY OC which inherit from an ABSTRACT OC
*/
@@ -721,7 +722,7 @@ public class MetaObjectClassHandlerIT ex
oc.add( "metaTop" );
oc.add( "metaObjectClass" );
attrs.put( oc );
-
+
attrs.put( "m-oid", NEW_OID );
attrs.put( "m-name", "abstractOCtest");
attrs.put( "m-description", "An abstract oC inheriting from top" );
@@ -729,16 +730,16 @@ public class MetaObjectClassHandlerIT ex
attrs.put( "m-supObjectClass", "top" );
attrs.put( "m-must", "cn" );
attrs.put( "m-may", "ou" );
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + NEW_OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
assertTrue( getObjectClassRegistry().contains( NEW_OID ) );
assertEquals( getObjectClassRegistry().getSchemaName( NEW_OID ), "apachemeta" );
}
-
+
/**
* Check that we can create an AUXILIARY OC which inherit from an AUXILIARY OC
*/
@@ -750,14 +751,14 @@ public class MetaObjectClassHandlerIT ex
oc.add( "metaTop" );
oc.add( "metaObjectClass" );
attrs.put( oc );
-
+
attrs.put( "m-oid", NEW_OID );
attrs.put( "m-name", "abstractOCtest");
attrs.put( "m-description", "An abstract oC inheriting from top" );
attrs.put( "m-typeObjectClass", "AUXILIARY" );
attrs.put( "m-must", "cn" );
attrs.put( "m-may", "ou" );
-
+
Attribute sup = new BasicAttribute( "m-supObjectClass" );
sup.add( "top" );
sup.add( "javaNamingReference");
@@ -765,13 +766,13 @@ public class MetaObjectClassHandlerIT ex
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + NEW_OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
assertTrue( getObjectClassRegistry().contains( NEW_OID ) );
assertEquals( getObjectClassRegistry().getSchemaName( NEW_OID ), "apachemeta" );
}
-
+
/**
* Check that we can't create an Auxiliary OC which inherit from an STRUCTURAL OC
*/
@@ -783,25 +784,25 @@ public class MetaObjectClassHandlerIT ex
oc.add( "metaTop" );
oc.add( "metaObjectClass" );
attrs.put( oc );
-
+
attrs.put( "m-oid", OID );
attrs.put( "m-name", "abstractOCtest");
attrs.put( "m-description", "An abstract oC inheriting from top" );
attrs.put( "m-typeObjectClass", "ABSTRACT" );
attrs.put( "m-must", "cn" );
attrs.put( "m-may", "ou" );
-
+
Attribute sup = new BasicAttribute( "m-supObjectClass" );
sup.add( "top" );
sup.add( "person");
attrs.put( sup );
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
-
+
try
{
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
fail();
}
catch ( NamingException ne )
@@ -810,7 +811,7 @@ public class MetaObjectClassHandlerIT ex
}
}
-
+
/**
* Check that we can create a STRUCTURAL OC which inherit from an ABSTRACT OC
*/
@@ -822,7 +823,7 @@ public class MetaObjectClassHandlerIT ex
oc.add( "metaTop" );
oc.add( "metaObjectClass" );
attrs.put( oc );
-
+
attrs.put( "m-oid", NEW_OID );
attrs.put( "m-name", "abstractOCtest");
attrs.put( "m-description", "An abstract oC inheriting from top" );
@@ -830,16 +831,16 @@ public class MetaObjectClassHandlerIT ex
attrs.put( "m-supObjectClass", "top" );
attrs.put( "m-must", "cn" );
attrs.put( "m-may", "ou" );
-
+
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + NEW_OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
assertTrue( getObjectClassRegistry().contains( NEW_OID ) );
assertEquals( getObjectClassRegistry().getSchemaName( NEW_OID ), "apachemeta" );
}
-
+
/**
* Check that we can create a STRUCTURAL OC which inherit from an AUXILIARY OC
*/
@@ -851,14 +852,14 @@ public class MetaObjectClassHandlerIT ex
oc.add( "metaTop" );
oc.add( "metaObjectClass" );
attrs.put( oc );
-
+
attrs.put( "m-oid", NEW_OID );
attrs.put( "m-name", "abstractOCtest");
attrs.put( "m-description", "An abstract oC inheriting from top" );
attrs.put( "m-typeObjectClass", "STRUCTURAL" );
attrs.put( "m-must", "cn" );
attrs.put( "m-may", "ou" );
-
+
Attribute sup = new BasicAttribute( "m-supObjectClass" );
sup.add( "top" );
sup.add( "javaNamingReference");
@@ -866,10 +867,10 @@ public class MetaObjectClassHandlerIT ex
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + NEW_OID );
-
+
try
{
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
fail();
}
catch ( NamingException ne )
@@ -878,7 +879,7 @@ public class MetaObjectClassHandlerIT ex
}
}
-
+
/**
* Check that we can create a STRUCTURAL OC which inherit from an STRUCTURAL OC
*/
@@ -890,14 +891,14 @@ public class MetaObjectClassHandlerIT ex
oc.add( "metaTop" );
oc.add( "metaObjectClass" );
attrs.put( oc );
-
+
attrs.put( "m-oid", NEW_OID );
attrs.put( "m-name", "abstractOCtest");
attrs.put( "m-description", "An abstract oC inheriting from top" );
attrs.put( "m-typeObjectClass", "STRUCTURAL" );
attrs.put( "m-must", "cn" );
attrs.put( "m-may", "ou" );
-
+
Attribute sup = new BasicAttribute( "m-supObjectClass" );
sup.add( "top" );
sup.add( "person");
@@ -905,8 +906,8 @@ public class MetaObjectClassHandlerIT ex
DN dn = getObjectClassContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + NEW_OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
assertTrue( getObjectClassRegistry().contains( NEW_OID ) );
assertEquals( getObjectClassRegistry().getSchemaName( NEW_OID ), "apachemeta" );
}
Modified: directory/apacheds/branches/apacheds-codec-merge/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-codec-merge/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.java?rev=982989&r1=982988&r2=982989&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-codec-merge/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.java (original)
+++ directory/apacheds/branches/apacheds-codec-merge/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerIT.java Fri Aug 6 14:28:50 2010
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.directory.server.core.schema;
@@ -41,6 +41,7 @@ import javax.naming.directory.Modificati
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.jndi.JndiUtils;
import org.apache.directory.shared.ldap.ldif.LdifUtils;
import org.apache.directory.shared.ldap.name.DN;
import org.apache.directory.shared.ldap.schema.LdapSyntax;
@@ -87,7 +88,7 @@ public class MetaSyntaxCheckerHandlerIT
DN dn = getSyntaxCheckerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
assertTrue( schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
assertEquals( schemaManager.getSyntaxCheckerRegistry().getSchemaName( OID ), "apachemeta" );
@@ -107,7 +108,7 @@ public class MetaSyntaxCheckerHandlerIT
// nis is by default inactive
DN dn = getSyntaxCheckerContainer( "nis" );
dn = dn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
assertFalse( "adding new syntaxChecker to disabled schema should not register it into the registries",
schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
@@ -128,7 +129,7 @@ public class MetaSyntaxCheckerHandlerIT
try
{
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
fail( "Should not be there" );
}
catch ( NameNotFoundException nnfe )
@@ -160,7 +161,7 @@ public class MetaSyntaxCheckerHandlerIT
DN dn = getSyntaxCheckerContainer( "apachemeta" );
dn = dn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
assertTrue( schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
assertEquals( schemaManager.getSyntaxCheckerRegistry().getSchemaName( OID ), "apachemeta" );
@@ -188,7 +189,7 @@ public class MetaSyntaxCheckerHandlerIT
DN dn = getSyntaxCheckerContainer( "nis" );
dn = dn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
assertFalse( schemaManager.getSyntaxCheckerRegistry().contains( OID ) );
assertTrue( isOnDisk( dn ) );
@@ -206,7 +207,7 @@ public class MetaSyntaxCheckerHandlerIT
.getSyntaxCheckerRegistry().contains( OID ) );
assertTrue( isOnDisk( dn ) );
- getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
+ getSchemaContext( service ).destroySubcontext( JndiUtils.toName( dn ) );
assertFalse( "syntaxChecker should be removed from the registry after being deleted", schemaManager
.getSyntaxCheckerRegistry().contains( OID ) );
@@ -235,7 +236,7 @@ public class MetaSyntaxCheckerHandlerIT
.getSyntaxCheckerRegistry().contains( OID ) );
assertTrue( isOnDisk( dn ) );
- getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
+ getSchemaContext( service ).destroySubcontext( JndiUtils.toName( dn ) );
assertFalse( "syntaxChecker should be removed from the registry after being deleted", schemaManager
.getSyntaxCheckerRegistry().contains( OID ) );
@@ -263,7 +264,7 @@ public class MetaSyntaxCheckerHandlerIT
DN newdn = getSyntaxCheckerContainer( "apachemeta" );
newdn = newdn.add( "m-oid" + "=" + NEW_OID );
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
assertFalse( "old syntaxChecker OID should be removed from the registry after being renamed", schemaManager
.getSyntaxCheckerRegistry().contains( OID ) );
@@ -296,7 +297,7 @@ public class MetaSyntaxCheckerHandlerIT
DN newdn = getSyntaxCheckerContainer( "apache" );
newdn = newdn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
assertTrue( "syntaxChecker OID should still be present", schemaManager.getSyntaxCheckerRegistry()
.contains( OID ) );
@@ -321,7 +322,7 @@ public class MetaSyntaxCheckerHandlerIT
DN newdn = getSyntaxCheckerContainer( "apache" );
newdn = newdn.add( "m-oid" + "=" + NEW_OID );
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
assertFalse( "old syntaxChecker OID should NOT be present", schemaManager.getSyntaxCheckerRegistry().contains(
OID ) );
@@ -349,7 +350,7 @@ public class MetaSyntaxCheckerHandlerIT
ModificationItem[] mods = new ModificationItem[1];
Attribute attr = new BasicAttribute( "m-fqcn", BogusSyntaxChecker.class.getName() );
mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
- getSchemaContext( service ).modifyAttributes( DN.toName( dn ), mods );
+ getSchemaContext( service ).modifyAttributes( JndiUtils.toName( dn ), mods );
assertTrue( "syntaxChecker OID should still be present", schemaManager.getSyntaxCheckerRegistry()
.contains( OID ) );
@@ -373,7 +374,7 @@ public class MetaSyntaxCheckerHandlerIT
Attributes mods = new BasicAttributes( true );
mods.put( "m-fqcn", BogusSyntaxChecker.class.getName() );
- getSchemaContext( service ).modifyAttributes( DN.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
+ getSchemaContext( service ).modifyAttributes( JndiUtils.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
assertTrue( "syntaxChecker OID should still be present", schemaManager.getSyntaxCheckerRegistry()
.contains( OID ) );
@@ -412,7 +413,7 @@ public class MetaSyntaxCheckerHandlerIT
assertFalse( service.getSchemaManager().getLdapSyntaxRegistry().contains( OID ) );
// Syntax Addition
- getSchemaContext( service ).createSubcontext( DN.toName( sDn ), attrs );
+ getSchemaContext( service ).createSubcontext( JndiUtils.toName( sDn ), attrs );
// Post-checks
assertTrue( isOnDisk( sDn ) );
@@ -420,7 +421,7 @@ public class MetaSyntaxCheckerHandlerIT
try
{
- getSchemaContext( service ).destroySubcontext( DN.toName( scDn ) );
+ getSchemaContext( service ).destroySubcontext( JndiUtils.toName( scDn ) );
fail( "should not be able to delete a syntaxChecker in use" );
}
catch ( OperationNotSupportedException e )
@@ -447,7 +448,7 @@ public class MetaSyntaxCheckerHandlerIT
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
fail( "should not be able to move a syntaxChecker in use" );
}
catch ( OperationNotSupportedException e )
@@ -476,7 +477,7 @@ public class MetaSyntaxCheckerHandlerIT
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
fail( "should not be able to move a syntaxChecker in use" );
}
catch ( OperationNotSupportedException e )
@@ -504,7 +505,7 @@ public class MetaSyntaxCheckerHandlerIT
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
fail( "should not be able to rename a syntaxChecker in use" );
}
catch ( OperationNotSupportedException e )
@@ -536,7 +537,7 @@ public class MetaSyntaxCheckerHandlerIT
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( top ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( top ) );
fail( "should not be able to move a syntaxChecker up to ou=schema" );
}
catch ( InvalidNameException e )
@@ -562,7 +563,7 @@ public class MetaSyntaxCheckerHandlerIT
try
{
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
fail( "should not be able to move a syntaxChecker into comparators container" );
}
catch ( InvalidNameException e )
@@ -587,7 +588,7 @@ public class MetaSyntaxCheckerHandlerIT
DN newdn = getSyntaxCheckerContainer( "nis" );
newdn = newdn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
assertFalse( "syntaxChecker OID should no longer be present", schemaManager.getSyntaxCheckerRegistry()
.contains( OID ) );
@@ -610,7 +611,7 @@ public class MetaSyntaxCheckerHandlerIT
DN newdn = getSyntaxCheckerContainer( "apachemeta" );
newdn = newdn.add( "m-oid" + "=" + OID );
- getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+ getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
assertTrue( "syntaxChecker OID should be present when moved to enabled schema", schemaManager
.getSyntaxCheckerRegistry().contains( OID ) );