What Is UserDetailsService in Spring Security?
UserDetailsService is the lookup hook that loads a user for authentication. Learn how DaoAuthenticationProvider uses it.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
UserDetailsService is the lookup hook that loads a user for authentication. Learn how DaoAuthenticationProvider uses it.
@InjectMocks builds the object under test and injects your mocks through constructor, setter or field injection. Learn the order, the JUnit 5 setup and common traps.
Why and how to verify mock interactions in Mockito: call counts, argument matching, call order and unexpected calls, with runnable JUnit 5 tests.
Stubbing tells a Mockito mock what to return or throw. See when/thenReturn, doReturn, matchers, answers and strict stubs with runnable examples.
Create mocks in Mockito with mock() or @Mock, stub behaviour with when().thenReturn() and check calls with verify, using JUnit 5 and Mockito 5.
Create JUnit 5 suites with @Suite and @SelectClasses or @SelectPackages, filter by tags, and avoid duplicate runs in Maven.
@BeforeEach marks a JUnit 5 method that runs before every test so each one starts from a clean, known state. It replaces @Before from JUnit 4.
Use assertThrows in JUnit 5 to verify the exception type, then assert on its message, cause or custom fields. Includes migration notes from JUnit 4.
Assertions compare expected and actual results in a JUnit test and fail it when they differ. This guide covers the main methods with runnable examples.
Run one JUnit test with many inputs using @ParameterizedTest and the value, CSV, method and enum sources, with examples and tips.
@Test tells JUnit to run a method as a test. See lifecycle, assertThrows, timeouts, parameterized tests and the differences from JUnit 4.
Write JUnit 5 unit tests with @Test, assertions, lifecycle annotations, parameterized tests and Mockito, with Maven and Gradle setup for current Java projects.
JUnit 5 and TestNG compared side by side with the same test in both, so you can pick the right Java testing framework for your project.
Keep settings outside your code in Spring using property files, @Value, Environment, profiles and typed @ConfigurationProperties classes.
@ConfigurationProperties binds application properties to typed Java objects with validation. Learn records, registration and how it differs from @Value.
Use ${key} and ${key:default} with @Value to inject values from properties files, environment variables and command-line arguments into Spring beans.
The @Value annotation injects property values, defaults and SpEL results into Spring beans. See placeholders, SpEL, limits and when to use @ConfigurationProperties.
Set spring.profiles.active in properties, on the command line or in Docker, then use profile files, @Profile and @ActiveProfiles correctly.
Spring Profiles let one build run in dev, test and prod by activating beans and configuration files for the chosen environment.
Use Spring profiles, profile-specific property files and @Profile beans to run the same build in dev, staging and production with the right settings.