// Path: src/test/java/org/neo4j/index/Neo4jTestCase.java
// public static <T> void assertContains( Collection<T> collection,
//     T... expectedItems )
// {
//     String collectionString = join( ", ", collection.toArray() );
//     assertEquals( collectionString, expectedItems.length,
//         collection.size() );
//     for ( T item : expectedItems )
//     {
//         assertTrue( collection.contains( item ) );
//     }
// }
// 
// Path: src/test/java/org/neo4j/index/impl/lucene/Contains.java
// @Factory
// public static <T> Contains<T> contains( T... expectedItems )
// {
//     return new Contains<T>( expectedItems );
// }


import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.index.Index;
import org.neo4j.graphdb.index.IndexHits;
import org.neo4j.test.ImpermanentGraphDatabase;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.neo4j.index.Neo4jTestCase.assertContains;
import static org.neo4j.index.impl.lucene.Contains.contains;
import java.util.ArrayList;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
		firstTx.deleteIndex();
		firstTx.commit();

		try
        {
            secondTx.queryIndex(key, "some other value");
            fail( "Should throw exception" );
        }
        catch ( Exception e ) { /* Good */ }

		secondTx.rollback();

		// Since $Before will start a tx, add a value and keep tx open and
		// workers will delete the index so this test will fail in @After
		// if we don't rollback this tx
		rollbackTx();
	}

    @Test
    public void indexDeletesShouldNotByVisibleUntilCommit() throws Exception
    {
        commitTx();

        WorkThread firstTx = createWorker( "First" );
        WorkThread secondTx = createWorker( "Second" );

        firstTx.beginTransaction();
        firstTx.removeFromIndex( key, value );

        IndexHits<Node> indexHits = secondTx.queryIndex( key, value );
// Path: src/test/java/org/neo4j/index/Neo4jTestCase.java
// public static <T> void assertContains( Collection<T> collection,
//     T... expectedItems )
// {
//     String collectionString = join( ", ", collection.toArray() );
//     assertEquals( collectionString, expectedItems.length,
//         collection.size() );
//     for ( T item : expectedItems )
//     {
//         assertTrue( collection.contains( item ) );
//     }
// }
// 
// Path: src/test/java/org/neo4j/index/impl/lucene/Contains.java
// @Factory
// public static <T> Contains<T> contains( T... expectedItems )
// {
//     return new Contains<T>( expectedItems );
// }


// Path: src/test/java/org/neo4j/index/impl/lucene/TestIndexDeletion.java
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.index.Index;
import org.neo4j.graphdb.index.IndexHits;
import org.neo4j.test.ImpermanentGraphDatabase;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.neo4j.index.Neo4jTestCase.assertContains;
import static org.neo4j.index.impl.lucene.Contains.contains;
import java.util.ArrayList;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;

		firstTx.deleteIndex();
		firstTx.commit();

		try
        {
            secondTx.queryIndex(key, "some other value");
            fail( "Should throw exception" );
        }
        catch ( Exception e ) { /* Good */ }

		secondTx.rollback();

		// Since $Before will start a tx, add a value and keep tx open and
		// workers will delete the index so this test will fail in @After
		// if we don't rollback this tx
		rollbackTx();
	}

    @Test
    public void indexDeletesShouldNotByVisibleUntilCommit() throws Exception
    {
        commitTx();

        WorkThread firstTx = createWorker( "First" );
        WorkThread secondTx = createWorker( "Second" );

        firstTx.beginTransaction();
        firstTx.removeFromIndex( key, value );

        IndexHits<Node> indexHits = secondTx.queryIndex( key, value );
        assertThat( indexHits, contains( node ) );