Polishing (aligned with 6.2.x)
Backport Bot / build (push) Has been cancelled
Details
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:22], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
Deploy Docs / Dispatch docs deployment (push) Has been cancelled
Details
Build and Deploy Snapshot / Verify (push) Has been cancelled
Details
Backport Bot / build (push) Has been cancelled
Details
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:22], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:ubuntu-latest name:Linux]) (push) Has been cancelled
Details
Deploy Docs / Dispatch docs deployment (push) Has been cancelled
Details
Build and Deploy Snapshot / Verify (push) Has been cancelled
Details
This commit is contained in:
parent
19257f4fdb
commit
7a1dfe79a0
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,6 +19,7 @@ package org.springframework.orm.jpa;
|
|||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.EntityTransaction;
|
||||
import jakarta.persistence.OptimisticLockException;
|
||||
import jakarta.persistence.PersistenceException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
|
@ -33,33 +34,37 @@ import static org.mockito.Mockito.mock;
|
|||
/**
|
||||
* @author Costin Leau
|
||||
* @author Phillip Webb
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
class DefaultJpaDialectTests {
|
||||
|
||||
private JpaDialect dialect = new DefaultJpaDialect();
|
||||
private final JpaDialect dialect = new DefaultJpaDialect();
|
||||
|
||||
@Test
|
||||
void testDefaultTransactionDefinition() {
|
||||
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
|
||||
definition.setIsolationLevel(TransactionDefinition.ISOLATION_REPEATABLE_READ);
|
||||
assertThatExceptionOfType(TransactionException.class).isThrownBy(() ->
|
||||
dialect.beginTransaction(null, definition));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultBeginTransaction() throws Exception {
|
||||
TransactionDefinition definition = new DefaultTransactionDefinition();
|
||||
EntityManager entityManager = mock();
|
||||
EntityTransaction entityTx = mock();
|
||||
|
||||
given(entityManager.getTransaction()).willReturn(entityTx);
|
||||
|
||||
dialect.beginTransaction(entityManager, definition);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTranslateException() {
|
||||
OptimisticLockException ex = new OptimisticLockException();
|
||||
assertThat(dialect.translateExceptionIfPossible(ex).getCause()).isEqualTo(EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(ex).getCause());
|
||||
void testCustomIsolationLevel() {
|
||||
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
|
||||
definition.setIsolationLevel(TransactionDefinition.ISOLATION_REPEATABLE_READ);
|
||||
|
||||
assertThatExceptionOfType(TransactionException.class).isThrownBy(() ->
|
||||
dialect.beginTransaction(null, definition));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTranslateException() {
|
||||
PersistenceException ex = new OptimisticLockException();
|
||||
assertThat(dialect.translateExceptionIfPossible(ex))
|
||||
.isInstanceOf(JpaOptimisticLockingFailureException.class).hasCause(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue