You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2006/11/16 17:05:29 UTC
svn commit: r475786 [13/13] - in
/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin: ./
META-INF/ icons/ ressources/ ressources/help/ ressources/help/html/
ressources/help/html/concepts/ ressources/help/html/concepts/images/
ressources/...
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/PoolListenerTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/PoolListenerTest.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/PoolListenerTest.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/PoolListenerTest.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,90 @@
+/*
+ * 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.ldapstudio.schemas.tests;
+
+
+import org.apache.directory.ldapstudio.schemas.model.AttributeType;
+import org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent;
+import org.apache.directory.ldapstudio.schemas.model.PoolListener;
+import org.apache.directory.ldapstudio.schemas.model.Schema;
+import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
+import org.apache.directory.server.core.tools.schema.AttributeTypeLiteral;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Tests pool listener events
+ *
+ */
+public class PoolListenerTest extends TestCase implements PoolListener
+{
+ SchemaPool pool;
+ boolean poolChanged;
+
+
+ public void setUp()
+ {
+ pool = new SchemaPool();
+ poolChanged = false;
+ }
+
+
+ public void testRegisterListener() throws Exception
+ {
+ pool.addListener( this );
+ }
+
+
+ public void testRemoveListener() throws Exception
+ {
+ pool.addListener( this );
+ pool.removeListener( this );
+ }
+
+
+ public void testNotification() throws Exception
+ {
+ //Add a schema to the pool -> notification
+ pool.addListener( this );
+ Schema schema = new Schema( "toto" ); //$NON-NLS-1$
+ pool.addSchema( schema );
+ assertTrue( poolChanged );
+
+ poolChanged = false;
+
+ //Add an attribute type to a schema inside the pool -> notification
+ schema.addAttributeType( new AttributeType( new AttributeTypeLiteral( "1.2.3" ), schema ) ); //$NON-NLS-1$
+ assertTrue( poolChanged );
+
+ poolChanged = false;
+
+ //Remove a schema from the pool -> notification
+ pool.removeSchema( schema );
+ assertTrue( poolChanged );
+ }
+
+
+ public void poolChanged( SchemaPool p, LDAPModelEvent e )
+ {
+ poolChanged = true;
+ }
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/SchemaElementListenerTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/SchemaElementListenerTest.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/SchemaElementListenerTest.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/SchemaElementListenerTest.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,114 @@
+/*
+ * 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.ldapstudio.schemas.tests;
+
+
+import org.apache.directory.ldapstudio.schemas.model.AttributeType;
+import org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent;
+import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
+import org.apache.directory.ldapstudio.schemas.model.Schema;
+import org.apache.directory.ldapstudio.schemas.model.SchemaElement;
+import org.apache.directory.ldapstudio.schemas.model.SchemaElementListener;
+import org.apache.directory.server.core.tools.schema.AttributeTypeLiteral;
+import org.apache.directory.server.core.tools.schema.ObjectClassLiteral;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Tests object-class and attribute-type listener events
+ *
+ */
+public class SchemaElementListenerTest extends TestCase implements SchemaElementListener
+{
+
+ boolean elementChanged;
+ Schema schema;
+ ObjectClass oc;
+ AttributeType at;
+
+
+ public void setUp()
+ {
+ elementChanged = false;
+ schema = new Schema( "test" ); //$NON-NLS-1$
+ at = new AttributeType( new AttributeTypeLiteral( "1.2.3" ), schema ); //$NON-NLS-1$
+ oc = new ObjectClass( new ObjectClassLiteral( "4.5.6" ), schema ); //$NON-NLS-1$
+ schema.addAttributeType( at );
+ schema.addObjectClass( oc );
+ }
+
+
+ public void testObjectClassNotification() throws Exception
+ {
+ oc.addListener( this );
+ oc.setNames( new String[]
+ { "toto" } ); //$NON-NLS-1$
+
+ assertTrue( elementChanged );
+ elementChanged = false;
+
+ oc.setOid( "8.9.10" ); //$NON-NLS-1$
+
+ assertTrue( elementChanged );
+ elementChanged = false;
+
+ oc.setDescription( "toto's description" ); //$NON-NLS-1$
+
+ assertTrue( elementChanged );
+ elementChanged = false;
+
+ oc.setMay( new String[]
+ { "at1", "at2" } ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue( elementChanged );
+ elementChanged = false;
+
+ oc.setMust( new String[]
+ { "at3", "at4" } ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue( elementChanged );
+ }
+
+
+ public void testAttributeTypeNotification() throws Exception
+ {
+ at.addListener( this );
+
+ at.setNames( new String[]
+ { "toto" } ); //$NON-NLS-1$
+
+ assertTrue( elementChanged );
+ elementChanged = false;
+
+ at.setDescription( "toto's description" ); //$NON-NLS-1$
+
+ assertTrue( elementChanged );
+ elementChanged = false;
+ }
+
+
+ public void schemaElementChanged( SchemaElement originatingSchemaElement, LDAPModelEvent e )
+ {
+ elementChanged = true;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/SchemaListenerTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/SchemaListenerTest.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/SchemaListenerTest.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/SchemaListenerTest.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,85 @@
+/*
+ * 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.ldapstudio.schemas.tests;
+
+
+import junit.framework.TestCase;
+
+import org.apache.directory.ldapstudio.schemas.model.AttributeType;
+import org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent;
+import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
+import org.apache.directory.ldapstudio.schemas.model.Schema;
+import org.apache.directory.ldapstudio.schemas.model.SchemaListener;
+import org.apache.directory.server.core.tools.schema.AttributeTypeLiteral;
+import org.apache.directory.server.core.tools.schema.ObjectClassLiteral;
+
+
+/**
+ * Tests schema listener events
+ *
+ */
+public class SchemaListenerTest extends TestCase implements SchemaListener
+{
+ boolean schemaChanged;
+ Schema schema;
+
+
+ public void setUp()
+ {
+ schemaChanged = false;
+ schema = new Schema( "test" ); //$NON-NLS-1$
+ }
+
+
+ public void testRegisterListener() throws Exception
+ {
+ schema.addListener( this );
+ }
+
+
+ public void testRemoveListener() throws Exception
+ {
+ schema.addListener( this );
+ schema.removeListener( this );
+ }
+
+
+ public void testNotification() throws Exception
+ {
+ schema.addListener( this );
+
+ //Add an attribute type to the schema -> notification
+ schema.addAttributeType( new AttributeType( new AttributeTypeLiteral( "1.2.3" ), schema ) ); //$NON-NLS-1$
+ assertTrue( schemaChanged );
+
+ schemaChanged = false;
+
+ schema.addObjectClass( new ObjectClass( new ObjectClassLiteral( "4.5.6" ), schema ) ); //$NON-NLS-1$
+ assertTrue( schemaChanged );
+ }
+
+
+ public void schemaChanged( Schema originatingSchema, LDAPModelEvent e )
+ {
+ schemaChanged = true;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/SchemaPoolTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/SchemaPoolTest.java?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/SchemaPoolTest.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/src/test/java/org/apache/directory/ldapstudio/schemas/tests/SchemaPoolTest.java Thu Nov 16 08:05:20 2006
@@ -0,0 +1,168 @@
+/*
+ * 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.ldapstudio.schemas.tests;
+
+
+import java.util.Hashtable;
+
+import org.apache.directory.ldapstudio.schemas.model.AttributeType;
+import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
+import org.apache.directory.ldapstudio.schemas.model.Schema;
+import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Tests the schema pool
+ *
+ */
+public class SchemaPoolTest extends TestCase
+{
+
+ private SchemaPool pool;
+ private Schema[] schemas;
+
+
+ public void setUp()
+ {
+ pool = new SchemaPool();
+ schemas = new Schema[100];
+ }
+
+
+ public void testAddSchemasToPool() throws Exception
+ {
+
+ for ( int i = 0; i < 100; i++ )
+ {
+ Schema sc = new Schema( "schema_" + i ); //$NON-NLS-1$
+ schemas[i] = sc;
+ pool.addSchema( sc );
+ }
+
+ assertEquals( pool.count(), 100 );
+
+ for ( int i = 0; i < 100; i++ )
+ {
+ assertTrue( pool.containsSchema( schemas[i] ) );
+ assertTrue( pool.containsSchema( schemas[i].getName() ) );
+ }
+ System.out.println();
+ }
+
+
+ public void testRemoveSchemasFromPool() throws Exception
+ {
+ testAddSchemasToPool();
+
+ for ( int i = 0; i < 100; i++ )
+ {
+ pool.removeSchema( schemas[i] );
+ assertFalse( pool.containsSchema( schemas[i] ) );
+ }
+
+ assertEquals( pool.count(), 0 );
+ }
+
+
+ public void testAddExistingSchemasToPool() throws Exception
+ {
+ Schema sc1 = new Schema( "ressources/schemas/apache.schema", Schema.SchemaType.coreSchema ); //$NON-NLS-1$
+ Schema sc2 = new Schema( "ressources/schemas/core.schema", Schema.SchemaType.coreSchema ); //$NON-NLS-1$
+ Schema sc3 = new Schema( "ressources/schemas/cosine.schema", Schema.SchemaType.coreSchema ); //$NON-NLS-1$
+ Schema sc4 = new Schema( "ressources/schemas/misc.schema", Schema.SchemaType.coreSchema ); //$NON-NLS-1$
+
+ pool.addSchemas( new Schema[]
+ { sc1, sc2, sc3, sc4 } );
+
+ assertTrue( pool.containsSchema( sc1 ) );
+ assertTrue( pool.containsSchema( sc2 ) );
+ assertTrue( pool.containsSchema( sc3 ) );
+ assertTrue( pool.containsSchema( sc4 ) );
+
+ Hashtable<String, ObjectClass> objectClasses = pool.getObjectClassesAsHashTableByName();
+ Hashtable<String, AttributeType> attributeTypes = pool.getAttributeTypesAsHashTableByName();
+
+ AttributeType[] sc1AT = sc1.getAttributeTypesAsArray();
+ for ( AttributeType type : sc1AT )
+ {
+ assertTrue( attributeTypes.containsValue( type ) );
+ }
+
+ AttributeType[] sc2AT = sc2.getAttributeTypesAsArray();
+ for ( AttributeType type : sc2AT )
+ {
+ assertTrue( attributeTypes.containsValue( type ) );
+ }
+
+ AttributeType[] sc3AT = sc3.getAttributeTypesAsArray();
+ for ( AttributeType type : sc3AT )
+ {
+ assertTrue( attributeTypes.containsValue( type ) );
+ }
+
+ AttributeType[] sc4AT = sc4.getAttributeTypesAsArray();
+ for ( AttributeType type : sc4AT )
+ {
+ assertTrue( attributeTypes.containsValue( type ) );
+ }
+
+ ObjectClass[] sc1OC = sc1.getObjectClassesAsArray();
+ for ( ObjectClass class1 : sc1OC )
+ {
+ assertTrue( objectClasses.contains( class1 ) );
+ }
+
+ ObjectClass[] sc2OC = sc1.getObjectClassesAsArray();
+ for ( ObjectClass class1 : sc2OC )
+ {
+ assertTrue( objectClasses.contains( class1 ) );
+ }
+
+ ObjectClass[] sc3OC = sc1.getObjectClassesAsArray();
+ for ( ObjectClass class1 : sc3OC )
+ {
+ assertTrue( objectClasses.contains( class1 ) );
+ }
+
+ ObjectClass[] sc4OC = sc1.getObjectClassesAsArray();
+ for ( ObjectClass class1 : sc4OC )
+ {
+ assertTrue( objectClasses.contains( class1 ) );
+ }
+
+ pool.removeSchemas( new Schema[]
+ { sc1, sc2, sc3, sc4 } );
+ assertFalse( pool.containsSchema( sc1 ) );
+ assertFalse( pool.containsSchema( sc2 ) );
+ assertFalse( pool.containsSchema( sc3 ) );
+ assertFalse( pool.containsSchema( sc4 ) );
+ assertEquals( pool.count(), 0 );
+
+ objectClasses = pool.getObjectClassesAsHashTableByName();
+ attributeTypes = pool.getAttributeTypesAsHashTableByName();
+
+ assertEquals( objectClasses.size(), 0 );
+ assertEquals( attributeTypes.size(), 0 );
+
+ }
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/toc.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/toc.xml?view=auto&rev=475786
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/toc.xml (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-schemas-plugin/toc.xml Thu Nov 16 08:05:20 2006
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?NLS TYPE="org.eclipse.help.toc"?>
+
+<toc label="LDAP Studio User Guide" topic="ressources/help/html/toc.html">
+ <topic label="Introduction to LDAP Studio" href="ressources/help/html/introduction.html" />
+ <topic label="Concepts" href="ressources/help/html/concepts/concepts.html">
+ <anchor id="concepts"/>
+ </topic>
+ <topic label="Tasks">
+ <anchor id="tasks"/>
+ </topic>
+ <topic label="Reference">
+ <anchor id="reference"/>
+ </topic>
+</toc>