2 * Copyright (C) 2014 Cisco Systems, Inc.
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
8 * Authors : Thomas Bachman
11 package org.opendaylight.groupbasedpolicy.renderer.opflex;
13 import static org.junit.Assert.assertTrue;
15 import java.util.List;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.mockito.MockitoAnnotations;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3Address;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
28 public class IdentityTest {
29 protected static final Logger logger = LoggerFactory.getLogger(IdentityTest.class);
34 public void setUp() throws Exception {
35 MockitoAnnotations.initMocks(this);
39 private static final String TEST_IP = "192.168.194.132";
40 private static final String TEST_MAC2 = "11:22:33:44:55:66";
41 private static final String TEST_CONTEXT = "9AC3DB0E-C47A-4409-B1AD-BDE647A29440";
44 public void testL3Identity() throws Exception {
45 id = new Identity(TEST_IP);
46 id.setContext(TEST_CONTEXT);
47 assertTrue(id.identityAsString().equals(TEST_IP));
48 assertTrue(id.getL3Context().getValue().equals(TEST_CONTEXT));
49 List<L3Address> lid = id.getL3Addresses();
50 assertTrue(lid.size() == 1);
51 for (L3Address l3addr : lid) {
52 assertTrue(l3addr.getIpAddress().equals(id.getL3Identity()));
53 assertTrue(l3addr.getL3Context().getValue().equals(TEST_CONTEXT));
55 //L2BridgeDomainId l2bdid = id.getL2Context();
56 //assertTrue(l2bdid.getValue().equals(TEST_CONTEXT));
60 public void testL2Identity() throws Exception {
61 id = new Identity(TEST_MAC2);
62 id.setContext(TEST_CONTEXT);
63 assertTrue(id.identityAsString().equals(TEST_MAC2));
64 assertTrue(id.getL2Identity().getValue().equals(TEST_MAC2));