Skip to content

Commit

Permalink
Change NeoLE tests to extend Kernel API tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fickludd committed Nov 9, 2017
1 parent 5cf08ec commit afc9c96
Show file tree
Hide file tree
Showing 15 changed files with 359 additions and 1,447 deletions.
Expand Up @@ -40,6 +40,7 @@

public abstract class PropertyCursorTestBase<G extends KernelAPIReadTestSupport> extends KernelAPIReadTestBase<G>
{
@SuppressWarnings( "SpellCheckingInspection" )
private static final String LONG_STRING = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque "
+ "eget nibh cursus, efficitur risus non, ultrices justo. Nulla laoreet eros mi, non molestie magna "
+ "luctus in. Fusce nibh neque, tristique ultrices laoreet et, aliquet non dolor. Donec ultrices nisi "
Expand Down Expand Up @@ -76,11 +77,18 @@ public abstract class PropertyCursorTestBase<G extends KernelAPIReadTestSupport>
+ "Proin massa enim, accumsan ac libero at, iaculis sodales tellus. Vivamus fringilla justo sed luctus "
+ "tincidunt. Sed placerat fringilla ex, vel placerat sem faucibus eget. Vestibulum semper dui sit amet "
+ "efficitur blandit. Donec eu tellus velit. Etiam a mi nec massa euismod posuere. Cras eget lacus leo.";

private static long bare, byteProp, shortProp, intProp, inlineLongProp, longProp,
floatProp, doubleProp, trueProp, falseProp, charProp, emptyStringProp, shortStringProp, longStringProp,
utf8Prop, smallArray, bigArray, allProps;

private static String chinese = "造Unicode之";

protected boolean supportsBigProperties()
{
return true;
}

@Override
void createTestGraph( GraphDatabaseService graphDb )
{
Expand Down Expand Up @@ -127,11 +135,17 @@ void createTestGraph( GraphDatabaseService graphDb )
all.setProperty( "charProp", 'x' );
all.setProperty( "emptyStringProp", "" );
all.setProperty( "shortStringProp", "hello" );
all.setProperty( "longStringProp", LONG_STRING );
if ( supportsBigProperties() )
{
all.setProperty( "longStringProp", LONG_STRING );
}
all.setProperty( "utf8Prop", chinese );

all.setProperty( "smallArray", new int[] {1, 2, 3, 4} );
all.setProperty( "bigArray", new String[] {LONG_STRING} );
if ( supportsBigProperties() )
{
all.setProperty( "smallArray", new int[] {1, 2, 3, 4} );
all.setProperty( "bigArray", new String[] {LONG_STRING} );
}

allProps = all.getId();

Expand Down Expand Up @@ -183,10 +197,16 @@ public void shouldAccessSingleProperty() throws Exception
assertAccessSingleProperty( charProp, Values.of( 'x' ) );
assertAccessSingleProperty( emptyStringProp, Values.of( "" ) );
assertAccessSingleProperty( shortStringProp, Values.of( "hello" ) );
assertAccessSingleProperty( longStringProp, Values.of( LONG_STRING ) );
if ( supportsBigProperties() )
{
assertAccessSingleProperty( longStringProp, Values.of( LONG_STRING ) );
}
assertAccessSingleProperty( utf8Prop, Values.of( chinese ) );
assertAccessSingleProperty( smallArray, Values.of( new int[] {1, 2, 3, 4} ) );
assertAccessSingleProperty( bigArray, Values.of( new String[] {LONG_STRING} ) );
if ( supportsBigProperties() )
{
assertAccessSingleProperty( smallArray, Values.of( new int[] {1, 2, 3, 4} ) );
assertAccessSingleProperty( bigArray, Values.of( new String[] {LONG_STRING} ) );
}
}

@Test
Expand Down Expand Up @@ -220,12 +240,15 @@ public void shouldAccessAllNodeProperties() throws Exception
assertTrue( "charProp", values.contains( 'x' ) );
assertTrue( "emptyStringProp", values.contains( "" ) );
assertTrue( "shortStringProp", values.contains( "hello" ) );
assertTrue( "longStringProp", values.contains( LONG_STRING ) );
assertTrue( "utf8Prop", values.contains( chinese ) );
assertThat( "smallArray", values, hasItem( intArray( 1, 2, 3, 4 ) ) );
assertThat( "bigArray", values, hasItem( arrayContaining( LONG_STRING ) ) );

assertEquals( "number of values", 16, values.size() );
if ( supportsBigProperties() )
{
assertTrue( "longStringProp", values.contains( LONG_STRING ) );
assertThat( "smallArray", values, hasItem( intArray( 1, 2, 3, 4 ) ) );
assertThat( "bigArray", values, hasItem( arrayContaining( LONG_STRING ) ) );
}
int expected = supportsBigProperties() ? 16 : 13;
assertEquals( "number of values", expected, values.size() );
}
}

