6180N/A/*
6180N/A * CDDL HEADER START
6180N/A *
6180N/A * The contents of this file are subject to the terms of the
6180N/A * Common Development and Distribution License, Version 1.0 only
6180N/A * (the "License"). You may not use this file except in compliance
6180N/A * with the License.
6180N/A *
6180N/A * You can obtain a copy of the license at
6180N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE
6180N/A * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
6180N/A * See the License for the specific language governing permissions
6180N/A * and limitations under the License.
6180N/A *
6180N/A * When distributing Covered Code, include this CDDL HEADER in each
6180N/A * file and include the License file at
6180N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
6180N/A * add the following below this CDDL HEADER, with the fields enclosed
6180N/A * by brackets "[]" replaced with your own identifying information:
6180N/A * Portions Copyright [yyyy] [name of copyright owner]
6180N/A *
6180N/A * CDDL HEADER END
6180N/A *
6180N/A *
6180N/A * Copyright 2013 ForgeRock AS
6180N/A */
6180N/Apackage org.opends.server.loggers;
6180N/A
6180N/Aimport static org.mockito.Mockito.*;
6180N/Aimport static org.testng.Assert.*;
6180N/A
6180N/Aimport org.opends.server.DirectoryServerTestCase;
6180N/Aimport org.opends.server.loggers.AbstractTextAccessLogPublisher.RootFilter;
6180N/Aimport org.opends.server.types.Operation;
6180N/Aimport org.testng.annotations.DataProvider;
6180N/Aimport org.testng.annotations.Test;
6180N/A
6180N/A@SuppressWarnings("javadoc")
6180N/Apublic class AbstractTextAccessLogPublisherTest extends DirectoryServerTestCase
6180N/A{
6180N/A
6180N/A @DataProvider(name = "isLoggableData")
6180N/A public Object[][] getIsLoggableData()
6180N/A {
6259N/A // When suppress is set to true and the corresponding operation is set to
6191N/A // true too, then the operation is not loggable.
6191N/A // You can read the array like this: read two by two from line start, if
6259N/A // both are true in a pair, then the expected result is false (not
6259N/A // loggable).
6259N/A // There is just one exception: when the operation is a synchronization
6259N/A // operation and we do not suppress synchronization operation, then we
6259N/A // return true regardless of whether this is an internal operation
6180N/A return new Object[][] {
6191N/A { true, true, true, true, false },
6191N/A { true, true, true, false, false },
6191N/A { true, true, false, true, false },
6191N/A { true, true, false, false, false },
6191N/A { true, false, true, true, false },
6191N/A { true, false, true, false, true },
6191N/A { true, false, false, true, true },
6191N/A { true, false, false, false, true },
6259N/A { false, true, true, true, true },
6191N/A { false, true, true, false, true },
6191N/A { false, true, false, true, true },
6191N/A { false, true, false, false, true },
6191N/A { false, false, true, true, false },
6191N/A { false, false, true, false, true },
6191N/A { false, false, false, true, true },
6191N/A { false, false, false, false, true }, };
6180N/A }
6180N/A
6180N/A @Test(dataProvider = "isLoggableData")
6191N/A public void rootFilterIsLoggable(boolean suppressSynchronization,
6191N/A boolean isSynchronizationOp, boolean suppressInternal,
6191N/A boolean isInternalOp, boolean expectedTestResult)
6180N/A {
6180N/A final Operation operation = mock(Operation.class);
6180N/A when(operation.isSynchronizationOperation())
6180N/A .thenReturn(isSynchronizationOp);
6191N/A when(operation.isInnerOperation()).thenReturn(isInternalOp);
6180N/A
6180N/A final RootFilter filter =
6180N/A new RootFilter(suppressInternal, suppressSynchronization, null, null);
6191N/A assertEquals(filter.isLoggable(operation), expectedTestResult);
6180N/A }
6180N/A
6180N/A}