Skip to content

Added InDev neo4j server version as a legal version #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

public class ServerVersion
{
private static final String NEO4J_IN_DEV_VERSION_STRING = "Neo4j/dev";
private final int major;
private final int minor;
private final int patch;
Expand All @@ -44,6 +45,7 @@ private ServerVersion( int major, int minor, int patch )
public static final ServerVersion v3_2_0 = new ServerVersion(3, 2, 0);
public static final ServerVersion v3_1_0 = new ServerVersion(3, 1, 0);
public static final ServerVersion v3_0_0 = new ServerVersion(3, 0, 0);
public static final ServerVersion vInDev = new ServerVersion(0, 0, 0);

public static ServerVersion version( Driver driver )
{
Expand Down Expand Up @@ -75,6 +77,10 @@ public static ServerVersion version( String server )
}
return new ServerVersion( major, minor, patch );
}
else if ( server.equalsIgnoreCase( NEO4J_IN_DEV_VERSION_STRING ) )
{
return vInDev;
}
else
{
throw new IllegalArgumentException( "Cannot parse " + server );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.neo4j.driver.internal.util;
/*
* Copyright (c) 2002-2017 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.fail;

public class ServerVersionTest
{
@Test
public void version() throws Exception
{
String nullVersion = null;
assertThat( ServerVersion.version( nullVersion ), is( ServerVersion.v3_0_0 ) );
assertThat( ServerVersion.version( "Neo4j/dev" ), is( ServerVersion.vInDev ) );
assertThat( ServerVersion.version( "Neo4j/3.2.0" ), is( ServerVersion.v3_2_0 ) );
}

@Test(expected = IllegalArgumentException.class)
public void versionShouldThrowExceptionIfServerVersionCantBeParsed() throws Exception
{
ServerVersion.version( "" );
fail( "Should have failed to parse version" );
}

}