<commit_before>package com.orientechnologies.orient.core.db.document;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import com.orientechnologies.orient.core.OCreateDatabaseUtil;
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.db.ODatabaseSession;
import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.OrientDBConfig;
import com.orientechnologies.orient.core.record.OElement;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.executor.OResultSet;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class ODatabasePessimisticLockTest {

  private OrientDB orientDB;

  @Before
  public void before() {
    OrientDBConfig config =
        OrientDBConfig.builder()
            .addConfig(
                OGlobalConfiguration.STORAGE_PESSIMISTIC_LOCKING,
                OrientDBConfig.LOCK_TYPE_READWRITE)
            .addConfig(OGlobalConfiguration.CREATE_DEFAULT_USERS, false)
            .build();
    orientDB =
        OCreateDatabaseUtil.createDatabase("test", "embedded:", OCreateDatabaseUtil.TYPE_MEMORY);
    final ODatabaseSession session =
        orientDB.open("test", "admin", OCreateDatabaseUtil.NEW_ADMIN_PASSWORD);
    session.createClass("test");
    session.save(new ODocument("test")).getIdentity();
  }

  @Test
  public void testPessimistic() throws InterruptedException {<commit_msg>fixed nasty pessimistic lock test<commit_after>package com.orientechnologies.orient.core.db.document;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import com.orientechnologies.orient.core.OCreateDatabaseUtil;
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.db.ODatabaseSession;
import com.orientechnologies.orient.core.db.ODatabaseType;
import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.OrientDBConfig;
import com.orientechnologies.orient.core.record.OElement;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.executor.OResultSet;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class ODatabasePessimisticLockTest {

  private OrientDB orientDB;

  @Before
  public void before() {
    OrientDBConfig config =
        OrientDBConfig.builder()
            .addConfig(
                OGlobalConfiguration.STORAGE_PESSIMISTIC_LOCKING,
                OrientDBConfig.LOCK_TYPE_READWRITE)
            .addConfig(OGlobalConfiguration.CREATE_DEFAULT_USERS, false)
            .build();
    orientDB = new OrientDB("embedded:", config);
    orientDB.execute(
        "create database "
            + "test"
            + " "
            + "memory"
            + " users ( admin identified by '"
            + OCreateDatabaseUtil.NEW_ADMIN_PASSWORD
            + "' role admin)");
    final ODatabaseSession session =
        orientDB.open("test", "admin", OCreateDatabaseUtil.NEW_ADMIN_PASSWORD);
    session.createClass("test");
    session.save(new ODocument("test")).getIdentity();
  }

  @Test
  public void testPessimistic() throws InterruptedException {
{'fraction_non_alphanumeric': 0.09637867122897063, 'fraction_numerical': 0.0, 'mean_word_length': 4.121167883211679, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1896366', 'n_tokens_mistral': 1036, 'n_tokens_neox': 1023, 'n_words': 162}