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 org.junit.Assert;
12 import org.junit.Test;
14 public class NeutronSecurityGroupJAXBTest {
15 private static final String NeutronSecurityGroup_sourceJson = "{"
16 + "\"id\": \"2076db17-a522-4506-91de-c6dd8e837028\", " + "\"name\": \"new-webservers\", "
17 + "\"description\": \"security group for webservers\", "
18 + "\"tenant_id\": \"b4f50856753b4dc6afee5fa6b9b6c550\", "
19 + "\"security_group_rules\": [ { \"id\": \"2bc0accf-312e-429a-956e-e4407625eb62\" , "
20 + "\"direction\": \"ingress\" , " + "\"protocol\": \"tcp\" , " + "\"port_range_min\": 80 , "
21 + "\"port_range_max\": 80 , " + "\"ethertype\": \"IPv4\" ," + "\"remote_ip_prefix\": \"0.0.0.0/0\" , "
22 + "\"remote_group_id\": \"85cc3048-abc3-43cc-89b3-377341426ac5\" , "
23 + "\"security_group_id\": \"a7734e61-b545-452d-a3cd-0189cbd9747a\" , "
24 + "\"tenant_id\": \"e4f50856753b4dc6afee5fa6b9b6c550\" } ]" + "}";
27 public void test_NeutronSecurityGroup_JAXB() {
28 NeutronSecurityGroup dummyObject = new NeutronSecurityGroup();
30 NeutronSecurityGroup testObject = (NeutronSecurityGroup) JaxbTestHelper.jaxbUnmarshall(dummyObject,
31 NeutronSecurityGroup_sourceJson);
32 Assert.assertEquals("NeutronSecurityGroup JAXB Test 1: Testing id failed",
33 "2076db17-a522-4506-91de-c6dd8e837028", testObject.getID());
35 Assert.assertEquals("NeutronSecurityGroup JAXB Test 2: Testing direction failed", "new-webservers",
36 testObject.getSecurityGroupName());
38 Assert.assertEquals("NeutronSecurityGroup JAXB Test 4: Testing port range min failed",
39 "b4f50856753b4dc6afee5fa6b9b6c550", testObject.getTenantID());
40 } catch (Exception e) {
41 Assert.fail("Tests failed");