JUnit JAXB tests for NeutronLoadBalancerPool 91/17691/2
authorshreshthajoshi <shreshtha.joshi@tcs.com>
Fri, 3 Apr 2015 09:42:15 +0000 (15:12 +0530)
committerRyan Moats <rmoats@us.ibm.com>
Mon, 6 Apr 2015 13:04:46 +0000 (08:04 -0500)
Change-Id: I069c4b27cffcd581bc9db467915211669449c5bc
Signed-off-by: shreshthajoshi <shreshtha.joshi@tcs.com>
neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronLoadBalancerPoolJAXBTest.java [new file with mode: 0644]

diff --git a/neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronLoadBalancerPoolJAXBTest.java b/neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronLoadBalancerPoolJAXBTest.java
new file mode 100644 (file)
index 0000000..2c121b8
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright IBM Corporation and others, 2015.  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.opendaylight.neutron.spi;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class NeutronLoadBalancerPoolJAXBTest {
+
+    private static final String NeutronLoadBalancerPool_sourceJson = "{ " +
+        "\"admin_state_up\": true, " +
+        "\"description\": \"simple pool\", " +
+        "\"healthmonitor_id\": \"00066a7b-796b-4f26-9cf9-9e82d248fda7\", " +
+        "\"id\": \"12ff63af-4127-4074-a251-bcb2ecc53ebe\", " +
+        "\"lb_algorithm\": \"ROUND_ROBIN\", " +
+        "\"listeners\": [ " +
+        "{ " +
+        "\"id\": \"39de4d56-d663-46e5-85a1-5b9d5fa17829\" " +
+        "} " +
+        "], " +
+        "\"members\": [], " +
+        "\"name\": \"pool1\", " +
+        "\"protocol\": \"HTTP\", " +
+        "\"session_persistence\": { " +
+        "\"cookie_name\": \"my_cookie\", " +
+        "\"type\": \"APP_COOKIE\" " +
+        "}, " +
+        "\"tenant_id\": \"1a3e005cf9ce40308c900bcb08e5320c\" " +
+        "} ";
+
+    @Test
+    public void test_NeutronLoadBalancerPool_JAXB() {
+        NeutronLoadBalancerPool dummyObject = new NeutronLoadBalancerPool();
+        try {
+            NeutronLoadBalancerPool testObject = (NeutronLoadBalancerPool) JaxbTestHelper.jaxbUnmarshall(dummyObject,
+                    NeutronLoadBalancerPool_sourceJson);
+            Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 1: Testing id failed",
+                    "12ff63af-4127-4074-a251-bcb2ecc53ebe", testObject.getLoadBalancerPoolID());
+
+            Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 2: Testing name failed", "pool1",
+                    testObject.getLoadBalancerPoolName());
+
+            Assert.assertTrue("NeutronLoadBalancerPool JAXB Test 3: Testing admin_state_up failed",
+                    testObject.getLoadBalancerPoolAdminIsStateIsUp());
+
+            Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 4: Testing Description failed",
+                    "simple pool", testObject.getLoadBalancerPoolDescription());
+
+            Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 5: Testing LbAlgorithm failed", "ROUND_ROBIN",
+                    testObject.getLoadBalancerPoolLbAlgorithm());
+
+            Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 6: Testing Protocol failed", "HTTP",
+                    testObject.getLoadBalancerPoolProtocol());
+
+            Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 7: Testing Tenant_id failed",
+                    "1a3e005cf9ce40308c900bcb08e5320c", testObject.getLoadBalancerPoolTenantID());
+
+            Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 8: Testing HealthMonitorID failed",
+                    "00066a7b-796b-4f26-9cf9-9e82d248fda7", testObject.getNeutronLoadBalancerPoolHealthMonitorID());
+
+            List<Neutron_ID> testListeners = testObject.getLoadBalancerPoolListeners();
+            Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 9.1: Testing Listeners failed",
+                    1, testListeners.size());
+
+            Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 9.2: Testing Listeners failed",
+                    "39de4d56-d663-46e5-85a1-5b9d5fa17829", testObject.getLoadBalancerPoolListeners().get(0).getID());
+
+            List<NeutronLoadBalancerPoolMember> testMembers = testObject.getLoadBalancerPoolMembers();
+            Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 10.1: Testing Listeners failed",
+                    0, testMembers.size());
+
+            Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 11: Testing session_persistence cookie_name failed",
+                    "my_cookie", testObject.getLoadBalancerPoolSessionPersistence().getCookieName());
+
+            Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 12: Testing session_persistence type failed",
+                    "APP_COOKIE", testObject.getLoadBalancerPoolSessionPersistence().getType());
+
+        } catch (Exception e) {
+            Assert.fail("Tests failed");
+        }
+    }
+}