/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt * or http://forgerock.org/license/CDDLv1.0.html. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at legal-notices/CDDLv1_0.txt. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: * Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END * * * Copyright 2006-2008 Sun Microsystems, Inc. */ package org.opends.server.schema; import java.util.ArrayList; import java.util.List; import org.opends.server.api.SubstringMatchingRule; import org.opends.server.types.ByteString; import org.opends.server.types.ByteSequence; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.testng.Assert.*; /** * Abstract class for building test for the substring matching rules. * This class is intended to be extended by one class for each substring * matching rules. */ public abstract class SubstringMatchingRuleTest extends SchemaTestCase { /** * Generate data for the test of the middle string match. * * @return the data for the test of the middle string match. */ @DataProvider(name="substringMiddleMatchData") public abstract Object[][] createSubstringMiddleMatchData(); /** * Generate data for the test of the initial string match. * * @return the data for the test of the initial string match. */ @DataProvider(name="substringInitialMatchData") public abstract Object[][] createSubstringInitialMatchData(); /** * Generate data for the test of the final string match. * * @return the data for the test of the final string match. */ @DataProvider(name="substringInitialMatchData") public abstract Object[][] createSubstringFinalMatchData(); /** * Get an instance of the matching rule. * * @return An instance of the matching rule to test. */ protected abstract SubstringMatchingRule getRule(); /** * Test the normalization and the middle substring match. */ @Test(dataProvider= "substringMiddleMatchData") public void middleMatchingRules( String value, String[] middleSubs, Boolean result) throws Exception { SubstringMatchingRule rule = getRule(); // normalize the 2 provided values and check that they are equals ByteString normalizedValue = rule.normalizeValue(ByteString.valueOf(value)); StringBuilder printableMiddleSubs = new StringBuilder(); List middleList = new ArrayList(middleSubs.length); for (int i=0; i