2 * Copyright (c) 2015 NetIDE Consortium 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.BarrierOutput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;
24 * @author giuseppex.petralia@intel.com
27 public class OF10BarrierReplyMessageFactoryTest {
28 private OFSerializer<BarrierOutput> factory;
29 private static final byte MESSAGE_TYPE = 19;
32 public void startUp() {
33 SerializerRegistry registry = new SerializerRegistryImpl();
35 factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierOutput.class));
39 public void testSerialize() throws Exception {
40 BarrierOutputBuilder builder = new BarrierOutputBuilder();
41 BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
42 BarrierOutput message = builder.build();
44 ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
45 factory.serialize(message, serializedBuffer);
46 BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 8);