Permalink
Browse files

Added an integration test which sees if legacy index works and plays …

…nice together

with the integrated index.
  • Loading branch information...
1 parent 7c3726b commit ce24db3e9d9cf2876392e6503739c84793e86d08 @tinwelint tinwelint committed Apr 6, 2011
View
@@ -0,0 +1 @@
+Stuff to be executed in a QA test phase goes here
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.neo4j</groupId>
+ <artifactId>parent-central</artifactId>
+ <version>18</version>
+ </parent>
+
+ <groupId>org.neo4j.qa</groupId>
+ <artifactId>legacy-index-tests</artifactId>
+ <version>1-SNAPSHOT</version>
+
+ <properties>
+ <neo4j.version>1.3-SNAPSHOT</neo4j.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.neo4j</groupId>
+ <artifactId>neo4j</artifactId>
+ <version>${neo4j.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.neo4j</groupId>
+ <artifactId>neo4j-legacy-index</artifactId>
+ <version>${neo4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
@@ -0,0 +1,105 @@
+/**
+ * Copyright (c) 2002-2011 "Neo Technology,"
+ * Network Engine for Objects in Lund AB [http://neotechnology.com]
+ *
+ * This file is part of Neo4j.
+ *
+ * Neo4j is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package legacy;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.After;
+import org.junit.Before;
+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.index.IndexService;
+import org.neo4j.index.lucene.LuceneFulltextIndexService;
+import org.neo4j.index.lucene.LuceneIndexService;
+import org.neo4j.kernel.EmbeddedGraphDatabase;
+
+/**
+ * Asserts that LuceneIndexService and friends play nice with
+ * {@link GraphDatabaseService#index()}
+ */
+public class TestPlayNiceWithIntegrated
+{
+ private GraphDatabaseService db;
+ private Transaction tx;
+
+ @Before
+ public void doBefore()
+ {
+ db = new EmbeddedGraphDatabase( "target/playground" );
+ }
+
+ @After
+ public void doAfter()
+ {
+ if ( tx != null )
+ {
+ commitTx();
+ }
+ db.shutdown();
+ }
+
+ private void beginTx()
+ {
+ tx = db.beginTx();
+ }
+
+ private void commitTx()
+ {
+ tx.success();
+ tx.finish();
+ tx = null;
+ }
+
+ private void restartTx()
+ {
+ commitTx();
+ beginTx();
+ }
+
+ @Test
+ public void smokeTestIt() throws Exception
+ {
+ IndexService indexService = new LuceneIndexService( db );
+ IndexService fulltextIndexService = new LuceneFulltextIndexService( db );
+ Index<Node> aNodeIndex = db.index().forNodes( "a" ); // "a" as in a node index
+ String key = "key";
+ String value = "value";
+
+ beginTx();
+ Node node = db.createNode();
+ indexService.index( node, key, value );
+ fulltextIndexService.index( node, key, value );
+ aNodeIndex.add( node, key, value );
+
+ for ( int i = 0; i < 2; i++ )
+ { // Do the assertions first just before the commit, then after
+ assertEquals( node, indexService.getSingleNode( key, value ) );
+ assertEquals( node, fulltextIndexService.getSingleNode( key, value ) );
+ assertEquals( node, aNodeIndex.get( key, value ).getSingle() );
+ restartTx();
+ }
+
+ fulltextIndexService.shutdown();
+ indexService.shutdown();
+ }
+}

0 comments on commit ce24db3

Please sign in to comment.