BAEL-1527 (#4324)
* commit first as binodpanta * revert test change * A short example of real-time event streaming using Spring WebFlux * Code for http://jira.baeldung.com/browse/BAEL-1527 * remove unrelated files * Apply feedback changes to rename test and remove link from readme file, ongoing work * Update formatting fixes to code and add pom changes, that partially fix test runnning issues in IDE but not in cmdline * Apply Eclipse formatter to test code and apply suggested pom fixes * BAEL-1527 Formatting fix in pom.xml
This commit is contained in:
committed by
Predrag Maric
parent
a3563f0ef5
commit
db233245e3
@@ -0,0 +1,27 @@
|
||||
package com.baeldung;
|
||||
|
||||
import com.baeldung.extensions.RegisterExtensionSampleExtension;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/**
|
||||
* This test demonstrates the use of the same extension in two ways.
|
||||
* 1. Once as instance level field: Only method level callbacks are called.
|
||||
* 2. Once as class level static field: All methods are called.
|
||||
*/
|
||||
public class RegisterExtensionUnitTest {
|
||||
|
||||
@RegisterExtension
|
||||
static RegisterExtensionSampleExtension staticExtension = new RegisterExtensionSampleExtension("static version");
|
||||
|
||||
@RegisterExtension
|
||||
RegisterExtensionSampleExtension instanceLevelExtension = new RegisterExtensionSampleExtension("instance version");
|
||||
|
||||
@Test
|
||||
public void demoTest() {
|
||||
Assertions.assertEquals("instance version", instanceLevelExtension.getType());
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.baeldung.extensions;
|
||||
|
||||
import org.junit.jupiter.api.extension.BeforeAllCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This extension is meant to demonstrate the use of RegisterExtension.
|
||||
*/
|
||||
public class RegisterExtensionSampleExtension implements BeforeAllCallback, BeforeEachCallback {
|
||||
|
||||
private final String type;
|
||||
Logger logger = LoggerFactory.getLogger(RegisterExtensionSampleExtension.class);
|
||||
|
||||
public RegisterExtensionSampleExtension(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeAll(ExtensionContext extensionContext) throws Exception {
|
||||
logger.info("Type " + type + " In beforeAll : " + extensionContext.getDisplayName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext extensionContext) throws Exception {
|
||||
logger.info("Type " + type + " In beforeEach : " + extensionContext.getDisplayName());
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user