Add test for HHH-14210

This commit is contained in:
Gavin King 2020-09-11 22:11:49 +02:00 committed by Andrea Boriero
parent 64338f2bf1
commit c7dd682257
1 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,50 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.dialect.unit.locktimeout;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author Gavin King
*/
public class DB2LockTimeoutTest extends BaseUnitTestCase {
private final Dialect dialect = new DB2Dialect();
@Test
public void testLockTimeoutNoAliasNoTimeout() {
assertEquals(
" for read only with rs use and keep share locks",
dialect.getForUpdateString( new LockOptions( LockMode.PESSIMISTIC_READ ) )
);
assertEquals(
" for read only with rs use and keep update locks",
dialect.getForUpdateString( new LockOptions( LockMode.PESSIMISTIC_WRITE ) )
);
}
@Test
public void testLockTimeoutNoAliasSkipLocked() {
assertEquals(
" for read only with rs use and keep share locks skip locked data",
dialect.getForUpdateString( new LockOptions( LockMode.PESSIMISTIC_READ )
.setTimeOut( LockOptions.SKIP_LOCKED ) )
);
assertEquals(
" for read only with rs use and keep update locks skip locked data",
dialect.getForUpdateString( new LockOptions( LockMode.PESSIMISTIC_WRITE )
.setTimeOut( LockOptions.SKIP_LOCKED ) )
);
}
}