| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS. |
| | | * Portions copyright 2011-2013 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.*; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.core.AttributeBuilder class. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class AttributeBuilderTest extends TypesTestCase |
| | | { |
| | | |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#addAll(Attribute)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderAddAllAttribute() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#addAll(java.util.Collection)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderAddAllAttributeValues() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#add(AttributeValue)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderAddAttributeValue() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#add(String)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderAddString() throws Exception |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#add(ByteString)}. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderAddByteString() throws Exception |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(cnType); |
| | | |
| | | assertTrue(builder.add(ByteString.valueOf("value1"))); |
| | | assertEquals(builder.size(), 1); |
| | | |
| | | assertFalse(builder.add(ByteString.valueOf("value1"))); |
| | | assertEquals(builder.size(), 1); |
| | | |
| | | assertTrue(builder.add(ByteString.valueOf("value2"))); |
| | | assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | assertEquals(a.size(), 2); |
| | | assertTrue(a.contains(AttributeValues.create(cnType, "value1"))); |
| | | assertTrue(a.contains(AttributeValues.create(cnType, "value2"))); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#clear()}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderClear() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#contains(AttributeValue)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderContains() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#containsAll(java.util.Collection)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderContainsAll() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#getAttributeType()}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderGetAttributeType() throws Exception |
| | |
| | | /** |
| | | * Tests {@link AttributeBuilder#toAttribute()} throws |
| | | * IllegalStateException after default constructor. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(expectedExceptions = IllegalStateException.class) |
| | | public void testAttributeBuilderIllegalStateException1() throws Exception |
| | |
| | | /** |
| | | * Tests {@link AttributeBuilder#toAttribute()} throws |
| | | * IllegalStateException when called twice. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(expectedExceptions = IllegalStateException.class) |
| | | public void testAttributeBuilderIllegalStateException2() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#isEmpty()}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderIsEmpty() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#iterator()}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderIterator() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#removeAll(Attribute)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderRemoveAllAttribute() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#removeAll(java.util.Collection)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderRemoveAllAttributeValues() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#remove(AttributeValue)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderRemoveAttributeValue() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#remove(String)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderRemoveString() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#replaceAll(Attribute)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderReplaceAllAttribute() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#replaceAll(java.util.Collection)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderReplaceAllAttributeValues() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#replace(AttributeValue)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderReplaceAttributeValue() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#replace(String)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderReplaceString() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#setAttributeType(AttributeType)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderSetAttributeType1() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#setAttributeType(String)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderSetAttributeType2() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#setAttributeType(String)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderSetAttributeType3() throws Exception |
| | |
| | | /** |
| | | * Tests |
| | | * {@link AttributeBuilder#setAttributeType(AttributeType, String)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderSetAttributeType4() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#setOptions(java.util.Collection)}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderSetOptions() throws Exception |
| | |
| | | |
| | | /** |
| | | * Tests {@link AttributeBuilder#size()}. |
| | | * |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test |
| | | public void testAttributeBuilderSize() throws Exception |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeContains(int testCase, Attribute a, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeContainsAll(int testCase, Attribute a, |
| | |
| | | * The second attribute. |
| | | * @param isEqual |
| | | * The expected result of equals. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createCompareAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeEquals(int testCase, Attribute a1, Attribute a2, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeGetAttribute(int testCase, Attribute a, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeGetName(int testCase, Attribute a, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeGetNameWithOptions(int testCase, Attribute a, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeGetOptions(int testCase, Attribute a, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeHasAllOptions(int testCase, Attribute a, |
| | |
| | | * The second attribute. |
| | | * @param isEqual |
| | | * The expected result of equals. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createCompareAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeHashCode(int testCase, Attribute a1, Attribute a2, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeHasOption(int testCase, Attribute a, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeHasOptions(int testCase, Attribute a, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeIsEmpty(int testCase, Attribute a, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeIsVirtual(int testCase, Attribute a, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeIterator(int testCase, Attribute a, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes") |
| | | public void testAttributeNotNull(int testCase, Attribute a, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeGetOptions") |
| | | public void testAttributeOptionOptimization(int testCase, Attribute a, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeOptionsEquals(int testCase, Attribute a, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeNotNull") |
| | | public void testAttributeSize(int testCase, Attribute a, AttributeType type, |
| | |
| | | * The expected attribute options. |
| | | * @param values |
| | | * The expected attribute values. |
| | | * @throws Exception |
| | | * If an unexpected error occurs. |
| | | */ |
| | | @Test(dataProvider = "createAttributes", dependsOnMethods = "testAttributeIterator") |
| | | public void testAttributeValueOptimization(int testCase, Attribute a, |