public void before() throws Throwable { DropwizardTestResourceConfig.CONFIGURATION_REGISTRY.put(configuration.getId(), configuration); test = new JerseyTest() { @Override protected TestContainerFactory getTestContainerFactory() { return configuration.testContainerFactory; } @Override protected DeploymentContext configureDeployment() { return ServletDeploymentContext.builder(new DropwizardTestResourceConfig(configuration)) .initParam(ServletProperties.JAXRS_APPLICATION_CLASS, DropwizardTestResourceConfig.class.getName()) .initParam(DropwizardTestResourceConfig.CONFIGURATION_ID, configuration.getId()) .build(); } @Override protected void configureClient(ClientConfig clientConfig) { final JacksonJsonProvider jsonProvider = new JacksonJsonProvider(); jsonProvider.setMapper(configuration.mapper); configuration.clientConfigurator.accept(clientConfig); clientConfig.register(jsonProvider); } }; test.setUp(); }
public void setup() throws Exception _jerseyTest.setUp();
public void before() throws Throwable { DropwizardTestResourceConfig.CONFIGURATION_REGISTRY.put(configuration.getId(), configuration); test = new JerseyTest() { @Override protected TestContainerFactory getTestContainerFactory() { return configuration.testContainerFactory; } @Override protected DeploymentContext configureDeployment() { return ServletDeploymentContext.builder(new DropwizardTestResourceConfig(configuration)) .initParam(ServletProperties.JAXRS_APPLICATION_CLASS, DropwizardTestResourceConfig.class.getName()) .initParam(DropwizardTestResourceConfig.CONFIGURATION_ID, configuration.getId()) .build(); } @Override protected void configureClient(ClientConfig clientConfig) { final JacksonJsonProvider jsonProvider = new JacksonJsonProvider(); jsonProvider.setMapper(configuration.mapper); configuration.clientConfigurator.accept(clientConfig); clientConfig.register(jsonProvider); } }; test.setUp(); }
public void setUp() throws Exception { log.info("setUp in class: {}", this.getClass().getCanonicalName()); super.setUp(); } public void tearDown() throws Exception {
/** * <ol> * <li>calls {@link JerseyTest#setUp()} * <li>passes the initialized JerseyTest to the consumer. * <li>calls {@link JerseyTest#tearDown()} * </ol> * * @param jerseyTest * @param test * @throws Exception */ public void runJerseyTest(JerseyTest jerseyTest, ThrowingConsumer<JerseyTest> test) throws Exception { try { jerseyTest.setUp(); test.accept(jerseyTest); } finally { jerseyTest.tearDown(); } }
@Override public void run() { try { harness.setUp(); configurationLoader = testBinderFactory.getConfigurationLoader(); } catch (Throwable e) { cause = e; } } }
@Override public void run() { try { harness.setUp(); configurationLoader = testBinderFactory.getConfigurationLoader(); } catch (Throwable e) { cause = e; } } }
@BeforeEach @Override // JerseyTest#setUp is annotated with @Before and as such not invoked by JUnit 5 => invoke public void setUp() throws Exception { super.setUp(); }
@BeforeEach @Override // JerseyTest#setUp is annotated with @Before and as such not invoked by JUnit 5 => invoke public void setUp() throws Exception { System.setProperty("sun.net.http.allowRestrictedHeaders", "true"); super.setUp(); System.setProperty("sun.net.http.allowRestrictedHeaders", "true"); }
@BeforeEach @Override // JerseyTest#setUp is annotated with @Before and as such not invoked by JUnit 5 => invoke public void setUp() throws Exception { super.setUp(); }
@BeforeAll public void before() throws Exception { super.setUp(); }
@Test public void testTearsDownTestOnSetupFailure() throws Exception { doThrow(new RuntimeException()).when(jerseyTest).setUp(); try { runner.runJerseyTest(jerseyTest, consumer); fail("expected exception to be thrown"); } catch (RuntimeException re) { } verify(jerseyTest).setUp(); verify(jerseyTest).tearDown(); }
@Test public void testDoesNotCallConsumerOnStartupFailure() throws Exception { doThrow(new RuntimeException()).when(jerseyTest).setUp(); try { runner.runJerseyTest(jerseyTest, consumer); fail("expected exception to be thrown"); } catch (RuntimeException re) { } verifyZeroInteractions(consumer);; }
@Test public void testCallSetupConsumerAndTearDownInOrder() throws Exception { runner.runJerseyTest(jerseyTest, consumer); InOrder inOrder = Mockito.inOrder(jerseyTest, consumer); inOrder.verify(jerseyTest).setUp(); inOrder.verify(consumer).accept(jerseyTest); inOrder.verify(jerseyTest).tearDown(); }
@BeforeAll public void before() throws Exception { super.setUp(); setDefaultPollInterval(100L, MILLISECONDS); }
@Test public void testRethrowsExceptionOnStartupFailure() throws Exception { RuntimeException thrownException = new RuntimeException("whatever"); doThrow(thrownException).when(jerseyTest).setUp(); try { runner.runJerseyTest(jerseyTest, consumer); fail("expected exception to be thrown"); } catch (RuntimeException re) { assertSame(thrownException, re); } }
jerseyTest.setUp();
public void setUp() throws Exception { initJerseyTest() jerseyTest.setUp();