mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-10 00:59:01 +00:00
Remove obsolete "test" prefix from test method names
Although this commit also changes the visibility of some test methods
to package-private, the remainder of that task will be addressed in
conjunction with gh-36496.
Closes gh-36495
(cherry picked from commit 4c14abf0cd)
This commit is contained in:
+23
-23
@@ -48,7 +48,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
extends AbstractEntityManagerFactoryIntegrationTests {
|
||||
|
||||
@Test
|
||||
protected void testEntityManagerFactoryImplementsEntityManagerFactoryInfo() {
|
||||
protected void entityManagerFactoryImplementsEntityManagerFactoryInfo() {
|
||||
assertThat(entityManagerFactory).isInstanceOf(EntityManagerFactoryInfo.class);
|
||||
EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
|
||||
assertThat(emfi.getPersistenceUnitName()).isEqualTo("Person");
|
||||
@@ -57,33 +57,33 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStateClean() {
|
||||
void stateClean() {
|
||||
assertThat(countRowsInTable("person")).as("Should be no people from previous transactions").isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJdbcTx1_1() {
|
||||
testJdbcTx2();
|
||||
void jdbcTx1_1() {
|
||||
jdbcTx2();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJdbcTx1_2() {
|
||||
testJdbcTx2();
|
||||
void jdbcTx1_2() {
|
||||
jdbcTx2();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJdbcTx1_3() {
|
||||
testJdbcTx2();
|
||||
void jdbcTx1_3() {
|
||||
jdbcTx2();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJdbcTx2() {
|
||||
void jdbcTx2() {
|
||||
assertThat(countRowsInTable("person")).as("Any previous tx must have been rolled back").isEqualTo(0);
|
||||
executeSqlScript("/org/springframework/orm/jpa/insertPerson.sql");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEntityManagerProxyIsProxy() {
|
||||
void entityManagerProxyIsProxy() {
|
||||
assertThat(Proxy.isProxyClass(sharedEntityManager.getClass())).isTrue();
|
||||
Query q = sharedEntityManager.createQuery("select p from Person as p");
|
||||
q.getResultList();
|
||||
@@ -94,7 +94,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBogusQuery() {
|
||||
void bogusQuery() {
|
||||
assertThatRuntimeException().isThrownBy(() -> {
|
||||
Query query = sharedEntityManager.createQuery("It's raining toads");
|
||||
// required in OpenJPA case
|
||||
@@ -103,7 +103,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetReferenceWhenNoRow() {
|
||||
void getReferenceWhenNoRow() {
|
||||
assertThatException().isThrownBy(() -> {
|
||||
Person notThere = sharedEntityManager.getReference(Person.class, 666);
|
||||
// We may get here (as with Hibernate). Either behavior is valid:
|
||||
@@ -114,7 +114,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLazyLoading() throws Exception {
|
||||
void lazyLoading() throws Exception {
|
||||
try {
|
||||
Person tony = new Person();
|
||||
tony.setFirstName("Tony");
|
||||
@@ -151,7 +151,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testMultipleResults() {
|
||||
protected void multipleResults() {
|
||||
// Add with JDBC
|
||||
String firstName = "Tony";
|
||||
insertPerson(firstName);
|
||||
@@ -170,17 +170,17 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEntityManagerProxyRejectsProgrammaticTxManagement() {
|
||||
void entityManagerProxyRejectsProgrammaticTxManagement() {
|
||||
assertThatIllegalStateException().as("Should not be able to create transactions on container managed EntityManager")
|
||||
.isThrownBy(sharedEntityManager::getTransaction);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInstantiateAndSaveWithSharedEmProxy() {
|
||||
testInstantiateAndSave(sharedEntityManager);
|
||||
void instantiateAndSaveWithSharedEmProxy() {
|
||||
instantiateAndSave(sharedEntityManager);
|
||||
}
|
||||
|
||||
protected void testInstantiateAndSave(EntityManager em) {
|
||||
protected void instantiateAndSave(EntityManager em) {
|
||||
assertThat(countRowsInTable("person")).as("Should be no people from previous transactions").isEqualTo(0);
|
||||
Person p = new Person();
|
||||
p.setFirstName("Tony");
|
||||
@@ -193,7 +193,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testQueryNoPersons() {
|
||||
protected void queryNoPersons() {
|
||||
EntityManager em = entityManagerFactory.createEntityManager();
|
||||
Query q = em.createQuery("select p from Person as p");
|
||||
List<Person> people = q.getResultList();
|
||||
@@ -203,7 +203,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testQueryNoPersonsNotTransactional() {
|
||||
protected void queryNoPersonsNotTransactional() {
|
||||
endTransaction();
|
||||
|
||||
EntityManager em = entityManagerFactory.createEntityManager();
|
||||
@@ -215,7 +215,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testQueryNoPersonsShared() {
|
||||
protected void queryNoPersonsShared() {
|
||||
Query q = this.sharedEntityManager.createQuery("select p from Person as p");
|
||||
q.setFlushMode(FlushModeType.AUTO);
|
||||
List<Person> people = q.getResultList();
|
||||
@@ -225,7 +225,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testQueryNoPersonsSharedNotTransactional() {
|
||||
protected void queryNoPersonsSharedNotTransactional() {
|
||||
endTransaction();
|
||||
|
||||
EntityManager em = this.sharedEntityManager;
|
||||
@@ -243,7 +243,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanSerializeProxies() throws Exception {
|
||||
void canSerializeProxies() throws Exception {
|
||||
assertThat(SerializationTestUtils.serializeAndDeserialize(entityManagerFactory)).isNotNull();
|
||||
assertThat(SerializationTestUtils.serializeAndDeserialize(sharedEntityManager)).isNotNull();
|
||||
}
|
||||
|
||||
+10
-10
@@ -41,7 +41,7 @@ class ApplicationManagedEntityManagerIntegrationTests extends AbstractEntityMana
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testEntityManagerProxyIsProxy() {
|
||||
void entityManagerProxyIsProxy() {
|
||||
EntityManager em = entityManagerFactory.createEntityManager();
|
||||
assertThat(Proxy.isProxyClass(em.getClass())).isTrue();
|
||||
Query q = em.createQuery("select p from Person as p");
|
||||
@@ -54,20 +54,20 @@ class ApplicationManagedEntityManagerIntegrationTests extends AbstractEntityMana
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEntityManagerProxyAcceptsProgrammaticTxJoining() {
|
||||
void entityManagerProxyAcceptsProgrammaticTxJoining() {
|
||||
EntityManager em = entityManagerFactory.createEntityManager();
|
||||
em.joinTransaction();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInstantiateAndSave() {
|
||||
void instantiateAndSave() {
|
||||
EntityManager em = entityManagerFactory.createEntityManager();
|
||||
em.joinTransaction();
|
||||
doInstantiateAndSave(em);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCannotFlushWithoutGettingTransaction() {
|
||||
void cannotFlushWithoutGettingTransaction() {
|
||||
EntityManager em = entityManagerFactory.createEntityManager();
|
||||
assertThatExceptionOfType(TransactionRequiredException.class).isThrownBy(() ->
|
||||
doInstantiateAndSave(em));
|
||||
@@ -80,8 +80,8 @@ class ApplicationManagedEntityManagerIntegrationTests extends AbstractEntityMana
|
||||
setComplete();
|
||||
}
|
||||
|
||||
protected void doInstantiateAndSave(EntityManager em) {
|
||||
testStateClean();
|
||||
void doInstantiateAndSave(EntityManager em) {
|
||||
stateClean();
|
||||
Person p = new Person();
|
||||
|
||||
p.setFirstName("Tony");
|
||||
@@ -93,12 +93,12 @@ class ApplicationManagedEntityManagerIntegrationTests extends AbstractEntityMana
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStateClean() {
|
||||
void stateClean() {
|
||||
assertThat(countRowsInTable("person")).as("Should be no people from previous transactions").isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testReuseInNewTransaction() {
|
||||
void reuseInNewTransaction() {
|
||||
EntityManager em = entityManagerFactory.createEntityManager();
|
||||
em.joinTransaction();
|
||||
|
||||
@@ -134,7 +134,7 @@ class ApplicationManagedEntityManagerIntegrationTests extends AbstractEntityMana
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRollbackOccurs() {
|
||||
void rollbackOccurs() {
|
||||
EntityManager em = entityManagerFactory.createEntityManager();
|
||||
em.joinTransaction();
|
||||
doInstantiateAndSave(em);
|
||||
@@ -143,7 +143,7 @@ class ApplicationManagedEntityManagerIntegrationTests extends AbstractEntityMana
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCommitOccurs() {
|
||||
void commitOccurs() {
|
||||
EntityManager em = entityManagerFactory.createEntityManager();
|
||||
em.joinTransaction();
|
||||
doInstantiateAndSave(em);
|
||||
|
||||
+12
-12
@@ -48,17 +48,17 @@ class ContainerManagedEntityManagerIntegrationTests extends AbstractEntityManage
|
||||
|
||||
|
||||
@Test
|
||||
void testExceptionTranslationWithDialectFoundOnIntroducedEntityManagerInfo() throws Exception {
|
||||
void exceptionTranslationWithDialectFoundOnIntroducedEntityManagerInfo() throws Exception {
|
||||
doTestExceptionTranslationWithDialectFound(((EntityManagerFactoryInfo) entityManagerFactory).getJpaDialect());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExceptionTranslationWithDialectFoundOnEntityManagerFactoryBean() throws Exception {
|
||||
void exceptionTranslationWithDialectFoundOnEntityManagerFactoryBean() throws Exception {
|
||||
assertThat(entityManagerFactoryBean.getJpaDialect()).as("Dialect must have been set").isNotNull();
|
||||
doTestExceptionTranslationWithDialectFound(entityManagerFactoryBean);
|
||||
}
|
||||
|
||||
protected void doTestExceptionTranslationWithDialectFound(PersistenceExceptionTranslator pet) {
|
||||
void doTestExceptionTranslationWithDialectFound(PersistenceExceptionTranslator pet) {
|
||||
RuntimeException in1 = new RuntimeException("in1");
|
||||
PersistenceException in2 = new PersistenceException();
|
||||
assertThat(pet.translateExceptionIfPossible(in1)).as("No translation here").isNull();
|
||||
@@ -69,7 +69,7 @@ class ContainerManagedEntityManagerIntegrationTests extends AbstractEntityManage
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testEntityManagerProxyIsProxy() {
|
||||
void entityManagerProxyIsProxy() {
|
||||
EntityManager em = createContainerManagedEntityManager();
|
||||
assertThat(Proxy.isProxyClass(em.getClass())).isTrue();
|
||||
Query q = em.createQuery("select p from Person as p");
|
||||
@@ -84,7 +84,7 @@ class ContainerManagedEntityManagerIntegrationTests extends AbstractEntityManage
|
||||
|
||||
// This would be legal, at least if not actually _starting_ a tx
|
||||
@Test
|
||||
void testEntityManagerProxyRejectsProgrammaticTxManagement() {
|
||||
void entityManagerProxyRejectsProgrammaticTxManagement() {
|
||||
assertThatIllegalStateException().isThrownBy(
|
||||
createContainerManagedEntityManager()::getTransaction);
|
||||
}
|
||||
@@ -94,24 +94,24 @@ class ContainerManagedEntityManagerIntegrationTests extends AbstractEntityManage
|
||||
* We take the view that this is a valid no op.
|
||||
*/
|
||||
@Test
|
||||
void testContainerEntityManagerProxyAllowsJoinTransactionInTransaction() {
|
||||
void containerEntityManagerProxyAllowsJoinTransactionInTransaction() {
|
||||
createContainerManagedEntityManager().joinTransaction();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testContainerEntityManagerProxyRejectsJoinTransactionWithoutTransaction() {
|
||||
void containerEntityManagerProxyRejectsJoinTransactionWithoutTransaction() {
|
||||
endTransaction();
|
||||
assertThatExceptionOfType(TransactionRequiredException.class).isThrownBy(
|
||||
createContainerManagedEntityManager()::joinTransaction);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInstantiateAndSave() {
|
||||
void instantiateAndSave() {
|
||||
EntityManager em = createContainerManagedEntityManager();
|
||||
doInstantiateAndSave(em);
|
||||
}
|
||||
|
||||
protected void doInstantiateAndSave(EntityManager em) {
|
||||
private void doInstantiateAndSave(EntityManager em) {
|
||||
assertThat(countRowsInTable(em, "person")).as("Should be no people from previous transactions").isEqualTo(0);
|
||||
Person p = new Person();
|
||||
|
||||
@@ -124,7 +124,7 @@ class ContainerManagedEntityManagerIntegrationTests extends AbstractEntityManage
|
||||
}
|
||||
|
||||
@Test
|
||||
void testReuseInNewTransaction() {
|
||||
void reuseInNewTransaction() {
|
||||
EntityManager em = createContainerManagedEntityManager();
|
||||
doInstantiateAndSave(em);
|
||||
endTransaction();
|
||||
@@ -146,7 +146,7 @@ class ContainerManagedEntityManagerIntegrationTests extends AbstractEntityManage
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRollbackOccurs() {
|
||||
void rollbackOccurs() {
|
||||
EntityManager em = createContainerManagedEntityManager();
|
||||
doInstantiateAndSave(em);
|
||||
endTransaction(); // Should roll back
|
||||
@@ -154,7 +154,7 @@ class ContainerManagedEntityManagerIntegrationTests extends AbstractEntityManage
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCommitOccurs() {
|
||||
void commitOccurs() {
|
||||
EntityManager em = createContainerManagedEntityManager();
|
||||
doInstantiateAndSave(em);
|
||||
setComplete();
|
||||
|
||||
@@ -42,7 +42,7 @@ class DefaultJpaDialectTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testDefaultBeginTransaction() throws Exception {
|
||||
void defaultBeginTransaction() throws Exception {
|
||||
TransactionDefinition definition = new DefaultTransactionDefinition();
|
||||
EntityManager entityManager = mock();
|
||||
EntityTransaction entityTx = mock();
|
||||
@@ -52,7 +52,7 @@ class DefaultJpaDialectTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomIsolationLevel() {
|
||||
void customIsolationLevel() {
|
||||
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
|
||||
definition.setIsolationLevel(TransactionDefinition.ISOLATION_REPEATABLE_READ);
|
||||
|
||||
@@ -61,7 +61,7 @@ class DefaultJpaDialectTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTranslateException() {
|
||||
void translateException() {
|
||||
PersistenceException ex = new OptimisticLockException();
|
||||
assertThat(dialect.translateExceptionIfPossible(ex))
|
||||
.isInstanceOf(JpaOptimisticLockingFailureException.class).hasCause(ex);
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import static org.mockito.Mockito.verify;
|
||||
class EntityManagerFactoryBeanSupportTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
|
||||
@Test
|
||||
void testHookIsCalled() {
|
||||
void hookIsCalled() {
|
||||
DummyEntityManagerFactoryBean demf = new DummyEntityManagerFactoryBean(mockEmf);
|
||||
|
||||
demf.afterPropertiesSet();
|
||||
|
||||
+6
-6
@@ -52,7 +52,7 @@ class EntityManagerFactoryUtilsTests {
|
||||
* 'org.springframework.orm.jpa.EntityManagerFactoryUtils.doGetEntityManager(EntityManagerFactory)'
|
||||
*/
|
||||
@Test
|
||||
void testDoGetEntityManager() {
|
||||
void doGetEntityManager() {
|
||||
// test null assertion
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
EntityManagerFactoryUtils.doGetTransactionalEntityManager(null, null));
|
||||
@@ -64,7 +64,7 @@ class EntityManagerFactoryUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDoGetEntityManagerWithTx() {
|
||||
void doGetEntityManagerWithTx() {
|
||||
try {
|
||||
EntityManagerFactory factory = mock();
|
||||
EntityManager manager = mock();
|
||||
@@ -84,7 +84,7 @@ class EntityManagerFactoryUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTranslatesIllegalStateException() {
|
||||
void translatesIllegalStateException() {
|
||||
IllegalStateException ise = new IllegalStateException();
|
||||
DataAccessException dex = EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(ise);
|
||||
assertThat(dex.getCause()).isSameAs(ise);
|
||||
@@ -92,7 +92,7 @@ class EntityManagerFactoryUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTranslatesIllegalArgumentException() {
|
||||
void translatesIllegalArgumentException() {
|
||||
IllegalArgumentException iae = new IllegalArgumentException();
|
||||
DataAccessException dex = EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(iae);
|
||||
assertThat(dex.getCause()).isSameAs(iae);
|
||||
@@ -103,7 +103,7 @@ class EntityManagerFactoryUtilsTests {
|
||||
* We do not convert unknown exceptions. They may result from user code.
|
||||
*/
|
||||
@Test
|
||||
void testDoesNotTranslateUnfamiliarException() {
|
||||
void doesNotTranslateUnfamiliarException() {
|
||||
UnsupportedOperationException userRuntimeException = new UnsupportedOperationException();
|
||||
assertThat(EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(userRuntimeException)).as("Exception should not be wrapped").isNull();
|
||||
}
|
||||
@@ -114,7 +114,7 @@ class EntityManagerFactoryUtilsTests {
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("serial")
|
||||
public void testConvertJpaPersistenceException() {
|
||||
void convertJpaPersistenceException() {
|
||||
EntityNotFoundException entityNotFound = new EntityNotFoundException();
|
||||
assertThat(EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(entityNotFound).getClass()).isSameAs(JpaObjectRetrievalFailureException.class);
|
||||
|
||||
|
||||
+21
-21
@@ -80,7 +80,7 @@ class JpaTransactionManagerTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testTransactionCommit() {
|
||||
void transactionCommit() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
|
||||
final List<String> l = new ArrayList<>();
|
||||
@@ -105,7 +105,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithRollbackException() {
|
||||
void transactionCommitWithRollbackException() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
given(tx.getRollbackOnly()).willReturn(true);
|
||||
willThrow(new RollbackException()).given(tx).commit();
|
||||
@@ -137,7 +137,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionRollback() {
|
||||
void transactionRollback() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
given(tx.isActive()).willReturn(true);
|
||||
|
||||
@@ -162,7 +162,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionRollbackWithAlreadyRolledBack() {
|
||||
void transactionRollbackWithAlreadyRolledBack() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
|
||||
final List<String> l = new ArrayList<>();
|
||||
@@ -185,7 +185,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionRollbackOnly() {
|
||||
void transactionRollbackOnly() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
given(tx.isActive()).willReturn(true);
|
||||
|
||||
@@ -213,7 +213,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testParticipatingTransactionWithCommit() {
|
||||
void participatingTransactionWithCommit() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
|
||||
final List<String> l = new ArrayList<>();
|
||||
@@ -240,7 +240,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testParticipatingTransactionWithRollback() {
|
||||
void participatingTransactionWithRollback() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
given(tx.isActive()).willReturn(true);
|
||||
|
||||
@@ -268,7 +268,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testParticipatingTransactionWithRollbackOnly() {
|
||||
void participatingTransactionWithRollbackOnly() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
given(tx.isActive()).willReturn(true);
|
||||
given(tx.getRollbackOnly()).willReturn(true);
|
||||
@@ -301,7 +301,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testParticipatingTransactionWithRequiresNew() {
|
||||
void participatingTransactionWithRequiresNew() {
|
||||
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
|
||||
given(factory.createEntityManager()).willReturn(manager);
|
||||
@@ -332,7 +332,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testParticipatingTransactionWithRequiresNewAndPrebound() {
|
||||
void participatingTransactionWithRequiresNewAndPrebound() {
|
||||
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
@@ -371,7 +371,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPropagationSupportsAndRequiresNew() {
|
||||
void propagationSupportsAndRequiresNew() {
|
||||
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
|
||||
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
@@ -402,7 +402,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPropagationSupportsAndRequiresNewAndEarlyAccess() {
|
||||
void propagationSupportsAndRequiresNewAndEarlyAccess() {
|
||||
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
|
||||
|
||||
given(factory.createEntityManager()).willReturn(manager);
|
||||
@@ -437,7 +437,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionWithRequiresNewInAfterCompletion() {
|
||||
void transactionWithRequiresNewInAfterCompletion() {
|
||||
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
|
||||
EntityManager manager2 = mock();
|
||||
@@ -478,7 +478,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithPropagationSupports() {
|
||||
void transactionCommitWithPropagationSupports() {
|
||||
given(manager.isOpen()).willReturn(true);
|
||||
|
||||
final List<String> l = new ArrayList<>();
|
||||
@@ -506,7 +506,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionRollbackWithPropagationSupports() {
|
||||
void transactionRollbackWithPropagationSupports() {
|
||||
given(manager.isOpen()).willReturn(true);
|
||||
|
||||
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
|
||||
@@ -531,7 +531,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithPrebound() {
|
||||
void transactionCommitWithPrebound() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
|
||||
final List<String> l = new ArrayList<>();
|
||||
@@ -562,7 +562,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionRollbackWithPrebound() {
|
||||
void transactionRollbackWithPrebound() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
given(tx.isActive()).willReturn(true);
|
||||
|
||||
@@ -592,7 +592,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithPreboundAndPropagationSupports() {
|
||||
void transactionCommitWithPreboundAndPropagationSupports() {
|
||||
final List<String> l = new ArrayList<>();
|
||||
l.add("test");
|
||||
|
||||
@@ -623,7 +623,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionRollbackWithPreboundAndPropagationSupports() {
|
||||
void transactionRollbackWithPreboundAndPropagationSupports() {
|
||||
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
|
||||
|
||||
assertThat(TransactionSynchronizationManager.hasResource(factory)).isFalse();
|
||||
@@ -652,7 +652,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInvalidIsolation() {
|
||||
void invalidIsolation() {
|
||||
tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
|
||||
|
||||
given(manager.isOpen()).willReturn(true);
|
||||
@@ -668,7 +668,7 @@ class JpaTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionFlush() {
|
||||
void transactionFlush() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
|
||||
assertThat(TransactionSynchronizationManager.hasResource(factory)).isFalse();
|
||||
|
||||
+2
-2
@@ -32,13 +32,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class EclipseLinkEntityManagerFactoryIntegrationTests extends AbstractContainerEntityManagerFactoryIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testCanCastNativeEntityManagerFactoryToEclipseLinkEntityManagerFactoryImpl() {
|
||||
void canCastNativeEntityManagerFactoryToEclipseLinkEntityManagerFactoryImpl() {
|
||||
EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
|
||||
assertThat(emfi.getNativeEntityManagerFactory().getClass().getName()).endsWith("EntityManagerFactoryImpl");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanCastSharedEntityManagerProxyToEclipseLinkEntityManager() {
|
||||
void canCastSharedEntityManagerProxyToEclipseLinkEntityManager() {
|
||||
assertThat(sharedEntityManager).isInstanceOf(JpaEntityManager.class);
|
||||
JpaEntityManager eclipselinkEntityManager = (JpaEntityManager) sharedEntityManager;
|
||||
assertThat(eclipselinkEntityManager.getActiveSession()).isNotNull();
|
||||
|
||||
+4
-4
@@ -46,18 +46,18 @@ class HibernateEntityManagerFactoryIntegrationTests extends AbstractContainerEnt
|
||||
|
||||
|
||||
@Test
|
||||
void testCanCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl() {
|
||||
void canCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl() {
|
||||
EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
|
||||
assertThat(emfi.getNativeEntityManagerFactory()).isInstanceOf(SessionFactory.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanCastSharedEntityManagerProxyToHibernateEntityManager() {
|
||||
void canCastSharedEntityManagerProxyToHibernateEntityManager() {
|
||||
assertThat(((EntityManagerProxy) sharedEntityManager).getTargetEntityManager()).isInstanceOf(Session.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanUnwrapAopProxy() {
|
||||
void canUnwrapAopProxy() {
|
||||
EntityManager em = entityManagerFactory.createEntityManager();
|
||||
EntityManager proxy = ProxyFactory.getProxy(EntityManager.class, new SingletonTargetSource(em));
|
||||
assertThat(proxy.unwrap(Session.class)).isSameAs(em);
|
||||
@@ -65,7 +65,7 @@ class HibernateEntityManagerFactoryIntegrationTests extends AbstractContainerEnt
|
||||
}
|
||||
|
||||
@Test // SPR-16956
|
||||
public void testReadOnly() {
|
||||
void readOnly() {
|
||||
assertThat(sharedEntityManager.unwrap(Session.class).getHibernateFlushMode()).isSameAs(FlushMode.AUTO);
|
||||
assertThat(sharedEntityManager.unwrap(Session.class).isDefaultReadOnly()).isFalse();
|
||||
endTransaction();
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ class HibernateJpaDialectTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testTranslateException() {
|
||||
void translateException() {
|
||||
// Plain JPA exception
|
||||
RuntimeException ex = new OptimisticLockException();
|
||||
assertThat(dialect.translateExceptionIfPossible(ex))
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ class HibernateMultiEntityManagerFactoryIntegrationTests extends AbstractContain
|
||||
|
||||
@Override
|
||||
@Test
|
||||
protected void testEntityManagerFactoryImplementsEntityManagerFactoryInfo() {
|
||||
protected void entityManagerFactoryImplementsEntityManagerFactoryInfo() {
|
||||
assertThat(this.entityManagerFactory).isInstanceOf(EntityManagerFactoryInfo.class);
|
||||
EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) this.entityManagerFactory;
|
||||
assertThat(emfi.getPersistenceUnitName()).isEqualTo("Drivers");
|
||||
@@ -56,7 +56,7 @@ class HibernateMultiEntityManagerFactoryIntegrationTests extends AbstractContain
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEntityManagerFactory2() {
|
||||
void entityManagerFactory2() {
|
||||
EntityManager em = this.entityManagerFactory2.createEntityManager();
|
||||
try {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
|
||||
+6
-6
@@ -55,14 +55,14 @@ class HibernateNativeEntityManagerFactoryIntegrationTests extends AbstractContai
|
||||
|
||||
@Override
|
||||
@Test
|
||||
protected void testEntityManagerFactoryImplementsEntityManagerFactoryInfo() {
|
||||
boolean condition = entityManagerFactory instanceof EntityManagerFactoryInfo;
|
||||
assertThat(condition).as("Must not have introduced config interface").isFalse();
|
||||
protected void entityManagerFactoryImplementsEntityManagerFactoryInfo() {
|
||||
assertThat(entityManagerFactory).as("Must not have introduced config interface")
|
||||
.isNotInstanceOf(EntityManagerFactoryInfo.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testEntityListener() {
|
||||
void entityListener() {
|
||||
String firstName = "Tony";
|
||||
insertPerson(firstName);
|
||||
|
||||
@@ -74,7 +74,7 @@ class HibernateNativeEntityManagerFactoryIntegrationTests extends AbstractContai
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void testCurrentSession() {
|
||||
void currentSession() {
|
||||
String firstName = "Tony";
|
||||
insertPerson(firstName);
|
||||
|
||||
@@ -86,7 +86,7 @@ class HibernateNativeEntityManagerFactoryIntegrationTests extends AbstractContai
|
||||
}
|
||||
|
||||
@Test // SPR-16956
|
||||
public void testReadOnly() {
|
||||
void readOnly() {
|
||||
assertThat(sessionFactory.getCurrentSession().getHibernateFlushMode()).isSameAs(FlushMode.AUTO);
|
||||
assertThat(sessionFactory.getCurrentSession().isDefaultReadOnly()).isFalse();
|
||||
endTransaction();
|
||||
|
||||
+12
-12
@@ -68,7 +68,7 @@ class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
|
||||
|
||||
@Test
|
||||
void testCanRetrieveBeanByTypeWithJpaCompliantOptions() {
|
||||
void canRetrieveBeanByTypeWithJpaCompliantOptions() {
|
||||
BeanContainer beanContainer = getBeanContainer();
|
||||
assertThat(beanContainer).isNotNull();
|
||||
|
||||
@@ -84,7 +84,7 @@ class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanRetrieveBeanByNameWithJpaCompliantOptions() {
|
||||
void canRetrieveBeanByNameWithJpaCompliantOptions() {
|
||||
BeanContainer beanContainer = getBeanContainer();
|
||||
assertThat(beanContainer).isNotNull();
|
||||
|
||||
@@ -101,7 +101,7 @@ class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanRetrieveBeanByTypeWithNativeOptions() {
|
||||
void canRetrieveBeanByTypeWithNativeOptions() {
|
||||
BeanContainer beanContainer = getBeanContainer();
|
||||
assertThat(beanContainer).isNotNull();
|
||||
|
||||
@@ -129,7 +129,7 @@ class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanRetrieveBeanByNameWithNativeOptions() {
|
||||
void canRetrieveBeanByNameWithNativeOptions() {
|
||||
BeanContainer beanContainer = getBeanContainer();
|
||||
assertThat(beanContainer).isNotNull();
|
||||
|
||||
@@ -157,7 +157,7 @@ class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanRetrieveFallbackBeanByTypeWithJpaCompliantOptions() {
|
||||
void canRetrieveFallbackBeanByTypeWithJpaCompliantOptions() {
|
||||
BeanContainer beanContainer = getBeanContainer();
|
||||
assertThat(beanContainer).isNotNull();
|
||||
NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer();
|
||||
@@ -178,7 +178,7 @@ class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanRetrieveFallbackBeanByNameWithJpaCompliantOptions() {
|
||||
void canRetrieveFallbackBeanByNameWithJpaCompliantOptions() {
|
||||
BeanContainer beanContainer = getBeanContainer();
|
||||
assertThat(beanContainer).isNotNull();
|
||||
NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer();
|
||||
@@ -200,7 +200,7 @@ class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanRetrieveFallbackBeanByTypeWithNativeOptions() {
|
||||
void canRetrieveFallbackBeanByTypeWithNativeOptions() {
|
||||
BeanContainer beanContainer = getBeanContainer();
|
||||
assertThat(beanContainer).isNotNull();
|
||||
NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer();
|
||||
@@ -221,7 +221,7 @@ class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanRetrieveFallbackBeanByNameWithNativeOptions() {
|
||||
void canRetrieveFallbackBeanByNameWithNativeOptions() {
|
||||
BeanContainer beanContainer = getBeanContainer();
|
||||
assertThat(beanContainer).isNotNull();
|
||||
NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer();
|
||||
@@ -243,7 +243,7 @@ class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFallbackExceptionInCaseOfNoSpringBeanFound() {
|
||||
void fallbackExceptionInCaseOfNoSpringBeanFound() {
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
|
||||
getBeanContainer().getBean(NoDefinitionInSpringContextTestBean.class,
|
||||
NativeLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE
|
||||
@@ -251,7 +251,7 @@ class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOriginalExceptionInCaseOfFallbackProducerFailure() {
|
||||
void originalExceptionInCaseOfFallbackProducerFailure() {
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
|
||||
getBeanContainer().getBean(AttributeConverter.class,
|
||||
NativeLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE
|
||||
@@ -259,7 +259,7 @@ class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFallbackExceptionInCaseOfNoSpringBeanFoundByName() {
|
||||
void fallbackExceptionInCaseOfNoSpringBeanFoundByName() {
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
|
||||
getBeanContainer().getBean("some name", NoDefinitionInSpringContextTestBean.class,
|
||||
NativeLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE
|
||||
@@ -267,7 +267,7 @@ class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOriginalExceptionInCaseOfFallbackProducerFailureByName() {
|
||||
void originalExceptionInCaseOfFallbackProducerFailureByName() {
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
|
||||
getBeanContainer().getBean("invalid", AttributeConverter.class,
|
||||
NativeLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE
|
||||
|
||||
+14
-14
@@ -49,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThatRuntimeException;
|
||||
class PersistenceXmlParsingTests {
|
||||
|
||||
@Test
|
||||
void testMetaInfCase() throws Exception {
|
||||
void metaInfCase() throws Exception {
|
||||
PersistenceUnitReader reader = new PersistenceUnitReader(
|
||||
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
|
||||
String resource = "/org/springframework/orm/jpa/META-INF/persistence.xml";
|
||||
@@ -66,7 +66,7 @@ class PersistenceXmlParsingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExample1() {
|
||||
void example1() {
|
||||
PersistenceUnitReader reader = new PersistenceUnitReader(
|
||||
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
|
||||
String resource = "/org/springframework/orm/jpa/persistence-example1.xml";
|
||||
@@ -80,7 +80,7 @@ class PersistenceXmlParsingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExample2() {
|
||||
void example2() {
|
||||
PersistenceUnitReader reader = new PersistenceUnitReader(
|
||||
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
|
||||
String resource = "/org/springframework/orm/jpa/persistence-example2.xml";
|
||||
@@ -98,7 +98,7 @@ class PersistenceXmlParsingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExample3() throws Exception {
|
||||
void example3() throws Exception {
|
||||
PersistenceUnitReader reader = new PersistenceUnitReader(
|
||||
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
|
||||
String resource = "/org/springframework/orm/jpa/persistence-example3.xml";
|
||||
@@ -120,7 +120,7 @@ class PersistenceXmlParsingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExample4() throws Exception {
|
||||
void example4() throws Exception {
|
||||
SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
|
||||
DataSource ds = new DriverManagerDataSource();
|
||||
builder.bind("java:comp/env/jdbc/MyDB", ds);
|
||||
@@ -148,7 +148,7 @@ class PersistenceXmlParsingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExample5() throws Exception {
|
||||
void example5() throws Exception {
|
||||
PersistenceUnitReader reader = new PersistenceUnitReader(
|
||||
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
|
||||
String resource = "/org/springframework/orm/jpa/persistence-example5.xml";
|
||||
@@ -171,7 +171,7 @@ class PersistenceXmlParsingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExampleComplex() throws Exception {
|
||||
void exampleComplex() throws Exception {
|
||||
DataSource ds = new DriverManagerDataSource();
|
||||
|
||||
String resource = "/org/springframework/orm/jpa/persistence-complex.xml";
|
||||
@@ -229,7 +229,7 @@ class PersistenceXmlParsingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExample6() {
|
||||
void example6() {
|
||||
PersistenceUnitReader reader = new PersistenceUnitReader(
|
||||
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
|
||||
String resource = "/org/springframework/orm/jpa/persistence-example6.xml";
|
||||
@@ -243,7 +243,7 @@ class PersistenceXmlParsingTests {
|
||||
|
||||
@Disabled("not doing schema parsing anymore for JPA 2.0 compatibility")
|
||||
@Test
|
||||
void testInvalidPersistence() {
|
||||
void invalidPersistence() {
|
||||
PersistenceUnitReader reader = new PersistenceUnitReader(
|
||||
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
|
||||
String resource = "/org/springframework/orm/jpa/persistence-invalid.xml";
|
||||
@@ -252,7 +252,7 @@ class PersistenceXmlParsingTests {
|
||||
|
||||
@Disabled("not doing schema parsing anymore for JPA 2.0 compatibility")
|
||||
@Test
|
||||
void testNoSchemaPersistence() {
|
||||
void noSchemaPersistence() {
|
||||
PersistenceUnitReader reader = new PersistenceUnitReader(
|
||||
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
|
||||
String resource = "/org/springframework/orm/jpa/persistence-no-schema.xml";
|
||||
@@ -260,7 +260,7 @@ class PersistenceXmlParsingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPersistenceUnitRootUrl() throws Exception {
|
||||
void persistenceUnitRootUrl() throws Exception {
|
||||
URL url = PersistenceUnitReader.determinePersistenceUnitRootUrl(new ClassPathResource("/org/springframework/orm/jpa/persistence-no-schema.xml"));
|
||||
assertThat(url).isNull();
|
||||
|
||||
@@ -270,7 +270,7 @@ class PersistenceXmlParsingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPersistenceUnitRootUrlWithJar() throws Exception {
|
||||
void persistenceUnitRootUrlWithJar() throws Exception {
|
||||
ClassPathResource archive = new ClassPathResource("/org/springframework/orm/jpa/jpa-archive.jar");
|
||||
String newRoot = "jar:" + archive.getURL().toExternalForm() + "!/META-INF/persist.xml";
|
||||
Resource insideArchive = new UrlResource(newRoot);
|
||||
@@ -281,7 +281,7 @@ class PersistenceXmlParsingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJpa1ExcludeUnlisted() {
|
||||
void jpa1ExcludeUnlisted() {
|
||||
PersistenceUnitReader reader = new PersistenceUnitReader(
|
||||
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
|
||||
String resource = "/org/springframework/orm/jpa/persistence-exclude-1.0.xml";
|
||||
@@ -312,7 +312,7 @@ class PersistenceXmlParsingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJpa2ExcludeUnlisted() {
|
||||
void jpa2ExcludeUnlisted() {
|
||||
PersistenceUnitReader reader = new PersistenceUnitReader(
|
||||
new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
|
||||
String resource = "/org/springframework/orm/jpa/persistence-exclude-2.0.xml";
|
||||
|
||||
+6
-6
@@ -90,7 +90,7 @@ class OpenEntityManagerInViewTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOpenEntityManagerInViewInterceptor() {
|
||||
void openEntityManagerInViewInterceptor() {
|
||||
OpenEntityManagerInViewInterceptor interceptor = new OpenEntityManagerInViewInterceptor();
|
||||
interceptor.setEntityManagerFactory(this.factory);
|
||||
|
||||
@@ -126,7 +126,7 @@ class OpenEntityManagerInViewTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOpenEntityManagerInViewInterceptorAsyncScenario() throws Exception {
|
||||
void openEntityManagerInViewInterceptorAsyncScenario() throws Exception {
|
||||
|
||||
// Initial request thread
|
||||
|
||||
@@ -183,7 +183,7 @@ class OpenEntityManagerInViewTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOpenEntityManagerInViewInterceptorAsyncTimeoutScenario() throws Exception {
|
||||
void openEntityManagerInViewInterceptorAsyncTimeoutScenario() throws Exception {
|
||||
|
||||
// Initial request thread
|
||||
|
||||
@@ -223,7 +223,7 @@ class OpenEntityManagerInViewTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOpenEntityManagerInViewInterceptorAsyncErrorScenario() throws Exception {
|
||||
void openEntityManagerInViewInterceptorAsyncErrorScenario() throws Exception {
|
||||
|
||||
// Initial request thread
|
||||
|
||||
@@ -263,7 +263,7 @@ class OpenEntityManagerInViewTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOpenEntityManagerInViewFilter() throws Exception {
|
||||
void openEntityManagerInViewFilter() throws Exception {
|
||||
given(manager.isOpen()).willReturn(true);
|
||||
|
||||
final EntityManagerFactory factory2 = mock();
|
||||
@@ -317,7 +317,7 @@ class OpenEntityManagerInViewTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOpenEntityManagerInViewFilterAsyncScenario() throws Exception {
|
||||
void openEntityManagerInViewFilterAsyncScenario() throws Exception {
|
||||
given(manager.isOpen()).willReturn(true);
|
||||
|
||||
final EntityManagerFactory factory2 = mock();
|
||||
|
||||
+11
-11
@@ -84,7 +84,7 @@ class PersistenceContextTransactionTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithSharedEntityManager() {
|
||||
void transactionCommitWithSharedEntityManager() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
|
||||
tt.execute(status -> {
|
||||
@@ -98,7 +98,7 @@ class PersistenceContextTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithSharedEntityManagerAndPropagationSupports() {
|
||||
void transactionCommitWithSharedEntityManagerAndPropagationSupports() {
|
||||
given(manager.isOpen()).willReturn(true);
|
||||
|
||||
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
|
||||
@@ -113,7 +113,7 @@ class PersistenceContextTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithExtendedEntityManager() {
|
||||
void transactionCommitWithExtendedEntityManager() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
|
||||
tt.execute(status -> {
|
||||
@@ -127,7 +127,7 @@ class PersistenceContextTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithExtendedEntityManagerAndPropagationSupports() {
|
||||
void transactionCommitWithExtendedEntityManagerAndPropagationSupports() {
|
||||
given(manager.isOpen()).willReturn(true);
|
||||
|
||||
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
|
||||
@@ -141,7 +141,7 @@ class PersistenceContextTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithSharedEntityManagerUnsynchronized() {
|
||||
void transactionCommitWithSharedEntityManagerUnsynchronized() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
|
||||
tt.execute(status -> {
|
||||
@@ -155,7 +155,7 @@ class PersistenceContextTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithSharedEntityManagerUnsynchronizedAndPropagationSupports() {
|
||||
void transactionCommitWithSharedEntityManagerUnsynchronizedAndPropagationSupports() {
|
||||
given(manager.isOpen()).willReturn(true);
|
||||
|
||||
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
|
||||
@@ -170,7 +170,7 @@ class PersistenceContextTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithExtendedEntityManagerUnsynchronized() {
|
||||
void transactionCommitWithExtendedEntityManagerUnsynchronized() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
|
||||
tt.execute(status -> {
|
||||
@@ -184,7 +184,7 @@ class PersistenceContextTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithExtendedEntityManagerUnsynchronizedAndPropagationSupports() {
|
||||
void transactionCommitWithExtendedEntityManagerUnsynchronizedAndPropagationSupports() {
|
||||
given(manager.isOpen()).willReturn(true);
|
||||
|
||||
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
|
||||
@@ -198,7 +198,7 @@ class PersistenceContextTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithSharedEntityManagerUnsynchronizedJoined() {
|
||||
void transactionCommitWithSharedEntityManagerUnsynchronizedJoined() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
|
||||
tt.execute(status -> {
|
||||
@@ -213,7 +213,7 @@ class PersistenceContextTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithExtendedEntityManagerUnsynchronizedJoined() {
|
||||
void transactionCommitWithExtendedEntityManagerUnsynchronizedJoined() {
|
||||
given(manager.getTransaction()).willReturn(tx);
|
||||
|
||||
tt.execute(status -> {
|
||||
@@ -228,7 +228,7 @@ class PersistenceContextTransactionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionCommitWithExtendedEntityManagerUnsynchronizedJoinedAndPropagationSupports() {
|
||||
void transactionCommitWithExtendedEntityManagerUnsynchronizedJoinedAndPropagationSupports() {
|
||||
given(manager.isOpen()).willReturn(true);
|
||||
|
||||
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
|
||||
|
||||
+2
-2
@@ -40,12 +40,12 @@ class PersistenceInjectionIntegrationTests extends AbstractEntityManagerFactoryI
|
||||
|
||||
|
||||
@Test
|
||||
void testDefaultPersistenceContextSetterInjection() {
|
||||
void defaultPersistenceContextSetterInjection() {
|
||||
assertThat(defaultSetterInjected.getEntityManager()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetterInjectionOfNamedPersistenceContext() {
|
||||
void setterInjectionOfNamedPersistenceContext() {
|
||||
assertThat(namedSetterInjected.getEntityManagerFactory()).isNotNull();
|
||||
}
|
||||
|
||||
|
||||
+27
-27
@@ -65,7 +65,7 @@ import static org.mockito.Mockito.withSettings;
|
||||
class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
|
||||
@Test
|
||||
void testPrivatePersistenceContextField() throws Exception {
|
||||
void privatePersistenceContextField() throws Exception {
|
||||
mockEmf = mock(EntityManagerFactory.class, withSettings().serializable());
|
||||
GenericApplicationContext gac = new GenericApplicationContext();
|
||||
gac.getDefaultListableBeanFactory().registerSingleton("entityManagerFactory", mockEmf);
|
||||
@@ -89,7 +89,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPrivateVendorSpecificPersistenceContextField() {
|
||||
void privateVendorSpecificPersistenceContextField() {
|
||||
GenericApplicationContext gac = new GenericApplicationContext();
|
||||
gac.getDefaultListableBeanFactory().registerSingleton("entityManagerFactory", mockEmf);
|
||||
gac.registerBeanDefinition("annotationProcessor",
|
||||
@@ -104,7 +104,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPublicExtendedPersistenceContextSetter() {
|
||||
void publicExtendedPersistenceContextSetter() {
|
||||
EntityManager mockEm = mock();
|
||||
given(mockEmf.createEntityManager()).willReturn(mockEm);
|
||||
|
||||
@@ -122,7 +122,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPublicSpecificExtendedPersistenceContextSetter() {
|
||||
void publicSpecificExtendedPersistenceContextSetter() {
|
||||
EntityManagerFactory mockEmf2 = mock();
|
||||
EntityManager mockEm2 = mock();
|
||||
given(mockEmf2.createEntityManager()).willReturn(mockEm2);
|
||||
@@ -145,7 +145,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInjectionIntoExistingObjects() {
|
||||
void injectionIntoExistingObjects() {
|
||||
EntityManager mockEm = mock();
|
||||
given(mockEmf.createEntityManager()).willReturn(mockEm);
|
||||
|
||||
@@ -165,7 +165,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPublicExtendedPersistenceContextSetterWithSerialization() throws Exception {
|
||||
void publicExtendedPersistenceContextSetterWithSerialization() throws Exception {
|
||||
DummyInvocationHandler ih = new DummyInvocationHandler();
|
||||
Object mockEm = Proxy.newProxyInstance(getClass().getClassLoader(), new Class<?>[] {EntityManager.class}, ih);
|
||||
given(mockEmf.createEntityManager()).willReturn((EntityManager) mockEm);
|
||||
@@ -194,7 +194,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void testPublicExtendedPersistenceContextSetterWithEntityManagerInfoAndSerialization() throws Exception {
|
||||
void publicExtendedPersistenceContextSetterWithEntityManagerInfoAndSerialization() throws Exception {
|
||||
EntityManager mockEm = mock(EntityManager.class, withSettings().serializable());
|
||||
given(mockEm.isOpen()).willReturn(true);
|
||||
EntityManagerFactoryWithInfo mockEmf = mock();
|
||||
@@ -218,7 +218,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPublicExtendedPersistenceContextSetterWithOverriding() {
|
||||
void publicExtendedPersistenceContextSetterWithOverriding() {
|
||||
EntityManager mockEm2 = mock();
|
||||
|
||||
GenericApplicationContext gac = new GenericApplicationContext();
|
||||
@@ -236,7 +236,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPrivatePersistenceUnitField() {
|
||||
void privatePersistenceUnitField() {
|
||||
GenericApplicationContext gac = new GenericApplicationContext();
|
||||
gac.getDefaultListableBeanFactory().registerSingleton("entityManagerFactory", mockEmf);
|
||||
gac.registerBeanDefinition("annotationProcessor",
|
||||
@@ -251,7 +251,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPublicPersistenceUnitSetter() {
|
||||
void publicPersistenceUnitSetter() {
|
||||
GenericApplicationContext gac = new GenericApplicationContext();
|
||||
gac.getDefaultListableBeanFactory().registerSingleton("entityManagerFactory", mockEmf);
|
||||
gac.registerBeanDefinition("annotationProcessor",
|
||||
@@ -266,7 +266,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPublicPersistenceUnitSetterWithOverriding() {
|
||||
void publicPersistenceUnitSetterWithOverriding() {
|
||||
EntityManagerFactory mockEmf2 = mock();
|
||||
|
||||
GenericApplicationContext gac = new GenericApplicationContext();
|
||||
@@ -284,7 +284,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPublicPersistenceUnitSetterWithUnitIdentifiedThroughBeanName() {
|
||||
void publicPersistenceUnitSetterWithUnitIdentifiedThroughBeanName() {
|
||||
EntityManagerFactory mockEmf2 = mock();
|
||||
|
||||
GenericApplicationContext gac = new GenericApplicationContext();
|
||||
@@ -309,7 +309,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPublicPersistenceUnitSetterWithMultipleUnitsIdentifiedThroughUnitName() {
|
||||
void publicPersistenceUnitSetterWithMultipleUnitsIdentifiedThroughUnitName() {
|
||||
EntityManagerFactoryWithInfo mockEmf2 = mock();
|
||||
given(mockEmf2.getPersistenceUnitName()).willReturn("Person");
|
||||
|
||||
@@ -334,7 +334,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPersistenceUnitsFromJndi() {
|
||||
void persistenceUnitsFromJndi() {
|
||||
EntityManager mockEm = mock();
|
||||
given(mockEmf.createEntityManager()).willReturn(mockEm);
|
||||
|
||||
@@ -376,7 +376,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPersistenceUnitsFromJndiWithDefaultUnit() {
|
||||
void persistenceUnitsFromJndiWithDefaultUnit() {
|
||||
EntityManagerFactoryWithInfo mockEmf2 = mock();
|
||||
|
||||
Map<String, String> persistenceUnits = new HashMap<>();
|
||||
@@ -406,7 +406,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSinglePersistenceUnitFromJndi() {
|
||||
void singlePersistenceUnitFromJndi() {
|
||||
Map<String, String> persistenceUnits = new HashMap<>();
|
||||
persistenceUnits.put("Person", "pu1");
|
||||
ExpectedLookupTemplate jt = new ExpectedLookupTemplate();
|
||||
@@ -431,7 +431,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPersistenceContextsFromJndi() {
|
||||
void persistenceContextsFromJndi() {
|
||||
EntityManager mockEm = mock();
|
||||
EntityManager mockEm2 = mock();
|
||||
EntityManager mockEm3 = mock();
|
||||
@@ -471,7 +471,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPersistenceContextsFromJndiWithDefaultUnit() {
|
||||
void persistenceContextsFromJndiWithDefaultUnit() {
|
||||
EntityManager mockEm = mock();
|
||||
EntityManager mockEm2 = mock();
|
||||
EntityManager mockEm3 = mock();
|
||||
@@ -512,7 +512,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSinglePersistenceContextFromJndi() {
|
||||
void singlePersistenceContextFromJndi() {
|
||||
EntityManager mockEm = mock();
|
||||
EntityManager mockEm2 = mock();
|
||||
|
||||
@@ -544,28 +544,28 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFieldOfWrongTypeAnnotatedWithPersistenceUnit() {
|
||||
void fieldOfWrongTypeAnnotatedWithPersistenceUnit() {
|
||||
PersistenceAnnotationBeanPostProcessor pabpp = new PersistenceAnnotationBeanPostProcessor();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
pabpp.postProcessProperties(null, new FieldOfWrongTypeAnnotatedWithPersistenceUnit(), "bean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetterOfWrongTypeAnnotatedWithPersistenceUnit() {
|
||||
void setterOfWrongTypeAnnotatedWithPersistenceUnit() {
|
||||
PersistenceAnnotationBeanPostProcessor pabpp = new PersistenceAnnotationBeanPostProcessor();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
pabpp.postProcessProperties(null, new SetterOfWrongTypeAnnotatedWithPersistenceUnit(), "bean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetterWithNoArgs() {
|
||||
void setterWithNoArgs() {
|
||||
PersistenceAnnotationBeanPostProcessor pabpp = new PersistenceAnnotationBeanPostProcessor();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
pabpp.postProcessProperties(null, new SetterWithNoArgs(), "bean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoPropertiesPassedIn() {
|
||||
void noPropertiesPassedIn() {
|
||||
EntityManager mockEm = mock();
|
||||
given(mockEmf.createEntityManager()).willReturn(mockEm);
|
||||
|
||||
@@ -576,7 +576,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPropertiesPassedIn() {
|
||||
void propertiesPassedIn() {
|
||||
Properties props = new Properties();
|
||||
props.put("foo", "bar");
|
||||
EntityManager mockEm = mock();
|
||||
@@ -590,7 +590,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPropertiesForTransactionalEntityManager() {
|
||||
void propertiesForTransactionalEntityManager() {
|
||||
Properties props = new Properties();
|
||||
props.put("foo", "bar");
|
||||
EntityManager em = mock();
|
||||
@@ -614,7 +614,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
* generate new EMs or not.
|
||||
*/
|
||||
@Test
|
||||
void testPropertiesForSharedEntityManager1() {
|
||||
void propertiesForSharedEntityManager1() {
|
||||
Properties props = new Properties();
|
||||
props.put("foo", "bar");
|
||||
EntityManager em = mock();
|
||||
@@ -647,7 +647,7 @@ class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPropertiesForSharedEntityManager2() {
|
||||
void propertiesForSharedEntityManager2() {
|
||||
Properties props = new Properties();
|
||||
props.put("foo", "bar");
|
||||
EntityManager em = mock();
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify;
|
||||
class SharedEntityManagerFactoryTests {
|
||||
|
||||
@Test
|
||||
void testValidUsage() {
|
||||
void validUsage() {
|
||||
Object o = new Object();
|
||||
|
||||
EntityManager mockEm = mock();
|
||||
|
||||
Reference in New Issue
Block a user