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;
13 import org.junit.Assert;
14 import org.junit.Test;
16 public class NeutronPortJAXBTest {
18 private static final String NeutronPort_sourceJson = "{ " + "\"status\": \"ACTIVE\", " + "\"name\": \"net1\", "
19 + "\"admin_state_up\": true, " + "\"tenant_id\": \"9bacb3c5d39d41a79512987f338cf177\", "
20 + "\"fixed_ips\": [ { \"ip_address\":\"192.168.111.3\" , "
21 + "\"subnet_id\": \"22b44fc2-4ffb-4de4-b0f9-69d58b37ae27\" } ],"
22 + "\"binding:vif_details\": {\"port_filter\": \"true\" , \"ovs_hybrid_plug\": \"false\" }, "
23 + "\"extra_dhcp_opts\": [\"\"], " + "\"security_groups\": [\"\"], " + "\"allowed_address_pairs\": [\"\"], "
24 + "\"device_id\": \"257614cc-e178-4c92-9c61-3b28d40eca44\", " + "\"device_owner\": \"\", "
25 + "\"binding:host_id\": \"\", " + "\"binding:vif_type\": \"unbound\", "
26 + "\"binding:vnic_type\": \"normal\", " + "\"mac_address\": \"fa:16:3e:c9:cb:f0\", "
27 + "\"network_id\": \"e9330b1f-a2ef-4160-a991-169e56ab17f5\", "
28 + "\"id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\" }";
31 public void test_NeutronPort_JAXB() {
32 NeutronPort testObject = new NeutronPort();
34 NeutronPort neutronObject = (NeutronPort) JaxbTestHelper.jaxbUnmarshall(testObject, NeutronPort_sourceJson);
35 Assert.assertEquals("NeutronPort JAXB Test 1: Testing id failed", "4e8e5957-649f-477b-9e5b-f1f75b21c03c",
36 neutronObject.getID());
38 Assert.assertEquals("NeutronPort JAXB Test 2: Testing tenant_id failed", "9bacb3c5d39d41a79512987f338cf177",
39 neutronObject.getTenantID());
41 Assert.assertEquals("NeutronPort JAXB Test 3: Testing network_id failed",
42 "e9330b1f-a2ef-4160-a991-169e56ab17f5", neutronObject.getNetworkUUID());
44 Assert.assertEquals("NeutronPort JAXB Test 4: Testing status failed", "ACTIVE", neutronObject.getStatus());
46 List<Neutron_IPs> fixedIPs = neutronObject.getFixedIPs();
47 Assert.assertEquals(" NeutronPort JAXB Test 5.1: Testing fixed_ips list length failed", 1, fixedIPs.size());
49 Assert.assertEquals(" NeutronPort JAXB Test 5.2: Testing ip_address value failed", "192.168.111.3",
50 fixedIPs.get(0).ipAddress);
52 Assert.assertEquals(" NeutronPort JAXB Test 5.3: Testing subnet_id value failed",
53 "22b44fc2-4ffb-4de4-b0f9-69d58b37ae27", fixedIPs.get(0).subnetUUID);
55 List<NeutronPort_ExtraDHCPOption> extraDHCPOptions = neutronObject.getExtraDHCPOptions();
57 Assert.assertEquals("NeutronPort JAXB Test 6: Testing extra_dhcp_opts list length failed", 1,
58 extraDHCPOptions.size());
60 List<NeutronSecurityGroup> securityGroups = neutronObject.getSecurityGroups();
61 Assert.assertEquals("NeutronPort JAXB Test 7: Testing security_groups list length failed", 1,
62 securityGroups.size());
64 List<NeutronPort_AllowedAddressPairs> allowedAddressPairs = neutronObject.getAllowedAddressPairs();
65 Assert.assertEquals("NeutronPort JAXB Test 8: Testing allowed_address_pairs list length failed", 1,
66 allowedAddressPairs.size());
68 Map<String, String> vifDetails = neutronObject.getVIFDetails();
70 Assert.assertEquals("NeutronPort JAXB Test 9.1: Testing vif_details list length failed", 2,
73 Assert.assertEquals("NeutronPort JAXB Test 9.2: Testing port_filter value failed", "true",
74 vifDetails.get("port_filter"));
76 Assert.assertEquals("NeutronPort JAXB Test 9.3: Testing ovs_hybrid_plug value failed", "false",
77 vifDetails.get("ovs_hybrid_plug"));
79 Assert.assertEquals("NeutronPort JAXB Test 10: Testing name failed", "net1", neutronObject.getName());
81 Assert.assertEquals("NeutronPort JAXB Test 11: Testing admin_state_up failed", true,
82 neutronObject.getAdminStateUp());
84 Assert.assertEquals("NeutronPort JAXB Test 12: Testing binding:vif_type failed", "unbound",
85 neutronObject.getBindingvifType());
87 Assert.assertEquals("NeutronPort JAXB Test 13: Testing binding:vnic_type failed", "normal",
88 neutronObject.getBindingvnicType());
90 Assert.assertEquals("NeutronPort JAXB Test 14: Testing mac_address failed", "fa:16:3e:c9:cb:f0",
91 neutronObject.getMacAddress());
93 Assert.assertEquals("NeutronPort JAXB Test 15: Testing device_id failed",
94 "257614cc-e178-4c92-9c61-3b28d40eca44", neutronObject.getDeviceID());
96 Assert.assertEquals("NeutronPort JAXB Test 16: Testing device_owner failed", "",
97 neutronObject.getDeviceOwner());
99 Assert.assertEquals("NeutronPort JAXB Test 17: Testing binding:host_id failed", "",
100 neutronObject.getBindinghostID());
102 } catch (Exception e) {
103 Assert.assertFalse("Tests Failed", true);