Expand Down
Expand Up @@ -23,6 +23,7 @@
import java.util.Map;
import java.util.function.Consumer;

import org.junit.Assume;
import org.junit.Test;

import org.neo4j.graphdb.GraphDatabaseService;
Expand All @@ -42,6 +43,16 @@ public abstract class RelationshipTraversalCursorTestBase<G extends KernelAPIRea
{
private static long bare, start, end, sparse, dense;

protected boolean supportsDirectTraversal()
{
return true;
}

protected boolean supportsSparseNodes()
{
return true;
}

@Override
void createTestGraph( GraphDatabaseService graphDb )
{
Expand Down Expand Up @@ -334,7 +345,7 @@ public void shouldHaveBeenAbleToCreateDenseAndSparseNodes() throws Exception

read.singleNode( sparse, node );
assertTrue( "access sparse node", node.next() );
assertFalse( "sparse node", node.isDense() );
assertFalse( "sparse node", node.isDense() && supportsSparseNodes() );
}
}

Expand Down Expand Up @@ -365,24 +376,28 @@ public void shouldTraverseDenseNodeViaGroupsWithDetachedReferences() throws Exce
@Test
public void shouldTraverseSparseNodeWithoutGroups() throws Exception
{
Assume.assumeTrue( supportsSparseNodes() && supportsDirectTraversal() );
traverseWithoutGroups( sparse, false );
}

@Test
public void shouldTraverseDenseNodeWithoutGroups() throws Exception
{
Assume.assumeTrue( supportsDirectTraversal() );
traverseWithoutGroups( dense, false );
}

@Test
public void shouldTraverseSparseNodeWithoutGroupsWithDetachedReferences() throws Exception
{
Assume.assumeTrue( supportsSparseNodes() );
traverseWithoutGroups( sparse, true );
}

@Test
public void shouldTraverseDenseNodeWithoutGroupsWithDetachedReferences() throws Exception
{
Assume.assumeTrue( supportsDirectTraversal() );
traverseWithoutGroups( dense, true );
}

Expand Down
7 changes: 7 additions & 0 deletions enterprise/runtime/neole/pom.xml
Expand Up @@ -61,6 +61,13 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel-api</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-lucene-index</artifactId>
Expand Down
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2002-2017 "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 org.neo4j.internal.store.prototype.neole;

import java.io.IOException;

import org.neo4j.internal.kernel.api.Kernel;
import org.neo4j.internal.kernel.api.Permissions;
import org.neo4j.internal.kernel.api.Session;
import org.neo4j.internal.kernel.api.Token;
import org.neo4j.internal.kernel.api.Transaction;

public class NeoLEKernel implements Kernel
{
private final CursorFactory cursorFactory;
private final ReadStore readStore;

public NeoLEKernel( ReadStore readStore )
{
this.readStore = readStore;
this.cursorFactory = new CursorFactory( readStore );
}

@Override
public CursorFactory cursors()
{
return cursorFactory;
}

@Override
public Session beginSession( Permissions permissions )
{
return new Session()
{

@Override
public Transaction beginTransaction()
{
try
{
return new NeoLETransaction( readStore );
}
catch ( IOException e )
{
throw new RuntimeException( "failed" );
}
}

@Override
public Token token()
{
return null;
}

@Override
public void close()
{
}
};
}
}
@@ -0,0 +1,94 @@
/*
* Copyright (c) 2002-2017 "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 org.neo4j.internal.store.prototype.neole;

import java.io.IOException;

import org.neo4j.internal.kernel.api.ExplicitIndexRead;
import org.neo4j.internal.kernel.api.ExplicitIndexWrite;
import org.neo4j.internal.kernel.api.Locks;
import org.neo4j.internal.kernel.api.Read;
import org.neo4j.internal.kernel.api.SchemaRead;
import org.neo4j.internal.kernel.api.SchemaWrite;
import org.neo4j.internal.kernel.api.Write;

public class NeoLETransaction implements org.neo4j.internal.kernel.api.Transaction
{
private final ReadStore read;

public NeoLETransaction( ReadStore read ) throws IOException
{
this.read = read;
}

@Override
public long commit()
{
return 0;
}

@Override
public void rollback()
{

}

@Override
public Read dataRead()
{
return read;
}

@Override
public Write dataWrite()
{
return null;
}

@Override
public ExplicitIndexRead indexRead()
{
return null;
}

@Override
public ExplicitIndexWrite indexWrite()
{
return null;
}

@Override
public SchemaRead schemaRead()
{
return null;
}

@Override
public SchemaWrite schemaWrite()
{
return null;
}

@Override
public Locks locks()
{
return null;
}
}

0 comments on commit afc9c96

Please sign in to comment.