[java-opensaml] 02/09: OSJ-413 - StorageService implementations compare version improperly

Scott Cantor cantor.2 at osu.edu
Thu Mar 13 18:41:53 UTC 2025


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch maint-5.1
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=82b2f2983871c800eb122de0eb07f1125b71ff6f

commit 82b2f2983871c800eb122de0eb07f1125b71ff6f
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Sep 4 08:40:57 2024 -0400

    OSJ-413 - StorageService implementations compare version improperly
    
    https://shibboleth.atlassian.net/browse/OSJ-413
    
    Add a unit test.
---
 .../storage/testing/StorageServiceTest.java        | 24 +++++++++-------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/opensaml-testing/src/main/java/org/opensaml/storage/testing/StorageServiceTest.java b/opensaml-testing/src/main/java/org/opensaml/storage/testing/StorageServiceTest.java
index e76cf04f4..79433a4b6 100644
--- a/opensaml-testing/src/main/java/org/opensaml/storage/testing/StorageServiceTest.java
+++ b/opensaml-testing/src/main/java/org/opensaml/storage/testing/StorageServiceTest.java
@@ -165,13 +165,13 @@ public abstract class StorageServiceTest {
     }
     
     /**
-     * Test of versioned update.
+     * Test of versions > 127.
      * 
-     * @throws IOException on error
-     * @throws VersionMismatchException on record version mismatch
+     * @throws IOException
+     * @throws VersionMismatchException 
      */
     @Test
-    public void updates() throws IOException, VersionMismatchException {
+    public void versions() throws IOException, VersionMismatchException {
         threadInit();
         
         final String key = "key";
@@ -179,20 +179,16 @@ public abstract class StorageServiceTest {
         
         shared.create(context, key, "foo", null);
         
-        assertEquals(shared.updateWithVersion(1, context, key, "bar", null), 2);
-        
-        try {
-            shared.updateWithVersion(1, context, key, "baz", null);
-            Assert.fail("updateStringWithVersion should have failed");
-        } catch (final VersionMismatchException e) {
-            // expected
+        for (long i = 1; i < 130; i++) {
+            shared.updateWithVersion(i, context, key, "foo" + i, null);
         }
         
         final StorageRecord<?> rec = shared.read(context, key);
-        assert rec!=null;
-        Assert.assertEquals(rec.getVersion(), 2);
+        assert rec != null;
+        Assert.assertEquals(rec.getVersion(), 130);
+        Assert.assertEquals(rec.getValue(), "foo129");
     }
-    
+        
     /**
      * Test updates.
      * 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list