Merge branch 'stable-2.13'

* stable-2.13:
  Make SearchingChangeCacheImpl nullable when replicating from slave

Change-Id: I0d23a61100350239432d8eeb701483afe0625fb6
diff --git a/.gitignore b/.gitignore
index 9c143f3..02bc5a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@
 /.buckd
 /buck-cache
 /buck-out
+*.iml
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 17904c0..1792fcc 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,9 +1,9 @@
 #Fri Jul 16 23:39:13 PDT 2010
 eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
diff --git a/BUCK b/BUCK
index d658b92..494d905 100644
--- a/BUCK
+++ b/BUCK
@@ -14,10 +14,6 @@
   deps = [
     ':commons-io',
   ],
-  provided_deps = [
-    '//lib:gson',
-    '//lib/log:log4j'
-  ],
 )
 
 maven_jar(
@@ -31,7 +27,6 @@
   name = 'replication_tests',
   srcs = glob(['src/test/java/**/*.java']),
   labels = ['replication'],
-  source_under_test = [':replication__plugin'],
   deps = [
     ':replication__plugin',
     '//gerrit-acceptance-framework:lib',
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..eeabb9d
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,42 @@
+load('//tools/bzl:junit.bzl', 'junit_tests')
+load('//tools/bzl:plugin.bzl', 'gerrit_plugin')
+
+gerrit_plugin(
+  name = 'replication',
+  srcs = glob(['src/main/java/**/*.java']),
+  resources = glob(['src/main/resources/**/*']),
+  manifest_entries = [
+    'Implementation-Title: Replication plugin',
+    'Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/replication',
+    'Gerrit-PluginName: replication',
+    'Gerrit-Module: com.googlesource.gerrit.plugins.replication.ReplicationModule',
+    'Gerrit-SshModule: com.googlesource.gerrit.plugins.replication.SshModule'
+  ],
+  deps = [
+    '//lib:commons-io',
+  ],
+)
+
+junit_tests(
+  name = 'replication_tests',
+  srcs = glob(['src/test/java/**/*Test.java']),
+  tags = ['replication'],
+  deps = [
+    ':replication_util',
+    ':replication__plugin',
+    '//gerrit-acceptance-framework:lib',
+    '//gerrit-plugin-api:lib',
+  ],
+  visibility = ['//visibility:public'],
+)
+
+java_library(
+  name = 'replication_util',
+  srcs = glob(['src/test/java/**/*.java'],
+              exclude = ['src/test/java/**/*Test.java']),
+  deps = [
+    ':replication__plugin',
+    '//gerrit-acceptance-framework:lib',
+    '//gerrit-plugin-api:lib',
+  ],
+)
diff --git a/src/main/resources/Documentation/cmd-list.md b/src/main/resources/Documentation/cmd-list.md
index 3c6b78f..b6688e0 100644
--- a/src/main/resources/Documentation/cmd-list.md
+++ b/src/main/resources/Documentation/cmd-list.md
@@ -70,5 +70,5 @@
 SEE ALSO
 --------
 
-* [Replication Configuration](config.html)
+* [Replication Configuration](config.md)
 * [Access Control](../../../Documentation/access-control.html)
diff --git a/src/main/resources/Documentation/cmd-start.md b/src/main/resources/Documentation/cmd-start.md
index 19b33ec..59c3d1d 100644
--- a/src/main/resources/Documentation/cmd-start.md
+++ b/src/main/resources/Documentation/cmd-start.md
@@ -134,5 +134,5 @@
 SEE ALSO
 --------
 
-* [Replication Configuration](config.html)
+* [Replication Configuration](config.md)
 * [Access Control](../../../Documentation/access-control.html)
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index 709d61f..cfdd91d 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -4,7 +4,7 @@
 Enabling Replication
 --------------------
 
-If replicating over SSH (recommended), ensure the host key of the
+If replicating over SSH, ensure the host key of the
 remote system(s) is already in the Gerrit user's `~/.ssh/known_hosts`
 file.  The easiest way to add the host key is to connect once by hand
 with the command line:
@@ -39,7 +39,7 @@
 ```
 
 To manually trigger replication at runtime, see
-SSH command [start](cmd-start.html).
+SSH command [start](cmd-start.md).
 
 File `replication.config`
 -------------------------
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/GitUpdateProcessingTest.java b/src/test/java/com/googlesource/gerrit/plugins/replication/GitUpdateProcessingTest.java
index 4cbac3a..21ee4b5 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/replication/GitUpdateProcessingTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/replication/GitUpdateProcessingTest.java
@@ -32,15 +32,15 @@
 import com.googlesource.gerrit.plugins.replication.PushResultProcessing.GitUpdateProcessing;
 import com.googlesource.gerrit.plugins.replication.ReplicationState.RefPushResult;
 
-import junit.framework.TestCase;
-
 import org.eclipse.jgit.transport.RemoteRefUpdate;
 import org.eclipse.jgit.transport.URIish;
+import org.junit.Before;
+import org.junit.Test;
 
 import java.net.URISyntaxException;
 
 @SuppressWarnings("unchecked")
-public class GitUpdateProcessingTest extends TestCase {
+public class GitUpdateProcessingTest {
   static {
     KeyUtil.setEncoderImpl(new StandardKeyEncoder());
   }
@@ -48,9 +48,8 @@
   private EventDispatcher dispatcherMock;
   private GitUpdateProcessing gitUpdateProcessing;
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUp() throws Exception {
     dispatcherMock = createMock(EventDispatcher.class);
     replay(dispatcherMock);
     ReviewDb reviewDbMock = createNiceMock(ReviewDb.class);
@@ -61,6 +60,7 @@
     gitUpdateProcessing = new GitUpdateProcessing(dispatcherMock);
   }
 
+  @Test
   public void testHeadRefReplicated() throws URISyntaxException, OrmException {
     reset(dispatcherMock);
     RefReplicatedEvent expectedEvent =
@@ -76,6 +76,7 @@
     verify(dispatcherMock);
   }
 
+  @Test
   public void testChangeRefReplicated() throws URISyntaxException, OrmException {
     reset(dispatcherMock);
     RefReplicatedEvent expectedEvent =
@@ -91,6 +92,7 @@
     verify(dispatcherMock);
   }
 
+  @Test
   public void testOnAllNodesReplicated() throws OrmException {
     reset(dispatcherMock);
     RefReplicationDoneEvent expectedDoneEvent =