2 * Copyright (c) 2015 Tata Consultancy Services. 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;
12 import javax.xml.bind.JAXBException;
13 import org.junit.Assert;
14 import org.junit.Test;
16 public class NeutronLoadBalancerPoolJAXBTest {
18 private static final String NEUTRON_LOAD_BALANCER_POOL_SOURCE_JSON = "{ " + "\"admin_state_up\": true, "
19 + "\"description\": \"simple pool\", " + "\"healthmonitor_id\": \"00066a7b-796b-4f26-9cf9-9e82d248fda7\", "
20 + "\"id\": \"12ff63af-4127-4074-a251-bcb2ecc53ebe\", " + "\"lb_algorithm\": \"ROUND_ROBIN\", "
21 + "\"listeners\": [ " + "{ " + "\"id\": \"39de4d56-d663-46e5-85a1-5b9d5fa17829\" " + "} " + "], "
22 + "\"members\": [], " + "\"name\": \"pool1\", " + "\"protocol\": \"HTTP\", " + "\"session_persistence\": { "
23 + "\"cookie_name\": \"my_cookie\", " + "\"type\": \"APP_COOKIE\" " + "}, "
24 + "\"tenant_id\": \"1a3e005cf9ce40308c900bcb08e5320c\" " + "} ";
27 public void test_NeutronLoadBalancerPool_JAXB() throws JAXBException {
28 NeutronLoadBalancerPool dummyObject = new NeutronLoadBalancerPool();
30 NeutronLoadBalancerPool testObject = (NeutronLoadBalancerPool) JaxbTestHelper.jaxbUnmarshall(dummyObject,
31 NEUTRON_LOAD_BALANCER_POOL_SOURCE_JSON);
32 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 1: Testing id failed",
33 "12ff63af-4127-4074-a251-bcb2ecc53ebe", testObject.getID());
35 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 2: Testing name failed", "pool1",
36 testObject.getName());
38 Assert.assertTrue("NeutronLoadBalancerPool JAXB Test 3: Testing admin_state_up failed",
39 testObject.getLoadBalancerPoolAdminIsStateIsUp());
41 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 5: Testing LbAlgorithm failed", "ROUND_ROBIN",
42 testObject.getLoadBalancerPoolLbAlgorithm());
44 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 6: Testing Protocol failed", "HTTP",
45 testObject.getLoadBalancerPoolProtocol());
47 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 7: Testing Tenant_id failed",
48 "1a3e005cf9ce40308c900bcb08e5320c", testObject.getTenantID());
50 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 8: Testing HealthMonitorID failed",
51 "00066a7b-796b-4f26-9cf9-9e82d248fda7", testObject.getNeutronLoadBalancerPoolHealthMonitorID());
53 List<NeutronID> testListeners = testObject.getLoadBalancerPoolListeners();
54 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 9.1: Testing Listeners failed", 1,
55 testListeners.size());
57 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 9.2: Testing Listeners failed",
58 "39de4d56-d663-46e5-85a1-5b9d5fa17829", testObject.getLoadBalancerPoolListeners().get(0).getID());
60 List<NeutronLoadBalancerPoolMember> testMembers = testObject.getLoadBalancerPoolMembers();
61 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 10.1: Testing Listeners failed", 0,
64 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 11: Testing session_persistence cookie_name failed",
65 "my_cookie", testObject.getLoadBalancerPoolSessionPersistence().getCookieName());
67 Assert.assertEquals("NeutronLoadBalancerPool JAXB Test 12: Testing session_persistence type failed",
68 "APP_COOKIE", testObject.getLoadBalancerPoolSessionPersistence().getType());