<commit_before>package org.testng.gigaspaces;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import net.jini.core.lease.Lease;
import net.jini.core.transaction.Transaction;
import net.jini.core.transaction.TransactionFactory;
import net.jini.core.transaction.server.TransactionManager;

import org.testng.ISuite;
import org.testng.ISuiteResult;
import org.testng.ITestResult;
import org.testng.SuiteRunner;
import org.testng.TestNG;
import org.testng.internal.Invoker;
import org.testng.internal.annotations.IAnnotationFinder;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlTest;

import com.j_spaces.core.IJSpace;
import com.j_spaces.core.client.FinderException;
import com.j_spaces.core.client.LocalTransactionManager;
import com.j_spaces.core.client.SpaceFinder;


/**
 * @author	<NAME>
 * @version	1.0
 */
public class SpaceAdapter
{
	final private TestNG				_testNG;
	final IJSpace						_space;


	public SpaceAdapter(String url, TestNG testNG) throws FinderException
	{
		_space = (IJSpace) SpaceFinder.find(url);
		_testNG = testNG;
	}

	public void waitForSuites()
	{
		SuiteEntry suiteTemplate	= new SuiteEntry();
		try
		{
			TransactionManager tm = LocalTransactionManager.getInstance(_space);
			while (true)
			{
				Transaction txn = TransactionFactory.create(tm, 100000).transaction;
				SuiteEntry entry = (SuiteEntry) _space.read(suiteTemplate, txn, Long.MAX_VALUE);
				XmlSuite suite = entry.getSuite();

				ArrayList<XmlSuite> suites = new ArrayList<XmlSuite>();
				suites.add(suite);
				_testNG.setXmlSuites(suites);
				List<ISuite> suiteRunners = _testNG.runSuitesLocally();
				for (ISuite sr : suiteRunners)
				{
					_space.write(new ResultEntry(sr), txn, Lease.FOREVER);
				}

				txn.commit();
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace(System.out);
		}
	}

	public List<ISuite> runSuitesRemotely(List<XmlSuite> suites,
			IAnnotationFinder javadocAnnotationFinder,
			IAnnotationFinder jdkAnnotationFinder) throws Exception
	{

		int tests = 0;
		for (XmlSuite suite : suites)
		{
			SuiteRunner suiteRunner = new SuiteRunner(suite, _testNG
					.getOutputDirectory(), new IAnnotationFinder[] {
					javadocAnnotationFinder, jdkAnnotationFinder });
			for (XmlTest test : suite.getTests())
			{
				XmlSuite tmpSuite = new XmlSuite();
				tmpSuite.setXmlPackages(suite.getXmlPackages());
				tmpSuite.setAnnotations(suite.getAnnotations());
				tmpSuite.setJUnit(suite.isJUnit());
				tmpSuite.setName("Temporary suite for " + test.getName());
				tmpSuite.setParallel(suite.getParallel());
				tmpSuite.setParameters(suite.getParameters());
				tmpSuite.setThreadCount(suite.getThreadCount());
				tmpSuite.setVerbose(suite.getVerbose());
				tmpSuite.setObjectFactory(suite.getObjectFactory());

				XmlTest tmpTest = new XmlTest(tmpSuite);
				tmpTest.setAnnotations(test.getAnnotations());
				tmpTest.setBeanShellExpression(test.getExpression());
				tmpTest.setXmlClasses(test.getXmlClasses());
				tmpTest.setExcludedGroups(test.getExcludedGroups());
				tmpTest.setIncludedGroups(test.getIncludedGroups());
				tmpTest.setJUnit(test.isJUnit());
				tmpTest.setMethodSelectors(test.getMethodSelectors());
				tmpTest.setName(test.getName());
				tmpTest.setParallel(test.getParallel());
				tmpTest.setParameters(test.getParameters());
				tmpTest.setVerbose(test.getVerbose());
				tmpTest.setXmlClasses(test.getXmlClasses());
				tmpTest.setXmlPackages(test.getXmlPackages());

				++tests;
				_space.write(tmpSuite, null, Lease.FOREVER);
			}
		}

		ResultEntry resultTemplate = new ResultEntry();
		List<ISuite> result = new ArrayList<ISuite>();
		for (int i = 0; i < tests; ++i)
		{
			ResultEntry rs = (ResultEntry) _space.take(resultTemplate, null,
																		Long.MAX_VALUE);
			result.add(rs.getSuite());
		}
<commit_msg>Wrap the XMLSuite with SuiteEntry<commit_after>package org.testng.gigaspaces;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import net.jini.core.lease.Lease;
import net.jini.core.transaction.Transaction;
import net.jini.core.transaction.TransactionFactory;
import net.jini.core.transaction.server.TransactionManager;

import org.testng.ISuite;
import org.testng.ISuiteResult;
import org.testng.ITestResult;
import org.testng.SuiteRunner;
import org.testng.TestNG;
import org.testng.internal.Invoker;
import org.testng.internal.annotations.IAnnotationFinder;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlTest;

import com.j_spaces.core.IJSpace;
import com.j_spaces.core.client.FinderException;
import com.j_spaces.core.client.LocalTransactionManager;
import com.j_spaces.core.client.SpaceFinder;


/**
 * @author	<NAME>
 * @version	1.0
 */
public class SpaceAdapter
{
	final private TestNG				_testNG;
	final IJSpace						_space;


	public SpaceAdapter(String url, TestNG testNG) throws FinderException
	{
		_space = (IJSpace) SpaceFinder.find(url);
		_testNG = testNG;
	}

	public void waitForSuites()
	{
		SuiteEntry suiteTemplate	= new SuiteEntry();
		try
		{
			TransactionManager tm = LocalTransactionManager.getInstance(_space);
			while (true)
			{
				Transaction txn = TransactionFactory.create(tm, 100000).transaction;
				SuiteEntry entry = (SuiteEntry) _space.read(suiteTemplate, txn, Long.MAX_VALUE);
				XmlSuite suite = entry.getSuite();

				ArrayList<XmlSuite> suites = new ArrayList<XmlSuite>();
				suites.add(suite);
				_testNG.setXmlSuites(suites);
				List<ISuite> suiteRunners = _testNG.runSuitesLocally();
				for (ISuite sr : suiteRunners)
				{
					_space.write(new ResultEntry(sr), txn, Lease.FOREVER);
				}

				txn.commit();
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace(System.out);
		}
	}

	public List<ISuite> runSuitesRemotely(List<XmlSuite> suites,
			IAnnotationFinder javadocAnnotationFinder,
			IAnnotationFinder jdkAnnotationFinder) throws Exception
	{

		int tests = 0;
		for (XmlSuite suite : suites)
		{
			SuiteRunner suiteRunner = new SuiteRunner(suite, _testNG
					.getOutputDirectory(), new IAnnotationFinder[] {
					javadocAnnotationFinder, jdkAnnotationFinder });
			for (XmlTest test : suite.getTests())
			{
				XmlSuite tmpSuite = new XmlSuite();
				tmpSuite.setXmlPackages(suite.getXmlPackages());
				tmpSuite.setAnnotations(suite.getAnnotations());
				tmpSuite.setJUnit(suite.isJUnit());
				tmpSuite.setName("Temporary suite for " + test.getName());
				tmpSuite.setParallel(suite.getParallel());
				tmpSuite.setParameters(suite.getParameters());
				tmpSuite.setThreadCount(suite.getThreadCount());
				tmpSuite.setVerbose(suite.getVerbose());
				tmpSuite.setObjectFactory(suite.getObjectFactory());

				XmlTest tmpTest = new XmlTest(tmpSuite);
				tmpTest.setAnnotations(test.getAnnotations());
				tmpTest.setBeanShellExpression(test.getExpression());
				tmpTest.setXmlClasses(test.getXmlClasses());
				tmpTest.setExcludedGroups(test.getExcludedGroups());
				tmpTest.setIncludedGroups(test.getIncludedGroups());
				tmpTest.setJUnit(test.isJUnit());
				tmpTest.setMethodSelectors(test.getMethodSelectors());
				tmpTest.setName(test.getName());
				tmpTest.setParallel(test.getParallel());
				tmpTest.setParameters(test.getParameters());
				tmpTest.setVerbose(test.getVerbose());
				tmpTest.setXmlClasses(test.getXmlClasses());
				tmpTest.setXmlPackages(test.getXmlPackages());

				++tests;
				SuiteEntry suiteEntry	= new SuiteEntry(tmpSuite);
				_space.write(suiteEntry, null, Lease.FOREVER);
			}
		}

		ResultEntry resultTemplate = new ResultEntry();
		List<ISuite> result = new ArrayList<ISuite>();
		for (int i = 0; i < tests; ++i)
		{
			ResultEntry rs = (ResultEntry) _space.take(resultTemplate, null,
																		Long.MAX_VALUE);
			result.add(rs.getSuite());
		}

{'fraction_non_alphanumeric': 0.11891614228842944, 'fraction_numerical': 0.0025683832027738537, 'mean_word_length': 4.6393917451122375, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '1455052', 'n_tokens_mistral': 2925, 'n_tokens_neox': 2521, 'n_words': 422}