77import io .teaql .core .businessid .BusinessIdGenerationRequest ;
88import io .teaql .core .businessid .BusinessIdPlan ;
99import io .teaql .runtime .businessid .DailySequenceBusinessIdProfile ;
10+ import io .teaql .core .sql .dialect .OracleDialect ;
1011import java .sql .Connection ;
1112import java .sql .DriverManager ;
1213import java .time .LocalDate ;
@@ -49,6 +50,11 @@ public void dm8AllocatesAcrossInstancesAndRestart() throws Exception {
4950 verify ("DM8" );
5051 }
5152
53+ @ Test
54+ public void oracleAllocatesAcrossInstancesAndRestart () throws Exception {
55+ verify ("ORACLE" );
56+ }
57+
5258 @ Test
5359 public void sqlServerConcurrentSchemaStartupIsIdempotent () throws Exception {
5460 String url = System .getenv ("TEAQL_TEST_MSSQL_URL" );
@@ -107,6 +113,9 @@ private void verify(String dialect) throws Exception {
107113 if ("DM8" .equals (dialect )) {
108114 Assert .assertEquals ("Use only an isolated disposable DM8 instance" ,
109115 "true" , System .getenv ("TEAQL_TEST_DM8_ISOLATED" ));
116+ } else if ("ORACLE" .equals (dialect )) {
117+ Assert .assertTrue ("Use only a dedicated TEAQL_LIVE_* Oracle user" ,
118+ user .toUpperCase (java .util .Locale .ROOT ).startsWith ("TEAQL_LIVE_" ));
110119 } else {
111120 Assert .assertTrue ("Use a dedicated teaql_live_* database for " + dialect ,
112121 url .contains ("teaql_live_" ));
@@ -120,8 +129,7 @@ private void verify(String dialect) throws Exception {
120129 "commerce_order" , BUSINESS_DATE ));
121130
122131 try (Connection schemaConnection = DriverManager .getConnection (url , user , password )) {
123- JdbcBusinessIdAllocator allocator = new JdbcBusinessIdAllocator (
124- BusinessIdRuntimeExampleTest .database (schemaConnection ));
132+ JdbcBusinessIdAllocator allocator = allocator (schemaConnection , dialect );
125133 UserContext context = BusinessIdRuntimeExampleTest .context (BUSINESS_DATE , allocator );
126134 context .putAttribute (SchemaExecutor .class .getName (),
127135 BusinessIdRuntimeExampleTest .noOpSchemaExecutor ());
@@ -136,8 +144,7 @@ private void verify(String dialect) throws Exception {
136144 for (int worker = 0 ; worker < 2 ; worker ++) {
137145 futures .add (workers .submit (() -> {
138146 try (Connection connection = DriverManager .getConnection (url , user , password )) {
139- JdbcBusinessIdAllocator allocator = new JdbcBusinessIdAllocator (
140- BusinessIdRuntimeExampleTest .database (connection ));
147+ JdbcBusinessIdAllocator allocator = allocator (connection , dialect );
141148 Assert .assertTrue ("Concurrent start timed out" ,
142149 start .await (15 , TimeUnit .SECONDS ));
143150 List <Long > sequences = new ArrayList <>();
@@ -163,10 +170,19 @@ private void verify(String dialect) throws Exception {
163170 }
164171
165172 try (Connection restarted = DriverManager .getConnection (url , user , password )) {
166- JdbcBusinessIdAllocator allocator = new JdbcBusinessIdAllocator (
167- BusinessIdRuntimeExampleTest .database (restarted ));
173+ JdbcBusinessIdAllocator allocator = allocator (restarted , dialect );
168174 Assert .assertEquals (2L * ALLOCATIONS_PER_INSTANCE + 1 ,
169175 allocator .allocate (plan ).sequence ());
170176 }
171177 }
178+
179+ private static JdbcBusinessIdAllocator allocator (Connection connection , String dialect ) {
180+ if ("ORACLE" .equals (dialect )) {
181+ return new JdbcBusinessIdAllocator (
182+ BusinessIdRuntimeExampleTest .database (connection ),
183+ JdbcBusinessIdAllocator .DEFAULT_TABLE ,
184+ new OracleDialect ());
185+ }
186+ return new JdbcBusinessIdAllocator (BusinessIdRuntimeExampleTest .database (connection ));
187+ }
172188}
0 commit comments