<commit_before>package org.lightmare;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.lightmare.cache.ConnectionContainer;
import org.lightmare.deploy.MetaCreator;
import org.lightmare.logger.Configure;

@Ignore
public class JpaTest {

    public static DBCreator getDBCreator() throws ClassNotFoundException,
	    IOException, ParseException, InterruptedException,
	    ExecutionException {
	DBCreator creator = getDBCreator(null, null, null, null);
	return creator;
    }

    public static DBCreator getDBCreator(String unitName)
	    throws ClassNotFoundException, IOException, ParseException,
	    InterruptedException, ExecutionException {
	DBCreator creator = getDBCreator(null, null, unitName, null);
	return creator;
    }

    public static DBCreator getDBCreator(String path, String dataSourcePath,
	    String unitName, String jndi) throws ClassNotFoundException,
	    IOException, ParseException, InterruptedException,
	    ExecutionException {
	Configure.configure();
	Map<String, String> properties = new HashMap<String, String>();

	properties.put("hibernate.default_schema", "PERSONS");
	properties.put("hibernate.show_sql", "true");
	properties.put("hibernate.sql_trace", "true");

	// properties.put("hibernate.connection.url",
	// "jdbc:derby:target/database/jpa-test-database;create=true");

	// properties.put("hibernate.connection.username", "user");
	// properties.put("hibernate.connection.password", "password");

	properties.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
	properties.put("hibernate.cache.provider_class",
		"org.hibernate.cache.NoCacheProvider");
	properties.put("hibernate.connection.driver_class", "org.h2.Driver");
	properties.put("hibernate.hbm2ddl.auto", "create-drop");
	// <!-- hiberanate key generation properties -->
	properties.put("hibernate.jdbc.use_get_generated_keys", "true");
	properties.put("hibernate.max_fetch_depth", "3");
	MetaCreator.Builder builder = new MetaCreator.Builder()
		.setPersistenceProperties(properties);
	builder.setPoolPropertiesPath("./pool/pool.properties");
	builder.addPoolProperty("statementCacheNumDeferredCloseThreads", "3");
	builder.setHotDeployment(true);
	builder.addDeploymentPath("./lib");
	if (unitName != null) {
	    builder.setScanForEntities(true).setUnitName(unitName);
	}
	builder.setSwapDataSource(true);
	if (dataSourcePath != null) {
	    builder.setSwapDataSource(true).addDataSourcePath(dataSourcePath);
	}

	MetaCreator metaCreator;
	if (path != null) {
	    builder.setXmlFromJar(true);
	    File file = new File(path);
	    File[] files = { file };
	    metaCreator = builder.build();
	    metaCreator.scanForBeans(files);
	} else {
	    metaCreator = builder.build();
	    metaCreator.scanForBeans();
	}
	Map<String, URL> classOwnershipURLs = metaCreator.getAnnotationFinder()
		.getClassOwnersURLs();
	Map<String, String> classOwnershipFiles = metaCreator.getAnnotationFinder()
		.getClassOwnersFiles();
	System.out
		.println("============URLs of scanned classes ================");
	for (Map.Entry<String, URL> entry : classOwnershipURLs.entrySet()) {
	    System.out.format("%s ------ %s\n", entry.getKey(),
		    entry.getValue());
	}
	System.out
		.println("============Files of scanned classes ================");
	for (Map.Entry<String, String> entry : classOwnershipFiles.entrySet()) {
	    System.out.format("%s ------ %s\n", entry.getKey(),
		    entry.getValue());
	}
	System.out
		.println("====================================================");
	EntityManagerFactory emf = null;
	EntityManager em = null;
	int tryCount = 0;<commit_msg>improved test cases<commit_after>package org.lightmare;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.lightmare.cache.ConnectionContainer;
import org.lightmare.deploy.MetaCreator;
import org.lightmare.logger.Configure;

@Ignore
public class JpaTest {

    public static DBCreator getDBCreator() throws ClassNotFoundException,
	    IOException, ParseException, InterruptedException,
	    ExecutionException {
	DBCreator creator = getDBCreator(null, null, null, null);
	return creator;
    }

    public static DBCreator getDBCreator(String unitName)
	    throws ClassNotFoundException, IOException, ParseException,
	    InterruptedException, ExecutionException {
	DBCreator creator = getDBCreator(null, null, unitName, null);
	return creator;
    }

    public static DBCreator getDBCreator(String path, String dataSourcePath,
	    String unitName, String jndi) throws ClassNotFoundException,
	    IOException, ParseException, InterruptedException,
	    ExecutionException {
	Configure.configure();
	Map<String, String> properties = new HashMap<String, String>();

	properties.put("hibernate.default_schema", "PERSONS");
	properties.put("hibernate.show_sql", "true");
	properties.put("hibernate.sql_trace", "true");

	// properties.put("hibernate.connection.url",
	// "jdbc:derby:target/database/jpa-test-database;create=true");

	// properties.put("hibernate.connection.username", "user");
	// properties.put("hibernate.connection.password", "password");

	properties.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
	properties.put("hibernate.cache.provider_class",
		"org.hibernate.cache.NoCacheProvider");
	properties.put("hibernate.connection.driver_class", "org.h2.Driver");
	properties.put("hibernate.hbm2ddl.auto", "create-drop");
	// <!-- hiberanate key generation properties -->
	properties.put("hibernate.jdbc.use_get_generated_keys", "true");
	properties.put("hibernate.max_fetch_depth", "3");
	MetaCreator.Builder builder = new MetaCreator.Builder()
		.setPersistenceProperties(properties);
	builder.setPoolPropertiesPath("./pool/pool.properties");
	builder.addPoolProperty("statementCacheNumDeferredCloseThreads", "3");
	builder.setHotDeployment(Boolean.FALSE);
	builder.addDeploymentPath("./lib");
	if (unitName != null) {
	    builder.setScanForEntities(Boolean.TRUE).setUnitName(unitName);
	}
	builder.setSwapDataSource(true);
	if (dataSourcePath != null) {
	    builder.setSwapDataSource(Boolean.TRUE).addDataSourcePath(
		    dataSourcePath);
	}

	MetaCreator metaCreator;
	if (path != null) {
	    builder.setXmlFromJar(Boolean.TRUE);
	    File file = new File(path);
	    File[] files = { file };
	    metaCreator = builder.build();
	    metaCreator.scanForBeans(files);
	} else {
	    metaCreator = builder.build();
	    metaCreator.scanForBeans();
	}
	Map<String, URL> classOwnershipURLs = metaCreator.getAnnotationFinder()
		.getClassOwnersURLs();
	Map<String, String> classOwnershipFiles = metaCreator
		.getAnnotationFinder().getClassOwnersFiles();
	System.out
		.println("============URLs of scanned classes ================");
	for (Map.Entry<String, URL> entry : classOwnershipURLs.entrySet()) {
	    System.out.format("%s ------ %s\n", entry.getKey(),
		    entry.getValue());
	}
	System.out
		.println("============Files of scanned classes ================");
	for (Map.Entry<String, String> entry : classOwnershipFiles.entrySet()) {
	    System.out.format("%s ------ %s\n", entry.getKey(),
		    entry.getValue());
	}
	System.out
		.println("====================================================");
	EntityManagerFactory emf = null;
	EntityManager em = null;
	int tryCount = 0;
{'fraction_non_alphanumeric': 0.15462392108508013, 'fraction_numerical': 0.0014796547472256474, 'mean_word_length': 5.427099841521395, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '2480573', 'n_tokens_mistral': 2532, 'n_tokens_neox': 2397, 'n_words': 444}