/* * 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 * trunk/opends/resource/legal-notices/OpenDS.LICENSE * or https://OpenDS.dev.java.net/OpenDS.LICENSE. * 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 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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 * * * Portions Copyright 2006 Sun Microsystems, Inc. */ package org.opends.server.core; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import org.opends.server.TestCaseUtils; import org.opends.server.types.ResultCode; import static org.testng.Assert.*; /** * A set of generic test cases for operations */ public abstract class OperationTestCase extends CoreTestCase { /** * Creates a set of valid operation instances of this type that may be used * for testing the general methods defined in the Operation superclass. Only * the constructors for the operation need to be used -- it does not require * any further initialization (no tests will be performed that require any * further processing). * * @return A set of operation instances of this type that may be used for * testing the general methods defined in the Operation superclass. * * @throws Exception If an unexpected problem occurs. */ public abstract Operation[] createTestOperations() throws Exception; /** * Retrieves a set of valid operation instances that may be used to test * methods common to all operations. * * @return A set of valid operation instances that may be used to test * methods common to all operations. * * @throws Exception If an unexpected problem occurs. */ @DataProvider(name = "testOperations") public Object[][] getTestOperations() throws Exception { Operation[] operationArray = createTestOperations(); Object[][] objectArray = new Object[operationArray.length][1]; for (int i=0; i < operationArray.length; i++) { objectArray[i][0] = operationArray[i]; } return objectArray; } /** * Tests the getOperationType method for the provided operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetOperationType(Operation operation) { assertNotNull(operation.getOperationType()); } /** * Tests the getCommonLogElements method for the provided * operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetCommonLogElements(Operation operation) { assertNotNull(operation.getCommonLogElements()); } /** * Tests the getRequestLogElements method for the provided * operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetRequestLogElements(Operation operation) { assertNotNull(operation.getRequestLogElements()); } /** * Tests the getClientConnection method for the provided * operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetClientConnection(Operation operation) { assertNotNull(operation.getClientConnection()); } /** * Tests the getConnectionID method for the provided operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetConnectionID(Operation operation) { operation.getConnectionID(); } /** * Tests the getOperationID method for the provided operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetOperationID(Operation operation) { operation.getOperationID(); } /** * Tests the getMessageID method for the provided operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetMessageID(Operation operation) { operation.getMessageID(); } /** * Tests the getRequestControls method for the provided * operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetRequestControls(Operation operation) { operation.getRequestControls(); } /** * Tests the getResponseControls method for the provided * operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetResponseControls(Operation operation) { operation.getResponseControls(); } /** * Tests the getResultCode method for the provided operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetResultCode(Operation operation) { assertNotNull(operation.getResultCode()); } /** * Tests the getErrorMessage method for the provided operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetErrorMessage(Operation operation) { assertNotNull(operation.getErrorMessage()); } /** * Tests the getAdditionalLogMessage method for the provided * operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetAdditionalLogMessage(Operation operation) { assertNotNull(operation.getAdditionalLogMessage()); } /** * Tests the getMatchedDN method for the provided operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetMatchedDN(Operation operation) { operation.getMatchedDN(); } /** * Tests the getReferralURLs method for the provided operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetReferralURLs(Operation operation) { operation.getReferralURLs(); } /** * Tests the isInternalOperation method for the provided \ * operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testIsInternalOperation(Operation operation) { operation.isInternalOperation(); } /** * Tests the isSynchronizationOperation method for the provided * operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testIsSynchronizationOperation(Operation operation) { operation.isSynchronizationOperation(); } /** * Tests the getAuthorizationDN method for the provided * operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetAuthorizationDN(Operation operation) { assertNotNull(operation.getAuthorizationDN()); } /** * Tests the getMatchedDN method for the provided operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetAttachments(Operation operation) { assertNotNull(operation.getAttachments()); } /** * Tests the getCancelRequest method for the provided operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetCancelRequest(Operation operation) { operation.getCancelRequest(); } /** * Tests the getCancelResult method for the provided operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testGetCancelResult(Operation operation) { operation.getCancelResult(); } /** * Tests the toString method for the provided operation. * * @param operation The operation to test. */ @Test(dataProvider = "testOperations") public void testToString(Operation operation) { assertNotNull(operation.toString()); } }