From ea8ed52749d859d62508c8c69091b25d227451b1 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 10 Apr 2013 11:07:22 +0000
Subject: [PATCH] TextAccessLogPublisher.java: Fixed issues with two consecutive spaces appearing in the access log.
---
opends/tests/unit-tests-testng/src/server/org/opends/server/loggers/AbstractTextAccessLogPublisherTest.java | 81 ++++++++++++++++++++++++++++++++++++++++
opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java | 2 -
opends/src/server/org/opends/server/loggers/AbstractTextAccessLogPublisher.java | 15 +++++--
3 files changed, 91 insertions(+), 7 deletions(-)
diff --git a/opends/src/server/org/opends/server/loggers/AbstractTextAccessLogPublisher.java b/opends/src/server/org/opends/server/loggers/AbstractTextAccessLogPublisher.java
index 0ff5563..cff6a52 100644
--- a/opends/src/server/org/opends/server/loggers/AbstractTextAccessLogPublisher.java
+++ b/opends/src/server/org/opends/server/loggers/AbstractTextAccessLogPublisher.java
@@ -29,9 +29,8 @@
import static org.opends.messages.ConfigMessages.*;
-import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
-import static org.opends.server.loggers.debug.DebugLogger.getTracer;
-import static org.opends.server.util.StaticUtils.toLowerCase;
+import static org.opends.server.loggers.debug.DebugLogger.*;
+import static org.opends.server.util.StaticUtils.*;
import java.net.InetAddress;
import java.util.ArrayList;
@@ -1063,8 +1062,14 @@
- // Determines whether the provided operation should be logged.
- private boolean isLoggable(final Operation operation)
+ /**
+ * Determines whether the provided operation should be logged.
+ *
+ * @param operation
+ * the operation to check
+ * @return true if the operation is loggable, false otherwise
+ */
+ boolean isLoggable(final Operation operation)
{
final long connectionID = operation.getConnectionID();
if (connectionID < 0)
diff --git a/opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java b/opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java
index 3fbd399..3da5ddf 100644
--- a/opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java
+++ b/opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java
@@ -583,7 +583,6 @@
// down below
buffer.append(" authFailureID=");
buffer.append(failureMessage.getDescriptor().getId());
- buffer.append(" ");
appendLabel(buffer, "authFailureReason", failureMessage);
if (bindOperation.getSASLMechanism() != null
&& bindOperation.getSASLAuthUserEntry() != null)
@@ -821,7 +820,6 @@
buffer.append("]");
buffer.append(" DISCONNECT conn=");
buffer.append(connectionID);
- buffer.append(" ");
appendLabel(buffer, "reason", disconnectReason);
appendLabelIfNotNull(buffer, "msg", message);
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/loggers/AbstractTextAccessLogPublisherTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/loggers/AbstractTextAccessLogPublisherTest.java
new file mode 100644
index 0000000..3199074
--- /dev/null
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/loggers/AbstractTextAccessLogPublisherTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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
+ *
+ *
+ * Copyright 2013 ForgeRock AS
+ */
+package org.opends.server.loggers;
+
+import static org.mockito.Mockito.*;
+import static org.testng.Assert.*;
+
+import org.opends.server.DirectoryServerTestCase;
+import org.opends.server.loggers.AbstractTextAccessLogPublisher.RootFilter;
+import org.opends.server.types.Operation;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+@SuppressWarnings("javadoc")
+public class AbstractTextAccessLogPublisherTest extends DirectoryServerTestCase
+{
+
+ @DataProvider(name = "isLoggableData")
+ public Object[][] getIsLoggableData()
+ {
+ return new Object[][] {
+ { 1L, false, false, false, false, true },
+ { -1L, true, true, true, true, false },
+ { -1L, true, true, true, false, false },
+ { -1L, true, true, false, true, false },
+ { -1L, true, true, false, false, false },
+ { -1L, true, false, true, true, false },
+ { -1L, true, false, true, false, false },// this will change
+ { -1L, true, false, false, true, true },
+ { -1L, true, false, false, false, true },
+ { -1L, false, true, true, true, true },// this will change
+ { -1L, false, true, true, false, true },
+ { -1L, false, true, false, true, true },
+ { -1L, false, true, false, false, true },
+ { -1L, false, false, true, true, false },
+ { -1L, false, false, true, false, false },// this will change
+ { -1L, false, false, false, true, true },
+ { -1L, false, false, false, false, true }, };
+ }
+
+ @Test(dataProvider = "isLoggableData")
+ public void rootFilterIsLoggable(long connectionID,
+ boolean suppressSynchronization, boolean isSynchronizationOp,
+ boolean suppressInternal, boolean isInternalOp, boolean testResult)
+ {
+ final Operation operation = mock(Operation.class);
+ when(operation.getConnectionID()).thenReturn(connectionID);
+ when(operation.isSynchronizationOperation())
+ .thenReturn(isSynchronizationOp);
+ when(operation.isInternalOperation()).thenReturn(isInternalOp);
+
+ final RootFilter filter =
+ new RootFilter(suppressInternal, suppressSynchronization, null, null);
+ assertEquals(filter.isLoggable(operation), testResult);
+ }
+
+}
--
Gitblit v1.10.0