Skip to content

Commit d188f5c

Browse files
committed
Update quarkus-http, create test coverage for Undertow session context events
1 parent c28e1b9 commit d188f5c

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

bom/application/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<resteasy.version>6.2.12.Final</resteasy.version>
3232
<opentelemetry-instrumentation.version>2.10.0-alpha</opentelemetry-instrumentation.version>
3333
<opentelemetry-semconv.version>1.29.0-alpha</opentelemetry-semconv.version>
34-
<quarkus-http.version>5.3.4</quarkus-http.version>
34+
<quarkus-http.version>5.3.5</quarkus-http.version>
3535
<micrometer.version>1.14.7</micrometer.version><!-- keep in sync with hdrhistogram: https://central.sonatype.com/artifact/io.micrometer/micrometer-core -->
3636
<hdrhistogram.version>2.2.2</hdrhistogram.version><!-- keep in sync with micrometer -->
3737
<google-auth.version>0.22.0</google-auth.version>

extensions/undertow/deployment/src/test/java/io/quarkus/undertow/test/sessioncontext/SessionContextTestCase.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public class SessionContextTestCase {
1717

1818
@RegisterExtension
1919
static QuarkusUnitTest runner = new QuarkusUnitTest()
20-
.withApplicationRoot((jar) -> jar.addClasses(TestServlet.class, Foo.class, ObservingBean.class));
20+
.withApplicationRoot(
21+
(jar) -> jar.addClasses(TestServlet.class, Foo.class, ObservingBean.class, SessionScopedObserver.class));
2122

2223
@Test
2324
public void testServlet() {
@@ -38,12 +39,17 @@ public void testContextEvents() {
3839

3940
// make sure we start with zero events to keep this test method independent
4041
observingBean.resetState();
42+
SessionScopedObserver.resetState();
4143

4244
// following request creates a session and also destroys it by enforcing invalidation
4345
when().get("/foo?destroy=true").then().statusCode(200);
4446
Assertions.assertEquals(1, observingBean.getTimesInitObserved());
4547
Assertions.assertEquals(1, observingBean.getTimesBeforeDestroyedObserved());
4648
Assertions.assertEquals(1, observingBean.getTimesDestroyedObserved());
49+
50+
// assert that @SessionScoped bean can observe init and before destroyed events as well
51+
Assertions.assertEquals(1, SessionScopedObserver.timesInitObserved);
52+
Assertions.assertEquals(1, SessionScopedObserver.timesBeforeDestroyedObserved);
4753
}
4854

4955
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package io.quarkus.undertow.test.sessioncontext;
2+
3+
import jakarta.enterprise.context.BeforeDestroyed;
4+
import jakarta.enterprise.context.Initialized;
5+
import jakarta.enterprise.context.SessionScoped;
6+
import jakarta.enterprise.event.Observes;
7+
8+
@SessionScoped
9+
public class SessionScopedObserver {
10+
11+
static int timesInitObserved = 0;
12+
static int timesBeforeDestroyedObserved = 0;
13+
14+
public void observeInit(@Observes @Initialized(SessionScoped.class) Object event) {
15+
timesInitObserved++;
16+
}
17+
18+
public void observeBeforeDestroyed(@Observes @BeforeDestroyed(SessionScoped.class) Object event) {
19+
timesBeforeDestroyedObserved++;
20+
}
21+
22+
public static void resetState() {
23+
timesInitObserved = 0;
24+
timesBeforeDestroyedObserved = 0;
25+
}
26+
}

0 commit comments

Comments
 (0)