directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r502498 - /directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java
Date Fri, 02 Feb 2007 05:07:28 GMT
Author: akarasulu
Date: Thu Feb  1 21:07:28 2007
New Revision: 502498

URL: http://svn.apache.org/viewvc?view=rev&rev=502498
Log:
the start of a new test case class for testing operations against the schema subentry

Added:
    directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java

Added: directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java?view=auto&rev=502498
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java
(added)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java
Thu Feb  1 21:07:28 2007
@@ -0,0 +1,95 @@
+/*
+ *  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.server.core.schema;
+
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+
+import org.apache.directory.server.core.unit.AbstractAdminTestCase;
+
+
+/**
+ * An integration test class for performing various operations on the 
+ * subschemaSubentry as listed in the rootDSE.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SubschemaSubentryITest extends AbstractAdminTestCase
+{
+    private static final String GLOBAL_SUBSCHEMA_DN = "cn=schema,ou=system";
+    private static final String SUBSCHEMA_SUBENTRY = "subschemaSubentry";
+
+    
+    /**
+     * Get's the subschemaSubentry attribute value from the rootDSE.
+     * 
+     * @return the subschemaSubentry distinguished name
+     * @throws NamingException if there are problems accessing the RootDSE
+     */
+    private String getSubschemaSubentryDN() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        controls.setReturningAttributes( new String[]{ SUBSCHEMA_SUBENTRY } );
+        
+        NamingEnumeration<SearchResult> results = rootDSE.search( "", "(objectClass=*)",
controls );
+        SearchResult result = results.next();
+        results.close();
+        Attribute subschemaSubentry = result.getAttributes().get( SUBSCHEMA_SUBENTRY );
+        return ( String ) subschemaSubentry.get();
+    }
+
+    
+    /**
+     * Gets the subschemaSubentry attributes for the global schema.
+     * 
+     * @return all operational attributes of the subschemaSubentry 
+     * @throws NamingException if there are problems accessing this entry
+     */
+    private Attributes getSubschemaSubentryAttributes() throws NamingException
+    {
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        controls.setReturningAttributes( new String[]{ "+" } );
+        
+        NamingEnumeration<SearchResult> results = rootDSE.search( getSubschemaSubentryDN(),

+            "(objectClass=*)", controls );
+        SearchResult result = results.next();
+        results.close();
+        return result.getAttributes();
+    }
+    
+    
+    /**
+     * Make sure the global subschemaSubentry is where it is expected to be. 
+     */
+    public void testRootDSEsSubschemaSubentry() throws NamingException
+    {
+        assertEquals( GLOBAL_SUBSCHEMA_DN, getSubschemaSubentryDN() );
+        Attributes subschemaSubentryAttrs = getSubschemaSubentryAttributes();
+        assertNotNull( subschemaSubentryAttrs );
+    }
+}



Mime
View raw message