X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-dom-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Ftest%2Fbugfix%2FFlagsSerializationTest.java;h=30c7af705f2ccba4a25e3b1d19f8261e3439386a;hb=a71bb09b4111391921854c2776edc746108c53c1;hp=1304f0d52a8fb5da53fc8aa6130badd8666917f1;hpb=1ff9939abc7a4072b07df6b79516fe344b1b42e3;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/FlagsSerializationTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/FlagsSerializationTest.java index 1304f0d52a..30c7af705f 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/FlagsSerializationTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/FlagsSerializationTest.java @@ -1,35 +1,25 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.sal.binding.test.bugfix; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - - - - - - - - - - - - - - - - - - import org.junit.Test; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; +import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action; @@ -48,16 +38,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -65,28 +52,21 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; - -import static org.junit.Assert.*; public class FlagsSerializationTest extends AbstractDataServiceTest { private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "id"); private static final QName FLOW_ID_QNAME = QName.create(Flow.QNAME, "id"); private static final QName FLOW_NODE_QNAME = QName.create(Flow.QNAME, "node"); - private static final long FLOW_ID = 1234; + private static final String FLOW_ID = "1234"; private static final short TABLE_ID = (short)0; private static final String NODE_ID = "node:1"; private static final NodeKey NODE_KEY = new NodeKey(new NodeId(NODE_ID)); private static final FlowKey FLOW_KEY = new FlowKey(new FlowId(FLOW_ID)); private static final TableKey TABLE_KEY = new TableKey(TABLE_ID); - + private static final Map NODE_KEY_BI = Collections. singletonMap(NODE_ID_QNAME, NODE_ID); @@ -104,12 +84,12 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { // private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier FLOW_INSTANCE_ID_BI = // // org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() // -// +// // .node(Flows.QNAME) // // .nodeWithKey(Flow.QNAME, FLOW_KEY_BI) // // .toInstance(); private static final InstanceIdentifier FLOW_INSTANCE_ID_BA = // - InstanceIdentifier.builder(NODE_INSTANCE_ID_BA) // + NODE_INSTANCE_ID_BA.builder() // .augmentation(FlowCapableNode.class) .child(Table.class,TABLE_KEY) .child(Flow.class, FLOW_KEY) // @@ -122,34 +102,34 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { FlowModFlags checkOverlapFlags = new FlowModFlags(true,false,false,false,false); ImmutableSet domCheckOverlapFlags = ImmutableSet.of("CHECK_OVERLAP"); testFlags(checkOverlapFlags,domCheckOverlapFlags); - - - + + + FlowModFlags allFalseFlags = new FlowModFlags(false,false,false,false,false); ImmutableSet domAllFalseFlags = ImmutableSet.of(); testFlags(allFalseFlags,domAllFalseFlags); - + FlowModFlags allTrueFlags = new FlowModFlags(true,true,true,true,true); ImmutableSet domAllTrueFlags = ImmutableSet.of("CHECK_OVERLAP","NO_BYT_COUNTS", "NO_PKT_COUNTS", "RESET_COUNTS", "SEND_FLOW_REM"); testFlags(allTrueFlags,domAllTrueFlags); - + FlowModFlags nullFlags = null; ImmutableSet domNullFlags = null; testFlags(null,null); - - + + } private void testFlags(FlowModFlags flagsToTest, ImmutableSet domFlags) throws Exception { Flow flow = createFlow(flagsToTest); assertNotNull(flow); - + CompositeNode domFlow = biDataService.readConfigurationData(mappingService.toDataDom(FLOW_INSTANCE_ID_BA)); - + assertNotNull(domFlow); org.opendaylight.yangtools.yang.data.api.Node readedFlags = domFlow.getFirstSimpleByName(FLOW_FLAGS_QNAME); - + if(domFlags != null) { assertNotNull(readedFlags); assertEquals(domFlags,readedFlags.getValue()); @@ -157,12 +137,12 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { assertNull(readedFlags); } assertEquals(flagsToTest, flow.getFlags()); - + DataModificationTransaction transaction = baDataService.beginTransaction(); transaction.removeConfigurationData(FLOW_INSTANCE_ID_BA); RpcResult result = transaction.commit().get(); assertEquals(TransactionStatus.COMMITED, result.getResult()); - + } private Flow createFlow(FlowModFlags flagsToTest) throws Exception { @@ -179,12 +159,12 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { flow.setKey(FLOW_KEY); flow.setMatch(match.build()); - + flow.setFlags(flagsToTest); - + InstructionsBuilder instructions = new InstructionsBuilder(); InstructionBuilder instruction = new InstructionBuilder(); - + instruction.setOrder(10); ApplyActionsBuilder applyActions = new ApplyActionsBuilder(); List actionList = new ArrayList<>();