Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.scheduling.annotation.EnableScheduling;
import playground.api.ACR;

@SpringBootApplication(exclude = {AuditAutoConfiguration.class, HttpTraceAutoConfiguration.class,
JmxAutoConfiguration.class, JmxEndpointAutoConfiguration.class,
JvmMetricsAutoConfiguration.class, MetricsAutoConfiguration.class, SimpleMetricsExportAutoConfiguration.class,
})
@EnableConfigurationProperties(ACR.class)
@EnableScheduling
public class PlaygroundServerApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package playground.heartbeat;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class HeartbeatLogger {
private static final Logger LOG = LoggerFactory.getLogger(HeartbeatLogger.class);

@Scheduled(cron = "0 0 * * * *")
public void mark() {
LOG.info("MARK");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package playground.heartbeat;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
import org.junit.Test;
import org.slf4j.LoggerFactory;

import java.util.List;

import static org.junit.Assert.assertEquals;

public class HeartbeatLoggerTest {

@Test
public void emitsMarkAtInfo() {
Logger logger = (Logger) LoggerFactory.getLogger(HeartbeatLogger.class);
ListAppender<ILoggingEvent> appender = new ListAppender<>();
appender.start();
logger.addAppender(appender);
try {
new HeartbeatLogger().mark();

List<ILoggingEvent> events = appender.list;
assertEquals(1, events.size());
assertEquals(Level.INFO, events.getFirst().getLevel());
assertEquals("MARK", events.getFirst().getFormattedMessage());
} finally {
logger.detachAppender(appender);
}
}
}
Loading