blob: daafa00ab3a46ef7d0fd2a4c6d2297e591f55a31 [file] [log] [blame]
tony-liuea76b8e2016-11-27 15:26:09 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
tony-liuea76b8e2016-11-27 15:26:09 +08003 *
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 */
16
17package org.onosproject.tetunnel.api.tunnel.path;
18
19import com.google.common.collect.Lists;
20import org.junit.Assert;
21import org.junit.Test;
22import org.onosproject.tetopology.management.api.TeTopologyKey;
23import org.onosproject.tetopology.management.api.node.TeNodeKey;
24import org.onosproject.tetopology.management.api.node.TtpKey;
25import org.onosproject.tetunnel.api.lsp.TeLspKey;
26
27import java.util.List;
28
29/**
30 * Unit tests for default TE path implementation.
31 */
32public class DefaultTePathTest {
33
34 /**
35 * Tests constructor of DefaultTePathSelection.
36 */
37 @Test
38 public void testConstructorOfDefaultTePathSelection() {
39 final int providerId = 1;
40 final int clientId = 2;
41 final int topologyId = 3;
42 final long costLimit = 4;
43 final short hopLimit = 5;
44
45 TePathSelection tePathSelection = new DefaultTePathSelection(
46 new TeTopologyKey(providerId, clientId, topologyId),
47 costLimit, hopLimit);
48 Assert.assertEquals(tePathSelection.teTopologyKey(),
49 new TeTopologyKey(providerId, clientId, topologyId));
50 Assert.assertEquals(tePathSelection.costLimit(), costLimit);
51 Assert.assertEquals(tePathSelection.hopLimit(), hopLimit);
52 }
53
54 /**
55 * Tests constructor of DefaultTeRouteUnnumberedLink.
56 */
57 @Test
58 public void testConstructorOfDefaultTeRouteUnnumberedLink() {
59 final int providerId = 1;
60 final int clientId = 2;
61 final int topologyId = 3;
62 final int teNodeId = 4;
63 final int teTtpId = 5;
64
65 TeRouteUnnumberedLink teRouteUnnumberedLink =
66 new DefaultTeRouteUnnumberedLink(
67 new TeNodeKey(providerId, clientId,
68 topologyId, teNodeId),
69 new TtpKey(providerId, clientId,
70 topologyId, teNodeId, teTtpId));
71
72 Assert.assertEquals(teRouteUnnumberedLink.type(),
73 TeRouteSubobject.Type.UNNUMBERED_LINK);
74 Assert.assertEquals(teRouteUnnumberedLink.node(),
75 new TeNodeKey(providerId, clientId,
76 topologyId, teNodeId));
77 Assert.assertEquals(teRouteUnnumberedLink.ttp(),
78 new TtpKey(providerId, clientId,
79 topologyId, teNodeId, teTtpId));
80 }
81
82 /**
83 * Tests constructor of DefaultTePath.
84 */
85 @Test
86 public void testConstructorOfDefaultTePath() {
87 final int providerId = 1;
88 final int clientId = 2;
89 final int topologyId = 3;
90 final int teNodeId = 4;
91 final int teTtpId = 5;
92 final int teLspId = 6;
93
94 List<TeLspKey> lspKeys = Lists.newArrayList(
95 new TeLspKey(providerId, clientId, topologyId, teLspId));
96
97 TeRouteUnnumberedLink teRouteUnnumberedLink =
98 new DefaultTeRouteUnnumberedLink(
99 new TeNodeKey(providerId, clientId,
100 topologyId, teNodeId),
101 new TtpKey(providerId, clientId,
102 topologyId, teNodeId, teTtpId));
103 List<TeRouteSubobject> explicitRoute = Lists.newArrayList(
104 teRouteUnnumberedLink);
105
106 List<TePath> secondaryPaths = Lists.newArrayList(
107 new DefaultTePath(TePath.Type.DYNAMIC, null, null, null)
108 );
109
110 TePath tePath = new DefaultTePath(TePath.Type.EXPLICIT, lspKeys,
111 explicitRoute, secondaryPaths);
112
113 Assert.assertEquals(tePath.type(), TePath.Type.EXPLICIT);
114 Assert.assertEquals(tePath.explicitRoute(), explicitRoute);
115 Assert.assertEquals(tePath.lsps(), lspKeys);
116 Assert.assertEquals(tePath.secondaryPaths(), secondaryPaths);
117 }
118}