[java-plugin-storage-jdbc] 01/01: JJDBC-14, JJDBC-18 Prepare for the Java 17 stack

Rod Widdowson rdw at steadingsoftware.com
Mon Dec 19 16:04:14 UTC 2022


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

rdw pushed a commit to branch dev/JJDBC-18
in repository java-plugin-storage-jdbc.

View the commit online:
http://git.shibboleth.net/view/?p=java-plugin-storage-jdbc.git;a=commit;h=c1f1f783be96243f33bcfc758c5569b05b95a064

commit c1f1f783be96243f33bcfc758c5569b05b95a064
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon Dec 19 16:02:28 2022 +0000

    JJDBC-14,  JJDBC-18 Prepare for the Java 17 stack
    
    https://shibboleth.atlassian.net/browse/JJDBC-14
    https://shibboleth.atlassian.net/browse/JJDBC-18
    
    Move poms forward.
    Remove use of StorageCapabilitiesEx.
    Move several imports to their new home
---
 jdbc-storage-impl/pom.xml                          |   5 +-
 .../storage/jdbc/impl/JDBCStorageRecord.java       |   3 +-
 .../storage/jdbc/impl/JDBCStorageService.java      |  26 ++-
 .../storage/jdbc/impl/JDBCStorageServiceTest.java  |   3 +-
 .../jdbc/impl/JDCBJPAMixedStorageServiceTest.java  | 230 ---------------------
 pom.xml                                            |   6 +-
 6 files changed, 21 insertions(+), 252 deletions(-)

diff --git a/jdbc-storage-impl/pom.xml b/jdbc-storage-impl/pom.xml
index 31a3f89..894a27d 100644
--- a/jdbc-storage-impl/pom.xml
+++ b/jdbc-storage-impl/pom.xml
@@ -38,9 +38,8 @@
         <!--  Test dependencies -->
         <dependency>
             <groupId>${opensaml.groupId}</groupId>
-            <artifactId>opensaml-storage-api</artifactId>
+            <artifactId>opensaml-testing</artifactId>
             <version>${opensaml.version}</version>
-            <type>test-jar</type>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -62,7 +61,7 @@
         <dependency>
             <groupId>com.microsoft.sqlserver</groupId>
             <artifactId>mssql-jdbc</artifactId>
-            <version>10.2.0.jre11</version>
+            <version>11.2.0.jre11</version>
             <scope>test</scope>
         </dependency>
         -->
diff --git a/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageRecord.java b/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageRecord.java
index 177540e..077b62a 100644
--- a/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageRecord.java
+++ b/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageRecord.java
@@ -22,7 +22,8 @@ import javax.annotation.Nullable;
 
 import org.opensaml.storage.MutableStorageRecord;
 
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+
 
 /** Storage record used by {@link JDBCStorageService}.
  * This is notable in that it allows creation with a specified version (from
diff --git a/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageService.java b/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageService.java
index 86c06c0..86b3446 100644
--- a/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageService.java
+++ b/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageService.java
@@ -39,28 +39,26 @@ import javax.sql.DataSource;
 
 import org.opensaml.storage.AbstractStorageService;
 import org.opensaml.storage.MutableStorageRecord;
-import org.opensaml.storage.StorageCapabilitiesEx;
+import org.opensaml.storage.StorageCapabilities;
 import org.opensaml.storage.StorageRecord;
 import org.opensaml.storage.VersionMismatchException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-import net.shibboleth.utilities.java.support.annotation.constraint.Positive;
-import net.shibboleth.utilities.java.support.collection.Pair;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.logic.ConstraintViolationException;
-import net.shibboleth.utilities.java.support.primitive.StringSupport;
-
+import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
+import net.shibboleth.shared.annotation.constraint.NonnullElements;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.annotation.constraint.Positive;
+import net.shibboleth.shared.collection.Pair;
+import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.logic.ConstraintViolationException;
+import net.shibboleth.shared.primitive.StringSupport;
 
 /**
  * Implementation of {@link org.opensaml.storage.StorageService} that uses native JDBC to persist to a database.
  */
