2 * Copyright (c) 2015 Cisco Systems, Inc. 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.lispflowmapping.serializer.address;
10 import static org.junit.Assert.assertEquals;
12 import java.nio.ByteBuffer;
14 import junitx.framework.ArrayAssert;
16 import org.junit.Test;
17 import org.opendaylight.lispflowmapping.lisp.serializer.address.LispAddressSerializer;
18 import org.opendaylight.lispflowmapping.lisp.serializer.address.LispAddressSerializerContext;
19 import org.opendaylight.lispflowmapping.lisp.util.ByteUtil;
20 import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
21 import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.ServicePathLcaf;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ServicePath;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
27 * Test class for Service Path Serializer.
29 * @author Lorand Jakab
32 public class ServicePathTest extends BaseTestCase {
35 public void deserialize__Simple() throws Exception {
36 Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer("40 03 00 00 "
39 new LispAddressSerializerContext(null));
40 assertEquals(ServicePathLcaf.class, address.getAddressType());
41 ServicePath sp = (ServicePath) address.getAddress();
43 assertEquals(ByteUtil.getPartialInt(new byte[] { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC }),
44 sp.getServicePath().getServicePathId().getValue().intValue());
45 assertEquals((byte) 0xFF, sp.getServicePath().getServiceIndex().byteValue());
49 public void serialize__Simple() throws Exception {
50 Eid eid = LispAddressUtil.asServicePathEid(-1, 1L, (short) 0xFF);
52 ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(eid));
53 LispAddressSerializer.getInstance().serialize(buf, eid);
54 ByteBuffer expectedBuf = hexToByteBuffer("40 03 00 00 "
57 ArrayAssert.assertEquals(expectedBuf.array(), buf.array());