legal headers
diff --git a/pom.xml b/pom.xml index 5b7c1c0..ecfb9ed 100644 --- a/pom.xml +++ b/pom.xml
@@ -9,7 +9,7 @@ <maven>3.0.0</maven> </prerequisites> - <groupId>pta.de</groupId> + <groupId>org.eclipse.openk</groupId> <artifactId>mics-central-service</artifactId> <version>0.1.3-SNAPSHOT</version> <packaging>jar</packaging> @@ -21,7 +21,7 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <dropwizard.version>1.2.0</dropwizard.version> - <mainClass>pta.de.MicsCentralApplication</mainClass> + <mainClass>org.eclipse.openK.MicsCentralApplication</mainClass> <easymock.version>3.4</easymock.version> <powermock-api-easymock.version>1.6.6</powermock-api-easymock.version> <jacoco-maven-plugin.version>0.7.9</jacoco-maven-plugin.version>
diff --git a/src/main/java/pta/de/MicsCentralApplication.java b/src/main/java/org/eclipse/openK/MicsCentralApplication.java similarity index 78% rename from src/main/java/pta/de/MicsCentralApplication.java rename to src/main/java/org/eclipse/openK/MicsCentralApplication.java index b37fe22..a3c7166 100644 --- a/src/main/java/pta/de/MicsCentralApplication.java +++ b/src/main/java/org/eclipse/openK/MicsCentralApplication.java
@@ -1,13 +1,25 @@ -package pta.de; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK; import com.codahale.metrics.health.HealthCheck; import io.dropwizard.Application; import io.dropwizard.setup.Bootstrap; import io.dropwizard.setup.Environment; import org.eclipse.jetty.servlets.CrossOriginFilter; -import pta.de.core.controller.InitServicesConfigCacheJob; -import pta.de.health.ConfigFilePresentHealthCheck; -import pta.de.resources.MicsCentralResource; +import org.eclipse.openK.core.controller.InitServicesConfigCacheJob; +import org.eclipse.openK.health.ConfigFilePresentHealthCheck; +import org.eclipse.openK.resources.MicsCentralResource; import javax.servlet.DispatcherType; import javax.servlet.FilterRegistration;
diff --git a/src/main/java/org/eclipse/openK/MicsCentralConfiguration.java b/src/main/java/org/eclipse/openK/MicsCentralConfiguration.java new file mode 100644 index 0000000..5fb7850 --- /dev/null +++ b/src/main/java/org/eclipse/openK/MicsCentralConfiguration.java
@@ -0,0 +1,32 @@ +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK; + +import io.dropwizard.Configuration; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.hibernate.validator.constraints.*; + +public class MicsCentralConfiguration extends Configuration { + @NotEmpty + private String servicesDistributionFileName; + + @JsonProperty + public String getServicesDistributionFileName() { + return servicesDistributionFileName; + } + + @JsonProperty + public void setServicesDistributionFileName(String servicesDistributionFileName) { + this.servicesDistributionFileName = servicesDistributionFileName; + } +}
diff --git a/src/main/java/pta/de/api/ServiceDistributionCluster.java b/src/main/java/org/eclipse/openK/api/ServiceDistributionCluster.java similarity index 87% rename from src/main/java/pta/de/api/ServiceDistributionCluster.java rename to src/main/java/org/eclipse/openK/api/ServiceDistributionCluster.java index 8a37f28..8a7acb3 100644 --- a/src/main/java/pta/de/api/ServiceDistributionCluster.java +++ b/src/main/java/org/eclipse/openK/api/ServiceDistributionCluster.java
@@ -1,4 +1,16 @@ -package pta.de.api; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.api; import com.fasterxml.jackson.annotation.JsonProperty; import org.hibernate.validator.constraints.NotEmpty;
diff --git a/src/main/java/pta/de/api/ServiceRequestEnvelope.java b/src/main/java/org/eclipse/openK/api/ServiceRequestEnvelope.java similarity index 81% rename from src/main/java/pta/de/api/ServiceRequestEnvelope.java rename to src/main/java/org/eclipse/openK/api/ServiceRequestEnvelope.java index fb5ce7a..9ade421 100644 --- a/src/main/java/pta/de/api/ServiceRequestEnvelope.java +++ b/src/main/java/org/eclipse/openK/api/ServiceRequestEnvelope.java
@@ -1,4 +1,16 @@ -package pta.de.api; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.api; import com.fasterxml.jackson.annotation.JsonProperty; import org.glassfish.jersey.internal.util.Base64;
diff --git a/src/main/java/org/eclipse/openK/api/VersionInfo.java b/src/main/java/org/eclipse/openK/api/VersionInfo.java new file mode 100644 index 0000000..7cd5c2b --- /dev/null +++ b/src/main/java/org/eclipse/openK/api/VersionInfo.java
@@ -0,0 +1,27 @@ +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.api; + +public class VersionInfo { + private String backendVersion; + + public String getBackendVersion() { + return backendVersion; + } + + public void setBackendVersion(String backendVersion) { + this.backendVersion = backendVersion; + } + + +}
diff --git a/src/main/java/org/eclipse/openK/core/common/Globals.java b/src/main/java/org/eclipse/openK/core/common/Globals.java new file mode 100644 index 0000000..1f789c8 --- /dev/null +++ b/src/main/java/org/eclipse/openK/core/common/Globals.java
@@ -0,0 +1,22 @@ +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.common; + + +public final class Globals { + public static final String HEADER_JSON_UTF8 = "application/json; charset=utf-8"; + public static final String HEALTH_CHECK_ADD_PATH = "healthcheck?pretty=true"; + + private Globals() { + } +}
diff --git a/src/main/java/pta/de/core/common/GsonUTCDateAdapter.java b/src/main/java/org/eclipse/openK/core/common/GsonUTCDateAdapter.java similarity index 71% rename from src/main/java/pta/de/core/common/GsonUTCDateAdapter.java rename to src/main/java/org/eclipse/openK/core/common/GsonUTCDateAdapter.java index 024080b..86d7bfa 100644 --- a/src/main/java/pta/de/core/common/GsonUTCDateAdapter.java +++ b/src/main/java/org/eclipse/openK/core/common/GsonUTCDateAdapter.java
@@ -1,4 +1,16 @@ -package pta.de.core.common; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.common; import com.google.gson.*;
diff --git a/src/main/java/org/eclipse/openK/core/common/JsonGeneratorBase.java b/src/main/java/org/eclipse/openK/core/common/JsonGeneratorBase.java new file mode 100644 index 0000000..4627bae --- /dev/null +++ b/src/main/java/org/eclipse/openK/core/common/JsonGeneratorBase.java
@@ -0,0 +1,28 @@ +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.common; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import java.util.Date; + +public class JsonGeneratorBase { + private JsonGeneratorBase() {} + public static Gson getGson() { + return new GsonBuilder() + .registerTypeAdapter(Date.class, new GsonUTCDateAdapter()) + .disableHtmlEscaping() + .create(); + } +}
diff --git a/src/main/java/org/eclipse/openK/core/common/util/ResourceLoaderBase.java b/src/main/java/org/eclipse/openK/core/common/util/ResourceLoaderBase.java new file mode 100644 index 0000000..96534c2 --- /dev/null +++ b/src/main/java/org/eclipse/openK/core/common/util/ResourceLoaderBase.java
@@ -0,0 +1,38 @@ +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.common.util; + +import org.apache.commons.io.IOUtils; + +import java.io.InputStream; +import java.io.StringWriter; + +public class ResourceLoaderBase { + private String stream2String(InputStream is) { + StringWriter writer = new StringWriter(); + try { + IOUtils.copy(is, writer, "UTF-8"); + } catch (Exception e) { // NOSONAR + return ""; + } + return writer.toString(); + + + } + + public String loadStringFromResource(String filename) { + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + InputStream jsonstream = classLoader.getResourceAsStream(filename); + return stream2String(jsonstream); + } +}
diff --git a/src/main/java/pta/de/core/communication/RestServiceWrapper.java b/src/main/java/org/eclipse/openK/core/communication/RestServiceWrapper.java similarity index 91% rename from src/main/java/pta/de/core/communication/RestServiceWrapper.java rename to src/main/java/org/eclipse/openK/core/communication/RestServiceWrapper.java index 1a5eead..3eb5387 100644 --- a/src/main/java/pta/de/core/communication/RestServiceWrapper.java +++ b/src/main/java/org/eclipse/openK/core/communication/RestServiceWrapper.java
@@ -1,4 +1,16 @@ -package pta.de.core.communication; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.communication; import org.apache.http.HttpResponse; @@ -13,8 +25,8 @@ import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.util.EntityUtils; import org.apache.log4j.Logger; -import pta.de.core.common.Globals; -import pta.de.core.exceptions.HttpStatusException; +import org.eclipse.openK.core.common.Globals; +import org.eclipse.openK.core.exceptions.HttpStatusException; import javax.ws.rs.core.Response; import java.io.IOException;
diff --git a/src/main/java/pta/de/core/controller/BackendController.java b/src/main/java/org/eclipse/openK/core/controller/BackendController.java similarity index 79% rename from src/main/java/pta/de/core/controller/BackendController.java rename to src/main/java/org/eclipse/openK/core/controller/BackendController.java index e163863..1c528fa 100644 --- a/src/main/java/pta/de/core/controller/BackendController.java +++ b/src/main/java/org/eclipse/openK/core/controller/BackendController.java
@@ -1,12 +1,24 @@ -package pta.de.core.controller; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.controller; import org.apache.log4j.Logger; import org.eclipse.jetty.http.HttpStatus; -import pta.de.api.ServiceDistributionCluster; -import pta.de.api.VersionInfo; -import pta.de.core.common.Globals; -import pta.de.core.communication.RestServiceWrapper; -import pta.de.core.exceptions.HttpStatusException; +import org.eclipse.openK.api.VersionInfo; +import org.eclipse.openK.api.ServiceDistributionCluster; +import org.eclipse.openK.core.common.Globals; +import org.eclipse.openK.core.communication.RestServiceWrapper; +import org.eclipse.openK.core.exceptions.HttpStatusException; import java.util.Arrays; import java.util.List; @@ -27,7 +39,7 @@ throw new HttpStatusException(HttpStatus.NOT_FOUND_404); } - public VersionInfo getVersionInfo( String version ) { + public VersionInfo getVersionInfo(String version ) { VersionInfo vi = new VersionInfo(); vi.setBackendVersion( version ); return vi;
diff --git a/src/main/java/pta/de/core/controller/BaseWebService.java b/src/main/java/org/eclipse/openK/core/controller/BaseWebService.java similarity index 74% rename from src/main/java/pta/de/core/controller/BaseWebService.java rename to src/main/java/org/eclipse/openK/core/controller/BaseWebService.java index 60c64bf..c26136d 100644 --- a/src/main/java/pta/de/core/controller/BaseWebService.java +++ b/src/main/java/org/eclipse/openK/core/controller/BaseWebService.java
@@ -1,8 +1,20 @@ -package pta.de.core.controller; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.controller; import org.apache.log4j.Logger; import org.eclipse.jetty.http.HttpStatus; -import pta.de.core.exceptions.HttpStatusException; +import org.eclipse.openK.core.exceptions.HttpStatusException; import javax.ws.rs.core.Response; import java.io.IOException;
diff --git a/src/main/java/pta/de/core/controller/DispatchController.java b/src/main/java/org/eclipse/openK/core/controller/DispatchController.java similarity index 75% rename from src/main/java/pta/de/core/controller/DispatchController.java rename to src/main/java/org/eclipse/openK/core/controller/DispatchController.java index 36329a3..1e59b62 100644 --- a/src/main/java/pta/de/core/controller/DispatchController.java +++ b/src/main/java/org/eclipse/openK/core/controller/DispatchController.java
@@ -1,13 +1,25 @@ -package pta.de.core.controller; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.controller; import com.google.common.collect.Lists; import org.apache.log4j.Logger; import org.eclipse.jetty.http.HttpStatus; -import pta.de.api.ServiceDistributionCluster; -import pta.de.api.ServiceDistributionCluster.ServiceDistribution; -import pta.de.api.ServiceRequestEnvelope; -import pta.de.core.communication.RestServiceWrapper; -import pta.de.core.exceptions.HttpStatusException; +import org.eclipse.openK.api.ServiceDistributionCluster; +import org.eclipse.openK.api.ServiceDistributionCluster.ServiceDistribution; +import org.eclipse.openK.api.ServiceRequestEnvelope; +import org.eclipse.openK.core.communication.RestServiceWrapper; +import org.eclipse.openK.core.exceptions.HttpStatusException; import javax.ws.rs.core.Response; import java.util.List;
diff --git a/src/main/java/org/eclipse/openK/core/controller/InitServicesConfigCacheJob.java b/src/main/java/org/eclipse/openK/core/controller/InitServicesConfigCacheJob.java new file mode 100644 index 0000000..1b9a088 --- /dev/null +++ b/src/main/java/org/eclipse/openK/core/controller/InitServicesConfigCacheJob.java
@@ -0,0 +1,33 @@ +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.controller; + +import org.apache.log4j.Logger; + +import java.util.Timer; +import java.util.TimerTask; + +public class InitServicesConfigCacheJob { + + private static final Logger LOGGER = Logger.getLogger(InitServicesConfigCacheJob.class.getName()); + + private InitServicesConfigCacheJob() { + } + + public static void init( String configFileName ) { + LOGGER.info("InitServicesConfigCacheJob called"); + TimerTask timerTask = new ServicesConfigCacheTimerTask(configFileName); + Timer timer = new Timer(); + timer.scheduleAtFixedRate(timerTask, 100, 5000L); + } +}
diff --git a/src/main/java/pta/de/core/controller/ServiceResolver.java b/src/main/java/org/eclipse/openK/core/controller/ServiceResolver.java similarity index 60% rename from src/main/java/pta/de/core/controller/ServiceResolver.java rename to src/main/java/org/eclipse/openK/core/controller/ServiceResolver.java index fca1e45..1bc06f8 100644 --- a/src/main/java/pta/de/core/controller/ServiceResolver.java +++ b/src/main/java/org/eclipse/openK/core/controller/ServiceResolver.java
@@ -1,7 +1,19 @@ -package pta.de.core.controller; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ -import pta.de.api.ServiceDistributionCluster; -import pta.de.api.ServiceDistributionCluster.ServiceDistribution; +package org.eclipse.openK.core.controller; + +import org.eclipse.openK.api.ServiceDistributionCluster; +import org.eclipse.openK.api.ServiceDistributionCluster.ServiceDistribution; import java.util.Arrays; import java.util.Optional;
diff --git a/src/main/java/pta/de/core/controller/ServicesConfigCache.java b/src/main/java/org/eclipse/openK/core/controller/ServicesConfigCache.java similarity index 78% rename from src/main/java/pta/de/core/controller/ServicesConfigCache.java rename to src/main/java/org/eclipse/openK/core/controller/ServicesConfigCache.java index 47b50b6..2802645 100644 --- a/src/main/java/pta/de/core/controller/ServicesConfigCache.java +++ b/src/main/java/org/eclipse/openK/core/controller/ServicesConfigCache.java
@@ -1,10 +1,22 @@ -package pta.de.core.controller; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.controller; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.log4j.Logger; import org.eclipse.jetty.http.HttpStatus; -import pta.de.api.ServiceDistributionCluster; -import pta.de.core.exceptions.HttpStatusException; +import org.eclipse.openK.api.ServiceDistributionCluster; +import org.eclipse.openK.core.exceptions.HttpStatusException; import javax.validation.ConstraintViolation; import javax.validation.Validation;
diff --git a/src/main/java/org/eclipse/openK/core/controller/ServicesConfigCacheTimerTask.java b/src/main/java/org/eclipse/openK/core/controller/ServicesConfigCacheTimerTask.java new file mode 100644 index 0000000..1bc56b0 --- /dev/null +++ b/src/main/java/org/eclipse/openK/core/controller/ServicesConfigCacheTimerTask.java
@@ -0,0 +1,41 @@ +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.controller; + +import org.apache.log4j.Logger; +import org.eclipse.openK.core.exceptions.HttpStatusException; + +import java.util.TimerTask; + +public class ServicesConfigCacheTimerTask extends TimerTask { + private static final Logger logger = Logger.getLogger(ServicesConfigCacheTimerTask.class.getName()); + private String configFileName; + + public ServicesConfigCacheTimerTask( String configFileName ) { + this.configFileName = configFileName; + } + + + @Override + public void run() { + logger.debug("ServicesConfigCacheTimerTask started"); + + try { + ServicesConfigCache.getInstance().readServerDistribution(this.configFileName); + } catch (HttpStatusException e) { + logger.error("Error reading ServerDistributionFile", e); + } + + logger.debug("ServicesConfigCacheTimerTask finished"); + } +}
diff --git a/src/main/java/org/eclipse/openK/core/exceptions/HttpStatusException.java b/src/main/java/org/eclipse/openK/core/exceptions/HttpStatusException.java new file mode 100644 index 0000000..c13fd02 --- /dev/null +++ b/src/main/java/org/eclipse/openK/core/exceptions/HttpStatusException.java
@@ -0,0 +1,25 @@ +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.exceptions; + +public class HttpStatusException extends Exception { + private final int httpStatus; + + public HttpStatusException(int httpStatus ) { + this.httpStatus = httpStatus; + } + + public int getHttpStatus() { + return httpStatus; + } +}
diff --git a/src/main/java/org/eclipse/openK/health/ConfigFilePresentHealthCheck.java b/src/main/java/org/eclipse/openK/health/ConfigFilePresentHealthCheck.java new file mode 100644 index 0000000..30bad60 --- /dev/null +++ b/src/main/java/org/eclipse/openK/health/ConfigFilePresentHealthCheck.java
@@ -0,0 +1,31 @@ +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.health; + +import com.codahale.metrics.health.HealthCheck; +import org.eclipse.openK.api.ServiceDistributionCluster; +import org.eclipse.openK.core.controller.ServicesConfigCache; + +public class ConfigFilePresentHealthCheck extends HealthCheck { + @Override + protected Result check() throws Exception { + ServiceDistributionCluster[] sdc = ServicesConfigCache.getInstance().getCache(); // Throws Exception if it fails + + if (sdc != null && sdc.length > 0) { + return Result.healthy(); + } + else { + return Result.unhealthy("No ServiceDistributionCluster available!"); + } + } +}
diff --git a/src/main/java/pta/de/resources/MicsCentralResource.java b/src/main/java/org/eclipse/openK/resources/MicsCentralResource.java similarity index 68% rename from src/main/java/pta/de/resources/MicsCentralResource.java rename to src/main/java/org/eclipse/openK/resources/MicsCentralResource.java index ee69d32..19a7fc2 100644 --- a/src/main/java/pta/de/resources/MicsCentralResource.java +++ b/src/main/java/org/eclipse/openK/resources/MicsCentralResource.java
@@ -1,14 +1,26 @@ -package pta.de.resources; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.resources; import org.apache.log4j.Logger; +import org.eclipse.openK.core.common.JsonGeneratorBase; +import org.eclipse.openK.core.controller.DispatchController; import org.hibernate.validator.constraints.NotEmpty; -import pta.de.api.ServiceRequestEnvelope; -import pta.de.core.common.JsonGeneratorBase; -import pta.de.core.controller.BackendController; -import pta.de.core.controller.BaseWebService; -import pta.de.core.controller.DispatchController; -import pta.de.core.exceptions.HttpStatusException; +import org.eclipse.openK.api.ServiceRequestEnvelope; +import org.eclipse.openK.core.controller.BackendController; +import org.eclipse.openK.core.controller.BaseWebService; +import org.eclipse.openK.core.exceptions.HttpStatusException; import javax.ws.rs.*; import javax.ws.rs.core.MediaType;
diff --git a/src/main/java/pta/de/MicsCentralConfiguration.java b/src/main/java/pta/de/MicsCentralConfiguration.java deleted file mode 100644 index 26ae324..0000000 --- a/src/main/java/pta/de/MicsCentralConfiguration.java +++ /dev/null
@@ -1,20 +0,0 @@ -package pta.de; - -import io.dropwizard.Configuration; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.hibernate.validator.constraints.*; - -public class MicsCentralConfiguration extends Configuration { - @NotEmpty - private String servicesDistributionFileName; - - @JsonProperty - public String getServicesDistributionFileName() { - return servicesDistributionFileName; - } - - @JsonProperty - public void setServicesDistributionFileName(String servicesDistributionFileName) { - this.servicesDistributionFileName = servicesDistributionFileName; - } -}
diff --git a/src/main/java/pta/de/api/VersionInfo.java b/src/main/java/pta/de/api/VersionInfo.java deleted file mode 100644 index 1a95df3..0000000 --- a/src/main/java/pta/de/api/VersionInfo.java +++ /dev/null
@@ -1,15 +0,0 @@ -package pta.de.api; - -public class VersionInfo { - private String backendVersion; - - public String getBackendVersion() { - return backendVersion; - } - - public void setBackendVersion(String backendVersion) { - this.backendVersion = backendVersion; - } - - -}
diff --git a/src/main/java/pta/de/core/common/Globals.java b/src/main/java/pta/de/core/common/Globals.java deleted file mode 100644 index a2e0d43..0000000 --- a/src/main/java/pta/de/core/common/Globals.java +++ /dev/null
@@ -1,10 +0,0 @@ -package pta.de.core.common; - - -public final class Globals { - public static final String HEADER_JSON_UTF8 = "application/json; charset=utf-8"; - public static final String HEALTH_CHECK_ADD_PATH = "healthcheck?pretty=true"; - - private Globals() { - } -}
diff --git a/src/main/java/pta/de/core/common/JsonGeneratorBase.java b/src/main/java/pta/de/core/common/JsonGeneratorBase.java deleted file mode 100644 index af20a84..0000000 --- a/src/main/java/pta/de/core/common/JsonGeneratorBase.java +++ /dev/null
@@ -1,16 +0,0 @@ -package pta.de.core.common; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import java.util.Date; - -public class JsonGeneratorBase { - private JsonGeneratorBase() {} - public static Gson getGson() { - return new GsonBuilder() - .registerTypeAdapter(Date.class, new GsonUTCDateAdapter()) - .disableHtmlEscaping() - .create(); - } -}
diff --git a/src/main/java/pta/de/core/common/util/ResourceLoaderBase.java b/src/main/java/pta/de/core/common/util/ResourceLoaderBase.java deleted file mode 100644 index ba3c3e6..0000000 --- a/src/main/java/pta/de/core/common/util/ResourceLoaderBase.java +++ /dev/null
@@ -1,26 +0,0 @@ -package pta.de.core.common.util; - -import org.apache.commons.io.IOUtils; - -import java.io.InputStream; -import java.io.StringWriter; - -public class ResourceLoaderBase { - private String stream2String(InputStream is) { - StringWriter writer = new StringWriter(); - try { - IOUtils.copy(is, writer, "UTF-8"); - } catch (Exception e) { // NOSONAR - return ""; - } - return writer.toString(); - - - } - - public String loadStringFromResource(String filename) { - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - InputStream jsonstream = classLoader.getResourceAsStream(filename); - return stream2String(jsonstream); - } -}
diff --git a/src/main/java/pta/de/core/controller/InitServicesConfigCacheJob.java b/src/main/java/pta/de/core/controller/InitServicesConfigCacheJob.java deleted file mode 100644 index 943a7b6..0000000 --- a/src/main/java/pta/de/core/controller/InitServicesConfigCacheJob.java +++ /dev/null
@@ -1,21 +0,0 @@ -package pta.de.core.controller; - -import org.apache.log4j.Logger; - -import java.util.Timer; -import java.util.TimerTask; - -public class InitServicesConfigCacheJob { - - private static final Logger LOGGER = Logger.getLogger(InitServicesConfigCacheJob.class.getName()); - - private InitServicesConfigCacheJob() { - } - - public static void init( String configFileName ) { - LOGGER.info("InitServicesConfigCacheJob called"); - TimerTask timerTask = new ServicesConfigCacheTimerTask(configFileName); - Timer timer = new Timer(); - timer.scheduleAtFixedRate(timerTask, 100, 5000L); - } -}
diff --git a/src/main/java/pta/de/core/controller/ServicesConfigCacheTimerTask.java b/src/main/java/pta/de/core/controller/ServicesConfigCacheTimerTask.java deleted file mode 100644 index 99ecee6..0000000 --- a/src/main/java/pta/de/core/controller/ServicesConfigCacheTimerTask.java +++ /dev/null
@@ -1,29 +0,0 @@ -package pta.de.core.controller; - -import org.apache.log4j.Logger; -import pta.de.core.exceptions.HttpStatusException; - -import java.util.TimerTask; - -public class ServicesConfigCacheTimerTask extends TimerTask { - private static final Logger logger = Logger.getLogger(ServicesConfigCacheTimerTask.class.getName()); - private String configFileName; - - public ServicesConfigCacheTimerTask( String configFileName ) { - this.configFileName = configFileName; - } - - - @Override - public void run() { - logger.debug("ServicesConfigCacheTimerTask started"); - - try { - ServicesConfigCache.getInstance().readServerDistribution(this.configFileName); - } catch (HttpStatusException e) { - logger.error("Error reading ServerDistributionFile", e); - } - - logger.debug("ServicesConfigCacheTimerTask finished"); - } -}
diff --git a/src/main/java/pta/de/core/exceptions/HttpStatusException.java b/src/main/java/pta/de/core/exceptions/HttpStatusException.java deleted file mode 100644 index 6b2c0cc..0000000 --- a/src/main/java/pta/de/core/exceptions/HttpStatusException.java +++ /dev/null
@@ -1,13 +0,0 @@ -package pta.de.core.exceptions; - -public class HttpStatusException extends Exception { - private final int httpStatus; - - public HttpStatusException(int httpStatus ) { - this.httpStatus = httpStatus; - } - - public int getHttpStatus() { - return httpStatus; - } -}
diff --git a/src/main/java/pta/de/health/ConfigFilePresentHealthCheck.java b/src/main/java/pta/de/health/ConfigFilePresentHealthCheck.java deleted file mode 100644 index e8de912..0000000 --- a/src/main/java/pta/de/health/ConfigFilePresentHealthCheck.java +++ /dev/null
@@ -1,19 +0,0 @@ -package pta.de.health; - -import com.codahale.metrics.health.HealthCheck; -import pta.de.api.ServiceDistributionCluster; -import pta.de.core.controller.ServicesConfigCache; - -public class ConfigFilePresentHealthCheck extends HealthCheck { - @Override - protected Result check() throws Exception { - ServiceDistributionCluster[] sdc = ServicesConfigCache.getInstance().getCache(); // Throws Exception if it fails - - if (sdc != null && sdc.length > 0) { - return Result.healthy(); - } - else { - return Result.unhealthy("No ServiceDistributionCluster available!"); - } - } -}
diff --git a/src/test/java/pta/de/MicsCentralApplicationTest.java b/src/test/java/org/eclipse/openK/MicsCentralApplicationTest.java similarity index 85% rename from src/test/java/pta/de/MicsCentralApplicationTest.java rename to src/test/java/org/eclipse/openK/MicsCentralApplicationTest.java index af299ca..9f4df5c 100644 --- a/src/test/java/pta/de/MicsCentralApplicationTest.java +++ b/src/test/java/org/eclipse/openK/MicsCentralApplicationTest.java
@@ -1,4 +1,16 @@ -package pta.de; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK; import com.codahale.metrics.health.HealthCheckRegistry; import io.dropwizard.jersey.setup.JerseyEnvironment;
diff --git a/src/test/java/pta/de/api/ServiceDistributionClusterTest.java b/src/test/java/org/eclipse/openK/api/ServiceDistributionClusterTest.java similarity index 86% rename from src/test/java/pta/de/api/ServiceDistributionClusterTest.java rename to src/test/java/org/eclipse/openK/api/ServiceDistributionClusterTest.java index 0efe76d..ff0b8f0 100644 --- a/src/test/java/pta/de/api/ServiceDistributionClusterTest.java +++ b/src/test/java/org/eclipse/openK/api/ServiceDistributionClusterTest.java
@@ -1,4 +1,16 @@ -package pta.de.api; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.api; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Test;
diff --git a/src/test/java/pta/de/api/ServiceRequestEnvelopeTest.java b/src/test/java/org/eclipse/openK/api/ServiceRequestEnvelopeTest.java similarity index 66% rename from src/test/java/pta/de/api/ServiceRequestEnvelopeTest.java rename to src/test/java/org/eclipse/openK/api/ServiceRequestEnvelopeTest.java index 6feece9..55e3e6f 100644 --- a/src/test/java/pta/de/api/ServiceRequestEnvelopeTest.java +++ b/src/test/java/org/eclipse/openK/api/ServiceRequestEnvelopeTest.java
@@ -1,8 +1,19 @@ -package pta.de.api; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.api; import org.glassfish.jersey.internal.util.Base64; import org.junit.Test; -import pta.de.api.ServiceRequestEnvelope.HttpHeader; import static junit.framework.TestCase.assertEquals; @@ -19,11 +30,11 @@ env.setUriFragment("Fraggel"); env.setServiceName("Salve"); - HttpHeader[] headers = new HttpHeader[2]; - headers[0] = new HttpHeader(); + ServiceRequestEnvelope.HttpHeader[] headers = new ServiceRequestEnvelope.HttpHeader[2]; + headers[0] = new ServiceRequestEnvelope.HttpHeader(); headers[0].setAttribute("1stAttr"); headers[0].setValue("1stValue"); - headers[1] = new HttpHeader(); + headers[1] = new ServiceRequestEnvelope.HttpHeader(); headers[1].setAttribute("2ndAttr"); headers[1].setValue("2ndValue"); env.setHeaders(headers);
diff --git a/src/test/java/org/eclipse/openK/api/VersionInfoTest.java b/src/test/java/org/eclipse/openK/api/VersionInfoTest.java new file mode 100644 index 0000000..26517c3 --- /dev/null +++ b/src/test/java/org/eclipse/openK/api/VersionInfoTest.java
@@ -0,0 +1,36 @@ +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.api; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Test; + +import java.io.IOException; + +import static org.junit.Assert.assertEquals; + +public class VersionInfoTest { + + @Test + public void testGetVersionInfo() throws IOException { + VersionInfo vi = new VersionInfo(); + vi.setBackendVersion("123"); + + ObjectMapper om = new ObjectMapper(); + String jsonString = om.writeValueAsString(vi); + + VersionInfo vi2 = om.readValue(jsonString, VersionInfo.class); + + assertEquals(vi.getBackendVersion(), vi2.getBackendVersion()); + } +}
diff --git a/src/test/java/pta/de/core/common/GsonUTCDateAdapterTest.java b/src/test/java/org/eclipse/openK/core/common/GsonUTCDateAdapterTest.java similarity index 76% rename from src/test/java/pta/de/core/common/GsonUTCDateAdapterTest.java rename to src/test/java/org/eclipse/openK/core/common/GsonUTCDateAdapterTest.java index a1bb423..efd4d3c 100644 --- a/src/test/java/pta/de/core/common/GsonUTCDateAdapterTest.java +++ b/src/test/java/org/eclipse/openK/core/common/GsonUTCDateAdapterTest.java
@@ -1,4 +1,16 @@ -package pta.de.core.common; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.common; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonElement;
diff --git a/src/test/java/org/eclipse/openK/core/common/util/ResourceLoaderBaseTest.java b/src/test/java/org/eclipse/openK/core/common/util/ResourceLoaderBaseTest.java new file mode 100644 index 0000000..976ac64 --- /dev/null +++ b/src/test/java/org/eclipse/openK/core/common/util/ResourceLoaderBaseTest.java
@@ -0,0 +1,27 @@ +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.common.util; + + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class ResourceLoaderBaseTest { + @Test + public void testloadStringFromResourceError() { + ResourceLoaderBase rlb = new ResourceLoaderBase(); + String str = rlb.loadStringFromResource("UNKNOWN_FILE"); + assertEquals("", str); + } +}
diff --git a/src/test/java/pta/de/core/controller/BackendControllerTest.java b/src/test/java/org/eclipse/openK/core/controller/BackendControllerTest.java similarity index 78% rename from src/test/java/pta/de/core/controller/BackendControllerTest.java rename to src/test/java/org/eclipse/openK/core/controller/BackendControllerTest.java index e13534f..d97234a 100644 --- a/src/test/java/pta/de/core/controller/BackendControllerTest.java +++ b/src/test/java/org/eclipse/openK/core/controller/BackendControllerTest.java
@@ -1,11 +1,23 @@ -package pta.de.core.controller; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.controller; import org.eclipse.jetty.http.HttpStatus; +import org.eclipse.openK.core.common.util.ResourceLoaderBase; import org.junit.Test; import org.powermock.reflect.Whitebox; -import pta.de.api.ServiceDistributionCluster; -import pta.de.core.common.util.ResourceLoaderBase; -import pta.de.core.exceptions.HttpStatusException; +import org.eclipse.openK.api.ServiceDistributionCluster; +import org.eclipse.openK.core.exceptions.HttpStatusException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
diff --git a/src/test/java/pta/de/core/controller/BaseWebServiceTest.java b/src/test/java/org/eclipse/openK/core/controller/BaseWebServiceTest.java similarity index 72% rename from src/test/java/pta/de/core/controller/BaseWebServiceTest.java rename to src/test/java/org/eclipse/openK/core/controller/BaseWebServiceTest.java index e6899e0..7deef09 100644 --- a/src/test/java/pta/de/core/controller/BaseWebServiceTest.java +++ b/src/test/java/org/eclipse/openK/core/controller/BaseWebServiceTest.java
@@ -1,10 +1,22 @@ -package pta.de.core.controller; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.controller; import org.eclipse.jetty.http.HttpStatus; +import org.eclipse.openK.core.common.util.ResourceLoaderBase; import org.junit.Test; import org.powermock.reflect.Whitebox; -import pta.de.core.common.util.ResourceLoaderBase; -import pta.de.core.exceptions.HttpStatusException; +import org.eclipse.openK.core.exceptions.HttpStatusException; import javax.ws.rs.core.Response;
diff --git a/src/test/java/pta/de/core/controller/DispatchControllerTest.java b/src/test/java/org/eclipse/openK/core/controller/DispatchControllerTest.java similarity index 81% rename from src/test/java/pta/de/core/controller/DispatchControllerTest.java rename to src/test/java/org/eclipse/openK/core/controller/DispatchControllerTest.java index b061565..9cc5507 100644 --- a/src/test/java/pta/de/core/controller/DispatchControllerTest.java +++ b/src/test/java/org/eclipse/openK/core/controller/DispatchControllerTest.java
@@ -1,16 +1,28 @@ -package pta.de.core.controller; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.controller; import org.easymock.EasyMock; import org.eclipse.jetty.http.HttpStatus; import org.junit.Before; import org.junit.Test; import org.powermock.reflect.Whitebox; -import pta.de.api.ServiceDistributionCluster; -import pta.de.api.ServiceRequestEnvelope; -import pta.de.core.common.JsonGeneratorBase; -import pta.de.core.common.util.ResourceLoaderBase; -import pta.de.core.communication.RestServiceWrapper; -import pta.de.core.exceptions.HttpStatusException; +import org.eclipse.openK.api.ServiceDistributionCluster; +import org.eclipse.openK.api.ServiceRequestEnvelope; +import org.eclipse.openK.core.common.JsonGeneratorBase; +import org.eclipse.openK.core.common.util.ResourceLoaderBase; +import org.eclipse.openK.core.communication.RestServiceWrapper; +import org.eclipse.openK.core.exceptions.HttpStatusException; import javax.ws.rs.core.Response;
diff --git a/src/test/java/pta/de/core/controller/ServicesConfigCacheTest.java b/src/test/java/org/eclipse/openK/core/controller/ServicesConfigCacheTest.java similarity index 74% rename from src/test/java/pta/de/core/controller/ServicesConfigCacheTest.java rename to src/test/java/org/eclipse/openK/core/controller/ServicesConfigCacheTest.java index b1b7772..3cf869b 100644 --- a/src/test/java/pta/de/core/controller/ServicesConfigCacheTest.java +++ b/src/test/java/org/eclipse/openK/core/controller/ServicesConfigCacheTest.java
@@ -1,11 +1,23 @@ -package pta.de.core.controller; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.controller; import org.eclipse.jetty.http.HttpStatus; import org.junit.Test; import org.powermock.reflect.Whitebox; -import pta.de.api.ServiceDistributionCluster; -import pta.de.core.common.util.ResourceLoaderBase; -import pta.de.core.exceptions.HttpStatusException; +import org.eclipse.openK.api.ServiceDistributionCluster; +import org.eclipse.openK.core.common.util.ResourceLoaderBase; +import org.eclipse.openK.core.exceptions.HttpStatusException; import static org.junit.Assert.assertEquals;
diff --git a/src/test/java/pta/de/core/controller/ServicesConfigCacheTimerTaskTest.java b/src/test/java/org/eclipse/openK/core/controller/ServicesConfigCacheTimerTaskTest.java similarity index 75% rename from src/test/java/pta/de/core/controller/ServicesConfigCacheTimerTaskTest.java rename to src/test/java/org/eclipse/openK/core/controller/ServicesConfigCacheTimerTaskTest.java index ca6e772..31c45c6 100644 --- a/src/test/java/pta/de/core/controller/ServicesConfigCacheTimerTaskTest.java +++ b/src/test/java/org/eclipse/openK/core/controller/ServicesConfigCacheTimerTaskTest.java
@@ -1,12 +1,24 @@ -package pta.de.core.controller; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.controller; import org.easymock.EasyMock; import org.eclipse.jetty.http.HttpStatus; +import org.eclipse.openK.core.exceptions.HttpStatusException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.powermock.reflect.Whitebox; -import pta.de.core.exceptions.HttpStatusException; import static org.easymock.EasyMock.*;
diff --git a/src/test/java/org/eclipse/openK/core/exceptions/HttpStatusExceptionTest.java b/src/test/java/org/eclipse/openK/core/exceptions/HttpStatusExceptionTest.java new file mode 100644 index 0000000..19589b2 --- /dev/null +++ b/src/test/java/org/eclipse/openK/core/exceptions/HttpStatusExceptionTest.java
@@ -0,0 +1,27 @@ +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.core.exceptions; + + +import org.eclipse.jetty.http.HttpStatus; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class HttpStatusExceptionTest { + @Test + public void testAll() { + HttpStatusException hse = new HttpStatusException( 200 ); + assertEquals(HttpStatus.OK_200, hse.getHttpStatus()); + } +}
diff --git a/src/test/java/pta/de/health/ConfigFilePresentHealthCheckTest.java b/src/test/java/org/eclipse/openK/health/ConfigFilePresentHealthCheckTest.java similarity index 69% rename from src/test/java/pta/de/health/ConfigFilePresentHealthCheckTest.java rename to src/test/java/org/eclipse/openK/health/ConfigFilePresentHealthCheckTest.java index d8798dc..f33c91e 100644 --- a/src/test/java/pta/de/health/ConfigFilePresentHealthCheckTest.java +++ b/src/test/java/org/eclipse/openK/health/ConfigFilePresentHealthCheckTest.java
@@ -1,10 +1,22 @@ -package pta.de.health; +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.health; import com.codahale.metrics.health.HealthCheck; +import org.eclipse.openK.api.ServiceDistributionCluster; +import org.eclipse.openK.core.controller.ServicesConfigCache; import org.junit.Test; import org.powermock.reflect.Whitebox; -import pta.de.api.ServiceDistributionCluster; -import pta.de.core.controller.ServicesConfigCache; import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertTrue;
diff --git a/src/test/java/org/eclipse/openK/resources/MicsCentralResourceTest.java b/src/test/java/org/eclipse/openK/resources/MicsCentralResourceTest.java new file mode 100644 index 0000000..ffecb61 --- /dev/null +++ b/src/test/java/org/eclipse/openK/resources/MicsCentralResourceTest.java
@@ -0,0 +1,39 @@ +/** +****************************************************************************** +* Copyright © 2018 PTA GmbH. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* +* http://www.eclipse.org/legal/epl-v10.html +* +****************************************************************************** +*/ + +package org.eclipse.openK.resources; + +import org.eclipse.jetty.http.HttpStatus; +import org.eclipse.openK.core.controller.ServicesConfigCache; +import org.eclipse.openK.core.exceptions.HttpStatusException; +import org.junit.Test; + +import javax.ws.rs.core.Response; + +import static junit.framework.TestCase.assertNotNull; +import static org.junit.Assert.assertEquals; + +public class MicsCentralResourceTest { + @Test + public void testGetVersionInfo() { + Response r = new MicsCentralResource().getVersionInfo(); + assertNotNull( r ); + } + + @Test + public void testGetServiceDistribution() throws HttpStatusException { + ServicesConfigCache.getInstance().readServerDistribution("servicesDistributionDevLocal.json"); + Response r = new MicsCentralResource().getServiceDistribution("elogbook.openK" ); + + assertEquals(HttpStatus.OK_200, r.getStatus()); + } +}
diff --git a/src/test/java/pta/de/api/VersionInfoTest.java b/src/test/java/pta/de/api/VersionInfoTest.java deleted file mode 100644 index e537f9f..0000000 --- a/src/test/java/pta/de/api/VersionInfoTest.java +++ /dev/null
@@ -1,24 +0,0 @@ -package pta.de.api; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; - -import java.io.IOException; - -import static org.junit.Assert.assertEquals; - -public class VersionInfoTest { - - @Test - public void testGetVersionInfo() throws IOException { - VersionInfo vi = new VersionInfo(); - vi.setBackendVersion("123"); - - ObjectMapper om = new ObjectMapper(); - String jsonString = om.writeValueAsString(vi); - - VersionInfo vi2 = om.readValue(jsonString, VersionInfo.class); - - assertEquals(vi.getBackendVersion(), vi2.getBackendVersion()); - } -}
diff --git a/src/test/java/pta/de/core/common/util/ResourceLoaderBaseTest.java b/src/test/java/pta/de/core/common/util/ResourceLoaderBaseTest.java deleted file mode 100644 index c56e0bd..0000000 --- a/src/test/java/pta/de/core/common/util/ResourceLoaderBaseTest.java +++ /dev/null
@@ -1,15 +0,0 @@ -package pta.de.core.common.util; - - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class ResourceLoaderBaseTest { - @Test - public void testloadStringFromResourceError() { - ResourceLoaderBase rlb = new ResourceLoaderBase(); - String str = rlb.loadStringFromResource("UNKNOWN_FILE"); - assertEquals("", str); - } -}
diff --git a/src/test/java/pta/de/core/exceptions/HttpStatusExceptionTest.java b/src/test/java/pta/de/core/exceptions/HttpStatusExceptionTest.java deleted file mode 100644 index 51e5fad..0000000 --- a/src/test/java/pta/de/core/exceptions/HttpStatusExceptionTest.java +++ /dev/null
@@ -1,15 +0,0 @@ -package pta.de.core.exceptions; - - -import org.eclipse.jetty.http.HttpStatus; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class HttpStatusExceptionTest { - @Test - public void testAll() { - HttpStatusException hse = new HttpStatusException( 200 ); - assertEquals(HttpStatus.OK_200, hse.getHttpStatus()); - } -}
diff --git a/src/test/java/pta/de/resources/MicsCentralResourceTest.java b/src/test/java/pta/de/resources/MicsCentralResourceTest.java deleted file mode 100644 index 3562fd1..0000000 --- a/src/test/java/pta/de/resources/MicsCentralResourceTest.java +++ /dev/null
@@ -1,27 +0,0 @@ -package pta.de.resources; - -import org.eclipse.jetty.http.HttpStatus; -import org.junit.Test; -import pta.de.core.controller.ServicesConfigCache; -import pta.de.core.exceptions.HttpStatusException; - -import javax.ws.rs.core.Response; - -import static junit.framework.TestCase.assertNotNull; -import static org.junit.Assert.assertEquals; - -public class MicsCentralResourceTest { - @Test - public void testGetVersionInfo() { - Response r = new MicsCentralResource().getVersionInfo(); - assertNotNull( r ); - } - - @Test - public void testGetServiceDistribution() throws HttpStatusException { - ServicesConfigCache.getInstance().readServerDistribution("servicesDistributionDevLocal.json"); - Response r = new MicsCentralResource().getServiceDistribution("elogbook.openK" ); - - assertEquals(HttpStatus.OK_200, r.getStatus()); - } -}