changeset 235:3fed9a0827ac

Pull system integration tests into common class Reviewed-by: stooke Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-August/024434.html
author Chris Lessard <clessard@redhat.com>
date Tue, 29 Aug 2017 11:31:10 -0400
parents 0e22b21cfe6c
children 082ffd8bc95a
files tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/system/SystemIntegrationTestSuites.java tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/system/cpu/SystemCPUIntegrationTest.java tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/system/memory/SystemMemoryIntegrationTest.java tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/system/network/SystemNetworkIntegrationTest.java tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/systems/SystemInfoIntegrationTest.java tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/tests/integration/SystemIntegrationTest.java
diffstat 6 files changed, 511 insertions(+), 617 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/system/SystemIntegrationTestSuites.java	Tue Aug 29 11:31:10 2017 -0400
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2012-2017 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.gateway.service.system;
+
+import org.eclipse.jetty.client.api.ContentResponse;
+import org.eclipse.jetty.http.HttpMethod;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import static org.junit.Assert.assertEquals;
+
+import com.redhat.thermostat.gateway.tests.integration.SystemIntegrationTest;
+
+public abstract class SystemIntegrationTestSuites<T> extends SystemIntegrationTest<T> {
+
+
+    protected static final String TIMESTAMP_TOKEN = "$TIMESTAMP$";
+    protected static final String AGENT_ID = getRandomSystemId();
+
+    private String systemId;
+    private String serviceURL;
+
+    protected SystemIntegrationTestSuites(String serviceUrl, String collectionName) {
+        super(serviceUrl, collectionName);
+        this.serviceURL = serviceUrl;
+        this.collectionName = collectionName;
+    }
+
+    protected abstract String createJSONTimeStamp(final long ts);
+
+    protected abstract List<T> parse(ContentResponse contentResponse, final String expectedsystemId);
+
+    @Before
+    public void setupSystemId() {
+        this.systemId = getRandomSystemId();
+        this.timeStamp = getTimeStamp();
+    }
+
+    @Test
+    public void testGetAll() throws InterruptedException, TimeoutException, ExecutionException {
+
+        for (int i = 0; i < 3; i++) {
+            post(systemId);
+        }
+
+        ContentResponse response = get(systemId);
+        final List<T> list = parse(response, systemId);
+        assertEquals(1, list.size());
+
+        ContentResponse response2 = get(systemId, "?limit=2");
+        final List<T> list2 = parse(response2, systemId);
+        assertEquals(2, list2.size());
+
+        ContentResponse response3 = get(systemId, "?limit=0");
+        final List<T> list3 = parse(response3, systemId);
+        assertEquals(3, list3.size());
+    }
+
+    @Test
+    public void testGetAllFails() throws InterruptedException, TimeoutException, ExecutionException {
+        ContentResponse response = client.newRequest(serviceURL).method(HttpMethod.GET).send();
+        assertEquals(HTTP_404_NOTFOUND, response.getStatus());
+    }
+
+    @Test
+    public void testGetUnknown() throws InterruptedException, TimeoutException, ExecutionException {
+        final String systemId = getRandomSystemId();
+        getUnknown(systemId);
+    }
+
+    @Test
+    public void testCreateOne() throws InterruptedException, TimeoutException, ExecutionException {
+        final String systemId = getRandomSystemId();
+        post(systemId);
+        getKnown(systemId);
+    }
+
+    @Test
+    public void testPutModifiesData() throws InterruptedException, TimeoutException, ExecutionException {
+        final long timestamp = getTimeStamp();
+
+        post(systemId);
+        final ContentResponse response1 = getKnown(systemId);
+        final List<T> list1 = parse(response1, systemId);
+        assertEquals(1, list1.size());
+
+        put(systemId, timestamp+1);
+
+        final ContentResponse response2 = getKnown(systemId);
+        final List<T> list2 = parse(response2, systemId);
+        assertEquals(1, list2.size());
+    }
+
+    @Test
+    public void testDeleteUnknown() throws InterruptedException, TimeoutException, ExecutionException {
+        delete(systemId);
+    }
+
+    @Test
+    public void testDeleteOne() throws InterruptedException, ExecutionException, TimeoutException {
+        post(systemId);
+        getKnown(systemId);
+        delete(systemId);
+        getUnknown(systemId);
+    }
+}
--- a/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/system/cpu/SystemCPUIntegrationTest.java	Fri Aug 25 09:59:56 2017 -0400
+++ b/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/system/cpu/SystemCPUIntegrationTest.java	Tue Aug 29 11:31:10 2017 -0400
@@ -36,38 +36,29 @@
 
 package com.redhat.thermostat.gateway.service.system.cpu;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import org.eclipse.jetty.client.api.ContentResponse;
