← All Spring Framework Flashcard Decks

Spring Security & Testing Flashcards

6 cards from real Spring Framework practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 6 Spring Security & Testing flashcards as text
  1. What is the purpose of @MockBean in a Spring Boot test?

    Answer: Adds a Mockito mock to the Spring application context, replacing any existing bean of that type

    @MockBean registers a Mockito mock in the Spring ApplicationContext, replacing any existing real bean of the same type for the duration of the test.

  2. Which annotation is used to test only the JPA layer (repositories) in Spring Boot?

    Answer: @DataJpaTest

    @DataJpaTest configures an in-memory database, scans for @Entity classes, and configures Spring Data JPA repositories without loading the full context.

  3. What does the MockMvc.perform() method do in Spring MVC tests?

    Answer: Simulates an HTTP request to a controller without starting a real server

    MockMvc.perform() simulates HTTP requests against Spring MVC controllers in-process without requiring an actual HTTP server, enabling fast controller tests.

  4. In Spring Security, what does the 'remember-me' feature do?

    Answer: Allows users to remain authenticated across browser sessions using a persistent token

    The remember-me feature issues a persistent cookie to the user, allowing them to be automatically re-authenticated in future sessions without logging in again.

  5. What is the purpose of @Transactional in Spring data access tests?

    Answer: Rolls back database changes after each test method by default

    In Spring tests, @Transactional causes each test to run in a transaction that is automatically rolled back after the test, keeping the database clean.

  6. Which Spring Security mechanism protects against session fixation attacks?

    Answer: Creating a new session upon successful authentication

    Spring Security mitigates session fixation attacks by creating a new HTTP session (or migrating attributes) upon successful authentication, invalidating any pre-authentication session ID.

How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. Exam facts are checked against the official sources listed below. Not reviewed by a subject-matter expert. Editorial policy

Sources & references

Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy

  1. docs.broadcom.com — Test delivery, retake policy, exam information · verified Oct 2026
  2. spring-academy.broadcom.com — Eligibility · verified Oct 2026
  3. broadcom.com — Fees, exam format, passing score, time limit · verified Oct 2026