blob: 7ec6288112561e7e8bae552adcc1c4fc82a66487 [file] [log] [blame]
Sean Condonfae8e662016-12-15 10:25:13 +00001/*
2 * Copyright 2017-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.drivers.microsemi.yang;
17
18import static org.junit.Assert.assertEquals;
19import static org.junit.Assert.assertNotNull;
20import static org.junit.Assert.assertTrue;
21import static org.junit.Assert.fail;
22
23import java.io.UncheckedIOException;
24
25import org.junit.After;
26import org.junit.Before;
27import org.junit.Test;
28import org.onlab.packet.Ip4Address;
29import org.onosproject.drivers.microsemi.yang.impl.MseaCfmManager;
30import org.onosproject.netconf.NetconfDeviceInfo;
31import org.onosproject.netconf.NetconfException;
32import org.onosproject.netconf.NetconfSession;
33import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.MseaCfm;
34import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.DefaultMefCfm;
35import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.MefCfm;
36import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.mefcfm.DefaultMaintenanceDomain;
37import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.mefcfm.MaintenanceDomain;
38import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.mefcfm.maintenancedomain.mdnameandtypecombo.DefaultNameCharacterString;
39import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.cfm.rev20160229.mseacfm.mefcfm.maintenancedomain.mdnameandtypecombo.NameCharacterString;
40import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types.rev20160229.mseatypes.Identifier45;
41import org.onosproject.yms.ymsm.YmsService;
42
43public class MseaCfmManagerTest {
44
45 MseaCfmManager mseaCfmService;
46 YmsService ymsService;
47 NetconfSession session;
48
49 @Before
50 public void setUp() throws Exception {
51 try {
52 mseaCfmService = new MockMseaCfmManager();
53 mseaCfmService.activate();
54 } catch (UncheckedIOException e) {
55 fail(e.getMessage());
56 }
57 NetconfDeviceInfo deviceInfo = new NetconfDeviceInfo("netconf", "netconf", Ip4Address.valueOf("1.2.3.4"), 830);
58 session = new MockNetconfSessionEa1000(deviceInfo);
59 }
60
61 @After
62 public void tearDown() throws Exception {
63 }
64
65 @Test
66 public void testGetConfigMseaCfmEssentials() throws NetconfException {
67 MseaCfm mseaCfm = mseaCfmService.getMepEssentials("md-1", "ma-1-1", 1, session);
68 assertNotNull(mseaCfm);
69
70 //See SAMPLE_MSEACFM_MD_MA_MEP_REPLY in MockNetconfSessionEa1000
71 assertEquals(1, mseaCfm.mefCfm().maintenanceDomain().size());
72 assertEquals(2, mseaCfm.mefCfm().maintenanceDomain().get(0).mdLevel().uint8());
73 }
74
75 /**
76 * Create the Maintenance Domain "md-1".
77 * @throws NetconfException
78 */
79 @Test
80 public void testSetMseaCfm() throws NetconfException {
81 NameCharacterString mdName = DefaultNameCharacterString.builder().name(Identifier45.fromString("md-1")).build();
82
83 MaintenanceDomain yangMd = DefaultMaintenanceDomain.builder()
84 .id((short) 1)
85 .mdNameAndTypeCombo(mdName)
86 .build();
87
88 MefCfm mefCfm = DefaultMefCfm.builder().addToMaintenanceDomain(yangMd).build();
89 //FIXME implement this
90// MseaCfmOpParam mseaCfmOpParam = (MseaCfmOpParam) MseaCfmOpParam.builder().mefCfm(mefCfm).build();
91// mseaCfmService.setMseaCfm(mseaCfmOpParam, session, NcDsType.running);
92 }
93
94 @Test
95 public void testTransmitLoopback() throws NetconfException {
96 try {
97 mseaCfmService.transmitLoopback(null, session);
98 } catch (UnsupportedOperationException e) {
99 assertTrue(e.getMessage().contains("Not yet implemented"));
100 }
101 }
102
103 @Test
104 public void testAbortLoopback() throws NetconfException {
105 try {
106 mseaCfmService.abortLoopback(null, session);
107 } catch (UnsupportedOperationException e) {
108 assertTrue(e.getMessage().contains("Not yet implemented"));
109 }
110 }
111
112 @Test
113 public void testTransmitLinktrace() throws NetconfException {
114 try {
115 mseaCfmService.transmitLinktrace(null, session);
116 } catch (UnsupportedOperationException e) {
117 assertTrue(e.getMessage().contains("Not yet implemented"));
118 }
119 }
120
121}