You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by vl...@apache.org on 2023/04/23 22:14:40 UTC

[tapestry-5] branch master updated: TAP5-2537: Added integration test to show this bug is fixed.

This is an automated email from the ASF dual-hosted git repository.

vlamp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git


The following commit(s) were added to refs/heads/master by this push:
     new 0b1437fca TAP5-2537: Added integration test to show this bug is fixed.
0b1437fca is described below

commit 0b1437fcaa26c5401e29a0f0e36cec7d886aea73
Author: Volker Lamp <vl...@apache.org>
AuthorDate: Mon Apr 24 00:12:32 2023 +0200

    TAP5-2537: Added integration test to show this bug is fixed.
---
 ...ionApplicationStatePersistenceStrategyTest.java | 68 +++++++++++++++++++++-
 1 file changed, 67 insertions(+), 1 deletion(-)

diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/SessionApplicationStatePersistenceStrategyTest.java b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/SessionApplicationStatePersistenceStrategyTest.java
index fe714465b..ca7f59e6b 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/SessionApplicationStatePersistenceStrategyTest.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/SessionApplicationStatePersistenceStrategyTest.java
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008 The Apache Software Foundation
+// Copyright 2007, 2008, 2023 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -154,4 +154,70 @@ public class SessionApplicationStatePersistenceStrategyTest extends InternalBase
 
         verify();
     }
+
+    @Test(description = "TAP5-2537")
+    public void getIfExists_where_no_session()
+    {
+        Request request = mockRequest();
+        Class asoClass = ReadOnlyBean.class;
+
+        train_getSession(request, false, null);
+
+        ApplicationStatePersistenceStrategy strategy = new SessionApplicationStatePersistenceStrategy(request);
+
+        replay();
+
+        assertNull(strategy.getIfExists(asoClass));
+
+        verify();
+
+    }
+
+
+    @Test
+    public void getIfExists_where_it_does_not()
+    {
+        Request request = mockRequest();
+        Session session = mockSession();
+        Class asoClass = ReadOnlyBean.class;
+        Object aso = new ReadOnlyBean();
+        String key = "sso:" + asoClass.getName();
+        ApplicationStateCreator creator = mockApplicationStateCreator();
+
+        train_getSession(request, false, session);
+        train_getAttribute(session, key, null);
+
+        ApplicationStatePersistenceStrategy strategy = new SessionApplicationStatePersistenceStrategy(request);
+
+        replay();
+
+        assertNull(strategy.getIfExists(asoClass));
+
+        verify();
+
+    }
+
+    @Test
+    public void getIfExists_where_it_does()
+    {
+        Request request = mockRequest();
+        Session session = mockSession();
+        Class asoClass = ReadOnlyBean.class;
+        Object aso = new ReadOnlyBean();
+        String key = "sso:" + asoClass.getName();
+        ApplicationStateCreator creator = mockApplicationStateCreator();
+
+        train_getSession(request, false, session);
+        train_getAttribute(session, key, aso);
+
+        ApplicationStatePersistenceStrategy strategy = new SessionApplicationStatePersistenceStrategy(request);
+
+        replay();
+
+        assertSame(strategy.getIfExists(asoClass), aso);
+
+        verify();
+
+    }
+
 }