You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ap...@apache.org on 2022/11/23 08:49:46 UTC
[sling-org-apache-sling-hc-api] branch SLING-11699 updated: SLING-11699: deprecate the module
This is an automated email from the ASF dual-hosted git repository.
apelluru pushed a commit to branch SLING-11699
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hc-api.git
The following commit(s) were added to refs/heads/SLING-11699 by this push:
new 1a770fb SLING-11699: deprecate the module
1a770fb is described below
commit 1a770fb7b50a4a6f90acbc71e4cf725e3ef96365
Author: Ashok Pelluru <ap...@apache.org>
AuthorDate: Wed Nov 23 09:49:41 2022 +0100
SLING-11699: deprecate the module
---
.asf.yaml | 7 +
CODE_OF_CONDUCT.md | 22 --
CONTRIBUTING.md | 24 ---
Jenkinsfile | 20 --
README.md | 4 +-
pom.xml | 85 --------
.../java/org/apache/sling/hc/api/HealthCheck.java | 92 ---------
src/main/java/org/apache/sling/hc/api/Result.java | 82 --------
.../java/org/apache/sling/hc/api/ResultLog.java | 125 ------------
.../api/execution/HealthCheckExecutionOptions.java | 111 -----------
.../api/execution/HealthCheckExecutionResult.java | 66 ------
.../hc/api/execution/HealthCheckExecutor.java | 78 --------
.../hc/api/execution/HealthCheckSelector.java | 104 ----------
.../sling/hc/api/execution/package-info.java | 23 ---
.../java/org/apache/sling/hc/api/package-info.java | 23 ---
.../apache/sling/hc/util/FormattingResultLog.java | 83 --------
.../apache/sling/hc/util/HealthCheckFilter.java | 222 ---------------------
.../apache/sling/hc/util/HealthCheckMetadata.java | 209 -------------------
.../sling/hc/util/SimpleConstraintChecker.java | 81 --------
.../org/apache/sling/hc/util/package-info.java | 23 ---
.../org/apache/sling/hc/api/ResultLogTest.java | 107 ----------
.../java/org/apache/sling/hc/api/ResultTest.java | 65 ------
.../sling/hc/util/HealthCheckFilterTest.java | 97 ---------
.../sling/hc/util/SimpleConstraintCheckerTest.java | 167 ----------------
24 files changed, 10 insertions(+), 1910 deletions(-)
diff --git a/.asf.yaml b/.asf.yaml
new file mode 100644
index 0000000..ae01a0f
--- /dev/null
+++ b/.asf.yaml
@@ -0,0 +1,7 @@
+github:
+ description: "Apache Sling Health Check API (deprecated)"
+ homepage: "https://sling.apache.org/"
+ labels:
+ - sling
+ - java
+ - deprecated
\ No newline at end of file
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
deleted file mode 100644
index 0fa18e5..0000000
--- a/CODE_OF_CONDUCT.md
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
-Apache Software Foundation Code of Conduct
-====
-
-Being an Apache project, Apache Sling adheres to the Apache Software Foundation's [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index ac82a1a..0000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
-Contributing
-====
-
-Thanks for choosing to contribute!
-
-You will find all the necessary details about how you can do this at https://sling.apache.org/contributing.html.
diff --git a/Jenkinsfile b/Jenkinsfile
deleted file mode 100644
index f582519..0000000
--- a/Jenkinsfile
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * 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.
- */
-
-slingOsgiBundleBuild()
diff --git a/README.md b/README.md
index b393a04..479a0d7 100644
--- a/README.md
+++ b/README.md
@@ -2,4 +2,6 @@
 [![Build Status](https://ci-builds.apache.org/job/Sling/job/modules/job/sling-org-apache-sling-hc-api/job/master/badge/icon)](https://ci-builds.apache.org/job/Sling/job/modules/job/sling-org-apache-sling-hc-api/job/master/) [![Test Status](https://img.shields.io/jenkins/tests.svg?jobUrl=https://ci-builds.apache.org/job/Sling/job/modules/job/sling-org-apache-sling-hc-api/job/master/)](https://ci-builds.apache.org/job/Sling/job/modules/job/sling-org-apache-sling-hc-api/job/master/ [...]
-This API **should not be used** now that the migration of Sling Health Checks to Apache Felix is completed - see [migration guide](https://sling.apache.org/documentation/bundles/sling-health-check-tool.html) on how to use [Apache Felix Health Checks](https://felix.apache.org/documentation/subprojects/apache-felix-healthchecks.html)
+It is now deprecated, and this API **should not be used** now that the migration of Sling Health Checks to Apache Felix is completed - see [migration guide](https://sling.apache.org/documentation/bundles/sling-health-check-tool.html) on how to use [Apache Felix Health Checks](https://felix.apache.org/documentation/subprojects/apache-felix-healthchecks.html)
+
+This modules's code has been saved to the `maintenance` branch before deprecation.
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 0f1c30c..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <groupId>org.apache.sling</groupId>
- <artifactId>sling</artifactId>
- <version>30</version>
- <relativePath />
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.hc.api</artifactId>
- <packaging>bundle</packaging>
- <version>1.0.5-SNAPSHOT</version>
-
- <name>Apache Sling Health Check API</name>
- <inceptionYear>2013</inceptionYear>
-
- <description>
- The Sling Health Check API
- </description>
-
- <scm>
- <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hc-api.git</connection>
- <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hc-api.git</developerConnection>
- <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-hc-api.git</url>
- <tag>HEAD</tag>
- </scm>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>3.1.0</version>
- <configuration>
- <doclint>none</doclint>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/hc/api/HealthCheck.java b/src/main/java/org/apache/sling/hc/api/HealthCheck.java
deleted file mode 100644
index 6044c52..0000000
--- a/src/main/java/org/apache/sling/hc/api/HealthCheck.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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 SF 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.sling.hc.api;
-
-import org.osgi.annotation.versioning.ConsumerType;
-
-/** Health Check services can be executed and return an execution {@link Result}.
- *
- * Clients should not look up health checks directly but rather use the {@link org.apache.sling.hc.api.execution.HealthCheckExecutor}
- * service and executed checks based on tags.
- *
- * If the {@link #MBEAN_NAME} service registration property is set, the health check is registered as an mbean and can be invoked by getting
- * the MBean from the JMX registry.
- *
- * @deprecated Use Apache Felix Health Checks now, see {@link https://sling.apache.org/documentation/bundles/sling-health-check-tool.html}
- * for migration guide. */
-@Deprecated
-@ConsumerType
-public interface HealthCheck {
-
- /**
- * Optional service property: the name of a health check.
- * This name should be unique, however there might be more than one
- * health check service with the same value for this property.
- * The value of this property must be of type String.
- */
- String NAME = "hc.name";
-
- /**
- * Optional service property: the name of the MBean for registering
- * the health check as an MBean. If this property is missing the
- * health check is not registered as a JMX MBean.
- * If there is more than one service with the same value for this
- * property, the one with the highest service ranking is registered
- * only.
- * The value of this property must be of type String.
- */
- String MBEAN_NAME = "hc.mbean.name";
-
- /**
- * Optional service property: tags for categorizing the health check
- * services.
- * The value of this property must be of type String or String array.
- */
- String TAGS = "hc.tags";
-
- /**
- * Optional service property: If this property is set the health check
- * will be executed asynchronously using the cron expression provided.
- */
- String ASYNC_CRON_EXPRESSION = "hc.async.cronExpression";
-
- /**
- * Optional service property: TTL for health check {@link Result}.
- * The value of this property must be of type {@link Long} and is
- * specified in ms.
- */
- String RESULT_CACHE_TTL_IN_MS = "hc.resultCacheTtlInMs";
-
- /**
- * Optional service property: If given, warning results (that is WARN,
- * CRITICAL or HEALTH_CHECK_ERROR) from the past executions will be
- * taken into account as well for the given minutes (use
- * Integer.MAX_VALUE for indefinitely). Useful for unhealthy system
- * states that disappear but might leave the system at an inconsistent
- * state (e.g. an event queue overflow).
- *
- */
- String WARNINGS_STICK_FOR_MINUTES = "hc.warningsStickForMinutes";
-
- /**
- * Execute this health check and return a {@link Result}
- * This is meant to execute quickly, access to external
- * systems, for example, should be managed asynchronously.
- */
- Result execute();
-}
diff --git a/src/main/java/org/apache/sling/hc/api/Result.java b/src/main/java/org/apache/sling/hc/api/Result.java
deleted file mode 100644
index a03c039..0000000
--- a/src/main/java/org/apache/sling/hc/api/Result.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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 SF 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.sling.hc.api;
-
-import java.util.Iterator;
-
-/** The result of executing a {@link HealthCheck} */
-@Deprecated
-public class Result implements Iterable <ResultLog.Entry> {
-
- protected final ResultLog resultLog;
-
- public enum Status {
- DEBUG, // used by ResultLog for debug messages, not an actual output status
- INFO, // used by ResultLog for info messages, not an actual output status
- OK, // no problem
- WARN, // health check detected something wrong but not critical
- CRITICAL, // health check detected a critical problem
- HEALTH_CHECK_ERROR // health check did not execute properly
- }
-
- /** Build a single-value Result
- * @param s if lower than OK, our status is set to OK */
- public Result(final Status s, final String explanation) {
- resultLog = new ResultLog().add(new ResultLog.Entry(s, explanation));
- }
-
- /**
- * Build a single-value Result with exception
- *
- * @param s if lower than OK, our status is set to OK
- */
- public Result(final Status s, final String explanation, final Exception e) {
- resultLog = new ResultLog().add(new ResultLog.Entry(s, explanation, e));
- }
-
- /** Build a a Result based on a ResultLog, which can provide
- * more details than a single-value Result.
- */
- public Result(final ResultLog log) {
- resultLog = new ResultLog(log);
- }
-
- /** True if our status is OK - provides a convenient way of
- * checking that.
- */
- public boolean isOk() {
- return getStatus().equals(Status.OK);
- }
-
- /** Return our Status */
- public Status getStatus() {
- return resultLog.getAggregateStatus();
- }
-
- /** Return an Iterator on the entries of our ResultLog */
- @Override
- public Iterator<ResultLog.Entry> iterator() {
- return resultLog.iterator();
- }
-
- @Override
- public String toString() {
- return "Result [status=" + getStatus() + ", resultLog=" + resultLog + "]";
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/hc/api/ResultLog.java b/src/main/java/org/apache/sling/hc/api/ResultLog.java
deleted file mode 100644
index 1844be3..0000000
--- a/src/main/java/org/apache/sling/hc/api/ResultLog.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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 SF 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.sling.hc.api;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.sling.hc.api.Result.Status;
-
-/** The log of a Result, allows for providing multiple lines
- * of information which are aggregated as a single Result. */
-@Deprecated
-public class ResultLog implements Iterable<ResultLog.Entry> {
-
- private List<Entry> entries = new LinkedList<Entry>();
- private Status aggregateStatus;
-
- /** An entry in this log */
- public static class Entry {
- private final Status status;
- private final String message;
- private final Exception exception;
-
- public Entry(Status s, String message) {
- this(s, message, null);
- }
-
- public Entry(Status s, String message, Exception exception) {
- this.status = s;
- this.message = message;
- this.exception = exception;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder(status.toString()).append(" ").append(message);
- if (exception != null) {
- builder.append(" Exception: " + exception.getMessage());
- }
- return builder.toString();
- }
-
- public Status getStatus() {
- return status;
- }
-
- public String getMessage() {
- return message;
- }
-
- public Exception getException() {
- return exception;
- }
-
- }
-
- /** Build a log. Initial aggregate status is
- * set to WARN, as an empty log is not considered ok.
- * That's reset to OK before adding the first log entry,
- * and then the status aggregation rules take over.
- */
- public ResultLog() {
- aggregateStatus = Result.Status.WARN;
- }
-
- /**
- * Create a copy of the result log
- */
- public ResultLog(final ResultLog log) {
- this.aggregateStatus = log.aggregateStatus;
- this.entries = new ArrayList<ResultLog.Entry>(log.entries);
- }
-
- /** Add an entry to this log. The aggregate status of
- * this is set to the highest of the current aggregate status
- * and the new Entry's status */
- public ResultLog add(Entry e) {
- if(entries.isEmpty()) {
- aggregateStatus = Result.Status.OK;
- }
- entries.add(e);
- if(e.getStatus().ordinal() > aggregateStatus.ordinal()) {
- aggregateStatus = e.getStatus();
- }
- return this;
- }
-
- /** Return an Iterator on our entries */
- @Override
- public Iterator<ResultLog.Entry> iterator() {
- return entries.iterator();
- }
-
- /** Return our aggregate status, i.e. the highest status
- * of the entries added to this log. Starts at OK for an
- * empty ResultLog, so cannot be lower than that.
- */
- public Status getAggregateStatus() {
- return aggregateStatus;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder("ResultLog: ");
- sb.append(this.entries.toString());
- return sb.toString();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutionOptions.java b/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutionOptions.java
deleted file mode 100644
index 79d1fcb..0000000
--- a/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutionOptions.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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 SF 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.sling.hc.api.execution;
-
-
-/** Options for behavior of health check execution. */
-@Deprecated
-public class HealthCheckExecutionOptions {
-
- private boolean forceInstantExecution = false;
- private boolean combineTagsWithOr = false;
- private int overrideGlobalTimeout = 0;
-
- @Override
- public String toString() {
- return "[HealthCheckExecutionOptions forceInstantExecution=" + forceInstantExecution + ", combineTagsWithOr=" + combineTagsWithOr
- + ", overrideGlobalTimeout=" + overrideGlobalTimeout + "]";
- }
-
- /**
- * If activated, this will ensure that asynchronous checks will be executed immediately.
- *
- * @param forceInstantExecution boolean flag
- */
- public void setForceInstantExecution(boolean forceInstantExecution) {
- this.forceInstantExecution = forceInstantExecution;
- }
-
- /**
- * If activated, the given tags will be combined with a logical "or" instead of "and".
- *
- * @param combineTagsWithOr boolean flag
- */
- public void setCombineTagsWithOr(boolean combineTagsWithOr) {
- this.combineTagsWithOr = combineTagsWithOr;
- }
-
- /**
- * Allows to override the global timeout for this particular execution of the health check.
- *
- * @param overrideGlobalTimeout timeout in ms to be used for this execution of the execution
- */
- public void setOverrideGlobalTimeout(int overrideGlobalTimeout) {
- this.overrideGlobalTimeout = overrideGlobalTimeout;
- }
-
- /**
- * @return true if instant execution is turned on
- */
- public boolean isForceInstantExecution() {
- return forceInstantExecution;
- }
-
- /**
- * @return true if combining tags with or is turned on
- */
- public boolean isCombineTagsWithOr() {
- return combineTagsWithOr;
- }
-
- /**
- * @return the timeout to be used for this execution (overriding the global timeout)
- */
- public int getOverrideGlobalTimeout() {
- return overrideGlobalTimeout;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (combineTagsWithOr ? 1231 : 1237);
- result = prime * result + (forceInstantExecution ? 1231 : 1237);
- result = prime * result + overrideGlobalTimeout;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- HealthCheckExecutionOptions other = (HealthCheckExecutionOptions) obj;
- if (combineTagsWithOr != other.combineTagsWithOr)
- return false;
- if (forceInstantExecution != other.forceInstantExecution)
- return false;
- if (overrideGlobalTimeout != other.overrideGlobalTimeout)
- return false;
- return true;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutionResult.java b/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutionResult.java
deleted file mode 100644
index e8b28b8..0000000
--- a/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutionResult.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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 SF 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.sling.hc.api.execution;
-
-import java.util.Date;
-
-import org.apache.sling.hc.api.Result;
-import org.apache.sling.hc.util.HealthCheckMetadata;
-import org.osgi.annotation.versioning.ProviderType;
-
-
-/**
- * Interface for health check executions via the {@link HealthCheckExecutor}.
- *
- * If the execution of the health check timed out, the method
- *
- */
-@Deprecated
-@ProviderType
-public interface HealthCheckExecutionResult {
-
- /**
- * Get the result of the health check run.
- */
- Result getHealthCheckResult();
-
- /**
- * Get the elapsed time in ms
- */
- long getElapsedTimeInMs();
-
- /**
- * Get the date, the health check finished or if the
- * execution timed out, the execution was aborted.
- * @return The finished date of the execution.
- */
- Date getFinishedAt();
-
- /**
- * Returns true if the execution has timed out. In this
- * case the result does not reflect the real result of the
- * underlying check, but a result indicating the timeout.
- * @return <code>true</code> if execution timed out.
- */
- boolean hasTimedOut();
-
- /**
- * Get the meta data about the health check service
- */
- HealthCheckMetadata getHealthCheckMetadata();
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutor.java b/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutor.java
deleted file mode 100644
index 2083f8e..0000000
--- a/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutor.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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 SF 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.sling.hc.api.execution;
-
-import java.util.List;
-
-import org.apache.sling.hc.api.HealthCheck;
-import org.osgi.annotation.versioning.ProviderType;
-
-
-/**
- * Executes health checks registered as OSGi services and
- * implementing the interface {@link HealthCheck}.
- *
- */
-@Deprecated
-@ProviderType
-public interface HealthCheckExecutor {
-
- /**
- * Executes all health checks matching the supplied filter options.
- * If no options are supplied, all health checks are executed.
- *
- * @param selector filter selector
- * @return List of results. The list might be empty.
- */
- List<HealthCheckExecutionResult> execute(HealthCheckSelector selector);
-
- /**
- * Executes all health checks with the supplied filter options.
- * If no options are supplied, all health checks are executed.
- *
- * @param selector filter selector
- * @param options options for controlling execution behavior
- *
- * @return List of results. The list might be empty.
- */
- List<HealthCheckExecutionResult> execute(HealthCheckSelector selector, HealthCheckExecutionOptions options);
-
- /**
- * Executes all health checks with the supplied list of tags.
- * If no tags are supplied, all health checks are executed.
- *
- * @return List of results. The list might be empty.
- * @deprecated use execute(HealthCheckFilter.Options)
- */
- @Deprecated
- List<HealthCheckExecutionResult> execute(String... tags);
-
- /**
- * Executes all health checks with the supplied list of tags.
- * If no tags are supplied, all health checks are executed.
- *
- * @param options options for controlling execution behavior
- * @param tags tags to be executed
- *
- * @return List of results. The list might be empty.
- * @deprecated use execute(HealthCheckFilter.Options, HealthCheckExecutionOptions)
- */
- @Deprecated
- List<HealthCheckExecutionResult> execute(HealthCheckExecutionOptions options, String... tags);
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/hc/api/execution/HealthCheckSelector.java b/src/main/java/org/apache/sling/hc/api/execution/HealthCheckSelector.java
deleted file mode 100644
index 5bd59b3..0000000
--- a/src/main/java/org/apache/sling/hc/api/execution/HealthCheckSelector.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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.sling.hc.api.execution;
-
-import java.util.Arrays;
-
-import org.osgi.annotation.versioning.ProviderType;
-
-/**
- * Parameter class to pass a set of tags and names to the filter.
- */
-@Deprecated
-@ProviderType
-public final class HealthCheckSelector {
-
- private String[] tags;
- private String[] names;
-
- public String[] tags() {
- return tags;
- }
-
- public String[] names() {
- return names;
- }
-
- private HealthCheckSelector() {}
-
- /**
- * Copy the specified names into the current tags array.
- * @param tags the new tags. Specify null to clear the current tag array
- * @return this
- */
- public HealthCheckSelector withTags(String... tags) {
- if (this.tags == null) {
- this.tags = tags;
- } else if (tags != null) {
- String[] copy = Arrays.copyOf(this.tags, this.tags.length + tags.length);
- System.arraycopy(tags, 0, copy, this.tags.length, tags.length);
- this.tags = copy;
- } else {
- this.tags = null;
- }
- return this;
- }
-
-
- /**
- * Copy the specified names into the current names array.
- * @param names the new names. Specify null to clear the current name array
- * @return this
- */
- public HealthCheckSelector withNames(String... names) {
- if (this.names == null) {
- this.names = names;
- } else if (names != null) {
- String[] copy = Arrays.copyOf(this.names, this.names.length + names.length);
- System.arraycopy(names, 0, copy, this.names.length, names.length);
- this.names = copy;
- } else {
- this.names = null;
- }
- return this;
- }
-
-
- public static HealthCheckSelector empty() {
- return new HealthCheckSelector();
- }
-
- public static HealthCheckSelector tags(String... tags) {
- HealthCheckSelector selector = new HealthCheckSelector();
- selector.tags = tags;
- return selector;
- }
-
- public static HealthCheckSelector names(String... names) {
- HealthCheckSelector selector = new HealthCheckSelector();
- selector.names = names;
- return selector;
- }
-
- @Override
- public String toString() {
- return "HealthCheckSelector{" +
- "tags=" + tags == null ? "*" : Arrays.toString(tags) +
- ", names=" + names == null ? "*" : Arrays.toString(names) +
- '}';
- }
-}
diff --git a/src/main/java/org/apache/sling/hc/api/execution/package-info.java b/src/main/java/org/apache/sling/hc/api/execution/package-info.java
deleted file mode 100644
index d34f80e..0000000
--- a/src/main/java/org/apache/sling/hc/api/execution/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-
-@Version("1.2.0")
-package org.apache.sling.hc.api.execution;
-
-import org.osgi.annotation.versioning.Version;
diff --git a/src/main/java/org/apache/sling/hc/api/package-info.java b/src/main/java/org/apache/sling/hc/api/package-info.java
deleted file mode 100644
index c2b2dc6..0000000
--- a/src/main/java/org/apache/sling/hc/api/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-
-@Version("1.2.0")
-package org.apache.sling.hc.api;
-
-import org.osgi.annotation.versioning.Version;
diff --git a/src/main/java/org/apache/sling/hc/util/FormattingResultLog.java b/src/main/java/org/apache/sling/hc/util/FormattingResultLog.java
deleted file mode 100644
index 852b163..0000000
--- a/src/main/java/org/apache/sling/hc/util/FormattingResultLog.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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 SF 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.sling.hc.util;
-
-import java.text.NumberFormat;
-import java.util.Locale;
-
-import org.apache.sling.hc.api.Result;
-import org.apache.sling.hc.api.ResultLog;
-import org.osgi.annotation.versioning.ProviderType;
-import org.slf4j.helpers.MessageFormatter;
-
-/** Utility that provides a logging-like facade on a ResultLog */
-@Deprecated
-@ProviderType
-public class FormattingResultLog extends ResultLog {
-
- private ResultLog.Entry createEntry(Result.Status status, String format, Object ... args) {
- return new ResultLog.Entry(status, MessageFormatter.arrayFormat(format, args).getMessage());
- }
-
- public void debug(String format, Object ... args) {
- add(createEntry(Result.Status.DEBUG, format, args));
- }
-
- public void info(String format, Object ... args) {
- add(createEntry(Result.Status.INFO, format, args));
- }
-
- public void warn(String format, Object ... args) {
- add(createEntry(Result.Status.WARN, format, args));
- }
-
- public void critical(String format, Object ... args) {
- add(createEntry(Result.Status.CRITICAL, format, args));
- }
-
- public void healthCheckError(String format, Object ... args) {
- add(createEntry(Result.Status.HEALTH_CHECK_ERROR, format, args));
- }
-
- /** Utility method to return any magnitude of milliseconds in a human readable format using the appropriate time unit (ms, sec, min) depending on the
- * magnitude of the input.
- *
- * @param millis milliseconds
- * @return a string with a number and a unit */
- public static String msHumanReadable(final long millis) {
-
- double number = millis;
- final String[] units = new String[] { "ms", "sec", "min", "h", "days" };
- final double[] divisors = new double[] { 1000, 60, 60, 24 };
-
- int magnitude = 0;
- do {
- double currentDivisor = divisors[Math.min(magnitude, divisors.length - 1)];
- if (number < currentDivisor) {
- break;
- }
- number /= currentDivisor;
- magnitude++;
- } while (magnitude < units.length - 1);
- NumberFormat format = NumberFormat.getNumberInstance(Locale.UK);
- format.setMinimumFractionDigits(0);
- format.setMaximumFractionDigits(1);
- String result = format.format(number) + units[magnitude];
- return result;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/hc/util/HealthCheckFilter.java b/src/main/java/org/apache/sling/hc/util/HealthCheckFilter.java
deleted file mode 100644
index c54846a..0000000
--- a/src/main/java/org/apache/sling/hc/util/HealthCheckFilter.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * 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 SF 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.sling.hc.util;
-
-import static org.apache.sling.hc.api.execution.HealthCheckSelector.empty;
-import static org.apache.sling.hc.api.execution.HealthCheckSelector.tags;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.sling.hc.api.HealthCheck;
-import org.apache.sling.hc.api.execution.HealthCheckSelector;
-import org.osgi.annotation.versioning.ProviderType;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Select from available {@link HealthCheck} services.
- * Once this filter object and the returned health check services are no longer
- * be used {@link #dispose()} should be called, to free the service
- * references.
- *
- * This class is not thread safe and instances shouldn't be used concurrently
- * from different threads.
- */
-@Deprecated
-@ProviderType
-public class HealthCheckFilter {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
- private final BundleContext bundleContext;
-
-
- public static final String OMIT_PREFIX = "-";
-
- private final Set<ServiceReference> usedReferences = new HashSet<ServiceReference>();
-
- /**
- * Create a new filter object
- */
- public HealthCheckFilter(final BundleContext bc) {
- bundleContext = bc;
- }
-
- public List<HealthCheck> getHealthChecks(final HealthCheckSelector selector) {
- final ServiceReference [] refs = this.getHealthCheckServiceReferences(selector);
- final List<HealthCheck> result = new ArrayList<HealthCheck>();
-
- if ( refs != null ) {
- final List<ServiceReference> sortedRefs = Arrays.asList(refs);
- Collections.sort(sortedRefs);
-
- for(final ServiceReference ref : sortedRefs) {
- final HealthCheck hc = (HealthCheck)bundleContext.getService(ref);
- log.debug("Selected HealthCheck service {}", hc);
- if ( hc != null ) {
- this.usedReferences.add(ref);
- result.add(hc);
- }
- }
- }
-
- return result;
- }
-
- public ServiceReference[] getHealthCheckServiceReferences(final HealthCheckSelector selector) {
- return getHealthCheckServiceReferences(selector, false);
- }
-
- public ServiceReference[] getHealthCheckServiceReferences(final HealthCheckSelector selector, boolean combineTagsWithOr) {
- final CharSequence filterBuilder = selector != null ? getServiceFilter(selector, combineTagsWithOr) : getServiceFilter(empty(), combineTagsWithOr);
-
- log.debug("OSGi service filter in getHealthCheckServiceReferences(): {}", filterBuilder);
-
- try {
- final String filterString = filterBuilder.length() == 0 ? null : filterBuilder.toString();
- bundleContext.createFilter(filterString); // check syntax early
- final ServiceReference[] refs = bundleContext.getServiceReferences(HealthCheck.class.getName(), filterString);
- if (refs == null) {
- log.debug("Found no HealthCheck services with filter [{}]", filterString);
- return new ServiceReference[0];
- } else {
- log.debug("Found {} HealthCheck services with filter [{}]", refs.length, filterString);
- }
- return refs;
- } catch (final InvalidSyntaxException ise) {
- // this should not happen, but we fail gracefully
- log.error("Invalid OSGi filter syntax in '" + filterBuilder + "'", ise);
- return new ServiceReference[0];
- }
- }
-
- /**
- * Get all health check services with one of the supplied tags.
- * @return A list of services - might be the empty list if none matches
- * @deprecated use getHealthChecks() instead
- */
- @Deprecated
- public List<HealthCheck> getTaggedHealthChecks(final String... tags) {
- final HealthCheckSelector selector = tags(tags);
- return getHealthChecks(selector);
- }
-
- /**
- * Get all service references for health check services with one of the supplied tags. Uses logical "and" to combine tags.
- * @return An array of service references - might be an empty error if none matches
- * @deprecated use getHealthCheckServiceReferences() instead
- */
- @Deprecated
- public ServiceReference[] getTaggedHealthCheckServiceReferences(final String... tags) {
- return getHealthCheckServiceReferences(tags(tags), false);
- }
-
- /**
- * Get all service references for health check services with one of the supplied tags.
- *
- * @param combineWithOr If true will return all health checks that have at least one of the tags set.
- * If false will return only health checks that have all given tags assigned.
- * @param tags the tags to look for
- * @return An array of service references - might be an empty error if none matches
- * @deprecated use getHealthCheckServiceReferences() instead
- */
- @Deprecated
- public ServiceReference[] getTaggedHealthCheckServiceReferences(boolean combineWithOr, final String... tags) {
- final HealthCheckSelector selector = tags(tags);
- return getHealthCheckServiceReferences(selector, combineWithOr);
- }
-
- /**
- * Dispose all used service references
- */
- public void dispose() {
- for(final ServiceReference ref : this.usedReferences) {
- this.bundleContext.ungetService(ref);
- }
- this.usedReferences.clear();
- }
-
- CharSequence getServiceFilter(HealthCheckSelector selector, boolean combineTagsWithOr) {
- // Build service filter
- final StringBuilder filterBuilder = new StringBuilder();
- filterBuilder.append("(&(objectClass=").append(HealthCheck.class.getName()).append(")");
- final int prefixLen = HealthCheckFilter.OMIT_PREFIX.length();
- final StringBuilder filterBuilderForOrOperator = new StringBuilder(); // or filters
- final StringBuilder tagsBuilder = new StringBuilder();
- int tagsAndClauses = 0;
- if (selector.tags() != null) {
- for (String tag : selector.tags()) {
- tag = tag.trim();
- if (tag.length() == 0) {
- continue;
- }
- if (tag.startsWith(HealthCheckFilter.OMIT_PREFIX)) {
- // ommit tags always have to be added as and-clause
- filterBuilder.append("(!(").append(HealthCheck.TAGS).append("=").append(tag.substring(prefixLen)).append("))");
- } else {
- // add regular tags in the list either to outer and-clause or inner or-clause
- if (combineTagsWithOr) {
- filterBuilderForOrOperator.append("(").append(HealthCheck.TAGS).append("=").append(tag).append(")");
- } else {
- tagsBuilder.append("(").append(HealthCheck.TAGS).append("=").append(tag).append(")");
- tagsAndClauses++;
- }
- }
- }
- }
- boolean addedNameToOrBuilder = false;
- if (selector.names() != null) {
- for (String name : selector.names()) {
- name = name.trim();
- if (name.length() == 0) {
- continue;
- }
- if (name.startsWith(HealthCheckFilter.OMIT_PREFIX)) {
- // ommit tags always have to be added as and-clause
- filterBuilder.append("(!(").append(HealthCheck.NAME).append("=").append(name.substring(prefixLen)).append("))");
- } else {
- // names are always ORd
- filterBuilderForOrOperator.append("(").append(HealthCheck.NAME).append("=").append(name).append(")");
- addedNameToOrBuilder = true;
- }
- }
- }
- if (addedNameToOrBuilder) {
- if (tagsAndClauses > 1) {
- filterBuilderForOrOperator.append("(&").append(tagsBuilder).append(")");
- } else {
- filterBuilderForOrOperator.append(tagsBuilder);
- }
- } else {
- filterBuilder.append(tagsBuilder);
- }
- // add "or" clause if we have accumulated any
- if (filterBuilderForOrOperator.length() > 0) {
- filterBuilder.append("(|").append(filterBuilderForOrOperator).append(")");
- }
- filterBuilder.append(")");
- return filterBuilder;
- }
-}
diff --git a/src/main/java/org/apache/sling/hc/util/HealthCheckMetadata.java b/src/main/java/org/apache/sling/hc/util/HealthCheckMetadata.java
deleted file mode 100644
index 7d582e9..0000000
--- a/src/main/java/org/apache/sling/hc/util/HealthCheckMetadata.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * 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 SF 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.sling.hc.util;
-
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.sling.hc.api.HealthCheck;
-import org.osgi.annotation.versioning.ProviderType;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-
-/**
- * This class helps retrieving meta data information about a health check service.
- * @since 1.1
- */
-@Deprecated
-@ProviderType
-public class HealthCheckMetadata {
-
- private final String name;
-
- private final String mbeanName;
-
- private final String title;
-
- private final long serviceId;
-
- private final List<String> tags;
-
- private final String asyncCronExpression;
-
- private final transient ServiceReference serviceReference;
-
- private final Long resultCacheTtlInMs;
-
- private final Long warningsStickForMinutes;
-
- public HealthCheckMetadata(final ServiceReference ref) {
- this.serviceId = (Long) ref.getProperty(Constants.SERVICE_ID);
- this.name = (String) ref.getProperty(HealthCheck.NAME);
- this.mbeanName = (String) ref.getProperty(HealthCheck.MBEAN_NAME);
- this.title = getHealthCheckTitle(ref);
- this.tags = arrayPropertyToListOfStr(ref.getProperty(HealthCheck.TAGS));
- this.asyncCronExpression = (String) ref.getProperty(HealthCheck.ASYNC_CRON_EXPRESSION);
- this.resultCacheTtlInMs = (Long)ref.getProperty(HealthCheck.RESULT_CACHE_TTL_IN_MS);
- this.warningsStickForMinutes = toLong(ref.getProperty(HealthCheck.WARNINGS_STICK_FOR_MINUTES));
- this.serviceReference = ref;
- }
-
- private Long toLong(Object configValue) {
- if(configValue == null) {
- return null;
- }
- if(configValue instanceof Long) {
- return (Long)configValue;
- }
- return Long.valueOf(configValue.toString());
- }
-
- /**
- * The name of the health check as defined through the {@link HealthCheck#NAME}
- * property.
- * @return The name or <code>null</code>
- */
- public String getName() {
- return name;
- }
-
- /**
- * The mbean name of the health check as defined through the {@link HealthCheck#MBEAN_NAME}
- * property.
- * @return The mbean name or <code>null</code>
- */
- public String getMBeanName() {
- return mbeanName;
- }
-
- /**
- * The title of the health check.
- * If the health check has a name, this is used as the title.
- * Otherwise the description, PID and service ID are checked
- * for values.
- */
- public String getTitle() {
- return title;
- }
-
- /**
- * Return the list of defined tags for this check as set
- * through {@link HealthCheckMetadata#tags}
- * @return
- */
- public List<String> getTags() {
- return tags;
- }
-
-
- /**
- * Return the cron expression used for asynchronous execution.
- */
- public String getAsyncCronExpression() {
- return asyncCronExpression;
- }
-
- /**
- * Return the service id.
- */
- public long getServiceId() {
- return this.serviceId;
- }
-
- /**
- * Get the service reference.
- */
- public ServiceReference getServiceReference() {
- return this.serviceReference;
- }
-
- /**
- * TTL for the result cache in ms.
- *
- * @return TTL for the result cache or <code>null</code> if not configured.
- */
- public Long getResultCacheTtlInMs() {
- return resultCacheTtlInMs;
- }
-
- /**
- * Make warnings stick for the given amount of time.
- *
- * @return Time to make warn results sticky in minutes.
- */
- public Long getWarningsStickForMinutes() {
- return warningsStickForMinutes;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (int) (serviceId ^ (serviceId >>> 32));
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if ( !(obj instanceof HealthCheckMetadata)) {
- return false;
- }
- final HealthCheckMetadata other = (HealthCheckMetadata) obj;
- return serviceId == other.serviceId;
- }
-
- @Override
- public String toString() {
- return "HealthCheck '" + name + "'";
- }
-
- private String getHealthCheckTitle(final ServiceReference ref) {
- String name = (String) ref.getProperty(HealthCheck.NAME);
- if (name == null || name.isEmpty()) {
- final Object val = ref.getProperty(Constants.SERVICE_DESCRIPTION);
- if ( val != null ) {
- name = val.toString();
- }
- }
- if (name == null || name.isEmpty()) {
- name = "HealthCheck:" + ref.getProperty(Constants.SERVICE_ID);
- final Object val = ref.getProperty(Constants.SERVICE_PID);
- String pid = null;
- if ( val instanceof String ) {
- pid = (String)val;
- } else if ( val instanceof String[]) {
- pid = Arrays.toString((String[])val);
- }
- if ( pid != null && !pid.isEmpty() ) {
- name = name + " (" + pid + ")";
- }
- }
- return name;
- }
-
- private List<String> arrayPropertyToListOfStr(final Object arrayProp) {
- List<String> res = new LinkedList<>();
- if (arrayProp instanceof String) {
- res.add((String) arrayProp);
- } else if (arrayProp instanceof String[]) {
- res.addAll(Arrays.asList((String[]) arrayProp));
- }
- return res;
- }
-}
diff --git a/src/main/java/org/apache/sling/hc/util/SimpleConstraintChecker.java b/src/main/java/org/apache/sling/hc/util/SimpleConstraintChecker.java
deleted file mode 100644
index 0f17b4d..0000000
--- a/src/main/java/org/apache/sling/hc/util/SimpleConstraintChecker.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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 SF 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.sling.hc.util;
-
-import org.apache.sling.hc.api.Result;
-import org.apache.sling.hc.api.ResultLog;
-
-/** Simple check of numeric values against expressions
- * like < N, > N, between two values etc.
- * See the SimpleConstraintCheckerTest for examples.
- */
-@Deprecated
-public class SimpleConstraintChecker {
-
- public static final String CONTAINS = "contains";
-
- /** Check value against expression and report to result */
- public void check(Object inputValue, String constraint, ResultLog resultLog) {
-
- final String stringValue = inputValue == null ? "" : inputValue.toString();
-
- if(constraint == null || constraint.trim().length() == 0) {
- throw new IllegalArgumentException("Empty constraint, cannot evaluate");
- }
-
- final String [] parts = constraint.split(" ");
- boolean matches = false;
- try {
- if(constraint.startsWith(">") && parts.length == 2) {
- final int value = Integer.valueOf(stringValue).intValue();
- matches = value > Integer.valueOf(parts[1]);
-
- } else if(constraint.startsWith("<") && parts.length == 2) {
- final int value = Integer.valueOf(stringValue).intValue();
- matches = value < Integer.valueOf(parts[1]);
-
- } else if(parts.length == 4 && "between".equalsIgnoreCase(parts[0]) && "and".equalsIgnoreCase(parts[2]) ) {
- final int value = Integer.valueOf(stringValue).intValue();
- final int lowerBound = Integer.valueOf(parts[1]);
- final int upperBound = Integer.valueOf(parts[3]);
- matches = value > lowerBound && value < upperBound;
-
- } else if(parts.length >1 && CONTAINS.equalsIgnoreCase(parts[0])) {
- final String pattern = constraint.substring(CONTAINS.length()).trim();
- matches = stringValue.contains(pattern);
-
- } else {
- matches = constraint.equals(stringValue);
- }
- } catch(NumberFormatException nfe) {
- resultLog.add(new ResultLog.Entry(
- Result.Status.WARN,
- "Invalid numeric value [" + inputValue + "] while evaluating " + constraint));
- }
-
- if(matches) {
- resultLog.add(new ResultLog.Entry(
- Result.Status.DEBUG,
- "Value [" + inputValue + "] matches constraint [" + constraint + "]"));
- } else {
- resultLog.add(new ResultLog.Entry(
- Result.Status.WARN,
- "Value [" + inputValue + "] does not match constraint [" + constraint + "]"));
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/hc/util/package-info.java b/src/main/java/org/apache/sling/hc/util/package-info.java
deleted file mode 100644
index 12e8182..0000000
--- a/src/main/java/org/apache/sling/hc/util/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-
-@Version("1.5.0")
-package org.apache.sling.hc.util;
-
-import org.osgi.annotation.versioning.Version;
diff --git a/src/test/java/org/apache/sling/hc/api/ResultLogTest.java b/src/test/java/org/apache/sling/hc/api/ResultLogTest.java
deleted file mode 100644
index 06a2349..0000000
--- a/src/test/java/org/apache/sling/hc/api/ResultLogTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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 SF 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.sling.hc.api;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import java.util.Iterator;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class ResultLogTest {
-
- private ResultLog log;
-
- @Before
- public void setup() {
- log = new ResultLog();
- }
-
- @Test
- public void testEmptyLogIsNotOk() {
- assertEquals(Result.Status.WARN, log.getAggregateStatus());
- assertFalse(log.iterator().hasNext());
- }
-
- @Test
- public void testSetStatusGoingUp() {
- log.add(new ResultLog.Entry(Result.Status.DEBUG, "argh"));
- assertEquals(Result.Status.OK, log.getAggregateStatus());
- log.add(new ResultLog.Entry(Result.Status.INFO, "argh"));
- assertEquals(Result.Status.OK, log.getAggregateStatus());
- log.add(new ResultLog.Entry(Result.Status.OK, "argh"));
- assertEquals(Result.Status.OK, log.getAggregateStatus());
- log.add(new ResultLog.Entry(Result.Status.WARN, "argh"));
- assertEquals(Result.Status.WARN, log.getAggregateStatus());
- log.add(new ResultLog.Entry(Result.Status.CRITICAL, "argh"));
- assertEquals(Result.Status.CRITICAL, log.getAggregateStatus());
- log.add(new ResultLog.Entry(Result.Status.HEALTH_CHECK_ERROR, "argh"));
- assertEquals(Result.Status.HEALTH_CHECK_ERROR, log.getAggregateStatus());
- }
-
- @Test
- public void testSetStatusGoingDownHCE() {
- log.add(new ResultLog.Entry(Result.Status.HEALTH_CHECK_ERROR, "argh"));
- assertEquals(Result.Status.HEALTH_CHECK_ERROR, log.getAggregateStatus());
- log.add(new ResultLog.Entry(Result.Status.CRITICAL, "argh"));
- assertEquals(Result.Status.HEALTH_CHECK_ERROR, log.getAggregateStatus());
- }
-
- @Test
- public void testSetStatusGoingDownCRIT() {
- log.add(new ResultLog.Entry(Result.Status.CRITICAL, "argh"));
- assertEquals(Result.Status.CRITICAL, log.getAggregateStatus());
- log.add(new ResultLog.Entry(Result.Status.WARN, "argh"));
- assertEquals(Result.Status.CRITICAL, log.getAggregateStatus());
- }
-
- @Test
- public void testSetStatusGoingDownWARN() {
- log.add(new ResultLog.Entry(Result.Status.WARN, "argh"));
- assertEquals(Result.Status.WARN, log.getAggregateStatus());
- log.add(new ResultLog.Entry(Result.Status.OK, "argh"));
- assertEquals(Result.Status.WARN, log.getAggregateStatus());
- }
-
- @Test
- public void testSetStatusGoingDownOK() {
- log.add(new ResultLog.Entry(Result.Status.OK, "argh"));
- assertEquals(Result.Status.OK, log.getAggregateStatus());
- log.add(new ResultLog.Entry(Result.Status.INFO, "argh"));
- assertEquals(Result.Status.OK, log.getAggregateStatus());
- log.add(new ResultLog.Entry(Result.Status.DEBUG, "argh"));
- assertEquals(Result.Status.OK, log.getAggregateStatus());
- }
-
- @Test
- public void testLogEntries() {
- log.add(new ResultLog.Entry(Result.Status.OK, "ok 1"));
- log.add(new ResultLog.Entry(Result.Status.DEBUG, "debug 2"));
- log.add(new ResultLog.Entry(Result.Status.WARN, "warn 3"));
- log.add(new ResultLog.Entry(Result.Status.CRITICAL, "critical 4"));
-
- final Iterator<ResultLog.Entry> it = log.iterator();
- assertEquals("OK ok 1", it.next().toString());
- assertEquals("DEBUG debug 2", it.next().toString());
- assertEquals("WARN warn 3", it.next().toString());
- assertEquals("CRITICAL critical 4", it.next().toString());
- assertFalse(it.hasNext());
- }
- }
diff --git a/src/test/java/org/apache/sling/hc/api/ResultTest.java b/src/test/java/org/apache/sling/hc/api/ResultTest.java
deleted file mode 100644
index dff455d..0000000
--- a/src/test/java/org/apache/sling/hc/api/ResultTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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 SF 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.sling.hc.api;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.junit.Test;
-
-public class ResultTest {
-
- private final AtomicInteger counter = new AtomicInteger();
-
- private void assertSingleResult(Result.Status toSet, Result.Status expected, boolean expectOk) {
- final String msg = "test " + counter.incrementAndGet();
- final Result r = new Result(toSet, msg);
- assertEquals(expected, r.getStatus());
- assertEquals(expectOk, r.isOk());
- assertTrue(r.iterator().hasNext());
- assertEquals(toSet.toString() + " " + msg, r.iterator().next().toString());
- }
-
- @Test
- public void testSingleResult() {
- assertSingleResult(Result.Status.DEBUG, Result.Status.OK, true);
- assertSingleResult(Result.Status.INFO, Result.Status.OK, true);
- assertSingleResult(Result.Status.OK, Result.Status.OK, true);
- assertSingleResult(Result.Status.WARN, Result.Status.WARN, false);
- assertSingleResult(Result.Status.CRITICAL, Result.Status.CRITICAL, false);
- assertSingleResult(Result.Status.HEALTH_CHECK_ERROR, Result.Status.HEALTH_CHECK_ERROR, false);
- }
-
- @Test
- public void testLog() {
- final ResultLog log = new ResultLog();
- log.add(new ResultLog.Entry(Result.Status.INFO, "argh"));
- log.add(new ResultLog.Entry(Result.Status.WARN, "bad stuff"));
-
- final Result result = new Result(log);
- assertEquals(Result.Status.WARN, result.getStatus());
-
- final StringBuilder sb = new StringBuilder();
- for(ResultLog.Entry e : result) {
- sb.append(e.toString()).append("#");
- }
- assertEquals("INFO argh#WARN bad stuff#", sb.toString());
- }
-}
diff --git a/src/test/java/org/apache/sling/hc/util/HealthCheckFilterTest.java b/src/test/java/org/apache/sling/hc/util/HealthCheckFilterTest.java
deleted file mode 100644
index 44be3ae..0000000
--- a/src/test/java/org/apache/sling/hc/util/HealthCheckFilterTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.sling.hc.util;
-
-import org.apache.sling.hc.api.execution.HealthCheckSelector;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.apache.sling.hc.api.execution.HealthCheckSelector.*;
-
-public class HealthCheckFilterTest {
-
- private HealthCheckFilter filter = new HealthCheckFilter(null);
-
- private static void assertStrEquals(String expected, CharSequence actual) {
- assertEquals(expected, actual.toString());
- }
-
- @Test
- public void testEmptyOptions() {
- assertStrEquals("(&(objectClass=org.apache.sling.hc.api.HealthCheck))", filter.getServiceFilter(empty(), false));
- }
-
- @Test
- public void testWithOneTag() {
- HealthCheckSelector selector = tags("foo");
- assertStrEquals("(&(objectClass=org.apache.sling.hc.api.HealthCheck)(hc.tags=foo))", filter.getServiceFilter(selector, false));
- }
-
- @Test
- public void testWithTwoTags() {
- HealthCheckSelector selector = tags("foo", "bar");
- assertStrEquals("(&(objectClass=org.apache.sling.hc.api.HealthCheck)(hc.tags=foo)(hc.tags=bar))", filter.getServiceFilter(selector, false));
- }
-
- @Test
- public void testWithTwoTagsOr() {
- HealthCheckSelector selector = tags("foo", "bar");
- assertStrEquals("(&(objectClass=org.apache.sling.hc.api.HealthCheck)(|(hc.tags=foo)(hc.tags=bar)))", filter.getServiceFilter(selector, true));
- }
-
- @Test
- public void testWithTwoTagsExcludeOne() {
- HealthCheckSelector selector = tags("foo", "bar").withTags("-baz");
- assertStrEquals("(&(objectClass=org.apache.sling.hc.api.HealthCheck)(!(hc.tags=baz))(hc.tags=foo)(hc.tags=bar))", filter.getServiceFilter(selector, false));
- }
-
- @Test
- public void testWithOneName() {
- HealthCheckSelector selector = names("foo");
- assertStrEquals("(&(objectClass=org.apache.sling.hc.api.HealthCheck)(|(hc.name=foo)))", filter.getServiceFilter(selector, false));
- }
-
- @Test
- public void testWithTwoNames() {
- HealthCheckSelector selector = names("foo").withNames("bar");
- assertStrEquals("(&(objectClass=org.apache.sling.hc.api.HealthCheck)(|(hc.name=foo)(hc.name=bar)))", filter.getServiceFilter(selector, false));
- }
-
- @Test
- public void testWithTwoNamesExcludingOne() {
- HealthCheckSelector selector = names("foo", "bar", "-baz");
- assertStrEquals("(&(objectClass=org.apache.sling.hc.api.HealthCheck)(!(hc.name=baz))(|(hc.name=foo)(hc.name=bar)))", filter.getServiceFilter(selector, false));
- }
-
- @Test
- public void testWithTagAndName() {
- HealthCheckSelector selector = empty().withTags("t1").withNames("foo");
- assertStrEquals("(&(objectClass=org.apache.sling.hc.api.HealthCheck)(|(hc.name=foo)(hc.tags=t1)))", filter.getServiceFilter(selector, false));
- }
-
- @Test
- public void testWithTwoOrTagsAndTwoNames() {
- HealthCheckSelector selector = empty().withNames("foo", "bar").withTags("t1", "t2");
- assertStrEquals("(&(objectClass=org.apache.sling.hc.api.HealthCheck)(|(hc.tags=t1)(hc.tags=t2)(hc.name=foo)(hc.name=bar)))", filter.getServiceFilter(selector, true));
- }
-
- @Test
- public void testWithTwoAndTagsAndTwoNames() {
- HealthCheckSelector selector = empty().withNames("foo", "bar").withTags("t1", "t2");
- assertStrEquals("(&(objectClass=org.apache.sling.hc.api.HealthCheck)(|(hc.name=foo)(hc.name=bar)(&(hc.tags=t1)(hc.tags=t2))))", filter.getServiceFilter(selector, false));
- }
-
-}
diff --git a/src/test/java/org/apache/sling/hc/util/SimpleConstraintCheckerTest.java b/src/test/java/org/apache/sling/hc/util/SimpleConstraintCheckerTest.java
deleted file mode 100644
index 3a58eb0..0000000
--- a/src/test/java/org/apache/sling/hc/util/SimpleConstraintCheckerTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * 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 SF 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.sling.hc.util;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.sling.hc.api.Result;
-import org.apache.sling.hc.api.ResultLog;
-import org.apache.sling.hc.util.SimpleConstraintChecker;
-import org.junit.Before;
-import org.junit.Test;
-
-public class SimpleConstraintCheckerTest {
- private ResultLog resultLog;
-
- private final SimpleConstraintChecker checker = new SimpleConstraintChecker();
-
- @Before
- public void setup() {
- resultLog = new ResultLog();
- }
-
- @Test
- public void testStringEquals() {
- final String s = "test_" + System.currentTimeMillis();
- checker.check(s, s, resultLog);
- assertTrue(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testStringNotEquals() {
- final String s = "test_" + System.currentTimeMillis();
- checker.check(s, "something else", resultLog);
- assertFalse(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testFiveEquals() {
- final String s = "5";
- checker.check(s, s, resultLog);
- assertTrue(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testIntTwelveEquals() {
- checker.check(12, "12", resultLog);
- assertTrue(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testIntTwelveGreaterThan() {
- checker.check(12, "> 11", resultLog);
- assertTrue(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testFiveNotEquals() {
- checker.check("5", "foo", resultLog);
- assertFalse(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testNullNotEquals() {
- checker.check(null, "foo", resultLog);
- assertFalse(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testNullNotGreater() {
- checker.check(null, "> 2", resultLog);
- assertFalse(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testGreaterThanTrue() {
- checker.check("5", "> 2", resultLog);
- assertTrue(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testGreaterThanFalse() {
- checker.check("5", "> 12", resultLog);
- assertFalse(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testLessThanTrue() {
- checker.check("5", "< 12", resultLog);
- assertTrue(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testLessThanFalse() {
- checker.check("5", "< 2", resultLog);
- assertFalse(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testBetweenA() {
- checker.check("5", "between 2 and 6", resultLog);
- assertTrue(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testBetweenB() {
- checker.check("5", "between 12 and 16", resultLog);
- assertFalse(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testBetweenC() {
- checker.check(5L, "between 12 and 16", resultLog);
- assertFalse(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testBetweenD() {
- checker.check(5L, "between 4 and 16", resultLog);
- assertTrue(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testBetweenE() {
- checker.check(5L, "betWEEN 4 aND 16", resultLog);
- assertTrue(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testNotAnInteger() {
- checker.check("foo", "between 12 and 16", resultLog);
- assertFalse(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testContainsA() {
- checker.check("This is a NICE STRING ok?", "contains NICE STRING", resultLog);
- assertTrue(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testContainsB() {
- checker.check("This is a NICE TOUCH ok?", "contains NICE STRING", resultLog);
- assertFalse(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-
- @Test
- public void testContainsC() {
- checker.check("This is a NICE TOUCH ok?", "contains NICE", resultLog);
- assertTrue(resultLog.getAggregateStatus().equals(Result.Status.OK));
- }
-}