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 org.junit.Assert;
12 import org.junit.Test;
14 import org.opendaylight.neutron.spi.NeutronVPNIPSECPolicy;
16 public class NeutronVPNIPSECPolicyJAXBTest {
18 private static final String NeutronVPNISECPolicy_SingleProvider_sourceJson = "{" +
19 "\"id\": \"5291b189-fd84-46e5-84bd-78f40c05d69c\", " +
20 "\"tenant_id\": \"ccb81365fe36411a9011e90491fe1330\", " +
21 "\"name\": \"ipsecpolicy1\", " +
22 "\"description\": \"update description\", " +
23 "\"transform_protocol\": \"esp\", " +
24 "\"encapsulaion_mode\": \"tunnel\", " +
25 "\"auth_algorithm\": \"sha1\", " +
26 "\"encryption_algorithm\": \"aes-128\", " +
27 "\"pfs\": \"group5\", " +
28 "\"lifetime\": { " + "\"units\": \"seconds\", " + "\"value\": 3600 " + "} }";
31 public void test_NeutronVPNISECPolicy_JAXB() {
32 NeutronVPNIPSECPolicy dummyObject = new NeutronVPNIPSECPolicy();
34 NeutronVPNIPSECPolicy testObject = (NeutronVPNIPSECPolicy) JaxbTestHelper.jaxbUnmarshall(dummyObject, NeutronVPNISECPolicy_SingleProvider_sourceJson);
35 Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 1: Testing id failed",
36 "5291b189-fd84-46e5-84bd-78f40c05d69c", testObject.getID());
38 Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 2: Testing tenant id failed",
39 "ccb81365fe36411a9011e90491fe1330", testObject.getTenantID());
41 Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 3: Testing name failed",
42 "ipsecpolicy1", testObject.getName());
44 Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 4: Testing description failed",
45 "update description", testObject.getDescription());
47 Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 5: Testing transform protocol failed",
48 "esp", testObject.getTransformProtocol());
50 Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 6: Testing encapsulation mode failed",
51 "tunnel", testObject.getEncapsulationMode());
53 Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 7: Testing authorization algorithm failed",
54 "sha1", testObject.getAuthAlgorithm());
56 Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 8: Testing encryption algorithm failed",
57 "aes-128", testObject.getEncryptionAlgorithm());
59 Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 9: Testing PerfectForwardSecrecy failed",
60 "group5", testObject.getPerfectForwardSecrecy());
62 Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 10: Testing Lifetime unit value failed",
63 "seconds", testObject.getLifetime().getUnits());
65 Assert.assertEquals("NeutronVPNISECPolicy JAXB Test 11: Testing Lifetime value failed",
66 new Integer(3600), testObject.getLifetime().getValue());
67 } catch (Exception e) {
68 Assert.fail("Tests failed");