Program: 66507
Project: 66507
Buggy source:
/** 
 * This tests verifies two things: 1 - That a metadata named query is processed correctly when it uses a  lock mode type. 2 - That a default persistence unit lock timeout value is correctly processed and utilized.
 */
public void testPessimisticLockingNamedQuery(){
  ServerSession session=JUnitTestCase.getServerSession("String_Node_Str");
  if (!isOnServer() && !session.getPlatform().isMySQL() && !session.getPlatform().isTimesTen()) {
    EntityManager em=createEntityManager("String_Node_Str");
    Employee employee;
    try {
      beginTransaction(em);
      employee=new Employee();
      employee.setFirstName("String_Node_Str");
      employee.setLastName("String_Node_Str");
      em.persist(employee);
      commitTransaction(em);
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      closeEntityManager(em);
      throw ex;
    }
    Exception lockTimeoutException=null;
    try {
      beginTransaction(em);
      employee=(Employee)em.createNamedQuery("String_Node_Str").setParameter("String_Node_Str",employee.getId()).getSingleResult();
      EntityManager em2=createEntityManager("String_Node_Str");
      try {
        beginTransaction(em2);
        HashMap properties=new HashMap();
        properties.put(QueryHints.JDBC_TIMEOUT,10);
        Employee emp2=em2.find(Employee.class,employee.getId(),LockModeType.PESSIMISTIC_READ);
      }
 catch (      PersistenceException ex) {
        if (ex instanceof javax.persistence.LockTimeoutException) {
          lockTimeoutException=ex;
        }
 else {
          throw ex;
        }
      }
 finally {
        closeEntityManager(em2);
      }
      commitTransaction(em);
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      closeEntityManager(em);
    }
    assertFalse("String_Node_Str",lockTimeoutException == null);
  }
}

Fixed version (ground truth):
/** 
 * This tests verifies two things: 1 - That a metadata named query is processed correctly when it uses a  lock mode type. 2 - That a default persistence unit lock timeout value is correctly processed and utilized.
 */
public void testPessimisticLockingNamedQuery(){
  ServerSession session=JUnitTestCase.getServerSession("String_Node_Str");
  if (!isOnServer() && isSelectForUpateSupported()) {
    EntityManager em=createEntityManager("String_Node_Str");
    Employee employee;
    try {
      beginTransaction(em);
      employee=new Employee();
      employee.setFirstName("String_Node_Str");
      employee.setLastName("String_Node_Str");
      em.persist(employee);
      commitTransaction(em);
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      closeEntityManager(em);
      throw ex;
    }
    Exception lockTimeoutException=null;
    try {
      beginTransaction(em);
      employee=(Employee)em.createNamedQuery("String_Node_Str").setParameter("String_Node_Str",employee.getId()).getSingleResult();
      EntityManager em2=createEntityManager("String_Node_Str");
      try {
        beginTransaction(em2);
        HashMap properties=new HashMap();
        properties.put(QueryHints.JDBC_TIMEOUT,10);
        Employee emp2=em2.find(Employee.class,employee.getId(),LockModeType.PESSIMISTIC_READ);
      }
 catch (      PersistenceException ex) {
        if (ex instanceof javax.persistence.LockTimeoutException) {
          lockTimeoutException=ex;
        }
 else {
          throw ex;
        }
      }
 finally {
        closeEntityManager(em2);
      }
      commitTransaction(em);
    }
 catch (    RuntimeException ex) {
      if (isTransactionActive(em)) {
        rollbackTransaction(em);
      }
      throw ex;
    }
 finally {
      closeEntityManager(em);
    }
    assertFalse("String_Node_Str",lockTimeoutException == null);
  }
}