You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ad...@apache.org on 2018/08/27 12:18:23 UTC
[6/8] james-project git commit: JAMES-2526 Bind health check routes
in Guice
JAMES-2526 Bind health check routes in Guice
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/07850163
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/07850163
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/07850163
Branch: refs/heads/master
Commit: 07850163215bb85983995dd481354d355f8510ad
Parents: c9cbe2c
Author: Antoine Duprat <ad...@linagora.com>
Authored: Wed Aug 22 16:07:12 2018 +0200
Committer: Antoine Duprat <ad...@linagora.com>
Committed: Mon Aug 27 14:18:06 2018 +0200
----------------------------------------------------------------------
.../modules/server/HealthCheckRoutesModule.java | 40 ++++++++++++++++++++
.../modules/server/WebAdminServerModule.java | 1 +
.../WebAdminServerIntegrationTest.java | 10 ++++-
3 files changed, 50 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/07850163/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/HealthCheckRoutesModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/HealthCheckRoutesModule.java b/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/HealthCheckRoutesModule.java
new file mode 100644
index 0000000..8ebd5b1
--- /dev/null
+++ b/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/HealthCheckRoutesModule.java
@@ -0,0 +1,40 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you 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. *
+ ****************************************************************/
+
+package org.apache.james.modules.server;
+
+import org.apache.james.core.healthcheck.HealthCheck;
+import org.apache.james.webadmin.Routes;
+import org.apache.james.webadmin.routes.HealthCheckRoutes;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Scopes;
+import com.google.inject.multibindings.Multibinder;
+
+public class HealthCheckRoutesModule extends AbstractModule {
+ @Override
+ protected void configure() {
+ bind(HealthCheckRoutes.class).in(Scopes.SINGLETON);
+
+ Multibinder<Routes> routesMultibinder = Multibinder.newSetBinder(binder(), Routes.class);
+ routesMultibinder.addBinding().to(HealthCheckRoutes.class);
+
+ Multibinder.newSetBinder(binder(), HealthCheck.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/07850163/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/WebAdminServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/WebAdminServerModule.java b/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/WebAdminServerModule.java
index d0bb7f6..ab0c93b 100644
--- a/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/WebAdminServerModule.java
+++ b/server/container/guice/protocols/webadmin/src/main/java/org/apache/james/modules/server/WebAdminServerModule.java
@@ -70,6 +70,7 @@ public class WebAdminServerModule extends AbstractModule {
@Override
protected void configure() {
install(new TaskRoutesModule());
+ install(new HealthCheckRoutesModule());
bind(JsonTransformer.class).in(Scopes.SINGLETON);
bind(WebAdminServer.class).in(Scopes.SINGLETON);
http://git-wip-us.apache.org/repos/asf/james-project/blob/07850163/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
index 07c63d0..6374bdf 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
@@ -41,6 +41,7 @@ import org.apache.james.utils.DataProbeImpl;
import org.apache.james.utils.WebAdminGuiceProbe;
import org.apache.james.webadmin.WebAdminUtils;
import org.apache.james.webadmin.routes.DomainsRoutes;
+import org.apache.james.webadmin.routes.HealthCheckRoutes;
import org.apache.james.webadmin.routes.MailQueueRoutes;
import org.apache.james.webadmin.routes.MailRepositoriesRoutes;
import org.apache.james.webadmin.routes.UserMailboxesRoutes;
@@ -328,4 +329,11 @@ public class WebAdminServerIntegrationTest {
.body(containsString("\"tags\":[\"Address Groups\"]"));
}
-}
+ @Test
+ public void validateHealthChecksShouldReturnOk() throws Exception {
+ when()
+ .get(HealthCheckRoutes.HEALTHCHECK)
+ .then()
+ .statusCode(HttpStatus.OK_200);
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org