Merge "Remove port concurrent hash map"
[neutron.git] / neutron-spi / src / test / java / org / opendaylight / neutron / spi / NeutronLoadBalancerHealthMonitorJAXBTest.java
1 /*
2  * Copyright Tata Consultancy Services, 2015.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.neutron.spi;
10
11 import java.util.ArrayList;
12 import java.util.List;
13
14 import org.junit.Assert;
15 import org.junit.Test;
16
17 public class NeutronLoadBalancerHealthMonitorJAXBTest {
18
19     private static final String NeutronLoadBalancerHealthMonitor_sourceJson = "{"
20             + "\"id\": \"2f245a7b-796b-4f26-9cf9-9e82d248fda7\", " + "\"type\": \"HTTP\", " + "\"delay\": 1, "
21             + "\"timeout\": 1, " + "\"admin_state_up\": \"false\", " + "\"max_retries\": 5, "
22             + "\"http_method\": \"get\", " + "\"url_path\": \"/index.html\", "
23             + "\"expected_codes\": \"200,201,202\", " + "\"tenant_id\": \"00045a7b-796b-4f26-9cf9-9e82d248fda7\" }";
24
25     @Test
26     public void test_NeutronLoadBalancerHealthMonitor_JAXB() {
27         NeutronLoadBalancerHealthMonitor dummyObject = new NeutronLoadBalancerHealthMonitor();
28         try {
29             NeutronLoadBalancerHealthMonitor testObject = (NeutronLoadBalancerHealthMonitor) JaxbTestHelper
30                     .jaxbUnmarshall(dummyObject, NeutronLoadBalancerHealthMonitor_sourceJson);
31             Assert.assertEquals("NeutronLoadBalancerHealthMonitor JAXB Test 1: Testing id failed",
32                     "2f245a7b-796b-4f26-9cf9-9e82d248fda7", testObject.getID());
33
34             Assert.assertEquals("NeutronLoadBalancerHealthMonitor JAXB Test 2: Testing  Type failed", "HTTP",
35                     testObject.getLoadBalancerHealthMonitorType());
36
37             Assert.assertEquals("NeutronLoadBalancerHealthMonitor JAXB Test 3: Testing  delay failed", 1,
38                     (long) testObject.getLoadBalancerHealthMonitorDelay());
39
40             Assert.assertEquals("NeutronLoadBalancerHealthMonitor JAXB Test 4: Testing  timeout failed", 1,
41                     (long) testObject.getLoadBalancerHealthMonitorTimeout());
42
43             Assert.assertFalse("NeutronLoadBalancerHealthMonitor JAXB Test 5: Testing  admin_state_up failed",
44                     testObject.getLoadBalancerHealthMonitorAdminStateIsUp());
45
46             Assert.assertEquals("NeutronLoadBalancerHealthMonitor JAXB Test 6: Testing  max_retries  failed", 5,
47                     (long) testObject.getLoadBalancerHealthMonitorMaxRetries());
48
49             Assert.assertEquals("NeutronLoadBalancerHealthMonitor JAXB Test 7: Testing  http_methods failed", "get",
50                     testObject.getLoadBalancerHealthMonitorHttpMethod());
51
52             Assert.assertEquals("NeutronLoadBalancerHealthMonitor JAXB Test 8: Testing  url_path failed",
53                     "/index.html", testObject.getLoadBalancerHealthMonitorUrlPath());
54
55             Assert.assertEquals("NeutronLoadBalancerHealthMonitor JAXB Test 9: Testing  expected_codes failed",
56                     "200,201,202", testObject.getLoadBalancerHealthMonitorExpectedCodes());
57
58             Assert.assertEquals("NeutronLoadBalancerHealthMonitor JAXB Test 10: Testing tenant_id failed",
59                     "00045a7b-796b-4f26-9cf9-9e82d248fda7", testObject.getLoadBalancerHealthMonitorTenantID());
60
61             Neutron_ID neutron_id = new Neutron_ID();
62             neutron_id.setID("2f245a7b-0000-4f26-9cf9-9e82d248fda7");
63             List<Neutron_ID> loadBalancerHealthMonitorPool = new ArrayList<Neutron_ID>();
64             loadBalancerHealthMonitorPool.add(neutron_id);
65             testObject.setLoadBalancerHealthMonitorPools(loadBalancerHealthMonitorPool);
66             Assert.assertEquals("NeutronLoadBalancerHealthMonitor JAXB Test 11: Testing Pools failed",
67                     "2f245a7b-0000-4f26-9cf9-9e82d248fda7", testObject.getLoadBalancerHealthMonitorPools().get(0)
68                             .getID());
69         } catch (Exception e) {
70             Assert.assertFalse("Tests Failed", true);
71         }
72     }
73 }