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 2009/10/17 10:57:39 UTC
svn commit: r826203 - in
/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap:
registries/ schema/registries/AttributeTypeRegistryTest.java
schema/registries/RegistriesTest.java
Author: elecharny
Date: Sat Oct 17 08:57:38 2009
New Revision: 826203
URL: http://svn.apache.org/viewvc?rev=826203&view=rev
Log:
Moved the AttributeTypeRegistryTest class to the right place
Added:
directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistryTest.java
directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/RegistriesTest.java
Removed:
directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/registries/
Added: directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistryTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistryTest.java?rev=826203&view=auto
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistryTest.java (added)
+++ directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistryTest.java Sat Oct 17 08:57:38 2009
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ *
+ */
+package org.apache.directory.shared.ldap.schema.registries;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * Test the AttributeTypeRegistry
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeTypeRegistryTest
+{
+ AttributeTypeRegistry atRegistry;
+
+ @Before
+ public void setup()
+ {
+ atRegistry = new AttributeTypeRegistry( new OidRegistry() );
+ }
+
+
+ @Test
+ public void testUnregister() throws NamingException
+ {
+ AttributeType at0 = new AttributeType( "1.1" );
+ at0.addName( "t", "test", "Test", "T" );
+ atRegistry.register( at0 );
+
+ atRegistry.unregister( "1.1" );
+ assertFalse( atRegistry.contains( "1.1" ) );
+ assertFalse( atRegistry.contains( "t" ) );
+ assertFalse( atRegistry.contains( "T" ) );
+ assertFalse( atRegistry.contains( "tEsT" ) );
+
+ try
+ {
+ atRegistry.getOidByName( "T" );
+ fail();
+ }
+ catch ( NamingException ne )
+ {
+ assertTrue( true );
+ }
+ }
+
+
+ @Test
+ public void testRegister() throws NamingException
+ {
+ AttributeType at0 = new AttributeType( "1.1" );
+ at0.addName( "t", "test", "Test", "T" );
+ atRegistry.register( at0 );
+
+ assertTrue( atRegistry.contains( "1.1" ) );
+ assertTrue( atRegistry.contains( "t" ) );
+ assertTrue( atRegistry.contains( "T" ) );
+ assertTrue( atRegistry.contains( "tEsT" ) );
+ assertEquals( "1.1", atRegistry.getOidByName( "T" ) );
+
+ try
+ {
+ atRegistry.register( at0 );
+ fail();
+ }
+ catch ( NamingException ne )
+ {
+ assertTrue( true );
+ }
+ }
+
+
+ @Test
+ public void testClone() throws Exception
+ {
+ AttributeType at0 = new AttributeType( "1.1" );
+ at0.addName( "t", "test", "Test", "T" );
+
+ atRegistry.register( at0 );
+
+ AttributeType at1 = new AttributeType( "1.2" );
+ at1.addName( "u", "unit", "Unit", "U" );
+
+ atRegistry.register( at1 );
+
+ // Clone the ATRegistry
+ AttributeTypeRegistry clone = atRegistry.clone();
+
+ assertEquals( at0, clone.lookup( "1.1" ) );
+ assertEquals( at1, clone.lookup( "1.2" ) );
+
+ atRegistry.unregister( "1.1" );
+ assertFalse( atRegistry.contains( "1.1" ) );
+ assertTrue( clone.contains( "1.1" ) );
+
+ AttributeType at = atRegistry.lookup( "1.2" );
+ at.setOid( "2.2" );
+
+ at = atRegistry.lookup( "1.2" );
+ assertEquals( "2.2", at.getOid() );
+
+ at = clone.lookup( "1.2" );
+ assertEquals( "1.2", at.getOid() );
+ }
+}
Added: directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/RegistriesTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/RegistriesTest.java?rev=826203&view=auto
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/RegistriesTest.java (added)
+++ directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/RegistriesTest.java Sat Oct 17 08:57:38 2009
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ *
+ */
+package org.apache.directory.shared.ldap.schema.registries;
+
+
+/**
+ * Test the registries class
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class RegistriesTest
+{
+
+}