2 * Copyright (c) 2014 Cisco Systems, Inc. and others. 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
8 package org.opendaylight.controller.sal.compatibility.test;
10 import junit.framework.Assert;
12 import org.junit.Test;
13 import org.opendaylight.controller.sal.action.Action;
14 import org.opendaylight.controller.sal.action.PushVlan;
15 import org.opendaylight.controller.sal.compatibility.MDFlowMapping;
16 import org.opendaylight.controller.sal.core.ConstructionException;
17 import org.opendaylight.controller.sal.core.Node;
18 import org.opendaylight.controller.sal.core.Node.NodeIDType;
19 import org.opendaylight.controller.sal.core.NodeConnector;
20 import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
21 import org.opendaylight.controller.sal.utils.EtherTypes;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
27 * test for {@link MDFlowMapping}
29 public class MDFlowMappingTest {
32 * Test method for {@link org.opendaylight.controller.sal.compatibility.MDFlowMapping#toUri(org.opendaylight.controller.sal.core.NodeConnector)}.
33 * @throws ConstructionException
36 public void testToUri() throws ConstructionException {
37 Node node = new Node(NodeIDType.OPENFLOW, 41L);
38 NodeConnector connector = new NodeConnector(NodeConnectorIDType.OPENFLOW, (short) 42, node);
39 Uri observed = MDFlowMapping.toUri(connector );
41 Assert.assertEquals("openflow:41:42", observed.getValue());
45 * Test method for {@link MDFlowMapping#toAction(Action, int)}.
48 public void testToAction() {
50 EtherTypes[] tags = {EtherTypes.VLANTAGGED, EtherTypes.QINQ};
52 for (EtherTypes tag: tags) {
53 Action action = new PushVlan(tag);
54 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.
55 rev131112.action.list.Action mdActionList =
56 MDFlowMapping.toAction(action, order);
57 Assert.assertEquals(order, mdActionList.getOrder().intValue());
59 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.
60 rev131112.action.Action mdAction = mdActionList.getAction();
61 Assert.assertTrue(mdAction instanceof PushVlanActionCase);
62 PushVlanActionCase pushVlan = (PushVlanActionCase)mdAction;
63 Assert.assertEquals(tag.intValue(),
64 pushVlan.getPushVlanAction().getEthernetType().