2 * Copyright Tata Consultancy Services, 2015. All rights reserved.
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
9 package org.opendaylight.neutron.spi;
11 import java.util.List;
13 import org.junit.Assert;
14 import org.junit.Test;
16 public class NeutronLoadBalancerPoolJAXBTest {
18 private static final String NeutronLoadBalancerPool_sourceJson = "{ " +
19 "\"admin_state_up\": true, " +
20 "\"description\": \"simple pool\", " +
21 "\"healthmonitor_id\": \"00066a7b-796b-4f26-9cf9-9e82d248fda7\", " +
22 "\"id\": \"12ff63af-4127-4074-a251-bcb2ecc53ebe\", " +
23 "\"lb_algorithm\": \"ROUND_ROBIN\", " +
26 "\"id\": \"39de4d56-d663-46e5-85a1-5b9d5fa17829\" " +
30 "\"name\": \"pool1\", " +
31 "\"protocol\": \"HTTP\", " +
32 "\"session_persistence\": { " +
33 "\"cookie_name\": \"my_cookie\", " +
34 "\"type\": \"APP_COOKIE\" " +
36 "\"tenant_id\": \"1a3e005cf9ce40308c900bcb08e5320c\" " +
40 public void test_NeutronLoadBalancerPool_JAXB() {
41 NeutronLoadBalancerPool dummyObject = new NeutronLoadBalancerPool();
43 NeutronLoadBalancerPool testObject = (NeutronLoadBalancerPool) JaxbTestHelper.jaxbUnmarshall(dummyObject,
44 NeutronLoadBalancerPool_sourceJson);
45 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 1: Testing id failed",
46 "12ff63af-4127-4074-a251-bcb2ecc53ebe", testObject.getID());
48 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 2: Testing name failed", "pool1",
49 testObject.getLoadBalancerPoolName());
51 Assert.assertTrue("NeutronLoadBalancerPool JAXB Test 3: Testing admin_state_up failed",
52 testObject.getLoadBalancerPoolAdminIsStateIsUp());
54 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 5: Testing LbAlgorithm failed", "ROUND_ROBIN",
55 testObject.getLoadBalancerPoolLbAlgorithm());
57 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 6: Testing Protocol failed", "HTTP",
58 testObject.getLoadBalancerPoolProtocol());
60 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 7: Testing Tenant_id failed",
61 "1a3e005cf9ce40308c900bcb08e5320c", testObject.getTenantID());
63 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 8: Testing HealthMonitorID failed",
64 "00066a7b-796b-4f26-9cf9-9e82d248fda7", testObject.getNeutronLoadBalancerPoolHealthMonitorID());
66 List<Neutron_ID> testListeners = testObject.getLoadBalancerPoolListeners();
67 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 9.1: Testing Listeners failed",
68 1, testListeners.size());
70 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 9.2: Testing Listeners failed",
71 "39de4d56-d663-46e5-85a1-5b9d5fa17829", testObject.getLoadBalancerPoolListeners().get(0).getID());
73 List<NeutronLoadBalancerPoolMember> testMembers = testObject.getLoadBalancerPoolMembers();
74 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 10.1: Testing Listeners failed",
75 0, testMembers.size());
77 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 11: Testing session_persistence cookie_name failed",
78 "my_cookie", testObject.getLoadBalancerPoolSessionPersistence().getCookieName());
80 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 12: Testing session_persistence type failed",
81 "APP_COOKIE", testObject.getLoadBalancerPoolSessionPersistence().getType());
83 } catch (Exception e) {
84 Assert.fail("Tests failed");