This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SLF4J: A number (4) of logging calls during the initialization phase have been intercepted and are | |
SLF4J: now being replayed. These are subject to the filtering rules of the underlying logging system. | |
SLF4J: See also http://www.slf4j.org/codes.html#replay |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LogbackInitializerExtension implements BeforeAllCallback { | |
@Override | |
public void beforeAll(ExtensionContext context) throws Exception { | |
pauseTillLogbackReady(); | |
} | |
private static void pauseTillLogbackReady() { | |
while(!isLogbackReady()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Retention(RetentionPolicy.RUNTIME) | |
@Target(ElementType.TYPE) | |
@ExtendWith(LogbackInitializerExtension.class) | |
public @interface LogbackInitializer { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LocalAppender extends AppenderBase<ILoggingEvent> { | |
private List<ILoggingEvent> events = new ArrayList<>(); | |
public LocalAppender() { | |
start(); | |
} | |
public static LocalAppender initialize(String... loggers) { | |
LocalAppender localAppender = new LocalAppender(); | |
for (String loggerName : loggers) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@LogbackInitializer | |
public class TestLocalAppender { | |
@Test | |
@ResourceLock(value = "LOGGING", mode = ResourceAccessMode.READ_WRITE) | |
public void testLocalAppenderA() { | |
OtherLogProducingService service = new OtherLogProducingService(); | |
LocalAppender localAppender = LocalAppender.initialize("com.bk.logging.OtherLogProducingService"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestAcceptedMediaTypes { | |
private static final MediaType[] SUPPORTED_MEDIA_TYPES = new MediaType[] { MediaType.APPLICATION_JSON, | |
MediaType.APPLICATION_XML }; | |
@TestFactory | |
Collection<DynamicTest> testAcceptedMediaTypes() throws Exception { | |
// Creating a classpath scanner to find all controller classes in project | |
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(new DefaultListableBeanFactory(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestAcceptedMediaTypes { | |
private static final MediaType[] SUPPORTED_MEDIA_TYPES = new MediaType[] { MediaType.APPLICATION_JSON_UTF8, | |
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }; | |
@TestFactory | |
Collection<DynamicContainer> testAcceptedMediaTypes() throws Exception { | |
... | |
List<DynamicContainer> dynamicContainers = new ArrayList<>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@TestFactory | |
public List<DynamicTest> exampleTestFactory() { | |
return Arrays.asList( | |
dynamicTest("Dynamic square " + 2, () -> assertEquals(4, 2 * 2)),// | |
dynamicTest("Dynamic true " + true, () -> assertTrue(true))); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.bk.booking</groupId> | |
<artifactId>spring-boot-simple-surefire-example</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<packaging>jar</packaging> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-surefire-plugin</artifactId> | |
<version>2.21.0</version> | |
<dependencies> | |
<dependency> | |
<groupId>org.junit.platform</groupId> | |
<artifactId>junit-platform-surefire-provider</artifactId> | |
<version>${junit-platform.version}</version> | |
</dependency> |