/[Apache-SVN]/directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceObjectClassChangeHandlingITest.java
ViewVC logotype

Contents of /directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceObjectClassChangeHandlingITest.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 477394 - (show annotations)
Mon Nov 20 23:10:07 2006 UTC (3 years ago) by ersiner
File size: 5676 byte(s)
Adding a new test case for a bug related to handling 
"subtree refinement selection membership" 
or "subentry references in entries" 
upon object class changes.

The test which shows the failing scenario is currently commented out. 
It should be fixed and activated.
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19 */
20
21 package org.apache.directory.server.core.subtree;
22
23
24 import java.util.HashMap;
25 import java.util.Map;
26
27 import javax.naming.NamingEnumeration;
28 import javax.naming.NamingException;
29 import javax.naming.directory.Attribute;
30 import javax.naming.directory.Attributes;
31 import javax.naming.directory.DirContext;
32 import javax.naming.directory.ModificationItem;
33 import javax.naming.directory.SearchControls;
34 import javax.naming.directory.SearchResult;
35
36 import org.apache.directory.server.core.unit.AbstractAdminTestCase;
37 import org.apache.directory.shared.ldap.message.LockableAttributeImpl;
38 import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
39
40
41 /**
42 * Testcases for the SubentryService. Investigation on handling Subtree Refinement
43 * Selection Membership upon objectClass attribute value changes.
44 *
45 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
46 * @version $Rev$
47 */
48 public class SubentryServiceObjectClassChangeHandlingITest extends AbstractAdminTestCase
49 {
50 public Attributes getTestEntry( String cn )
51 {
52 Attributes entry = new LockableAttributesImpl();
53 Attribute objectClass = new LockableAttributeImpl( "objectClass" );
54 objectClass.add( "top" );
55 objectClass.add( "person" );
56 entry.put( objectClass );
57 entry.put( "cn", cn );
58 entry.put( "sn", cn );
59 return entry;
60 }
61
62
63 public Attributes getModsForIntroducingNewOC() throws NamingException
64 {
65 Attributes changes = new LockableAttributesImpl();
66 Attribute objectClass = new LockableAttributeImpl( "objectClass" );
67 objectClass.add( "organizationalPerson" );
68 changes.put( objectClass );
69 changes.put( "ou", "Test Organizational Unit" );
70 return changes;
71 }
72
73
74 public Attributes getCollectiveAttributeTestSubentry( String cn )
75 {
76 Attributes subentry = new LockableAttributesImpl();
77 Attribute objectClass = new LockableAttributeImpl( "objectClass" );
78 objectClass.add( "top" );
79 objectClass.add( "subentry" );
80 objectClass.add( "collectiveAttributeSubentry" );
81 subentry.put( objectClass );
82 subentry.put( "subtreeSpecification", "{ specificationFilter item:organizationalPerson }" );
83 subentry.put( "c-o", "Test Org" );
84 subentry.put( "cn", cn );
85 return subentry;
86 }
87
88
89 public void addAdministrativeRoles() throws NamingException
90 {
91 Attribute attribute = new LockableAttributeImpl( "administrativeRole" );
92 attribute.add( "autonomousArea" );
93 attribute.add( "collectiveAttributeSpecificArea" );
94 ModificationItem item = new ModificationItem( DirContext.ADD_ATTRIBUTE, attribute );
95 super.sysRoot.modifyAttributes( "", new ModificationItem[]
96 { item } );
97 }
98
99
100 public Map getAllEntries() throws NamingException
101 {
102 Map resultMap = new HashMap();
103 SearchControls controls = new SearchControls();
104 controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
105 controls.setReturningAttributes( new String[]
106 { "+", "*" } );
107 NamingEnumeration results = super.sysRoot.search( "", "(objectClass=*)", controls );
108 while ( results.hasMore() )
109 {
110 SearchResult result = ( SearchResult ) results.next();
111 resultMap.put( result.getName(), result.getAttributes() );
112 }
113 return resultMap;
114 }
115
116
117 /*
118 * FIXME: The following test fails.
119 */
120
121 // public void testTrackingOfOCChangesInSubentryServiceModifyRoutine() throws Exception
122 // {
123 // addAdministrativeRoles();
124 // super.sysRoot.createSubcontext( "cn=collectiveAttributeTestSubentry",
125 // getCollectiveAttributeTestSubentry( "collectiveAttributeTestSubentry" ) );
126 // super.sysRoot.createSubcontext( "cn=testEntry", getTestEntry( "testEntry" ) );
127 //
128 // //----------------------------------------------------------------------
129 //
130 // Map results = getAllEntries();
131 // Attributes testEntry = ( Attributes ) results.get( "cn=testEntry,ou=system" );
132 //
133 // Attribute collectiveAttributeSubentries = testEntry.get( "collectiveAttributeSubentries" );
134 //
135 // assertNull( collectiveAttributeSubentries );
136 //
137 // //----------------------------------------------------------------------
138 //
139 // super.sysRoot.modifyAttributes( "cn=testEntry", DirContext.ADD_ATTRIBUTE, getModsForIntroducingNewOC() );
140 //
141 // results = getAllEntries();
142 // testEntry = ( Attributes ) results.get( "cn=testEntry,ou=system" );
143 //
144 // collectiveAttributeSubentries = testEntry.get( "collectiveAttributeSubentries" );
145 //
146 // /**
147 // * FIXME: The following assertion fails.
148 // */
149 //
150 // assertNotNull( collectiveAttributeSubentries );
151 // }
152
153 }

apache@apache.org
ViewVC Help
Powered by ViewVC 1.1.2