File tree 1 file changed +27
-0
lines changed
core/src/test/java/io/undertow/server/handlers/session
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 20
20
21
21
import java .io .IOException ;
22
22
23
+ import io .undertow .UndertowMessages ;
23
24
import io .undertow .server .HttpHandler ;
24
25
import io .undertow .server .HttpServerExchange ;
25
26
import io .undertow .server .session .InMemorySessionManager ;
@@ -249,4 +250,30 @@ public void run() {
249
250
client .getConnectionManager ().shutdown ();
250
251
}
251
252
}
253
+
254
+ @ Test
255
+ public void inMemorySessionNoConfigTest () throws IOException {
256
+ try (TestHttpClient client = new TestHttpClient ()) {
257
+ client .setCookieStore (new BasicCookieStore ());
258
+
259
+ final SessionAttachmentHandler handler = new SessionAttachmentHandler (new InMemorySessionManager ("" ), null );
260
+ handler .setNext (new HttpHandler () {
261
+ @ Override
262
+ public void handleRequest (final HttpServerExchange exchange ) throws Exception {
263
+ final SessionManager manager = exchange .getAttachment (SessionManager .ATTACHMENT_KEY );
264
+
265
+ IllegalStateException thrown = Assert .assertThrows (IllegalStateException .class , () -> {
266
+ manager .getSession (exchange , null );
267
+ });
268
+
269
+ Assert .assertEquals (UndertowMessages .MESSAGES .couldNotFindSessionCookieConfig ().getCause (), thrown .getCause ());
270
+ Assert .assertEquals (UndertowMessages .MESSAGES .couldNotFindSessionCookieConfig ().getMessage (), thrown .getMessage ());
271
+ }
272
+ });
273
+ DefaultServer .setRootHandler (handler );
274
+
275
+ HttpGet get = new HttpGet (DefaultServer .getDefaultServerURL () + "/notamatchingpath" );
276
+ client .execute (get );
277
+ }
278
+ }
252
279
}
You can’t perform that action at this time.
0 commit comments