Skip to content

Five Data REST tests boot an embedded server the MockMvc suites already cover #316

Closed

Description

@fjlopez

What is wrong

Five tests use @SpringBootTest(webEnvironment = RANDOM_PORT) and RestTemplate against http://localhost:{port}.

DatabaseConnectionRepositoryIntegrationTest pays the port bind (4.40s gap on the 2026-10-21 H2 run). These four then reuse that context at a 0s gap:

  • RoleRepositoryIntegrationTest
  • TerritoryRepositoryIntegrationTest
  • TerritoryGroupTypeRepositoryIntegrationTest (@Deprecated)
  • UserResourceIntegrationTest

They assert HAL status and JSON. Sibling *DataRestTest classes already observe that contract with MockMvc on the shared MOCK context. Login goes through TestUtils.adminAuthHeaders (admin_access_token and X-SITMUN-Client).

Why this is not a test-only edit

Replacing RestTemplate with MockMvc is a route decision. The cookie login may not be what the MockMvc Data REST tests send. UserResourceIntegrationTest create-and-delete also overlaps UserResourceTest. Keep the 404-after-delete check on one surface. That overlap is #313.

Done when

One HTTP entry point covers each of these contracts, and the embedded server is gone unless a test needs a real port.

Activity

  1. added
    plannedActive backlog; exempt from stale bot
    on Oct 21, 2026
  2. added theissue type on Oct 21, 2026
  3. fjlopez commented on Oct 21, 2026

    @fjlopez
    ContributorAuthor

    A later H2 run the same day, 08:04:19Z to 08:06:49Z, measured a 1.53s gap before DatabaseConnectionRepositoryIntegrationTest and 1.289s of method time for its three tests. The issue's 4.40s gap is from the earlier run. The five RANDOM_PORT classes are unchanged.

    The working tree deletes @Disabled putCanUpdateCartographySpatialSelectionConnection. That method did not run, so removing it does not remove the port. TestUtils.adminAuthHeaders and the sibling MockMvc overlap, including #313, still stand.

  4. fjlopez commented on Oct 21, 2026

    @fjlopez
    ContributorAuthor

    Fixed on dev by #349.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plannedActive backlog; exempt from stale bot

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions