|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2016 the original author or authors.
|
|
|
|
* Copyright 2012-2017 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -16,33 +16,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot;
|
|
|
|
package org.springframework.boot;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.impl.SimpleLog;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.mockito.ArgumentMatchers.startsWith;
|
|
|
|
|
|
|
|
import static org.mockito.BDDMockito.given;
|
|
|
|
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
|
|
|
|
import static org.mockito.Mockito.verify;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Tests for {@link StartupInfoLogger}.
|
|
|
|
* Tests for {@link StartupInfoLogger}.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Dave Syer
|
|
|
|
* @author Dave Syer
|
|
|
|
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class StartUpLoggerTests {
|
|
|
|
public class StartUpLoggerTests {
|
|
|
|
|
|
|
|
|
|
|
|
private final StringBuffer output = new StringBuffer();
|
|
|
|
private final Log log = mock(Log.class);
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
|
|
|
|
|
|
private final SimpleLog log = new SimpleLog("test") {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void write(StringBuffer buffer) {
|
|
|
|
|
|
|
|
StartUpLoggerTests.this.output.append(buffer).append("\n");
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void sourceClassIncluded() {
|
|
|
|
public void sourceClassIncluded() {
|
|
|
|
|
|
|
|
given(this.log.isInfoEnabled()).willReturn(true);
|
|
|
|
new StartupInfoLogger(getClass()).logStarting(this.log);
|
|
|
|
new StartupInfoLogger(getClass()).logStarting(this.log);
|
|
|
|
assertThat(this.output.toString())
|
|
|
|
verify(this.log).info(startsWith("Starting " + getClass().getSimpleName()));
|
|
|
|
.contains("Starting " + getClass().getSimpleName());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|