Skip to content

Commit

Permalink
Use SLF4J.
Browse files Browse the repository at this point in the history
[162794188] https://www.pivotaltracker.com/story/show/162794188

Signed-off-by: Jeremy Morony <jmorony@pivotal.io>
Co-authored-by: Jeremy Morony <jmorony@pivotal.io>
  • Loading branch information
2 people authored and andrewedstrom committed Mar 18, 2019
1 parent 73c9483 commit 505cc3f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 33 deletions.
@@ -1,20 +1,8 @@
/*******************************************************************************
* Cloud Foundry
* Copyright (c) [2009-2016] Pivotal Software, Inc. All Rights Reserved.
*
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
*
* This product includes a number of subcomponents with
* separate copyright notices and license terms. Your use of these
* subcomponents is subject to the terms and conditions of the
* subcomponent's license, as noted in the LICENSE file.
*******************************************************************************/
package org.cloudfoundry.identity.uaa.audit;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.cloudfoundry.identity.uaa.logging.LogSanitizerUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jmx.export.annotation.ManagedMetric;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.jmx.support.MetricType;
Expand All @@ -36,7 +24,7 @@
)
public class LoggingAuditService implements UaaAuditService {

private Log logger = LogFactory.getLog("UAA.Audit");
private Logger logger = LoggerFactory.getLogger("UAA.Audit");

private AtomicInteger userAuthenticationCount = new AtomicInteger();

Expand Down Expand Up @@ -174,11 +162,11 @@ private void log(String msg) {
}
}

public void setLogger(Log logger) {
public void setLogger(Logger logger) {
this.logger = logger;
}

public Log getLogger() {
public Logger getLogger() {
return logger;
}
}
@@ -1,11 +1,11 @@
package org.cloudfoundry.identity.uaa.audit;


import org.apache.commons.logging.Log;
import org.cloudfoundry.identity.uaa.logging.LogSanitizerUtil;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.slf4j.Logger;

import static org.cloudfoundry.identity.uaa.audit.AuditEventType.PasswordChangeFailure;
import static org.cloudfoundry.identity.uaa.audit.AuditEventType.UserAuthenticationSuccess;
Expand All @@ -17,12 +17,12 @@
class LoggingAuditServiceTest {

private LoggingAuditService loggingAuditService;
private Log mockLogger;
private Logger mockLogger;

@BeforeEach
void setup() {
loggingAuditService = new LoggingAuditService();
mockLogger = mock(Log.class);
mockLogger = mock(Logger.class);
loggingAuditService.setLogger(mockLogger);
}

Expand Down
Expand Up @@ -3,10 +3,8 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.Sets;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.NoOpLog;
import org.cloudfoundry.identity.uaa.DefaultTestContext;
import org.cloudfoundry.identity.uaa.SpringServletAndHoneycombTestConfig;
import org.cloudfoundry.identity.uaa.account.LostPasswordChangeRequest;
import org.cloudfoundry.identity.uaa.account.event.PasswordChangeEvent;
import org.cloudfoundry.identity.uaa.account.event.PasswordChangeFailureEvent;
Expand All @@ -33,16 +31,19 @@
import org.cloudfoundry.identity.uaa.scim.event.ScimEventPublisher;
import org.cloudfoundry.identity.uaa.scim.event.UserModifiedEvent;
import org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimUserProvisioning;
import org.cloudfoundry.identity.uaa.security.PollutionPreventionExtension;
import org.cloudfoundry.identity.uaa.test.*;
import org.cloudfoundry.identity.uaa.test.TestApplicationEventListener;
import org.cloudfoundry.identity.uaa.test.TestClient;
import org.cloudfoundry.identity.uaa.test.UaaTestAccounts;
import org.cloudfoundry.identity.uaa.util.JsonUtils;
import org.cloudfoundry.identity.uaa.zone.ClientServicesExtension;
import org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManager;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.slf4j.Logger;
import org.slf4j.helpers.NOPLogger;
import org.slf4j.helpers.SubstituteLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -60,10 +61,6 @@
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.client.BaseClientDetails;
import org.springframework.security.web.FilterChainProxy;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.ResultActions;
Expand Down Expand Up @@ -126,7 +123,7 @@ class AuditCheckMockMvcTests {
@Autowired
private LoggingAuditService loggingAuditService;
private InterceptingLogger testLogger;
private Log originalAuditServiceLogger;
private Logger originalAuditServiceLogger;

@Autowired
JdbcScimUserProvisioning jdbcScimUserProvisioning;
Expand Down Expand Up @@ -1262,12 +1259,16 @@ private void assertGroupMembershipLogMessage(String actualLogMessage, AuditEvent
assertThat(memberIdsFromLogMessage, equalTo(Sets.newHashSet(expectedUserIds)));
}

private class InterceptingLogger extends NoOpLog {
private class InterceptingLogger extends SubstituteLogger {
private List<String> messages = new ArrayList<>();

InterceptingLogger() {
super("InterceptingLogger", new LinkedList<>(), true);
}

@Override
public void info(Object message) {
messages.add(message.toString());
public void info(String message) {
messages.add(message);
}

void reset() {
Expand Down

0 comments on commit 505cc3f

Please sign in to comment.