Skip to content

Commit

Permalink
Add a test for security provider run time registration.
Browse files Browse the repository at this point in the history
  • Loading branch information
jovanstevanovic committed Dec 25, 2024
1 parent bcc8d2e commit 032d899
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ public void duringSetup(final DuringSetupAccess access) {
}
}

/**
* This test ensures that the list of security providers is populated at run time, and not at
* build time.
*/
@Test
public void testSecurityProviderRuntimeRegistration() {
Provider notRegistered = Security.getProvider("no-op-provider");
Assert.assertNull("Provider is registered.", notRegistered);

Security.addProvider(new NoOpProvider());

Provider registered = Security.getProvider("no-op-provider");
Assert.assertNotNull("Provider is not registered.", registered);
}

/**
* Tests that native-image generation doesn't run into an issue (like NPE) if the application
* uses a java.security.Provider.Service which isn't part of the services shipped in the JDK.
Expand Down

0 comments on commit 032d899

Please sign in to comment.