/* * The contents of this file are subject to the terms of the Common Development and * Distribution License (the License). You may not use this file except in compliance with the * License. * * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the * specific language governing permission and limitations under the License. * * When distributing Covered Software, include this CDDL Header Notice in each file and include * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL * Header, with the fields enclosed by brackets [] replaced by your own identifying * information: "Portions Copyright [year] [name of copyright owner]". * * Copyright 2006-2010 Sun Microsystems, Inc. * Portions Copyright 2014-2015 ForgeRock AS. */ package org.opends.server.monitors; import org.testng.annotations.Test; import org.testng.annotations.AfterClass; import org.opends.server.TestCaseUtils; import org.opends.server.api.MonitorProvider; import org.opends.server.config.ConfigEntry; import org.opends.server.core.DirectoryServer; import org.opends.server.types.DN; import static org.testng.Assert.*; /** * An abstract base class for all monitor test cases in which most tests are * performed in a generic manner. */ public abstract class GenericMonitorTestCase extends MonitorTestCase { /** The configuration entry for this test case. */ protected ConfigEntry configEntry; /** * Creates a new instance of this monitor test case. * * @param dnString The DN of the configuration entry for this test case, or * null if there is none. * * @throws Exception If an unexpected problem occurs. */ protected GenericMonitorTestCase(String dnString) throws Exception { super(); TestCaseUtils.startServer(); if (dnString != null) { DN dn = DN.valueOf(dnString); configEntry = DirectoryServer.getConfigEntry(dn); assertNotNull(configEntry); } } /** * Retrieves an initialized instance of the associated monitor provider. * * @return An initialized instance of the associated monitor provider. * * @throws Exception If an unexpected problem occurs. */ protected abstract MonitorProvider getMonitorInstance() throws Exception; /** * Creates an instance of the stack trace monitor and performs basic * initialization for it. * * @throws Exception If an unexpected problem occurs. */ @Test public void testInitialization() throws Exception { MonitorProvider monitorProvider = getMonitorInstance(); assertNotNull(monitorProvider); } /** * Tests the getMonitorInstanceName method. * * @throws Exception If an unexpected problem occurs. */ @Test public void testGetMonitorInstanceName() throws Exception { getMonitorInstance().getMonitorInstanceName(); } /** * Tests the getMonitorData method. * * @throws Exception If an unexpected problem occurs. */ @Test public void testGetMonitorData() throws Exception { getMonitorInstance().getMonitorData(); } /** * We need to drop all of the memory that we can. */ @AfterClass public void cleanupMem() { configEntry = null; } }