From d6625ca144c4c8cb55f29b7a4d82e5735ea437af Mon Sep 17 00:00:00 2001 From: Tim Kafalas tkafalas Date: Fri, 2 Feb 2024 12:02:44 -0500 Subject: [PATCH] [BACKLOG-39719][BACKLOG-39705][SP-4826] Bug fixes and changes for Integrated Tests --- extensions/pom.xml | 18 +++++++++++ .../plugin/services/cache/CacheManagerIT.java | 4 +-- .../cache/CacheManagerWithRegionIT.java | 2 +- .../plugin/services/cache/CacheManager.java | 7 +++-- .../services/cache/LastModifiedCache.java | 2 +- .../system/hibernate/hibernate-settings.xml | 31 +++++++++++++++++++ 6 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 extensions/src/test/resources/cache-solution/system/hibernate/hibernate-settings.xml diff --git a/extensions/pom.xml b/extensions/pom.xml index 874155d759..d84fa7ce8c 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -451,6 +451,24 @@ + + c3p0 + c3p0 + 0.9.1.2 + test + + + javax.persistence + javax.persistence-api + ${javax.persistence-api.version} + test + + + jakarta.validation + jakarta.validation-api + 2.0.2 + test + org.hibernate hibernate-core diff --git a/extensions/src/it/java/org/pentaho/test/platform/plugin/services/cache/CacheManagerIT.java b/extensions/src/it/java/org/pentaho/test/platform/plugin/services/cache/CacheManagerIT.java index b000d07405..b8df7270a0 100644 --- a/extensions/src/it/java/org/pentaho/test/platform/plugin/services/cache/CacheManagerIT.java +++ b/extensions/src/it/java/org/pentaho/test/platform/plugin/services/cache/CacheManagerIT.java @@ -14,7 +14,7 @@ * See the GNU Lesser General Public License for more details. * * - * Copyright (c) 2002-2018 Hitachi Vantara. All rights reserved. + * Copyright (c) 2002-2024 Hitachi Vantara. All rights reserved. * */ @@ -52,8 +52,6 @@ public String getSolutionPath() { } } - // private final StringBuffer longString = new StringBuffer(); - public void testCache() { // Make sure we have a cache first... diff --git a/extensions/src/it/java/org/pentaho/test/platform/plugin/services/cache/CacheManagerWithRegionIT.java b/extensions/src/it/java/org/pentaho/test/platform/plugin/services/cache/CacheManagerWithRegionIT.java index 1798759ce0..2c39959d08 100644 --- a/extensions/src/it/java/org/pentaho/test/platform/plugin/services/cache/CacheManagerWithRegionIT.java +++ b/extensions/src/it/java/org/pentaho/test/platform/plugin/services/cache/CacheManagerWithRegionIT.java @@ -14,7 +14,7 @@ * See the GNU Lesser General Public License for more details. * * - * Copyright (c) 2002-2018 Hitachi Vantara. All rights reserved. + * Copyright (c) 2002-2024 Hitachi Vantara. All rights reserved. * */ diff --git a/extensions/src/main/java/org/pentaho/platform/plugin/services/cache/CacheManager.java b/extensions/src/main/java/org/pentaho/platform/plugin/services/cache/CacheManager.java index 32132980e3..7807b69588 100644 --- a/extensions/src/main/java/org/pentaho/platform/plugin/services/cache/CacheManager.java +++ b/extensions/src/main/java/org/pentaho/platform/plugin/services/cache/CacheManager.java @@ -320,7 +320,6 @@ public void clearRegionCache( String region ) { try { try ( SessionImpl session = (SessionImpl) cache.getSessionFactory().openSession() ) { cache.getStorageAccess().clearCache( session ); - cache.evictAll(); } } catch ( CacheException e ) { CacheManager.logger.error( Messages.getInstance().getString( @@ -425,7 +424,7 @@ public void clearCache() { String key = ( entry.getKey() != null ) ? entry.getKey().toString() : ""; //$NON-NLS-1$ if ( key != null ) { Cache cache = regionCache.get( key ); - cache.evictAll(); + removeRegionCache( key ); } } } @@ -450,7 +449,9 @@ public void killSessionCache( IPentahoSession session ) { while ( it.hasNext() ) { String key = (String) it.next(); if ( key.indexOf( session.getId() ) >= 0 ) { - hvcache.evictEntityData( key ); + try ( SessionImpl hibSession = (SessionImpl) hvcache.getSessionFactory().openSession() ) { + hvcache.getStorageAccess().removeFromCache( key, hibSession ); + } } } } diff --git a/extensions/src/main/java/org/pentaho/platform/plugin/services/cache/LastModifiedCache.java b/extensions/src/main/java/org/pentaho/platform/plugin/services/cache/LastModifiedCache.java index ecbb121b91..d369ad62ff 100644 --- a/extensions/src/main/java/org/pentaho/platform/plugin/services/cache/LastModifiedCache.java +++ b/extensions/src/main/java/org/pentaho/platform/plugin/services/cache/LastModifiedCache.java @@ -141,7 +141,7 @@ protected void setLastModified() { } @Override public void evictEntityData() { - sessionFactory.getMetamodel().entityPersisters().values().forEach( this::evictEntityData ); + throwNotImplemented(); } @Override diff --git a/extensions/src/test/resources/cache-solution/system/hibernate/hibernate-settings.xml b/extensions/src/test/resources/cache-solution/system/hibernate/hibernate-settings.xml new file mode 100644 index 0000000000..855ee61992 --- /dev/null +++ b/extensions/src/test/resources/cache-solution/system/hibernate/hibernate-settings.xml @@ -0,0 +1,31 @@ + + + + + system/hibernate/postgresql.hibernate.cfg.xml + + + + false + \ No newline at end of file