BAEL-5336 Move code for the article to spring-di-3 (#11807)
* JAVA-7535 Moved ebook specific code snippets to maven-simple module * COMAUTO-9485 Fixed DB url in spring-project and added missing maven wrapper * Code for the Spring @Autowired Field Null – Common Causes and Solutions article * JAVA-7535 Added code for maven-multi-module * JAVA-7535 Pom formatting * JAVA-7535 Pom formatting * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Create README.md * Create README.md * JAVA-9825: Upgrade log4j version for modules that use log4j-core library directly * BAEL-5188 Add CSRF cookie protection + test (#11775) * BAEL-5188 Add CSRF cookie protection + test * BAEL-5188 Break long lines of code * BAEL-5188 Remove line-breaks before semi-colons * BAEL-5378 Rename exceptions to avoid confusion (#11801) * BAEL-5336 Move code for the article to spring-di-3 Co-authored-by: Dhawal Kapil <dhawal.kapil@africa.airtel.com> Co-authored-by: Dhawal Kapil <dhawalkapil@gmail.com> Co-authored-by: johnA1331 <53036378+johnA1331@users.noreply.github.com> Co-authored-by: sampadawagde <sampada.aws@gmail.com> Co-authored-by: Benjamin Caure <bcaure@gmail.com> Co-authored-by: ashleyfrieze <ashley@incredible.org.uk>
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
package com.baeldung.autowiring.controller;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest
|
||||
public class CorrectControllerIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
CorrectController controller;
|
||||
|
||||
@Test
|
||||
void whenControl_ThenRunSuccessfully() {
|
||||
assertDoesNotThrow(() -> controller.control());
|
||||
}
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.baeldung.autowiring.controller;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest
|
||||
public class FlawedControllerIntegrationTest {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FlawedControllerIntegrationTest.class);
|
||||
|
||||
@Autowired
|
||||
FlawedController myController;
|
||||
|
||||
@Test
|
||||
void whenControl_ThenThrowNullPointerException() {
|
||||
NullPointerException npe = assertThrows(NullPointerException.class, () -> myController.control());
|
||||
LOGGER.error("Got a NullPointerException", npe);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user