2 * Copyright (c) 2017 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.openflowplugin.extension.onf.serializer;
11 import io.netty.buffer.ByteBuf;
12 import io.netty.buffer.UnpooledByteBufAllocator;
13 import java.util.ArrayList;
14 import java.util.Collections;
15 import java.util.List;
16 import org.junit.Assert;
17 import org.junit.Test;
18 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundlePropertyType;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.add.message.grouping.bundle.inner.message.BundlePortModCase;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.add.message.grouping.bundle.inner.message.BundlePortModCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundlePropertyBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenterBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.bundle.property.experimenter.BundlePropertyExperimenterData;
34 * Test for {@link org.opendaylight.openflowplugin.extension.onf.serializer.AbstractBundleMessageFactory}
37 public class AbstractBundleMessageFactoryTest {
40 public void writeBundleFlags() throws Exception {
41 ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
42 AbstractBundleMessageFactory.writeBundleFlags(new BundleFlags(true, true), out);
43 Assert.assertEquals("Wrong flags", 3, out.readUnsignedShort());
46 public static List<BundleProperty> createListWithBundleExperimenterProperty(BundlePropertyExperimenterData data) {
47 BundlePropertyBuilder propertyBuilder = new BundlePropertyBuilder();
48 propertyBuilder.setType(BundlePropertyType.ONFETBPTEXPERIMENTER);
49 BundlePropertyExperimenterBuilder experimenterPropertyBuilder = new BundlePropertyExperimenterBuilder();
50 experimenterPropertyBuilder.setExperimenter(new ExperimenterId(1L));
51 experimenterPropertyBuilder.setExpType(2L);
53 experimenterPropertyBuilder.setBundlePropertyExperimenterData(data);
54 propertyBuilder.setBundlePropertyEntry(experimenterPropertyBuilder.build());
55 return new ArrayList<>(Collections.singleton(propertyBuilder.build()));
58 public static BundlePropertyExperimenterData createBundleExperimenterPropertyData() {
62 public static BundlePortModCase createBundlePortModCase() {
63 BundlePortModCaseBuilder caseBuilder = new BundlePortModCaseBuilder();
64 caseBuilder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
65 caseBuilder.setXid(3L);
66 caseBuilder.setPortNo(new PortNumber(9L));
67 caseBuilder.setHwAddress(new MacAddress("08:00:27:00:B0:EB"));
68 caseBuilder.setConfig(new PortConfig(true, false, true, false));
69 caseBuilder.setMask(new PortConfig(false, true, false, true));
70 caseBuilder.setAdvertise(new PortFeatures(true, false, false, false,
71 false, false, false, true,
72 false, false, false, false,
73 false, false, false, false));
74 return caseBuilder.build();