HHH-7356 add failure expected test

This commit is contained in:
Strong Liu 2012-05-29 16:58:28 +08:00
parent 51aa114224
commit 32d36f6ea9
3 changed files with 18 additions and 1 deletions

View File

@ -426,7 +426,7 @@ public abstract class QueryBinder {
if ( timeout != null ) {
// convert milliseconds to seconds
timeout = new Integer ((int)Math.round(timeout.doubleValue() / 1000.0 ) );
timeout = (int)Math.round(timeout.doubleValue() / 1000.0 );
}
else {
// timeout is already in seconds

View File

@ -29,6 +29,8 @@ import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.ejb.AvailableSettings;
import org.hibernate.ejb.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.internal.AbstractSessionImpl;
import org.hibernate.internal.QueryImpl;
import org.hibernate.testing.*;
import org.jboss.logging.Logger;
import org.junit.Test;
@ -50,6 +52,17 @@ import static org.junit.Assert.*;
public class LockTest extends BaseEntityManagerFunctionalTestCase {
private static final Logger log = Logger.getLogger( LockTest.class );
@Test
@FailureExpected( jiraKey = "HHH-7356")
public void testLockTimeoutASNamedQueryHint(){
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
Query query = em.createNamedQuery( "getAll" );
query.setLockMode( LockModeType.PESSIMISTIC_READ );
int timeout = ((QueryImpl)(((org.hibernate.ejb.QueryImpl)query).getHibernateQuery())).getLockOptions().getTimeOut();
assertEquals( 3, timeout );
}
@Test
public void testFindWithTimeoutHint() {
EntityManager em = getOrCreateEntityManager();

View File

@ -3,11 +3,15 @@ package org.hibernate.ejb.test.lock;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.QueryHint;
/**
* @author Emmanuel Bernard
*/
@Entity
@NamedQuery(name = "getAll", query = "select u from UnversionedLock u",
hints = @QueryHint( name = "javax.persistence.lock.timeout", value = "3000"))
public class UnversionedLock {
@Id
@GeneratedValue