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
9 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
11 import io.netty.buffer.ByteBuf;
12 import io.netty.buffer.UnpooledByteBufAllocator;
13 import org.junit.Before;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
16 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
17 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
18 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
19 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
20 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder;
25 * Unit tests for OF10HelloInputMessageFactory.
27 * @author michal.polkorab
29 public class OF10HelloInputMessageFactoryTest {
31 private SerializerRegistry registry;
32 private OFSerializer<HelloInput> helloFactory;
35 * Initializes serializer registry and stores correct factory in field.
38 public void startUp() {
39 registry = new SerializerRegistryImpl();
41 helloFactory = registry.getSerializer(
42 new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, HelloInput.class));
46 * Testing of {@link OF10HelloInputMessageFactory} for correct translation from POJO.
49 public void testWithoutElementsSet() throws Exception {
50 HelloInputBuilder hib = new HelloInputBuilder();
51 BufferHelper.setupHeader(hib, EncodeConstants.OF10_VERSION_ID);
52 HelloInput hi = hib.build();
54 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
55 helloFactory.serialize(hi, out);
57 BufferHelper.checkHeaderV10(out, (byte) 0, 8);