Skip to content

Commit b3c74b3

Browse files
author
Zhen
committed
Added InDev neo4j server version as a legal version
Related tests are added too
1 parent 75cb8a4 commit b3c74b3

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

driver/src/main/java/org/neo4j/driver/internal/util/ServerVersion.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
public class ServerVersion
3030
{
31+
private static final String NEO4J_IN_DEV_VERSION_STRING = "Neo4j/dev";
3132
private final int major;
3233
private final int minor;
3334
private final int patch;
@@ -44,6 +45,7 @@ private ServerVersion( int major, int minor, int patch )
4445
public static final ServerVersion v3_2_0 = new ServerVersion(3, 2, 0);
4546
public static final ServerVersion v3_1_0 = new ServerVersion(3, 1, 0);
4647
public static final ServerVersion v3_0_0 = new ServerVersion(3, 0, 0);
48+
public static final ServerVersion vInDev = new ServerVersion(0, 0, 0);
4749

4850
public static ServerVersion version( Driver driver )
4951
{
@@ -75,6 +77,10 @@ public static ServerVersion version( String server )
7577
}
7678
return new ServerVersion( major, minor, patch );
7779
}
80+
else if ( server.equalsIgnoreCase( NEO4J_IN_DEV_VERSION_STRING ) )
81+
{
82+
return vInDev;
83+
}
7884
else
7985
{
8086
throw new IllegalArgumentException( "Cannot parse " + server );
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.neo4j.driver.internal.util;
2+
/*
3+
* Copyright (c) 2002-2017 "Neo Technology,"
4+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
5+
*
6+
* This file is part of Neo4j.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
import org.junit.Test;
21+
22+
import static org.hamcrest.MatcherAssert.assertThat;
23+
import static org.hamcrest.Matchers.is;
24+
import static org.junit.Assert.fail;
25+
26+
public class ServerVersionTest
27+
{
28+
@Test
29+
public void version() throws Exception
30+
{
31+
String nullVersion = null;
32+
assertThat( ServerVersion.version( nullVersion ), is( ServerVersion.v3_0_0 ) );
33+
assertThat( ServerVersion.version( "Neo4j/dev" ), is( ServerVersion.vInDev ) );
34+
assertThat( ServerVersion.version( "Neo4j/3.2.0" ), is( ServerVersion.v3_2_0 ) );
35+
}
36+
37+
@Test(expected = IllegalArgumentException.class)
38+
public void versionShouldThrowExceptionIfServerVersionCantBeParsed() throws Exception
39+
{
40+
ServerVersion.version( "" );
41+
fail( "Should have failed to parse version" );
42+
}
43+
44+
}

0 commit comments

Comments
 (0)