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

fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-persistence-jdbc.git


The following commit(s) were added to refs/heads/main by this push:
     new 9b15428  Journal test with db schema (#288)
9b15428 is described below

commit 9b154281bb6b56526b6c4082a3f4735405b2bb0e
Author: PJ Fanning <[email protected]>
AuthorDate: Wed Apr 23 11:19:58 2025 +0200

    Journal test with db schema (#288)
    
    * add journal test with schema
    
    * Update JdbcJournalSpec.scala
    
    * test issue
---
 .../persistence/jdbc/journal/JdbcJournalSpec.scala | 41 +++++++++++++++++++++-
 .../jdbc/snapshot/JdbcSnapshotStoreSpec.scala      |  4 +--
 .../jdbc/integration/JdbcJournalSpec.scala         | 20 +++++++++--
 3 files changed, 59 insertions(+), 6 deletions(-)

diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/journal/JdbcJournalSpec.scala
 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/journal/JdbcJournalSpec.scala
index de8e7d8..b7ce015 100644
--- 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/journal/JdbcJournalSpec.scala
+++ 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/journal/JdbcJournalSpec.scala
@@ -20,10 +20,11 @@ import pekko.persistence.CapabilityFlag
 import pekko.persistence.journal.JournalSpec
 import pekko.persistence.jdbc.config.JournalConfig
 import pekko.persistence.jdbc.db.SlickExtension
-import pekko.persistence.jdbc.testkit.internal.{ H2, SchemaType }
+import pekko.persistence.jdbc.testkit.internal.{ H2, SchemaType, 
SchemaUtilsImpl }
 import pekko.persistence.jdbc.util.{ ClasspathResources, DropCreate }
 import org.scalatest.{ BeforeAndAfterAll, BeforeAndAfterEach }
 import org.scalatest.concurrent.ScalaFutures
+import org.slf4j.LoggerFactory
 
 import scala.concurrent.ExecutionContext
 import scala.concurrent.duration._
@@ -61,5 +62,43 @@ abstract class JdbcJournalSpec(config: Config, schemaType: 
SchemaType)
   }
 }
 
+abstract class JdbcJournalSchemaSpec(config: Config, schemaType: SchemaType)
+    extends JdbcJournalSpec(config, schemaType) {
+  private val logger = LoggerFactory.getLogger(this.getClass)
+  protected def defaultSchemaName: String = "public"
+  private val schemaName: String = "pekko"
+
+  override def beforeAll(): Unit = {
+    // need to drop the schema first, because a previous test may have left 
tables behind
+    SchemaUtilsImpl.dropWithSlick(schemaType, logger, db, false)
+    SchemaUtilsImpl.createWithSlickButChangeSchema(
+      schemaType, logger, db, defaultSchemaName, schemaName)
+    super.beforeAll()
+  }
+
+  override def afterAll(): Unit = {
+    SchemaUtilsImpl.dropWithSlickButChangeSchema(
+      schemaType, logger, db, defaultSchemaName, schemaName)
+    super.afterAll()
+  }
+}
+
 class H2JournalSpec extends 
JdbcJournalSpec(ConfigFactory.load("h2-application.conf"), H2)
 class H2JournalSpecSharedDb extends 
JdbcJournalSpec(ConfigFactory.load("h2-shared-db-application.conf"), H2)
+
+object H2JournalSchemaSpec {
+  val config: Config = ConfigFactory.parseString("""
+    jdbc-journal {
+      tables {
+        snapshot {
+          schemaName = "pekko"
+        }
+      }
+    }
+  """).withFallback(
+    ConfigFactory.load("h2-application.conf"))
+}
+
+class H2JournalSchemaSpec extends 
JdbcJournalSchemaSpec(H2JournalSchemaSpec.config, H2) {
+  override protected def defaultSchemaName: String = "PUBLIC"
+}
diff --git 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/snapshot/JdbcSnapshotStoreSpec.scala
 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/snapshot/JdbcSnapshotStoreSpec.scala
index 107fd21..56b91bf 100644
--- 
a/core/src/test/scala/org/apache/pekko/persistence/jdbc/snapshot/JdbcSnapshotStoreSpec.scala
+++ 
b/core/src/test/scala/org/apache/pekko/persistence/jdbc/snapshot/JdbcSnapshotStoreSpec.scala
@@ -19,8 +19,7 @@ import pekko.persistence.CapabilityFlag
 import pekko.persistence.jdbc.config._
 import pekko.persistence.jdbc.util.{ ClasspathResources, DropCreate }
 import pekko.persistence.jdbc.db.SlickDatabase
-import pekko.persistence.jdbc.testkit.internal.H2
-import pekko.persistence.jdbc.testkit.internal.{ SchemaType, SchemaUtilsImpl }
+import pekko.persistence.jdbc.testkit.internal.{ H2, SchemaType, 
SchemaUtilsImpl }
 import pekko.persistence.snapshot.SnapshotStoreSpec
 import pekko.testkit.TestKit
 
@@ -76,7 +75,6 @@ abstract class JdbcSnapshotStoreSchemaSpec(config: Config, 
schemaType: SchemaTyp
       schemaType, logger, db, defaultSchemaName, schemaName)
     super.afterAll()
   }
-
 }
 
 class H2SnapshotStoreSpec extends 
JdbcSnapshotStoreSpec(ConfigFactory.load("h2-application.conf"), H2)
diff --git 
a/integration-test/src/test/scala/org/apache/pekko/persistence/jdbc/integration/JdbcJournalSpec.scala
 
b/integration-test/src/test/scala/org/apache/pekko/persistence/jdbc/integration/JdbcJournalSpec.scala
index 948e191..c028ad4 100644
--- 
a/integration-test/src/test/scala/org/apache/pekko/persistence/jdbc/integration/JdbcJournalSpec.scala
+++ 
b/integration-test/src/test/scala/org/apache/pekko/persistence/jdbc/integration/JdbcJournalSpec.scala
@@ -10,14 +10,30 @@
 package org.apache.pekko.persistence.jdbc.integration
 
 import org.apache.pekko
-import pekko.persistence.jdbc.journal.JdbcJournalSpec
+import pekko.persistence.jdbc.journal.{ JdbcJournalSchemaSpec, JdbcJournalSpec 
}
 import pekko.persistence.jdbc.testkit.internal.{ MySQL, Oracle, Postgres, 
SqlServer }
-import com.typesafe.config.ConfigFactory
+import com.typesafe.config.{ Config, ConfigFactory }
 
 class PostgresJournalSpec extends 
JdbcJournalSpec(ConfigFactory.load("postgres-application.conf"), Postgres)
 class PostgresJournalSpecSharedDb
     extends 
JdbcJournalSpec(ConfigFactory.load("postgres-shared-db-application.conf"), 
Postgres)
 
+object PostgresJournalSchemaSpec {
+  val config: Config = ConfigFactory.parseString("""
+    jdbc-journal{
+      tables {
+        snapshot {
+          schemaName = "pekko"
+        }
+      }
+    }
+  """).withFallback(
+    ConfigFactory.load("postgres-application.conf"))
+}
+
+class PostgresJournalSchemaSpec
+    extends JdbcJournalSchemaSpec(PostgresJournalSchemaSpec.config, Postgres)
+
 class MySQLJournalSpec extends 
JdbcJournalSpec(ConfigFactory.load("mysql-application.conf"), MySQL)
 class MySQLJournalSpecSharedDb extends 
JdbcJournalSpec(ConfigFactory.load("mysql-shared-db-application.conf"), MySQL)
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to