Extract test json to separate files

Change-Id: Ica815b7c5ff0a77f411e621bbb6cfc8b78fcd012
diff --git a/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfigTest.java b/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfigTest.java
index a43c2ba..1c9abd7 100644
--- a/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfigTest.java
+++ b/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingAppConfigTest.java
@@ -30,6 +30,7 @@
 import org.onosproject.net.config.ConfigApplyDelegate;
 import org.onosproject.segmentrouting.SegmentRoutingManager;
 
+import java.io.InputStream;
 import java.util.Optional;
 import java.util.Set;
 
@@ -45,29 +46,7 @@
 
     private SegmentRoutingAppConfig config;
     private SegmentRoutingAppConfig invalidConfig;
-    private static final String JSON_STRING = "{" +
-            "\"vRouterMacs\" : [" +
-            "    \"00:00:00:00:00:01\"," +
-            "    \"00:00:00:00:00:02\"" +
-            "]," +
-            "\"vRouterId\" : \"of:1\"," +
-            "\"suppressSubnet\" : [" +
-            "    \"of:1/1\"," +
-            "    \"of:1/2\"" +
-            "]," +
-            "\"suppressHost\" : [" +
-            "    \"of:1/1\"," +
-            "    \"of:1/2\"" +
-            "]}";
-    private static final String INVALID_JSON_STRING = "{" +
-            "\"vRouterMacs\" : [" +
-            "    \"00:00:00:00:00:01\"," +
-            "    \"00:00:00:00:00:02\"" +
-            "]," +
-            "\"suppressSubnet\" : [" +
-            "    \"of:1/1\"," +
-            "    \"wrongport\"" +
-            "]}";
+
     private static final MacAddress ROUTER_MAC_1 = MacAddress.valueOf("00:00:00:00:00:01");
     private static final MacAddress ROUTER_MAC_2 = MacAddress.valueOf("00:00:00:00:00:02");
     private static final MacAddress ROUTER_MAC_3 = MacAddress.valueOf("00:00:00:00:00:03");
@@ -84,11 +63,16 @@
      */
     @Before
     public void setUp() throws Exception {
+        InputStream jsonStream = SegmentRoutingAppConfigTest.class
+                .getResourceAsStream("/sr-app-config.json");
+        InputStream invalidJsonStream = SegmentRoutingAppConfigTest.class
+                .getResourceAsStream("/sr-app-config-invalid.json");
+
         ApplicationId subject = APP_ID;
         String key = SegmentRoutingManager.SR_APP_ID;
         ObjectMapper mapper = new ObjectMapper();
-        JsonNode jsonNode = mapper.readTree(JSON_STRING);
-        JsonNode invalidJsonNode = mapper.readTree(INVALID_JSON_STRING);
+        JsonNode jsonNode = mapper.readTree(jsonStream);
+        JsonNode invalidJsonNode = mapper.readTree(invalidJsonStream);
         ConfigApplyDelegate delegate = new MockDelegate();
 
         config = new SegmentRoutingAppConfig();
diff --git a/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingDeviceConfigTest.java b/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingDeviceConfigTest.java
index fd661b6..58fea85 100644
--- a/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingDeviceConfigTest.java
+++ b/src/test/java/org/onosproject/segmentrouting/config/SegmentRoutingDeviceConfigTest.java
@@ -26,6 +26,7 @@
 import org.onosproject.net.config.Config;
 import org.onosproject.net.config.ConfigApplyDelegate;
 
+import java.io.InputStream;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -45,16 +46,8 @@
 
     @Before
     public void setUp() throws Exception {
-        String jsonString = "{" +
-                "\"name\" : \"Leaf-R1\"," +
-                "\"nodeSid\" : 101," +
-                "\"routerIp\" : \"10.0.1.254\"," +
-                "\"routerMac\" : \"00:00:00:00:01:80\"," +
-                "\"isEdgeRouter\" : true," +
-                "\"adjacencySids\" : [" +
-                "    { \"adjSid\" : 100, \"ports\" : [2, 3] }," +
-                "    { \"adjSid\" : 200, \"ports\" : [4, 5] }" +
-                "]}";
+        InputStream jsonStream = SegmentRoutingDeviceConfigTest.class
+                .getResourceAsStream("/sr-device-config.json");
 
         adjacencySids1 = new HashMap<>();
         Set<Integer> ports1 = new HashSet<>();
@@ -74,7 +67,7 @@
         DeviceId subject = DeviceId.deviceId("of:0000000000000001");
         String key = "segmentrouting";
         ObjectMapper mapper = new ObjectMapper();
-        JsonNode jsonNode = mapper.readTree(jsonString);
+        JsonNode jsonNode = mapper.readTree(jsonStream);
         ConfigApplyDelegate delegate = new MockDelegate();
 
         config = new SegmentRoutingDeviceConfig();
diff --git a/src/test/resources/sr-app-config-invalid.json b/src/test/resources/sr-app-config-invalid.json
new file mode 100644
index 0000000..e2851d5
--- /dev/null
+++ b/src/test/resources/sr-app-config-invalid.json
@@ -0,0 +1,15 @@
+{
+  "vRouterMacs" : [
+      "00:00:00:00:00:01",
+      "00:00:00:00:00:02"
+  ],
+  "vRouterId" : "of:1",
+  "suppressSubnet" : [
+      "of:1/1",
+      "of:1/2"
+  ],
+  "suppressHost" : [
+      "of:1/1",
+      "wrongPort"
+  ]
+}
diff --git a/src/test/resources/sr-app-config.json b/src/test/resources/sr-app-config.json
new file mode 100644
index 0000000..9e8b33e
--- /dev/null
+++ b/src/test/resources/sr-app-config.json
@@ -0,0 +1,15 @@
+{
+  "vRouterMacs" : [
+      "00:00:00:00:00:01",
+      "00:00:00:00:00:02"
+  ],
+  "vRouterId" : "of:1",
+  "suppressSubnet" : [
+      "of:1/1",
+      "of:1/2"
+  ],
+  "suppressHost" : [
+      "of:1/1",
+      "of:1/2"
+  ]
+}
diff --git a/src/test/resources/sr-device-config.json b/src/test/resources/sr-device-config.json
new file mode 100644
index 0000000..133f6d4
--- /dev/null
+++ b/src/test/resources/sr-device-config.json
@@ -0,0 +1,11 @@
+{
+  "name" : "Leaf-R1",
+  "nodeSid" : 101,
+  "routerIp" : "10.0.1.254",
+  "routerMac" : "00:00:00:00:01:80",
+  "isEdgeRouter" : true,
+  "adjacencySids" : [
+    { "adjSid" : 100, "ports" : [2, 3] },
+    { "adjSid" : 200, "ports" : [4, 5] }
+  ]
+}
\ No newline at end of file