2 * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.openflowjava.protocol.impl.serialization.factories;
10 import io.netty.buffer.ByteBuf;
11 import io.netty.buffer.UnpooledByteBufAllocator;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
15 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
16 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
17 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
18 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
19 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInputBuilder;
24 * Unit tests for GetaAsyncRequestMessageFactory.
26 * @author timotej.kubas
27 * @author michal.polkorab
29 public class GetaAsyncRequestMessageFactoryTest {
30 private static final byte MESSAGE_TYPE = 26;
31 private static final int MESSAGE_LENGTH = 8;
32 private SerializerRegistry registry;
33 private OFSerializer<GetAsyncInput> getAsyncFactory;
36 * Initializes serializer registry and stores correct factory in field.
39 public void startUp() {
40 registry = new SerializerRegistryImpl();
42 getAsyncFactory = registry.getSerializer(
43 new MessageTypeKey<>(EncodeConstants.OF_VERSION_1_3, GetAsyncInput.class));
47 * Testing of {@link GetAsyncRequestMessageFactory} for correct translation from POJO.
50 public void testGetAsyncReques() throws Exception {
51 GetAsyncInputBuilder builder = new GetAsyncInputBuilder();
52 BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
53 GetAsyncInput message = builder.build();
55 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
56 getAsyncFactory.serialize(message, out);
58 BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);