Skip to content

Commit

Permalink
Moved test from community server to enterprise server
Browse files Browse the repository at this point in the history
  • Loading branch information
systay committed Feb 7, 2017
1 parent edfcb70 commit 9d26b69
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 80 deletions.
Expand Up @@ -35,21 +35,6 @@

public class CypherQueriesIT extends AbstractRestFunctionalTestBase
{
@Test
public void runningInCompiledRuntime() throws JsonParseException
{
// Document
ResponseEntity response = gen.get()
.expectedStatus( 200 )
.payload( quotedJson(
"{ 'statements': [ { 'statement': 'CYPHER runtime=compiled MATCH (n) RETURN n' } ] }" ) )
.post( getDataUri() + "transaction/commit" );

// Then
Map<String, Object> result = jsonToMap( response.entity() );
assertNoErrors( result );
}

@Test
public void runningWithGeometryTypes() throws JsonParseException
{
Expand Down
5 changes: 5 additions & 0 deletions enterprise/server-enterprise/pom.xml
Expand Up @@ -64,6 +64,11 @@
<artifactId>neo4j-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-enterprise-cypher</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-enterprise</artifactId>
Expand Down
@@ -0,0 +1,42 @@
/*
* 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.server.rest;

import org.junit.Test;
import org.neo4j.test.server.HTTP;

import static org.junit.Assert.assertEquals;

public class CypherQueriesIT extends EnterpriseVersionIT {

@Test
public void runningInCompiledRuntime() throws Exception
{
// Given
String uri = functionalTestHelper.dataUri() + "transaction/commit";
String payload = "{ 'statements': [ { 'statement': 'CYPHER runtime=compiled MATCH (n) RETURN n' } ] }";

// When
HTTP.Response res = HTTP.POST(uri, payload.replaceAll("'", "\""));

// Then
assertEquals( 200, res.status() );
}
}
Expand Up @@ -19,85 +19,21 @@
*/
package org.neo4j.server.rest;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

import java.util.concurrent.Callable;

import org.neo4j.kernel.internal.KernelData;
import org.neo4j.server.NeoServer;
import org.neo4j.server.enterprise.helpers.EnterpriseServerBuilder;
import org.neo4j.server.helpers.FunctionalTestHelper;
import org.neo4j.server.rest.management.VersionAndEditionService;
import org.neo4j.test.server.ExclusiveServerTestBase;
import org.neo4j.test.server.HTTP;
import org.neo4j.time.Clocks;
import org.neo4j.time.FakeClock;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.neo4j.test.rule.SuppressOutput.suppressAll;

/*
Note that when running this test from within an IDE, the version field will be an empty string. This is because the
code that generates the version identifier is written by Maven as part of the build process(!). The tests will pass
both in the IDE (where the empty string will be correctly compared).
*/
public class EnterpriseVersionAndEditionServiceIT extends ExclusiveServerTestBase
{
private static NeoServer server;
private static FunctionalTestHelper functionalTestHelper;

@ClassRule
public static TemporaryFolder staticFolder = new TemporaryFolder();

private static FakeClock clock;

@BeforeClass
public static void setupServer() throws Exception
{
clock = Clocks.fakeClock();
server = EnterpriseServerBuilder.server()
.usingDataDir( staticFolder.getRoot().getAbsolutePath() )
.withClock( clock )
.build();

suppressAll().call( new Callable<Void>()
{
@Override
public Void call() throws Exception
{
server.start();
return null;
}
} );
functionalTestHelper = new FunctionalTestHelper( server );
}

@Before
public void setupTheDatabase() throws Exception
{
// do nothing, we don't care about the database contents here
}

@AfterClass
public static void stopServer() throws Exception
{
suppressAll().call( new Callable<Void>()
{
@Override
public Void call() throws Exception
{
server.stop();
return null;
}
} );
}
public class EnterpriseVersionAndEditionServiceIT extends EnterpriseVersionIT {

@Test
public void shouldReportEnterpriseEdition() throws Exception
Expand Down
@@ -0,0 +1,74 @@
/*
* 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.server.rest;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.rules.TemporaryFolder;
import org.neo4j.server.NeoServer;
import org.neo4j.server.enterprise.helpers.EnterpriseServerBuilder;
import org.neo4j.server.helpers.FunctionalTestHelper;
import org.neo4j.test.server.ExclusiveServerTestBase;
import org.neo4j.time.Clocks;
import org.neo4j.time.FakeClock;

import java.util.concurrent.Callable;

import static org.neo4j.test.rule.SuppressOutput.suppressAll;

public abstract class EnterpriseVersionIT extends ExclusiveServerTestBase {
@ClassRule
public static TemporaryFolder staticFolder = new TemporaryFolder();
protected static NeoServer server;
static FunctionalTestHelper functionalTestHelper;

@BeforeClass
public static void setupServer() throws Exception
{
FakeClock clock = Clocks.fakeClock();
server = EnterpriseServerBuilder.server()
.usingDataDir( staticFolder.getRoot().getAbsolutePath() )
.withClock(clock)
.build();

suppressAll().call((Callable<Void>) () -> {
server.start();
return null;
});
functionalTestHelper = new FunctionalTestHelper( server );
}

@AfterClass
public static void stopServer() throws Exception
{
suppressAll().call((Callable<Void>) () -> {
server.stop();
return null;
});
}

@Before
public void setupTheDatabase() throws Exception
{
// do nothing, we don't care about the database contents here
}
}

0 comments on commit 9d26b69

Please sign in to comment.