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 NeutronVPNIPSECPolicyJAXBTest {
16 private static final String NeutronVPNIPSECPolicy_SingleProvider_sourceJson = "{"
17 + "\"id\": \"5291b189-fd84-46e5-84bd-78f40c05d69c\", "
18 + "\"tenant_id\": \"ccb81365fe36411a9011e90491fe1330\", " + "\"name\": \"ipsecpolicy1\", "
19 + "\"description\": \"update description\", " + "\"transform_protocol\": \"esp\", "
20 + "\"encapsulation_mode\": \"tunnel\", " + "\"auth_algorithm\": \"sha1\", "
21 + "\"encryption_algorithm\": \"aes-128\", " + "\"pfs\": \"group5\", " + "\"lifetime\": { "
22 + "\"units\": \"seconds\", " + "\"value\": 3600 " + "} }";
25 public void test_NeutronVPNIPSECPolicy_JAXB() {
26 NeutronVPNIPSECPolicy dummyObject = new NeutronVPNIPSECPolicy();
28 NeutronVPNIPSECPolicy testObject = (NeutronVPNIPSECPolicy) JaxbTestHelper.jaxbUnmarshall(dummyObject,
29 NeutronVPNIPSECPolicy_SingleProvider_sourceJson);
30 Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 1: Testing id failed",
31 "5291b189-fd84-46e5-84bd-78f40c05d69c", testObject.getID());
33 Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 2: Testing tenant id failed",
34 "ccb81365fe36411a9011e90491fe1330", testObject.getTenantID());
36 Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 3: Testing name failed", "ipsecpolicy1",
37 testObject.getName());
39 Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 5: Testing transform protocol failed", "esp",
40 testObject.getTransformProtocol());
42 Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 6: Testing encapsulation mode failed", "tunnel",
43 testObject.getEncapsulationMode());
45 Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 7: Testing authorization algorithm failed", "sha1",
46 testObject.getAuthAlgorithm());
48 Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 8: Testing encryption algorithm failed", "aes-128",
49 testObject.getEncryptionAlgorithm());
51 Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 9: Testing PerfectForwardSecrecy failed", "group5",
52 testObject.getPerfectForwardSecrecy());
54 Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 10: Testing Lifetime unit value failed", "seconds",
55 testObject.getLifetime().getUnits());
57 Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 11: Testing Lifetime value failed", new Integer(3600),
58 testObject.getLifetime().getValue());
59 } catch (Exception e) {
60 Assert.fail("Tests failed");