-public final class JDBCStorageService extends AbstractStorageService implements StorageCapabilitiesEx {
+public final class JDBCStorageService extends AbstractStorageService implements StorageCapabilities {
     
     /** The context, key and value we test the database with. */
     static final String VERIFY_STRING = "net.shibboleth.plugin.storage.jdbc.impl.test";
@@ -257,7 +255,7 @@ public final class JDBCStorageService extends AbstractStorageService implements
      * @param what do we want to lock locally?
      */
     public void setLocalLocking(final boolean what) {
-        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        ifInitializedThrowUnmodifiabledComponentException();
         if (what) {
             readWriteLock = new ReentrantReadWriteLock(true);
         } else {
diff --git a/jdbc-storage-impl/src/test/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageServiceTest.java b/jdbc-storage-impl/src/test/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageServiceTest.java
index 9871da6..6731887 100644
--- a/jdbc-storage-impl/src/test/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageServiceTest.java
+++ b/jdbc-storage-impl/src/test/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageServiceTest.java
@@ -43,7 +43,8 @@ import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.shared.component.ComponentInitializationException;
+
 
 /**
  * Test of {@link JDBCStorageService} implementation.
diff --git a/jdbc-storage-impl/src/test/java/net/shibboleth/plugin/storage/jdbc/impl/JDCBJPAMixedStorageServiceTest.java b/jdbc-storage-impl/src/test/java/net/shibboleth/plugin/storage/jdbc/impl/JDCBJPAMixedStorageServiceTest.java
deleted file mode 100644
index bcc224d..0000000
--- a/jdbc-storage-impl/src/test/java/net/shibboleth/plugin/storage/jdbc/impl/JDCBJPAMixedStorageServiceTest.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements.  See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID licenses this file to You under the Apache
- * License, Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.shibboleth.plugin.storage.jdbc.impl;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.io.IOException;
-import java.security.SecureRandom;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-
-import org.opensaml.storage.StorageRecord;
-import org.opensaml.storage.impl.JPAStorageService;
-import org.springframework.context.support.ConversionServiceFactoryBean;
-import org.springframework.context.support.GenericApplicationContext;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import net.shibboleth.ext.spring.config.StringToDurationConverter;
-import net.shibboleth.ext.spring.util.ApplicationContextBuilder;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-
-/**
- * Test of {@link JPAStorageService} and {@link JDBCStorageService} coexistence.
- */
-public class JDCBJPAMixedStorageServiceTest  {
-
-    /** Storage service. */
-    private JPAStorageService jpaService;
-    
-    private JDBCStorageService jdbcService;
-
-    private final SecureRandom random = new SecureRandom();
-
-    /** Contexts used for testing. */
-    private Object[][] contexts;
-
-    public JDCBJPAMixedStorageServiceTest() {
-        final SecureRandom random1 = new SecureRandom();
-        contexts = new Object[10][1];
-        for (int i = 0; i < 10; i++) {
-            contexts[i] = new Object[] {Long.toString(random1.nextLong()), };
-        }
-    }
-
-    /**
-     * Creates the shared instance of the entity manager factory.
-     */
-    @BeforeClass public void setUp() throws ComponentInitializationException {
-        final Resource resource = new ClassPathResource("/mixed.xml");
-        final ConversionServiceFactoryBean service = new ConversionServiceFactoryBean();
-        service.setConverters(new HashSet<>(Arrays.asList(
-                new StringToDurationConverter())));
-        service.afterPropertiesSet();
-
-        final GenericApplicationContext context =
-                new ApplicationContextBuilder()
-                    .setName("StorageServiceTest")
-                    .setServiceConfiguration(resource)
-                    .setConversionService(service.getObject())
-                    .build();
-        jdbcService = context.getBean(JDBCStorageService.class);
-        jpaService = context.getBean(JPAStorageService.class);
-    }
-
-    @AfterClass
-    protected void tearDown() {
-        try {
-            List<String> contexts1 = jpaService.readContexts();
-            for (String ctx : contexts1) {
-                jdbcService.deleteContext(ctx);
-            }
-            List<?> recs = jpaService.readAll();
-            Assert.assertEquals(recs.size(), 0);
-        } catch (IOException e){ 
-            throw new RuntimeException(e);
-        }
-    }
-
-	    @Test
-	    public void cleanup() throws ComponentInitializationException, IOException {
-	    assertNotNull(jdbcService.getCleanupTask());
-	    assertTrue(jpaService.getCleanupInterval().isZero());
-        String context = Long.toString(random.nextLong());
-        for (int i = 1; i <= 100; i++) {
-            jpaService.create(context, Integer.toString(i), Integer.toString(i + 1), System.currentTimeMillis() + 100);
-            jdbcService.create(context, Integer.toString(110 + i), Integer.toString(110 + i + 2), System.currentTimeMillis() + 100);
-        }
-        Assert.assertEquals(jdbcService.readAll(context).size(), 200);
-        Assert.assertEquals(jpaService.readAll(context).size(), 200);
-        try {
-            Thread.sleep(7500);
-        } catch (InterruptedException e) {
-            throw new IOException(e);
-        }
-        Assert.assertEquals(jdbcService.readAll(context).size(), 0);
-        Assert.assertEquals(jpaService.readAll(context).size(), 0);
-    }
-
-    @Test(dependsOnMethods = "cleanup")
-    public void keyCollision() throws IOException {
-        jpaService.create("unit_test", "dlo1", "value", null);
-        jdbcService.create("unit_test", "dn11", "value", null);
-        StorageRecord<?> rec1 = jdbcService.read("unit_test", "dlo1");
-        StorageRecord<?> rec2 = jpaService.read("unit_test", "dn11");
-        Assert.assertNotNull(rec1);
-        Assert.assertNotNull(rec2);
-        Assert.assertNotEquals(rec1, rec2);
-
-        jpaService.update("unit_test", "dlo1", "value2", null);
-        jdbcService.update("unit_test", "dn11", "value2", null);
-        rec1 = jdbcService.read("unit_test", "dlo1");
-        rec2 = jpaService.read("unit_test", "dn11");
-        Assert.assertNotNull(rec1);
-        Assert.assertNotNull(rec2);
-        Assert.assertNotEquals(rec1, rec2);
-
-        Assert.assertEquals(2, jdbcService.readAll().size());
-        Assert.assertEquals(2, jdbcService.readAll("unit_test").size());
-        Assert.assertEquals(2, jpaService.readAll().size());
-        Assert.assertEquals(2, jpaService.readAll("unit_test").size());
-
-        jpaService.delete("unit_test", "dlo1");
-        rec1 = jdbcService.read("unit_test", "dlo1");
-        rec2 = jdbcService.read("unit_test", "dn11");
-        Assert.assertNull(rec1);
-        Assert.assertNotNull(rec2);
-        jdbcService.delete("unit_test", "dn11");
-        rec1 = jpaService.read("unit_test", "dlo1");
-        rec2 = jpaService.read("unit_test", "dn11");
-        Assert.assertNull(rec1);
-        Assert.assertNull(rec2);
-    }
-
-    @Test(dependsOnMethods = "cleanup")
-    public void caseSensitiveContext() throws IOException {
-        assertTrue(jpaService.create("foo", "bar", "value", null));
-        assertTrue(jdbcService.create("FOO", "bar", "value", null));
-        StorageRecord<?> rec1 = jdbcService.read("foo", "bar");
-        StorageRecord<?> rec2 = jpaService.read("FOO", "bar");
-        Assert.assertNotNull(rec1);
-        Assert.assertNotNull(rec2);
-        Assert.assertNotEquals(rec1, rec2);
-        Assert.assertEquals(2, jpaService.readAll().size());
-        Assert.assertEquals(2, jdbcService.readAll().size());
-
-        jdbcService.update("foo", "bar", "value2", null);
-        jpaService.update("FOO", "bar", "value2", null);
-        rec1 = jpaService.read("foo", "bar");
-        rec2 = jdbcService.read("FOO", "bar");
-        Assert.assertNotNull(rec1);
-        Assert.assertNotNull(rec2);
-        Assert.assertNotEquals(rec1, rec2);
-
-        Assert.assertEquals(jpaService.readAll().size(), 2);
-        Assert.assertEquals(jpaService.readAll("foo").size(), 1);
-        Assert.assertEquals(jpaService.readAll("FOO").size(), 1);
-        Assert.assertEquals(jdbcService.readAll().size(), 2);
-        Assert.assertEquals(jdbcService.readAll("foo").size(), 1);
-        Assert.assertEquals(jdbcService.readAll("FOO").size(), 1);
-
-        jpaService.delete("foo", "bar");
-        rec1 = jdbcService.read("foo", "bar");
-        rec2 = jdbcService.read("FOO", "bar");
-        Assert.assertNull(rec1);
-        Assert.assertNotNull(rec2);
-        jdbcService.delete("FOO", "bar");
-        rec1 = jpaService.read("foo", "bar");
-        rec2 = jpaService.read("FOO", "bar");
-        Assert.assertNull(rec1);
-        Assert.assertNull(rec2);
-    }
-
-    @Test(dependsOnMethods = "cleanup")
-    public void caseSensitiveKey() throws IOException {
-        jdbcService.create("unit_test", "foo", "value", null);
-        jpaService.create("unit_test", "FOO", "value", null);
-        StorageRecord<?> rec1 = jpaService.read("unit_test", "foo");
-        StorageRecord<?> rec2 = jdbcService.read("unit_test", "FOO");
-        Assert.assertNotNull(rec1);
-        Assert.assertNotNull(rec2);
-        Assert.assertNotEquals(rec1, rec2);
-
-        jpaService.update("unit_test", "foo", "value2", null);
-        jdbcService.update("unit_test", "FOO", "value2", null);
-        rec1 = jdbcService.read("unit_test", "foo");
-        rec2 = jpaService.read("unit_test", "FOO");
-        Assert.assertNotNull(rec1);
-        Assert.assertNotNull(rec2);
-        Assert.assertNotEquals(rec1, rec2);
-
-        Assert.assertEquals(2, jpaService.readAll().size());
-        Assert.assertEquals(2, jpaService.readAll("unit_test").size());
-        Assert.assertEquals(2, jdbcService.readAll().size());
-        Assert.assertEquals(2, jdbcService.readAll("unit_test").size());
-
-        jdbcService.delete("unit_test", "foo");
-        rec1 = jpaService.read("unit_test", "foo");
-        rec2 = jpaService.read("unit_test", "FOO");
-        Assert.assertNull(rec1);
-        Assert.assertNotNull(rec2);
-        jpaService.delete("unit_test", "FOO");
-        rec1 = jdbcService.read("unit_test", "foo");
-        rec2 = jdbcService.read("unit_test", "FOO");
-        Assert.assertNull(rec1);
-        Assert.assertNull(rec2);
-    }
-
-}
diff --git a/pom.xml b/pom.xml
index 3e968a6..d3aa01d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
     <parent>
         <groupId>net.shibboleth</groupId>
         <artifactId>parent</artifactId>
-        <version>11.3.4</version>
+        <version>17.0.0-SNAPSHOT</version>
     </parent>
     <groupId>net.shibboleth.plugin.storage.jdbc</groupId>
     <artifactId>jdbc-storage-parent</artifactId>
@@ -14,9 +14,9 @@
     <description>jdbc-storage plugin for the Shibboleth Projects.</description>
     <properties>
         <idp.groupId>net.shibboleth.idp</idp.groupId>
-        <idp.version>4.1.0</idp.version>
+        <idp.version>5.0.0-SNAPSHOT</idp.version>
         <opensaml.groupId>org.opensaml</opensaml.groupId>
-        <opensaml.version>4.1.0</opensaml.version>
+        <opensaml.version>5.0.0-SNAPSHOT</opensaml.version>
         <checkstyle.configLocation>${project.basedir}/checkstyle.xml</checkstyle.configLocation>
     </properties>
     <distributionManagement>

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


More information about the commits mailing list