<commit_before>/*
 *
 *  *  Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
 *  *
 *  *  Licensed under the Apache License, Version 2.0 (the "License");
 *  *  you may not use this file except in compliance with the License.
 *  *  You may obtain a copy of the License at
 *  *
 *  *       http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  *  Unless required by applicable law or agreed to in writing, software
 *  *  distributed under the License is distributed on an "AS IS" BASIS,
 *  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  *  See the License for the specific language governing permissions and
 *  *  limitations under the License.
 *  *
 *  * For more information: http://www.orientechnologies.com
 *
 */

package com.orientechnologies.orient.graph;

import com.orientechnologies.common.io.OFileUtils;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import org.junit.AfterClass;
import org.junit.BeforeClass;

import java.io.File;

/**
 * Base class for tests against transactional Graphs.
 * 
 * @author <NAME>
 */
public abstract class GraphTxAbstractTest {
  protected static OrientGraph graph;

  public static enum ENV {
    DEV, RELEASE, CI
  }

  public static ENV getEnvironment() {
    String envName = System.getProperty("orientdb.test.env", "dev").toUpperCase();
    ENV result = null;
    try {
      result = ENV.valueOf(envName);
    } catch (IllegalArgumentException e) {
    }

    if (result == null)
      result = ENV.DEV;

    return result;
  }

  public static String getStorageType() {
    if (getEnvironment().equals(ENV.DEV))
      return "memory";

    return "plocal";
  }

  @BeforeClass
  public static void beforeClass() {
    final String dbName = GraphTxAbstractTest.class.getSimpleName();
    final String storageType = getStorageType();
    final String buildDirectory = System.getProperty("buildDirectory", ".");

    OFileUtils.deleteRecursively(new File(buildDirectory + "/" + dbName));

    graph = new OrientGraph(storageType + ":" + buildDirectory + "/" + dbName);
  }

  @AfterClass
  public static void afterClass() throws Exception {
    graph.shutdown();<commit_msg>fixed delete of files of an open database.<commit_after>/*
 *
 *  *  Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
 *  *
 *  *  Licensed under the Apache License, Version 2.0 (the "License");
 *  *  you may not use this file except in compliance with the License.
 *  *  You may obtain a copy of the License at
 *  *
 *  *       http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  *  Unless required by applicable law or agreed to in writing, software
 *  *  distributed under the License is distributed on an "AS IS" BASIS,
 *  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  *  See the License for the specific language governing permissions and
 *  *  limitations under the License.
 *  *
 *  * For more information: http://www.orientechnologies.com
 *
 */

package com.orientechnologies.orient.graph;

import com.orientechnologies.common.io.OFileUtils;
import com.orientechnologies.orient.core.Orient;
import com.orientechnologies.orient.core.storage.OStorage;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;

import org.junit.AfterClass;
import org.junit.BeforeClass;

import java.io.File;

/**
 * Base class for tests against transactional Graphs.
 * 
 * @author <NAME>
 */
public abstract class GraphTxAbstractTest {
  protected static OrientGraph graph;

  public static enum ENV {
    DEV, RELEASE, CI
  }

  public static ENV getEnvironment() {
    String envName = System.getProperty("orientdb.test.env", "dev").toUpperCase();
    ENV result = null;
    try {
      result = ENV.valueOf(envName);
    } catch (IllegalArgumentException e) {
    }

    if (result == null)
      result = ENV.DEV;

    return result;
  }

  public static String getStorageType() {
    if (getEnvironment().equals(ENV.DEV))
      return "memory";

    return "plocal";
  }

  @BeforeClass
  public static void beforeClass() {
    final String dbName = GraphTxAbstractTest.class.getSimpleName();
    final String storageType = getStorageType();
    final String buildDirectory = System.getProperty("buildDirectory", ".");
    graph = new OrientGraph(storageType + ":" + buildDirectory + "/" + dbName);
    graph.drop();
    graph = new OrientGraph(storageType + ":" + buildDirectory + "/" + dbName);

  }

  @AfterClass
  public static void afterClass() throws Exception {
    graph.shutdown();
{'fraction_non_alphanumeric': 0.10673415492957747, 'fraction_numerical': 0.0035211267605633804, 'mean_word_length': 3.477832512315271, 'pattern_counts': {'":': 3, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6544513', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1318, 'n_words': 397}