+import org.junit.Test;
+
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
-
-import com.redhat.thermostat.gateway.tests.integration.MongoIntegrationTest;
-import com.redhat.thermostat.gateway.tests.integration.VersionTestUtil;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.util.StringContentProvider;
-import org.eclipse.jetty.http.HttpHeader;
-import org.eclipse.jetty.http.HttpMethod;
-import org.junit.Test;
+import com.redhat.thermostat.gateway.service.system.SystemIntegrationTestSuites;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class SystemCPUIntegrationTest extends MongoIntegrationTest {
+public class SystemCPUIntegrationTest extends SystemIntegrationTestSuites<SystemCPUIntegrationTest.TinyCPUInfo> {
 
     private static final String collectionName = "cpu-info";
     private static final String versionString = "0.0.1";
     private static final String serviceURL = baseUrl + "/system-cpu/" + versionString;
-    private static final int HTTP_200_OK = 200;
-    private static final int HTTP_404_NOTFOUND = 404;
-    private static final String TIMESTAMP_TOKEN = "$TIMESTAMP$";
-    private static final String AGENT_ID = getRandomSystemId();
+
     private static final String cpuInfoJSON =
             "{\n" +
             "    \"perProcessorUsage\" : [ \n" +
@@ -81,133 +72,36 @@
             "}";
 
 
-    private static class TinyCPUInfo {
+    static class TinyCPUInfo {
+        private String agentId;
+        private String systemId;
+        private int[] perProcessorUsage;
+
         TinyCPUInfo(String systemId, String agentId, int[] ppusage) {
             this.systemId = systemId;
             this.agentId = agentId;
             this.perProcessorUsage = ppusage;
         }
-        String agentId;
-        String systemId;
-        int[] perProcessorUsage;
+
+        public String getAgentId() {
+            return agentId;
+        }
+
+        public String getSystemId() {
+            return systemId;
+        }
     }
 
     public SystemCPUIntegrationTest() {
         super(serviceURL, collectionName);
     }
 
-    @Test
-    public void testGetAll() throws InterruptedException, TimeoutException, ExecutionException {
-        final String systemid = getRandomSystemId();
-
-        post(systemid);
-        Thread.sleep(5);
-        post(systemid);
-        Thread.sleep(5);
-        post(systemid);
-
-        ContentResponse response = get(systemid);
-        final List<TinyCPUInfo> list = parse(response, systemid);
-        assertEquals(1, list.size());
-
-        ContentResponse response2 = get(systemid, "?limit=2");
-        final List<TinyCPUInfo> list2 = parse(response2, systemid);
-        assertEquals(2, list2.size());
-
-        ContentResponse response3 = get(systemid, "?limit=0");
-        final List<TinyCPUInfo> list3 = parse(response3, systemid);
-        assertEquals(3, list3.size());
-    }
-
-    @Test
-    public void testGetAllFails() throws InterruptedException, TimeoutException, ExecutionException {
-        ContentResponse response = client.newRequest(serviceURL).method(HttpMethod.GET).send();
-        assertEquals(HTTP_404_NOTFOUND, response.getStatus());
-    }
-
-    @Test
-    public void testGetUnknown() throws InterruptedException, TimeoutException, ExecutionException {
-        final String systemid = getRandomSystemId();
-        getUnknown(systemid);
-    }
-
-    @Test
-    public void testCreateOne() throws InterruptedException, TimeoutException, ExecutionException {
-
-        final String systemid = getRandomSystemId();
-        post(systemid);
-        getKnown(systemid);
+    @Override
+    protected String createJSONTimeStamp(long ts) {
+        return cpuInfoJSON.replace(TIMESTAMP_TOKEN, Long.toString(ts));
     }
 
-    @Test
-    public void testPut() throws InterruptedException, TimeoutException, ExecutionException {
-
-        final String systemid = getRandomSystemId();
-        final long timestamp = getTimestamp();
-
-        // create it
-        post(systemid);
-
-        // retrieve it
-        final ContentResponse response1 = getKnown(systemid);
-        final List<TinyCPUInfo> list1 = parse(response1, systemid);
-        assertEquals(1, list1.size());
-        //assertEquals(CPU_STRING1, list1.get(0).cpuModel);
-
-        // modify it
-        put(systemid, timestamp+1);
-
-        // ensure it was changed
-        final ContentResponse response2 = getKnown(systemid);
-        final List<TinyCPUInfo> list2 = parse(response2, systemid);
-        assertEquals(1, list2.size());
-        //assertEquals(timestamp+1, list2.get(0).????);
-    }
-
-    @Test
-    public void testDeleteUnknown() throws InterruptedException, TimeoutException, ExecutionException {
-        final String systemid = getRandomSystemId();
-
-        // delete it
-        delete(systemid);
-    }
-
-    @Test
-    public void testDeleteOne() throws InterruptedException, ExecutionException, TimeoutException {
-        final String systemid = getRandomSystemId();
-
-        // create the new record
-        post(systemid);
-
-        // check that it's there
-        getKnown(systemid);
-
-        // delete it
-        delete(systemid);
-
-        // check that it's not there
-        getUnknown(systemid);
-    }
-
-    @Test
-    public void testVersions() throws Exception {
-        final String systemid = getRandomSystemId();
-        post(systemid);
-        VersionTestUtil.testAllVersions(baseUrl + "/system-cpu", versionString, "/systems/" + systemid);
-    }
-
-    private ContentResponse post(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        final Request request = client.newRequest(serviceURL + "/systems/" + systemid);
-        request.header(HttpHeader.CONTENT_TYPE, "application/json");
-        request.content(new StringContentProvider("[" + createJSON() + "]"));
-        ContentResponse response = request.method(HttpMethod.POST).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        final String expected = "";
-        assertEquals(expected, response.getContentAsString());
-        return response;
-    }
-
-    private List<TinyCPUInfo> parse(ContentResponse contentResponse, final String expectedSystemId) {
+    protected List<TinyCPUInfo> parse(ContentResponse contentResponse, final String expectedSystemId) {
 
         JsonParser parser = new JsonParser();
         JsonObject json = (JsonObject) parser.parse(contentResponse.getContentAsString());
@@ -253,65 +147,39 @@
         return result;
     }
 
-    private ContentResponse put(final String systemid, final long ts) throws InterruptedException, ExecutionException, TimeoutException {
-        final Request request = client.newRequest(serviceURL + "/systems/" + systemid);
-        request.header(HttpHeader.CONTENT_TYPE, "application/json");
-        final String contentStr = createJSON(ts);
-        request.content(new StringContentProvider("{ \"set\" : " +contentStr + "}"));
-        ContentResponse response = request.method(HttpMethod.PUT).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        final String expected = "";
-        assertEquals(expected, response.getContentAsString());
-        return response;
+    @Test
+    public void testSystemCPUGetAll() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testGetAll();
     }
 
-    private ContentResponse getUnknown(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = get(systemid);
-        assertTrue(parse(response, systemid).isEmpty());
-        return response;
+    @Test
+    public void testSystemCPUGetAllFails() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testGetAllFails();
     }
 
-    private ContentResponse getKnown(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = get(systemid);
-        assertEquals(1, parse(response, systemid).size());
-        return response;
-    }
-
-    private ContentResponse get(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = client.newRequest(serviceURL + "/systems/" + systemid).method(HttpMethod.GET).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        return response;
+    @Test
+    public void testSystemCPUGetUnknown() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testGetUnknown();
     }
 
-    private ContentResponse get(final String systemid, final String query) throws InterruptedException, ExecutionException, TimeoutException {
-        final Request rq = client.newRequest(serviceURL + "/systems/" + systemid + query);
-        rq.method(HttpMethod.GET);
-        ContentResponse response = rq.send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        return response;
+    @Test
+    public void testSystemCPUCreateOne() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testCreateOne();
     }
 
-    private ContentResponse delete(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = client.newRequest(serviceURL + "/systems/" + systemid).method(HttpMethod.DELETE).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        final String expected = "";
-        assertEquals(expected, response.getContentAsString());
-        return response;
+    @Test
+    public void testSystemCPUPutModifiesData() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testPutModifiesData();
     }
 
-    private static String getRandomSystemId() {
-        return UUID.randomUUID().toString();
-    }
-
-    private static long getTimestamp() {
-        return java.lang.System.nanoTime();
+    @Test
+    public void testSystemCPUDeleteUnknown() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testDeleteUnknown();
     }
 
-    private String createJSON() {
-        return createJSON(getTimestamp());
+    @Test
+    public void testSystemCPUDeleteOne() throws InterruptedException, ExecutionException, TimeoutException {
+        super.testDeleteOne();
     }
 
-    private String createJSON(final long ts) {
-        return cpuInfoJSON.replace(TIMESTAMP_TOKEN, Long.toString(ts));
-    }
 }
--- a/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/system/memory/SystemMemoryIntegrationTest.java	Fri Aug 25 09:59:56 2017 -0400
+++ b/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/system/memory/SystemMemoryIntegrationTest.java	Tue Aug 29 11:31:10 2017 -0400
@@ -36,40 +36,32 @@
 
 package com.redhat.thermostat.gateway.service.system.memory;
 
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import org.eclipse.jetty.client.api.ContentResponse;
+import org.junit.Test;
+
+import com.google.gson.Gson;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
-
-import com.redhat.thermostat.gateway.tests.integration.MongoIntegrationTest;
+import com.redhat.thermostat.gateway.service.system.SystemIntegrationTestSuites;
 import com.redhat.thermostat.gateway.tests.integration.VersionTestUtil;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.util.StringContentProvider;
-import org.eclipse.jetty.http.HttpHeader;
-import org.eclipse.jetty.http.HttpMethod;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 
 
-public class SystemMemoryIntegrationTest extends MongoIntegrationTest {
+public class SystemMemoryIntegrationTest extends SystemIntegrationTestSuites<SystemMemoryIntegrationTest.TinyMemoryInfo> {
     
     private static final String collectionName = "memory-info";
     private static final String versionString = "0.0.1";
     private static final String serviceURL = baseUrl + "/system-memory/" + versionString;
-    private static final int HTTP_200_OK = 200;
-    private static final int HTTP_404_NOTFOUND = 404;
     private static final String TIMESTAMP_TOKEN = "$TIMESTAMP$";
     private static final String AGENT_ID = getRandomSystemId();
-    private static long timeStamp = java.lang.System.nanoTime();
     private static final String memInfoJSON =
             "{\n" +
             "    \"total\" : 12566220800,\n" +
@@ -83,7 +75,13 @@
             "    \"agentId\" : \"" + AGENT_ID + "\",\n" +
             "}";
 
-    private static class TinyMemoryInfo {
+    static class TinyMemoryInfo {
+        private String agentId;
+        private String systemId;
+        private long total;
+        private long free;
+        private long buffers;
+
         TinyMemoryInfo(String systemId, String agentId, long total, long free, long buffers) {
             this.systemId = systemId;
             this.agentId = agentId;
@@ -91,11 +89,14 @@
             this.free = free;
             this.buffers = buffers;
         }
-        String agentId;
-        String systemId;
-        long total;
-        long free;
-        long buffers;
+
+        public String getAgentId() {
+            return agentId;
+        }
+
+        public String getSystemId() {
+            return systemId;
+        }
     }
 
     public SystemMemoryIntegrationTest() {
@@ -103,113 +104,12 @@
     }
 
     @Test
-    public void testGetAll() throws InterruptedException, TimeoutException, ExecutionException {
-
-        final String systemid = getRandomSystemId();
-
-        post(systemid);
-        post(systemid);
-        post(systemid);
-
-        ContentResponse response = get(systemid);
-        final List<TinyMemoryInfo> list = parse(response, systemid);
-        assertEquals(1, list.size());
-
-        ContentResponse response2 = get(systemid, "?limit=2");
-        final List<TinyMemoryInfo> list2 = parse(response2, systemid);
-        assertEquals(2, list2.size());
-
-        ContentResponse response3 = get(systemid, "?limit=0");
-        final List<TinyMemoryInfo> list3 = parse(response3, systemid);
-        assertEquals(3, list3.size());
-    }
-
-    @Test
-    public void testGetAllFails() throws InterruptedException, TimeoutException, ExecutionException {
-        ContentResponse response = client.newRequest(serviceURL).method(HttpMethod.GET).send();
-        assertEquals(HTTP_404_NOTFOUND, response.getStatus());
-    }
-
-    @Test
-    public void testGetUnknown() throws InterruptedException, TimeoutException, ExecutionException {
-        final String systemid = getRandomSystemId();
-        getUnknown(systemid);
-    }
-
-    @Test
-    public void testCreateOne() throws InterruptedException, TimeoutException, ExecutionException {
-
-        final String systemid = getRandomSystemId();
-        post(systemid);
-        getKnown(systemid);
-    }
-
-    @Test
-    public void testPut() throws InterruptedException, TimeoutException, ExecutionException {
-
-        final String systemid = getRandomSystemId();
-        final long timestamp = getTimestamp();
-
-        // create it
-        post(systemid);
-
-        // retrieve it
-        final ContentResponse response1 = getKnown(systemid);
-        final List<TinyMemoryInfo> list1 = parse(response1, systemid);
-        assertEquals(1, list1.size());
-
-        // modify it
-        put(systemid, timestamp+1);
-
-        // ensure it was changed
-        final ContentResponse response2 = getKnown(systemid);
-        final List<TinyMemoryInfo> list2 = parse(response2, systemid);
-        assertEquals(1, list2.size());
-    }
-
-    @Test
-    public void testDeleteUnknown() throws InterruptedException, TimeoutException, ExecutionException {
-        final String systemid = getRandomSystemId();
-
-        // delete it
-        delete(systemid);
-    }
-
-    @Test
-    public void testDeleteOne() throws InterruptedException, ExecutionException, TimeoutException {
-        final String systemid = getRandomSystemId();
-
-        // create the new record
-        post(systemid);
-
-        // check that it's there
-        getKnown(systemid);
-
-        // delete it
-        delete(systemid);
-
-        // check that it's not there
-        getUnknown(systemid);
-    }
-
-    @Test
     public void testVersions() throws Exception {
-        final String systemid = getRandomSystemId();
+        final String systemid = super.getRandomSystemId();
         post(systemid);
         VersionTestUtil.testAllVersions(baseUrl + "/system-memory", versionString, "/systems/" + systemid);
     }
 
-    private ContentResponse post(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        final Request request = client.newRequest(serviceURL + "/systems/" + systemid);
-        request.header(HttpHeader.CONTENT_TYPE, "application/json");
-        request.content(new StringContentProvider("[" + createJSON() + "]"));
-        ContentResponse response = request.method(HttpMethod.POST).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        final String expected = "";
-        assertEquals(expected, response.getContentAsString());
-        return response;
-    }
-
     private static long getLong(JsonObject json, final String id) {
         JsonElement el = json.get(id);
         if (el.isJsonObject()) {
@@ -220,105 +120,68 @@
         }
     }
 
-    private List<TinyMemoryInfo> parse(ContentResponse contentResponse, final String expectedSystemId) {
+    @Override
+    protected List<TinyMemoryInfo> parse(ContentResponse contentResponse, final String expectedSystemId) {
+        List<SystemMemoryIntegrationTest.TinyMemoryInfo> result = new ArrayList<>();
 
         JsonParser parser = new JsonParser();
         JsonObject json = (JsonObject) parser.parse(contentResponse.getContentAsString());
         JsonElement response = json.get("response");
 
         JsonArray allData = response.getAsJsonArray();
-        List<TinyMemoryInfo> result = new ArrayList<>();
-
-        for (JsonElement entry : allData) {
-
-            json = (JsonObject) parser.parse(entry.toString());
 
-            assertTrue(json.has("systemId"));
-            assertTrue(json.has("agentId"));
-            assertTrue(json.has("timeStamp"));
-            assertTrue(json.has("total"));
-            assertTrue(json.has("free"));
-            assertTrue(json.has("buffers"));
+        Gson gson = new Gson();
+        for (JsonElement entry : allData) {
+            TinyMemoryInfo TinyMemoryEntry = gson.fromJson(entry.toString(), TinyMemoryInfo.class);
 
-            final String systemId = json.get("systemId").getAsString();
-            final String agentId = json.get("agentId").getAsString();
-            //final long timeStamp = getLong(json, "timeStamp");
-            final long total = getLong(json, "total");
-            final long free = getLong(json, "free");
-            final long bufsiz = getLong(json, "buffers");
-
-            assertEquals(AGENT_ID, agentId);
+            assertEquals(AGENT_ID, TinyMemoryEntry.getAgentId());
             if (expectedSystemId != null) {
-                assertEquals(expectedSystemId, systemId);
+                assertEquals(expectedSystemId, TinyMemoryEntry.getSystemId());
             }
 
-            TinyMemoryInfo hi = new TinyMemoryInfo(systemId, agentId, total, free, bufsiz);
+            result.add(TinyMemoryEntry);
+        }
 
-            result.add(hi);
-        }
         return result;
     }
 
-    private ContentResponse put(final String systemid, final long ts) throws InterruptedException, ExecutionException, TimeoutException {
-        final Request request = client.newRequest(serviceURL + "/systems/" + systemid);
-        request.header(HttpHeader.CONTENT_TYPE, "application/json");
-        final String contentStr = createJSON(ts);
-        request.content(new StringContentProvider("{ \"set\" : " +contentStr + "}"));
-        ContentResponse response = request.method(HttpMethod.PUT).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        final String expected = "";
-        assertEquals(expected, response.getContentAsString());
-        return response;
+    @Override
+    protected String createJSONTimeStamp(final long ts) {
+        return memInfoJSON.replace(TIMESTAMP_TOKEN, Long.toString(ts));
     }
 
-    private ContentResponse getUnknown(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = get(systemid);
-        assertTrue(parse(response, systemid).isEmpty());
-        return response;
+    @Test
+    public void testSystemMemoryGetAll() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testGetAll();
     }
 
-    private ContentResponse getKnown(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = get(systemid);
-        assertEquals(1, parse(response, systemid).size());
-        return response;
+    @Test
+    public void testSystemMemoryGetAllFails() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testGetAllFails();
     }
 
-    private ContentResponse get(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = client.newRequest(serviceURL + "/systems/" + systemid).method(HttpMethod.GET).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        return response;
+    @Test
+    public void testSystemMemoryGetUnknown() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testGetUnknown();
     }
 
-    private ContentResponse get(final String systemid, final String query) throws InterruptedException, ExecutionException, TimeoutException {
-        final Request rq = client.newRequest(serviceURL + "/systems/" + systemid + query);
-        rq.method(HttpMethod.GET);
-        ContentResponse response = rq.send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        return response;
+    @Test
+    public void testSystemMemoryCreateOne() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testCreateOne();
     }
 
-    private ContentResponse delete(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = client.newRequest(serviceURL + "/systems/" + systemid).method(HttpMethod.DELETE).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        final String expected = "";
-        assertEquals(expected, response.getContentAsString());
-        return response;
+    @Test
+    public void testSystemMemoryPutModifiesData() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testPutModifiesData();
     }
 
-    private static String getRandomSystemId() {
-        return UUID.randomUUID().toString();
-    }
-
-    private static long getTimestamp() {
-        timeStamp += 1;
-        return timeStamp;
+    @Test
+    public void testSystemMemoryDeleteUnknown() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testDeleteUnknown();
     }
 
-    private String createJSON() {
-        return createJSON(getTimestamp());
-    }
-
-    private String createJSON(final long ts) {
-        return memInfoJSON.replace(TIMESTAMP_TOKEN, Long.toString(ts));
+    @Test
+    public void testSystemMemoryDeleteOne() throws InterruptedException, ExecutionException, TimeoutException {
+        super.testDeleteOne();
     }
 }
--- a/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/system/network/SystemNetworkIntegrationTest.java	Fri Aug 25 09:59:56 2017 -0400
+++ b/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/system/network/SystemNetworkIntegrationTest.java	Tue Aug 29 11:31:10 2017 -0400
@@ -36,38 +36,28 @@
 
 package com.redhat.thermostat.gateway.service.system.network;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import org.eclipse.jetty.client.api.ContentResponse;
+import org.junit.Test;
+
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
-import com.redhat.thermostat.gateway.tests.integration.MongoIntegrationTest;
-import com.redhat.thermostat.gateway.tests.integration.VersionTestUtil;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.util.StringContentProvider;
-import org.eclipse.jetty.http.HttpHeader;
-import org.eclipse.jetty.http.HttpMethod;
-import org.junit.Test;
+import com.redhat.thermostat.gateway.service.system.SystemIntegrationTestSuites;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class SystemNetworkIntegrationTest extends MongoIntegrationTest {
+public class SystemNetworkIntegrationTest extends SystemIntegrationTestSuites<SystemNetworkIntegrationTest.TinyNetworkInfo> {
 
     private static final String collectionName = "network-info";
     private static final String versionString = "0.0.1";
     private static final String serviceURL = baseUrl + "/system-network/" + versionString;
-    private static final int HTTP_200_OK = 200;
-    private static final int HTTP_404_NOTFOUND = 404;
-    private static final String TIMESTAMP_TOKEN = "$TIMESTAMP$";
-    private static final String AGENT_ID = getRandomSystemId();
-    private static long timeStamp = java.lang.System.nanoTime();
     private static final String memInfoJSON =
             "{\n" +
                     "   \"timeStamp\" : " + TIMESTAMP_TOKEN + ",\n" +
@@ -86,128 +76,28 @@
                     "   ]\n" +
                     "}\n";
 
-    private static class TineyNetworkInfo {
-        TineyNetworkInfo(String systemId, String agentId) {
+    static class TinyNetworkInfo {
+        private String agentId;
+        private String systemId;
+
+        TinyNetworkInfo(String systemId, String agentId) {
             this.systemId = systemId;
             this.agentId = agentId;
         }
-        String agentId;
-        String systemId;
+
+        public String getAgentId() {
+            return agentId;
+        }
+
+        public String getSystemId() {
+            return systemId;
+        }
     }
 
     public SystemNetworkIntegrationTest() {
         super(serviceURL, collectionName);
     }
 
-    @Test
-    public void testGetAll() throws InterruptedException, TimeoutException, ExecutionException {
-
-        final String systemid = getRandomSystemId();
-
-        post(systemid);
-        post(systemid);
-        post(systemid);
-
-        ContentResponse response = get(systemid);
-        final List<TineyNetworkInfo> list = parse(response, systemid);
-        assertEquals(1, list.size());
-
-        ContentResponse response2 = get(systemid, "?limit=2");
-        final List<TineyNetworkInfo> list2 = parse(response2, systemid);
-        assertEquals(2, list2.size());
-
-        ContentResponse response3 = get(systemid, "?limit=0");
-        final List<TineyNetworkInfo> list3 = parse(response3, systemid);
-        assertEquals(3, list3.size());
-    }
-
-    @Test
-    public void testGetAllFails() throws InterruptedException, TimeoutException, ExecutionException {
-        ContentResponse response = client.newRequest(serviceURL).method(HttpMethod.GET).send();
-        assertEquals(HTTP_404_NOTFOUND, response.getStatus());
-    }
-
-    @Test
-    public void testGetUnknown() throws InterruptedException, TimeoutException, ExecutionException {
-        final String systemid = getRandomSystemId();
-        getUnknown(systemid);
-    }
-
-    @Test
-    public void testCreateOne() throws InterruptedException, TimeoutException, ExecutionException {
-
-        final String systemid = getRandomSystemId();
-        post(systemid);
-        getKnown(systemid);
-    }
-
-    @Test
-    public void testPut() throws InterruptedException, TimeoutException, ExecutionException {
-
-        final String systemid = getRandomSystemId();
-        final long timestamp = getTimestamp();
-
-        // create it
-        post(systemid);
-
-        // retrieve it
-        final ContentResponse response1 = getKnown(systemid);
-        final List<TineyNetworkInfo> list1 = parse(response1, systemid);
-        assertEquals(1, list1.size());
-
-        // modify it
-        put(systemid, timestamp+1);
-
-        // ensure it was changed
-        final ContentResponse response2 = getKnown(systemid);
-        final List<TineyNetworkInfo> list2 = parse(response2, systemid);
-        assertEquals(1, list2.size());
-    }
-
-    @Test
-    public void testDeleteUnknown() throws InterruptedException, TimeoutException, ExecutionException {
-        final String systemid = getRandomSystemId();
-
-        // delete it
-        delete(systemid);
-    }
-
-    @Test
-    public void testDeleteOne() throws InterruptedException, ExecutionException, TimeoutException {
-        final String systemid = getRandomSystemId();
-
-        // create the new record
-        post(systemid);
-
-        // check that it's there
-        getKnown(systemid);
-
-        // delete it
-        delete(systemid);
-
-        // check that it's not there
-        getUnknown(systemid);
-    }
-
-
-    @Test
-    public void testVersions() throws Exception {
-        final String systemid = getRandomSystemId();
-        post(systemid);
-        VersionTestUtil.testAllVersions(baseUrl + "/system-network", versionString, "/systems/" + systemid);
-    }
-
-    private ContentResponse post(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        final Request request = client.newRequest(serviceURL + "/systems/" + systemid);
-        request.header(HttpHeader.CONTENT_TYPE, "application/json");
-        request.content(new StringContentProvider( '[' + createJSON() + ']'));
-        ContentResponse response = request.method(HttpMethod.POST).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        final String expected = "";
-        assertEquals(expected, response.getContentAsString());
-        return response;
-    }
-
     private static long getLong(JsonObject json, final String id) {
         JsonElement el = json.get(id);
         if (el.isJsonObject()) {
@@ -218,14 +108,19 @@
         }
     }
 
-    private List<TineyNetworkInfo> parse(ContentResponse contentResponse, final String expectedSystemId) {
+    @Override
+    protected String createJSONTimeStamp(long ts) {
+        return memInfoJSON.replace(TIMESTAMP_TOKEN, Long.toString(ts));
+    }
+
+    protected List<TinyNetworkInfo> parse(ContentResponse contentResponse, final String expectedSystemId) {
 
         JsonParser parser = new JsonParser();
         JsonObject json = (JsonObject) parser.parse(contentResponse.getContentAsString());
         JsonElement response = json.get("response");
 
         JsonArray allData = response.getAsJsonArray();
-        List<TineyNetworkInfo> result = new ArrayList<>();
+        List<TinyNetworkInfo> result = new ArrayList<>();
 
         for (JsonElement entry : allData) {
 
@@ -244,73 +139,45 @@
                 assertEquals(expectedSystemId, systemId);
             }
 
-            TineyNetworkInfo hi = new TineyNetworkInfo(systemId, agentId);
+            TinyNetworkInfo hi = new TinyNetworkInfo(systemId, agentId);
 
             result.add(hi);
         }
         return result;
     }
 
-    private ContentResponse put(final String systemid, final long ts) throws InterruptedException, ExecutionException, TimeoutException {
-        final Request request = client.newRequest(serviceURL + "/systems/" + systemid);
-        request.header(HttpHeader.CONTENT_TYPE, "application/json");
-        final String contentStr = createJSON(ts);
-        request.content(new StringContentProvider("{ \"set\" : " +contentStr + "}"));
-        ContentResponse response = request.method(HttpMethod.PUT).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        final String expected = "";
-        assertEquals(expected, response.getContentAsString());
-        return response;
+    @Test
+    public void testSystemNetworkGetAll() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testGetAll();
     }
 
-    private ContentResponse getUnknown(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = get(systemid);
-        assertTrue(parse(response, systemid).isEmpty());
-        return response;
+    @Test
+    public void testSystemNetworkGetAllFails() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testGetAllFails();
     }
 
-    private ContentResponse getKnown(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = get(systemid);
-        assertEquals(1, parse(response, systemid).size());
-        return response;
-    }
-
-    private ContentResponse get(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = client.newRequest(serviceURL + "/systems/" + systemid).method(HttpMethod.GET).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        return response;
+    @Test
+    public void testSystemNetworkGetUnknown() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testGetUnknown();
     }
 
-    private ContentResponse get(final String systemid, final String query) throws InterruptedException, ExecutionException, TimeoutException {
-        final Request rq = client.newRequest(serviceURL + "/systems/" + systemid + query);
-        rq.method(HttpMethod.GET);
-        ContentResponse response = rq.send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        return response;
+    @Test
+    public void testSystemNetworkCreateOne() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testCreateOne();
     }
 
-    private ContentResponse delete(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = client.newRequest(serviceURL + "/systems/" + systemid).method(HttpMethod.DELETE).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        final String expected = "";
-        assertEquals(expected, response.getContentAsString());
-        return response;
+    @Test
+    public void testSystemNetworkPutModifiesData() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testPutModifiesData();
     }
 
-    private static String getRandomSystemId() {
-        return UUID.randomUUID().toString();
-    }
-
-    private static long getTimestamp() {
-        timeStamp += 1;
-        return timeStamp;
+    @Test
+    public void testSystemNetworkDeleteUnknown() throws InterruptedException, TimeoutException, ExecutionException {
+        super.testDeleteUnknown();
     }
 
-    private String createJSON() {
-        return createJSON(getTimestamp());
-    }
-
-    private String createJSON(final long ts) {
-        return memInfoJSON.replace(TIMESTAMP_TOKEN, Long.toString(ts));
+    @Test
+    public void testSystemNetworkDeleteOne() throws InterruptedException, ExecutionException, TimeoutException {
+        super.testDeleteOne();
     }
 }
--- a/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/systems/SystemInfoIntegrationTest.java	Fri Aug 25 09:59:56 2017 -0400
+++ b/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/systems/SystemInfoIntegrationTest.java	Tue Aug 29 11:31:10 2017 -0400
@@ -40,7 +40,7 @@
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
-import com.redhat.thermostat.gateway.tests.integration.MongoIntegrationTest;
+import com.redhat.thermostat.gateway.tests.integration.SystemIntegrationTest;
 import com.redhat.thermostat.gateway.tests.integration.VersionTestUtil;
 import org.eclipse.jetty.client.api.ContentResponse;
 import org.eclipse.jetty.client.api.Request;
@@ -57,14 +57,12 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-public class SystemInfoIntegrationTest extends MongoIntegrationTest {
+public class SystemInfoIntegrationTest extends SystemIntegrationTest<SystemInfoIntegrationTest.TinyHostInfo> {
 
     private static final String serviceName = "system-info";
     private static final String versionString = "0.0.1";
-    private static final int HTTP_200_OK = 200;
     private static final String CPU_STRING1 = "Intel";
     private static final String CPU_STRING2 = "AMD";
-    private static final String AGENT_ID = getRandomSystemId();
     private static final String HOSTNAME = getRandomSystemId();
     private static final String systemInfoJSON =
             "{\n" +
@@ -79,7 +77,7 @@
             "  }\n" +
             "}";
 
-    private static class TinyHostInfo {
+    static class TinyHostInfo {
         TinyHostInfo(String sytehId, String agentId, String hostName, String cpuModel) {
             this.systemId = sytehId;
             this.agentId = agentId;
@@ -106,17 +104,17 @@
 
         ContentResponse response = client.newRequest(resourceUrl).method(HttpMethod.GET).send();
         assertEquals(HTTP_200_OK, response.getStatus());
-        final List<TinyHostInfo> list = parseHostInfo(response, null);
+        final List<TinyHostInfo> list = parse(response, null);
         assertEquals(1, list.size());
 
         ContentResponse response2 = client.newRequest(resourceUrl + "?limit=99").method(HttpMethod.GET).send();
         assertEquals(HTTP_200_OK, response2.getStatus());
-        final List<TinyHostInfo> list2 = parseHostInfo(response2, null);
+        final List<TinyHostInfo> list2 = parse(response2, null);
         assertEquals(2, list2.size());
 
         ContentResponse response3 = client.newRequest(resourceUrl + "?limit=0").method(HttpMethod.GET).send();
         assertEquals(HTTP_200_OK, response3.getStatus());
-        final List<TinyHostInfo> list3 = parseHostInfo(response3, null);
+        final List<TinyHostInfo> list3 = parse(response3, null);
         assertEquals(2, list3.size());
     }
 
@@ -124,7 +122,7 @@
     public void testGetAllEmpty() throws InterruptedException, TimeoutException, ExecutionException {
         ContentResponse response = client.newRequest(resourceUrl).method(HttpMethod.GET).send();
         assertEquals(HTTP_200_OK, response.getStatus());
-        final List<TinyHostInfo> list = parseHostInfo(response, null);
+        final List<TinyHostInfo> list = parse(response, null);
         assertTrue(list.isEmpty());
     }
 
@@ -136,7 +134,6 @@
 
     @Test
     public void testCreateOne() throws InterruptedException, TimeoutException, ExecutionException {
-
         final String systemid = getRandomSystemId();
         postSystemInfo(systemid);
         getKnownSystemInfo(systemid);
@@ -152,7 +149,7 @@
 
         // retrieve it
         final ContentResponse response1 = getKnownSystemInfo(systemid);
-        final List<TinyHostInfo> list1 = parseHostInfo(response1, systemid);
+        final List<TinyHostInfo> list1 = parse(response1, systemid);
         assertEquals(1, list1.size());
         assertEquals(CPU_STRING1, list1.get(0).cpuModel);
 
@@ -161,7 +158,7 @@
 
         // ensure it was changed
         final ContentResponse response2 = getKnownSystemInfo(systemid);
-        final List<TinyHostInfo> list2 = parseHostInfo(response2, systemid);
+        final List<TinyHostInfo> list2 = parse(response2, systemid);
         assertEquals(1, list2.size());
         assertEquals(CPU_STRING2, list2.get(0).cpuModel);
     }
@@ -198,18 +195,9 @@
         VersionTestUtil.testAllVersions(baseUrl + "/systems", versionString, "/systems/" + systemid);
     }
 
-    private ContentResponse postSystemInfo(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        final Request request = client.newRequest(resourceUrl + "/systems/" + systemid);
-        request.header("Content-Type", "application/json");
-        request.content(new StringContentProvider("[" + createSystemInfoJSON(systemid) + "]"));
-        ContentResponse response = request.method(HttpMethod.POST).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        final String expected = "";
-        assertEquals(expected, response.getContentAsString());
-        return response;
-    }
 
-    private List<TinyHostInfo> parseHostInfo(ContentResponse contentResponse, final String expectedSystemId) {
+    @Override
+    protected List<TinyHostInfo> parse(ContentResponse contentResponse, final String expectedSystemId) {
 
         JsonParser parser = new JsonParser();
         JsonObject json = (JsonObject) parser.parse(contentResponse.getContentAsString());
@@ -245,6 +233,10 @@
         return result;
     }
 
+    protected String generateRequestContent() {
+        return createSystemInfoJSON(systemId);
+    }
+
     private ContentResponse putSystemInfo(final String systemid, final String cpuid) throws InterruptedException, ExecutionException, TimeoutException {
         final Request request = client.newRequest(resourceUrl + "/systems/" + systemid);
         request.header("Content-Type", "application/json");
@@ -257,37 +249,27 @@
         return response;
     }
 
-    private ContentResponse getUnknownSystemInfo(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = getSystemInfo(systemid);
-        assertTrue(parseHostInfo(response, systemid).isEmpty());
-        return response;
-    }
-
-    private ContentResponse getKnownSystemInfo(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = getSystemInfo(systemid);
-        assertEquals(1, parseHostInfo(response, systemid).size());
-        return response;
-    }
-
-    private ContentResponse getSystemInfo(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = client.newRequest(resourceUrl + "/systems/" + systemid).method(HttpMethod.GET).send();
-        assertEquals(HTTP_200_OK, response.getStatus());
-        return response;
-    }
-
-    private ContentResponse deleteSystemInfo(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
-        ContentResponse response = client.newRequest(resourceUrl + "/systems/" + systemid).method(HttpMethod.DELETE).send();
+    protected ContentResponse postSystemInfo(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
+        final Request request = client.newRequest(resourceUrl + "/systems/" + systemid);
+        request.header("Content-Type", "application/json");
+        request.content(new StringContentProvider("[" + generateRequestContent() + "]"));
+        ContentResponse response = request.method(HttpMethod.POST).send();
         assertEquals(HTTP_200_OK, response.getStatus());
         final String expected = "";
         assertEquals(expected, response.getContentAsString());
         return response;
     }
 
-    private static String getRandomSystemId() {
+    @Override
+    protected String createJSONTimeStamp(long ts) {
+        return null;
+    }
+
+    protected static String getRandomSystemId() {
         return UUID.randomUUID().toString();
     }
 
-    private String createSystemInfoJSON(final String systemid) {
+    protected String createSystemInfoJSON(final String systemid) {
         return systemInfoJSON;
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/tests/integration/SystemIntegrationTest.java	Tue Aug 29 11:31:10 2017 -0400
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2012-2017 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.gateway.tests.integration;
+
+import org.eclipse.jetty.client.api.ContentResponse;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.util.StringContentProvider;
+import org.eclipse.jetty.http.HttpHeader;
+import org.eclipse.jetty.http.HttpMethod;
+
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public abstract class SystemIntegrationTest<T> extends MongoIntegrationTest {
+
+    protected static final int HTTP_200_OK = 200;
+    protected static final int HTTP_404_NOTFOUND = 404;
+    protected static final String TIMESTAMP_TOKEN = "$TIMESTAMP$";
+    protected static final String AGENT_ID = getRandomSystemId();
+
+    protected long timeStamp = java.lang.System.nanoTime();
+    protected String systemId;
+    private String serviceURL;
+
+    protected SystemIntegrationTest(String serviceUrl, String collectionName) {
+        super(serviceUrl, collectionName);
+        this.serviceURL = serviceUrl;
+        this.collectionName = collectionName;
+    }
+
+    protected abstract String createJSONTimeStamp(final long ts);
+
+    protected abstract List<T> parse(ContentResponse contentResponse, final String expectedsystemId);
+
+    protected long getTimeStamp() {
+        timeStamp += 1;
+        return timeStamp;
+    }
+
+    protected static String getRandomSystemId() {
+        return UUID.randomUUID().toString();
+    }
+
+    private String createJSONTimeStamp() {
+        return createJSONTimeStamp(getTimeStamp());
+    }
+
+    protected ContentResponse post(final String systemId) throws InterruptedException, ExecutionException, TimeoutException {
+        final Request request = client.newRequest(serviceURL + "/systems/" + systemId);
+        request.header(HttpHeader.CONTENT_TYPE, "application/json");
+        request.content(new StringContentProvider("[" + createJSONTimeStamp() + "]"));
+        ContentResponse response = request.method(HttpMethod.POST).send();
+        assertEquals(HTTP_200_OK, response.getStatus());
+        final String expected = "";
+        assertEquals(expected, response.getContentAsString());
+        return response;
+    }
+
+    protected ContentResponse getSystemInfo(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
+        ContentResponse response = client.newRequest(resourceUrl + "/systems/" + systemid).method(HttpMethod.GET).send();
+        assertEquals(HTTP_200_OK, response.getStatus());
+        return response;
+    }
+
+    protected ContentResponse deleteSystemInfo(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
+        ContentResponse response = client.newRequest(resourceUrl + "/systems/" + systemid).method(HttpMethod.DELETE).send();
+        assertEquals(HTTP_200_OK, response.getStatus());
+        final String expected = "";
+        assertEquals(expected, response.getContentAsString());
+        return response;
+    }
+
+    protected ContentResponse get(final String systemId) throws InterruptedException, ExecutionException, TimeoutException {
+        ContentResponse response = client.newRequest(serviceURL + "/systems/" + systemId).method(HttpMethod.GET).send();
+        assertEquals(HTTP_200_OK, response.getStatus());
+        return response;
+    }
+
+    protected ContentResponse get(final String systemId, final String query) throws InterruptedException, ExecutionException, TimeoutException {
+        final Request rq = client.newRequest(serviceURL + "/systems/" + systemId + query);
+        rq.method(HttpMethod.GET);
+        ContentResponse response = rq.send();
+        assertEquals(HTTP_200_OK, response.getStatus());
+        return response;
+    }
+
+    protected ContentResponse put(final String systemId, final long ts) throws InterruptedException, ExecutionException, TimeoutException {
+        final Request request = client.newRequest(serviceURL + "/systems/" + systemId);
+        request.header(HttpHeader.CONTENT_TYPE, "application/json");
+        final String contentStr = createJSONTimeStamp(ts);
+        request.content(new StringContentProvider("{ \"set\" : " +contentStr + "}"));
+        ContentResponse response = request.method(HttpMethod.PUT).send();
+        assertEquals(HTTP_200_OK, response.getStatus());
+        final String expected = "";
+        assertEquals(expected, response.getContentAsString());
+        return response;
+    }
+
+    protected ContentResponse delete(final String systemId) throws InterruptedException, ExecutionException, TimeoutException {
+        ContentResponse response = client.newRequest(serviceURL + "/systems/" + systemId).method(HttpMethod.DELETE).send();
+        assertEquals(HTTP_200_OK, response.getStatus());
+        final String expected = "";
+        assertEquals(expected, response.getContentAsString());
+        return response;
+    }
+
+    protected ContentResponse getUnknown(final String systemId) throws InterruptedException, ExecutionException, TimeoutException {
+        ContentResponse response = get(systemId);
+        assertTrue(parse(response, systemId).isEmpty());
+        return response;
+    }
+
+    protected ContentResponse getKnown(final String systemId) throws InterruptedException, ExecutionException, TimeoutException {
+        ContentResponse response = get(systemId);
+        assertEquals(1, parse(response, systemId).size());
+        return response;
+    }
+
+
+    protected ContentResponse getUnknownSystemInfo(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
+        ContentResponse response = getSystemInfo(systemid);
+        assertTrue(parse(response, systemid).isEmpty());
+        return response;
+    }
+
+    protected ContentResponse getKnownSystemInfo(final String systemid) throws InterruptedException, ExecutionException, TimeoutException {
+        ContentResponse response = getSystemInfo(systemid);
+        assertEquals(1, parse(response, systemid).size());
+        return response;
+    }
+}