GitProtocolV2IT: Split git client version check to a separate method

Split the version check to a separate method annotated @BeforeClass so
that the entire test is failed if the client version is not suitable.

Currently there is only one test method, but creating a separate method
means that we don't need to copy and paste the same check into each new
test method that gets added later.

Change-Id: I09ab265f95f56d1ead3128c87edfa17c2e0fa02b
diff --git a/javatests/com/google/gerrit/integration/git/GitProtocolV2IT.java b/javatests/com/google/gerrit/integration/git/GitProtocolV2IT.java
index 162f73a..4acd8b8 100644
--- a/javatests/com/google/gerrit/integration/git/GitProtocolV2IT.java
+++ b/javatests/com/google/gerrit/integration/git/GitProtocolV2IT.java
@@ -39,6 +39,7 @@
 import java.net.InetSocketAddress;
 import org.eclipse.jgit.lib.Config;
 import org.eclipse.jgit.lib.Constants;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 @UseSsh
@@ -56,16 +57,19 @@
   @Inject private @TestSshServerAddress InetSocketAddress sshAddress;
   @Inject private @GerritServerConfig Config config;
 
-  @Test
-  public void testGitWireProtocolV2WithSsh() throws Exception {
+  @BeforeClass
+  public static void assertGitClientVersion() throws Exception {
     // Minimum required git-core version that supports wire protocol v2 is 2.18.0
     GitClientVersion requiredGitVersion = new GitClientVersion(2, 18, 0);
     GitClientVersion actualGitVersion =
-        new GitClientVersion(execute(ImmutableList.of("git", "version")));
+        new GitClientVersion(execute(ImmutableList.of("git", "version"), new File("/")));
     // If git client version cannot be updated, consider to skip this tests. Due to
     // an existing issue in bazel, JUnit assumption violation feature cannot be used.
     assertThat(actualGitVersion).isAtLeast(requiredGitVersion);
+  }
 
+  @Test
+  public void testGitWireProtocolV2WithSsh() throws Exception {
     try (ServerContext ctx = startServer()) {
       ctx.getInjector().injectMembers(this);