2 * Copyright (c) 2015 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.openflowplugin.impl.services;
10 import static org.junit.Assert.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertTrue;
13 import static org.mockito.Mockito.verify;
15 import org.junit.Test;
16 import org.opendaylight.openflowplugin.api.OFConstants;
17 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
21 import org.opendaylight.yangtools.yang.common.Uint32;
23 public class SendEchoImplTest extends ServiceMocking {
24 private static final Uint32 DUMMY_XID_VALUE = Uint32.valueOf(100);
25 private static final byte[] DUMMY_DATA = "DUMMY DATA".getBytes();
27 private SendEchoImpl sendEcho;
31 sendEcho = new SendEchoImpl(mockedRequestContextStack, mockedDeviceContext);
35 public void testSendEcho() {
36 EchoInputBuilder sendEchoInput = new EchoInputBuilder();
37 sendEcho.handleServiceCall(sendEchoInput);
38 verify(mockedRequestContextStack).createRequestContext();
42 public void testBuildRequest() {
43 EchoInputBuilder sendEchoInput = new EchoInputBuilder().setData(DUMMY_DATA);
44 final OfHeader request = sendEcho.buildRequest(new Xid(DUMMY_XID_VALUE), sendEchoInput);
45 assertEquals(DUMMY_XID_VALUE, request.getXid());
46 assertTrue(request instanceof EchoInput);
47 final byte[] data = ((EchoInput) request).getData();
48 assertArrayEquals(DUMMY_DATA, data);
49 assertEquals(OFConstants.OFP_VERSION_1_3, request.getVersion());