39632638bf83a631fb8e0c529370b2b792cb8951
[neutron.git] / neutron-spi / src / test / java / org / opendaylight / neutron / spi / NeutronVPNIPSECPolicyJAXBTest.java
1 /*
2  * Copyright (c) 2015 Tata Consultancy Services.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.neutron.spi;
10
11 import org.junit.Assert;
12 import org.junit.Test;
13
14 public class NeutronVPNIPSECPolicyJAXBTest {
15
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 " + "} }";
23
24     @Test
25     public void test_NeutronVPNIPSECPolicy_JAXB() {
26         NeutronVPNIPSECPolicy dummyObject = new NeutronVPNIPSECPolicy();
27         try {
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());
32
33             Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 2: Testing tenant id failed",
34                     "ccb81365fe36411a9011e90491fe1330", testObject.getTenantID());
35
36             Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 3: Testing name failed", "ipsecpolicy1",
37                     testObject.getName());
38
39             Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 5: Testing transform protocol failed", "esp",
40                     testObject.getTransformProtocol());
41
42             Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 6: Testing encapsulation mode failed", "tunnel",
43                     testObject.getEncapsulationMode());
44
45             Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 7: Testing authorization algorithm failed", "sha1",
46                     testObject.getAuthAlgorithm());
47
48             Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 8: Testing encryption algorithm failed", "aes-128",
49                     testObject.getEncryptionAlgorithm());
50
51             Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 9: Testing PerfectForwardSecrecy failed", "group5",
52                     testObject.getPerfectForwardSecrecy());
53
54             Assert.assertEquals("NeutronVPNIPSECPolicy JAXB Test 10: Testing Lifetime unit value failed", "seconds",
55                     testObject.getLifetime().getUnits());
56
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");
61         }
62     }
63 }