Skip to content

Commit

Permalink
Merge pull request #27284 from manovotn/failingCpTest
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Aug 15, 2022
2 parents 8c3beb0 + a189bf9 commit 81e4ecb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
@@ -1,12 +1,15 @@
package io.quarkus.context.test;

import java.util.concurrent.CountDownLatch;

import javax.annotation.PreDestroy;
import javax.enterprise.context.RequestScoped;

@RequestScoped
public class RequestBean {

public static volatile int DESTROY_INVOKED = 0;
public static volatile CountDownLatch LATCH;

public String callMe() {
return "Hello " + System.identityHashCode(this);
Expand All @@ -15,5 +18,14 @@ public String callMe() {
@PreDestroy
public void destroy() {
DESTROY_INVOKED++;
// bean is also used in tests where there is no latch
if (LATCH != null) {
LATCH.countDown();
}
}

public static void initState() {
LATCH = new CountDownLatch(2);
DESTROY_INVOKED = 0;
}
}
Expand Up @@ -75,20 +75,22 @@ public void testArcTCContextPropagation() {
}

@Test()
public void testArcMEContextPropagationDisabled() {
public void testArcMEContextPropagationDisabled() throws InterruptedException {
// reset state
RequestBean.DESTROY_INVOKED = 0;
RequestBean.initState();
RestAssured.when().get("/context/noarc").then()
.statusCode(Response.Status.OK.getStatusCode());
Assertions.assertTrue(RequestBean.LATCH.await(3, TimeUnit.SECONDS));
Assertions.assertEquals(2, RequestBean.DESTROY_INVOKED);
}

@Test()
public void testArcTCContextPropagationDisabled() {
public void testArcTCContextPropagationDisabled() throws InterruptedException {
// reset state
RequestBean.DESTROY_INVOKED = 0;
RequestBean.initState();
RestAssured.when().get("/context/noarc-tc").then()
.statusCode(Response.Status.OK.getStatusCode());
Assertions.assertTrue(RequestBean.LATCH.await(3, TimeUnit.SECONDS));
Assertions.assertEquals(2, RequestBean.DESTROY_INVOKED);
}

Expand Down

0 comments on commit 81e4ecb

Please sign in to comment.