CC
diff --git a/src/test/java/pta/de/core/common/util/JsonGeneratorBaseTest.java b/src/test/java/pta/de/core/common/util/JsonGeneratorBaseTest.java
new file mode 100644
index 0000000..e678739
--- /dev/null
+++ b/src/test/java/pta/de/core/common/util/JsonGeneratorBaseTest.java
@@ -0,0 +1,61 @@
+package pta.de.core.common.util;
+
+import org.junit.Test;
+import pta.de.core.common.JsonGeneratorBase;
+
+import java.util.Date;
+
+import static org.junit.Assert.assertEquals;
+
+public class JsonGeneratorBaseTest extends ResourceLoaderBase {
+ public static class TestPojo {
+ private String name;
+ private int number;
+ private Date date;
+
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ }
+
+ @Test
+ public void testInputOutput() {
+ Date now = new Date(System.currentTimeMillis());
+ TestPojo pojo = new TestPojo();
+ pojo.setDate(now);
+ pojo.setName("Haferkamp");
+ pojo.setNumber(6758);
+
+ String jsonString = JsonGeneratorBase.getGson().toJson(pojo);
+
+ TestPojo pojoIncoming = JsonGeneratorBase.getGson().fromJson(jsonString, TestPojo.class);
+
+ assertEquals(pojo.getDate(), pojoIncoming.getDate());
+ assertEquals(pojo.getName(), pojoIncoming.getName());
+ assertEquals(pojo.getNumber(), pojoIncoming.getNumber());
+ }
+
+
+}
diff --git a/src/test/java/pta/de/core/controller/ServicesConfigCacheTest.java b/src/test/java/pta/de/core/controller/ServicesConfigCacheTest.java
index 3416583..95ae466 100644
--- a/src/test/java/pta/de/core/controller/ServicesConfigCacheTest.java
+++ b/src/test/java/pta/de/core/controller/ServicesConfigCacheTest.java
@@ -17,13 +17,7 @@
String json = resourceLoaderBase.loadStringFromResource(jsonFile);
ServicesConfigCache scc = ServicesConfigCache.getInstance();
-
-
-
- ServiceDistributionCluster[] sdc = (ServiceDistributionCluster[])
- Whitebox.invokeMethod(scc,"readServerDistributionFromText", json);
-
- return sdc;
+ return Whitebox.invokeMethod(scc, "readServerDistributionFromText", json);
}
@Test
@@ -45,4 +39,23 @@
}
}
+ @Test
+ public void testReadServerDistribution_FileNotExist() throws Exception {
+ try {
+ baseTestReadServerDistribution("Nowhere.json");
+ } catch (HttpStatusException e) {
+ assertEquals(e.getHttpStatus(), HttpStatus.INTERNAL_SERVER_ERROR_500);
+ }
+ }
+
+ @Test
+ public void testReadServerDistribution_FileNotExistEither() throws Exception {
+ try {
+ ServicesConfigCache.getInstance().readServerDistribution("Nowhere.json");
+ } catch (HttpStatusException e) {
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR_500, e.getHttpStatus());
+ }
+ }
+
+
}