| /* |
| * 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.entry; |
| |
| import org.apache.directory.shared.ldap.entry.Modification; |
| import org.apache.directory.shared.ldap.entry.ModificationOperation; |
| import org.apache.directory.shared.ldap.schema.AttributeType; |
| |
| import static org.junit.Assert.assertEquals; |
| import static org.junit.Assert.assertTrue; |
| |
| import org.junit.Test; |
| |
| |
| /** |
| * Test the ServerModification class |
| * |
| * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> |
| * @version $Rev$, $Date$ |
| */ |
| public class ServerModificationTest |
| { |
| @Test public void testCreateServerModification() |
| { |
| AttributeType at = TestServerEntryUtils.getIA5StringAttributeType(); |
| ServerAttribute attribute = new DefaultServerAttribute( at ); |
| attribute.add( "test1", "test2" ); |
| |
| Modification mod = new ServerModification( ModificationOperation.ADD_ATTRIBUTE, attribute ); |
| Modification clone = mod.clone(); |
| |
| attribute.remove( "test2" ); |
| |
| ServerAttribute clonedAttribute = (ServerAttribute)clone.getAttribute(); |
| |
| assertEquals( 1, mod.getAttribute().size() ); |
| assertTrue( mod.getAttribute().contains( "test1" ) ); |
| |
| assertEquals( 2, clonedAttribute.size() ); |
| assertTrue( clone.getAttribute().contains( "test1" ) ); |
| assertTrue( clone.getAttribute().contains( "test2" ) ); |
| } |
| } |