Merge branch 'stable-2.15' into stable-2.16

* stable-2.15:
  Upgrade bazlets to latest stable-2.15 to build with 2.15.19 API
  Upgrade bazlets to latest stable-2.14 to build with 2.14.21 API

Change-Id: Id267beb6fa06da19e785942162fe64fe046f594f
diff --git a/.bazelversion b/.bazelversion
index 9084fa2..fd2a018 100644
--- a/.bazelversion
+++ b/.bazelversion
@@ -1 +1 @@
-1.1.0
+3.1.0
diff --git a/WORKSPACE b/WORKSPACE
index 275e4d3..908791b 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
 load("//:bazlets.bzl", "load_bazlets")
 
 load_bazlets(
-    commit = "9af263722b7eafe99af079d6ef7cf1de23e6f8d7",
+    commit = "fff6f20bb2eceaf872a8acf8ad51471c25a82d38",
     #local_path = "/home/<user>/projects/bazlets",
 )
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java b/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java
index f0ffbbd..30f8904 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java
@@ -71,7 +71,9 @@
         && request instanceof HttpServletRequest
         && response instanceof HttpServletResponse
         && shouldBlock((HttpServletRequest) request)) {
-      ((HttpServletResponse) response).sendError(SC_SERVICE_UNAVAILABLE, config.message());
+      HttpServletResponse httpResponse = (HttpServletResponse) response;
+      httpResponse.setStatus(SC_SERVICE_UNAVAILABLE);
+      httpResponse.getWriter().println(config.message());
       return;
     }
     chain.doFilter(request, response);
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index 213ebe6..ebf028a 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -35,6 +35,12 @@
   bazel-bin/lib@PLUGIN@__plugin-src.jar
 ```
 
+To execute the tests run:
+
+```
+  bazel test //...
+```
+
 This project can be imported into the Eclipse IDE:
 
 ```
@@ -50,21 +56,18 @@
   bazel build plugins/@PLUGIN@
 ```
 
-Note that due to a [known issue in Bazel][bazelissue], if the plugin
-has previously been built in standalone mode, it is necessary to clean
-the workspace before building in-tree:
-
-```
-  cd plugins/@PLUGIN@
-  bazel clean --expunge
-```
-
 The output is created in
 
 ```
   bazel-bin/plugins/@PLUGIN@/@PLUGIN@.jar
 ```
 
+To execute the tests run:
+
+```
+  bazel test plugins/@PLUGIN@:@PLUGIN@_tests
+```
+
 This project can be imported into the Eclipse IDE.
 Add the plugin name to the `CUSTOM_PLUGINS` set in
 Gerrit core in `tools/bzl/plugins.bzl`, and execute:
@@ -79,4 +82,3 @@
 [Back to @PLUGIN@ documentation index][index]
 
 [index]: index.html
-[bazelissue]: https://github.com/bazelbuild/bazel/issues/2797
diff --git a/src/test/java/com/googlesource/gerrit/plugins/readonly/AbstractReadOnlyTest.java b/src/test/java/com/googlesource/gerrit/plugins/readonly/AbstractReadOnlyTest.java
index f0bf1cf..d680abd 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/readonly/AbstractReadOnlyTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/readonly/AbstractReadOnlyTest.java
@@ -16,16 +16,15 @@
 
 import static com.google.common.truth.Truth.assertThat;
 import static org.apache.http.HttpStatus.SC_SERVICE_UNAVAILABLE;
-import static org.junit.Assert.fail;
 
 import com.google.gerrit.acceptance.GitUtil;
 import com.google.gerrit.acceptance.LightweightPluginDaemonTest;
 import com.google.gerrit.acceptance.TestPlugin;
 import com.google.gerrit.acceptance.UseLocalDisk;
 import com.google.gerrit.acceptance.UseSsh;
+import com.google.gerrit.extensions.api.changes.TopicInput;
 import com.google.gerrit.extensions.common.ChangeInfo;
 import com.google.gerrit.extensions.common.ChangeInput;
-import com.google.gerrit.server.change.PutTopic;
 import org.eclipse.jgit.api.errors.TransportException;
 import org.eclipse.jgit.transport.CredentialsProvider;
 import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
@@ -53,7 +52,7 @@
     adminRestSession.get(url).assertOK();
 
     // PUT should be allowed
-    PutTopic.Input topic = new PutTopic.Input();
+    TopicInput topic = new TopicInput();
     topic.topic = "topic";
     adminRestSession.put(url + "/topic", topic).assertOK();
 
@@ -123,16 +122,16 @@
   @UseLocalDisk
   @UseSsh
   public void pushBySshIsRejectedWhenReadOnly() throws Exception {
-    pushForReview(true);
+    pushForReview(true, "READ ONLY");
   }
 
   @Test
   @UseLocalDisk
   public void pushByHttpIsRejectedWhenReadOnly() throws Exception {
-    pushForReview(false);
+    pushForReview(false, "Service Unavailable");
   }
 
-  private void pushForReview(boolean ssh) throws Exception {
+  private void pushForReview(boolean ssh, String expectedMessage) throws Exception {
     String url = ssh ? adminSshSession.getUrl() : admin.getHttpUrl(server);
     if (!ssh) {
       CredentialsProvider.setDefault(
@@ -151,7 +150,7 @@
       pushTo("refs/for/master");
       fail("expected TransportException");
     } catch (TransportException e) {
-      assertThat(e).hasMessageThat().contains("READ ONLY");
+      assertThat(e).hasMessageThat().contains(expectedMessage);
     }
 
     // Disable read-only
diff --git a/src/test/java/com/googlesource/gerrit/plugins/readonly/ReadOnlyByHttpIT.java b/src/test/java/com/googlesource/gerrit/plugins/readonly/ReadOnlyByHttpIT.java
index b078dae..af41081 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/readonly/ReadOnlyByHttpIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/readonly/ReadOnlyByHttpIT.java
@@ -18,7 +18,7 @@
 
 import com.google.gerrit.acceptance.RestResponse;
 import com.google.gerrit.server.config.GerritServerConfig;
-import com.google.gerrit.testutil.ConfigSuite;
+import com.google.gerrit.testing.ConfigSuite;
 import com.google.inject.Inject;
 import org.eclipse.jgit.lib.Config;
 
diff --git a/tools/BUILD b/tools/BUILD
new file mode 100644
index 0000000..1fa2160
--- /dev/null
+++ b/tools/BUILD
@@ -0,0 +1 @@
+# Empty file - bazel treat directories with BUILD file as a package
\ No newline at end of file