JUnit JAXB tests for dependent Neutron classes 11/17911/2
authorShreshthaJoshi <shreshtha.joshi@tcs.com>
Wed, 8 Apr 2015 09:50:05 +0000 (15:20 +0530)
committerRyan Moats <rmoats@us.ibm.com>
Wed, 8 Apr 2015 13:38:00 +0000 (08:38 -0500)
Covers NeutronNetwork_Segment, Neutron_IPs and Neutron_ID

Change-Id: I70ee097bcb19ad419a904283f63e6e874405f291
Signed-off-by: ShreshthaJoshi <shreshtha.joshi@tcs.com>
neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronNetwork_SegmentJAXBTest.java [new file with mode: 0644]
neutron-spi/src/test/java/org/opendaylight/neutron/spi/Neutron_IDJAXBTest.java [new file with mode: 0644]
neutron-spi/src/test/java/org/opendaylight/neutron/spi/Neutron_IPsJAXBTest.java [new file with mode: 0644]

diff --git a/neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronNetwork_SegmentJAXBTest.java b/neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronNetwork_SegmentJAXBTest.java
new file mode 100644 (file)
index 0000000..8d396af
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2015 IBM, Inc.
+ *
+ * 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.opendaylight.neutron.spi;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.opendaylight.neutron.spi.JaxbTestHelper;
+import org.opendaylight.neutron.spi.NeutronNetwork_Segment;
+
+public class NeutronNetwork_SegmentJAXBTest {
+
+    private static final String NeutronNetwork_Segment_sourceJson = "{ "
+            + "\"provider:network_type\": \"vlan\", "
+            + "\"provider:physical_network\": \"physnet1\", "
+            + "\"provider:segmentation_id\": \"1001\" }";
+
+    @Test
+    public void test_NeutronNetwork_Segment_JAXB() {
+        NeutronNetwork_Segment segmentObject = new NeutronNetwork_Segment();
+        try {
+            NeutronNetwork_Segment testObject = (NeutronNetwork_Segment) JaxbTestHelper.jaxbUnmarshall(segmentObject,
+                    NeutronNetwork_Segment_sourceJson);
+
+            Assert.assertEquals("NeutronNetwork_Segment JAXB Test 1: Testing provider:network_type failed", "vlan",
+                    testObject.getProviderNetworkType());
+
+            Assert.assertEquals("NeutronNetwork_Segment JAXB Test 2: Testing provider:physical_network failed",
+                    "physnet1", testObject.getProviderPhysicalNetwork());
+
+            Assert.assertEquals("NeutronNetwork_Segment JAXB Test 3: Testing provider:segmentation_id failed", "1001",
+                    testObject.getProviderSegmentationID());
+
+        } catch (Exception e) {
+            Assert.fail("Test failed");
+        }
+    }
+
+}
diff --git a/neutron-spi/src/test/java/org/opendaylight/neutron/spi/Neutron_IDJAXBTest.java b/neutron-spi/src/test/java/org/opendaylight/neutron/spi/Neutron_IDJAXBTest.java
new file mode 100644 (file)
index 0000000..2ee6d21
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2015 IBM, Inc.
+ *
+ * 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.opendaylight.neutron.spi;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.opendaylight.neutron.spi.JaxbTestHelper;
+import org.opendaylight.neutron.spi.Neutron_ID;
+
+public class Neutron_IDJAXBTest {
+
+    private static final String Neutron_ID_sourceJson = "{ " +
+
+    "\"id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\" }";
+
+    @Test
+    public void test_Neutron_ID_JAXB() {
+        Neutron_ID neutronObject = new Neutron_ID();
+        try {
+            Neutron_ID testObject = (Neutron_ID) JaxbTestHelper.jaxbUnmarshall(neutronObject, Neutron_ID_sourceJson);
+
+            Assert.assertEquals("Neutron_ID JAXB Test 1: Testing id failed", "4e8e5957-649f-477b-9e5b-f1f75b21c03c",
+                    testObject.getID());
+
+        } catch (Exception e) {
+            Assert.fail("Test failed");
+        }
+    }
+
+}
diff --git a/neutron-spi/src/test/java/org/opendaylight/neutron/spi/Neutron_IPsJAXBTest.java b/neutron-spi/src/test/java/org/opendaylight/neutron/spi/Neutron_IPsJAXBTest.java
new file mode 100644 (file)
index 0000000..e39af7c
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2015 IBM, Inc.
+ *
+ * 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.opendaylight.neutron.spi;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.opendaylight.neutron.spi.JaxbTestHelper;
+import org.opendaylight.neutron.spi.Neutron_IPs;
+
+public class Neutron_IPsJAXBTest {
+
+    private static final String Neutron_IPs_sourceJson = "{ " +
+
+    "\"ip_address\": \"192.168.111.3\", " + "\"subnet_id\": \"22b44fc2-4ffb-4de4-b0f9-69d58b37ae27\" }";
+
+    @Test
+    public void test_Neutron_IPs_JAXB() {
+        Neutron_IPs neutronObject = new Neutron_IPs();
+        try {
+            Neutron_IPs testObject = (Neutron_IPs) JaxbTestHelper.jaxbUnmarshall(neutronObject, Neutron_IPs_sourceJson);
+
+            Assert.assertEquals("Neutron_IPs JAXB Test 1: Testing ip_address failed", "192.168.111.3",
+                    testObject.getIpAddress());
+
+            Assert.assertEquals("Neutron_IPs JAXB Test 2: Testing subnet_id failed",
+                    "22b44fc2-4ffb-4de4-b0f9-69d58b37ae27", testObject.getSubnetUUID());
+
+        } catch (Exception e) {
+            Assert.fail("Test failed");
+        }
+    }
+
+}