Class BaseJerseyTest5

java.lang.Object
org.glassfish.jersey.test.JerseyTest
ubic.gemma.rest.util.BaseJerseyTest5
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
AnnotationsUsageCountCacheTest, AnnotationsWebServiceTest, BaseJerseyIntegrationTest5, DatasetsWebServiceTest, TasksWebServiceTest

@ActiveProfiles({"web","test"}) @WebAppConfiguration @ExtendWith(org.springframework.test.context.junit.jupiter.SpringExtension.class) @TestExecutionListeners({org.springframework.test.context.web.ServletTestExecutionListener.class,org.springframework.test.context.support.DependencyInjectionTestExecutionListener.class,org.springframework.test.context.support.DirtiesContextTestExecutionListener.class}) public abstract class BaseJerseyTest5 extends org.glassfish.jersey.test.JerseyTest implements org.springframework.context.ApplicationContextAware
JUnit 5 (Jupiter) counterpart of BaseJerseyTest.

Jersey 3.1's jersey-test-framework-core does not ship a Jupiter extension (only the JUnit 4 base JerseyTest and a TestNG variant), so the container lifecycle is bridged by overriding JerseyTest.setUp() / JerseyTest.tearDown() and re-annotating them with BeforeEach / AfterEach. The underlying methods on JerseyTest are plain public methods (no JUnit 4 annotations baked into the bytecode), so this re-annotation is the canonical bridge pattern and does not double-fire the lifecycle.

Spring's SpringExtension replaces the JUnit 4 SpringClassRule/SpringMethodRule pair used in BaseJerseyTest.

Author:
poirigui
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final jakarta.ws.rs.core.Application
     
    protected final void
    configureClient(org.glassfish.jersey.client.ClientConfig config)
     
    protected final org.glassfish.jersey.test.spi.TestContainerFactory
     
    final void
    setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
     
    final void
    Bridge the Jersey test-container setUp into Jupiter's lifecycle.
    final void
    Bridge the Jersey test-container tearDown into Jupiter's lifecycle.

    Methods inherited from class org.glassfish.jersey.test.JerseyTest

    client, close, closeIfNotNull, configureDeployment, disable, enable, forceDisable, forceEnable, forceSet, getAsyncTimeoutMultiplier, getBaseUri, getClient, getLastLoggedRecord, getLoggedRecords, getPort, getSslContext, getSslParameters, isEnabled, set, set, setClient, target, target

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BaseJerseyTest5

      public BaseJerseyTest5()
  • Method Details

    • getTestContainerFactory

      protected final org.glassfish.jersey.test.spi.TestContainerFactory getTestContainerFactory() throws org.glassfish.jersey.test.spi.TestContainerException
      Overrides:
      getTestContainerFactory in class org.glassfish.jersey.test.JerseyTest
      Throws:
      org.glassfish.jersey.test.spi.TestContainerException
    • configure

      protected final jakarta.ws.rs.core.Application configure()
      Overrides:
      configure in class org.glassfish.jersey.test.JerseyTest
    • setApplicationContext

      public final void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
    • configureClient

      protected final void configureClient(org.glassfish.jersey.client.ClientConfig config)
      Overrides:
      configureClient in class org.glassfish.jersey.test.JerseyTest
    • setUp

      @BeforeEach public final void setUp() throws Exception
      Bridge the Jersey test-container setUp into Jupiter's lifecycle.

      Intentionally final so subclasses cannot accidentally re-annotate this with a conflicting @BeforeEach or override the container bootstrap.

      Overrides:
      setUp in class org.glassfish.jersey.test.JerseyTest
      Throws:
      Exception
    • tearDown

      @AfterEach public final void tearDown() throws Exception
      Bridge the Jersey test-container tearDown into Jupiter's lifecycle.
      Overrides:
      tearDown in class org.glassfish.jersey.test.JerseyTest
      Throws:
      Exception