From 69eca29208f36b9a02992319cc36d1d221189ff0 Mon Sep 17 00:00:00 2001 From: Basheeruddin Ahmed Date: Fri, 1 Aug 2014 16:06:18 -0700 Subject: [PATCH] Added test cases for each .proto file to ensure that test case fail in case incompatible version of the protocol buffer is utilized. New Patch: Updated with copyright header Change-Id: Ib7fe9e212c6319f46202506d96544d149da28004 Signed-off-by: Basheeruddin Ahmed --- .../sal-protocolbuffer-encoding/README-FIRST | 6 +- .../node/NodeToNormalizedNodeBuilder.java | 10 + .../datastore/node/NodeValueCodec.java | 10 +- .../node/NormalizedNodeToNodeCodec.java | 10 + .../NormalizedNodeToProtocolBufferNode.java | 10 + .../AugmentationIdentifierGenerator.java | 10 + .../node/utils/NodeIdentifierFactory.java | 10 + .../node/utils/NodeIdentifierGenerator.java | 10 + ...NodeIdentifierWithPredicatesGenerator.java | 10 + .../NodeIdentifierWithValueGenerator.java | 10 + .../node/utils/NormalizedNodeGetter.java | 10 + .../node/utils/NormalizedNodeNavigator.java | 10 + .../node/utils/NormalizedNodePrinter.java | 10 + .../node/utils/NormalizedNodeVisitor.java | 10 + .../datastore/node/utils/PathUtils.java | 10 + .../datastore/node/utils/QNameFactory.java | 10 + .../datastore/util/EncoderDecoderUtil.java | 17 +- .../util/InstanceIdentifierUtils.java | 10 + .../mdsal/CompositeModificationPayload.java | 10 + .../ThreePhaseCommitCohortMessages.java | 12 +- .../common/NormalizedNodeMessages.java | 186 ++-- .../common/SimpleNormalizedNodeMessage.java | 26 +- .../DataChangeListenerMessages.java | 46 +- .../persistent/PersistentMessages.java | 44 +- .../ListenerRegistrationMessages.java | 34 +- .../messages/shard/ShardManagerMessages.java | 34 +- .../ShardTransactionChainMessages.java | 18 +- .../transaction/ShardTransactionMessages.java | 82 +- .../node/NormalizedNodeToNodeCodecTest.java | 200 +++-- .../node/utils/NodeIdentifierFactoryTest.java | 25 +- .../util/InstanceIdentifierUtilsTest.java | 176 ++-- .../util/NormalizedNodeXmlConverterTest.java | 709 +++++++-------- .../cluster/datastore/util/TestModel.java | 838 +++++++++--------- .../messages/AbstractMessagesTest.java | 77 ++ .../messages/ShardManagerMessagesTest.java | 42 - .../ThreePhaseCommitCohortMessagesTest.java | 68 ++ .../common/NormalizedNodeMessagesTest.java | 58 ++ .../DataChangeListenerMessagesTest.java | 78 ++ .../persistent/PersistentMessagesTest.java | 82 ++ .../ListenerRegistrationMessagesTest.java | 58 ++ .../shard/ShardManagerMessagesTest.java | 61 ++ .../ShardTransactionChainMessagesTest.java | 69 ++ .../ShardTransactionMessagesTest.java | 79 +- .../src/test/resources/augment_choice.xml | 10 + .../resources/simple_xml_with_attributes.xml | 10 + .../DataChangeListenerMessagesData | 4 + .../ListenerRegistrationMessagesData | 2 + .../NormalizedNodeMessagesTestData | 2 + .../PersistentMessagesTestData | 5 + .../ShardManagerMessagesTestData | 2 + .../ShardTransactionChainMessagesTestData | 2 + .../ShardTransactionMessagesTestData | 5 + .../ThreePhaseCommitCohortMessagesTestData | 1 + .../readme.txt | 18 + 54 files changed, 2149 insertions(+), 1207 deletions(-) create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/AbstractMessagesTest.java delete mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/ShardManagerMessagesTest.java create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessagesTest.java create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessagesTest.java create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessagesTest.java create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessagesTest.java create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessagesTest.java create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessagesTest.java create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessagesTest.java create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/DataChangeListenerMessagesData create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ListenerRegistrationMessagesData create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/NormalizedNodeMessagesTestData create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/PersistentMessagesTestData create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardManagerMessagesTestData create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardTransactionChainMessagesTestData create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardTransactionMessagesTestData create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ThreePhaseCommitCohortMessagesTestData create mode 100644 opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/readme.txt diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/README-FIRST b/opendaylight/md-sal/sal-protocolbuffer-encoding/README-FIRST index d0be2cbcbb..4791979c17 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/README-FIRST +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/README-FIRST @@ -24,5 +24,9 @@ machine 6. !!!WARNING!!! - never edit the generated sources files of protocol buffer -7. !!!NOTE!!! if you are planning to add new .proto file option java_package should begin with +7. !!!IMPORTANT!!! if you are planning to add new .proto file option java_package should begin with org.opendaylight.controller.protobuff.messages to properly exclude from sonar. + +8. !!!IMPORTANT!!! for any new .proto file added you need to create corresponding version-compatibility-serialized-data + serialized test file under test/resources and a test case for one message in your .proto file. + Please follow the instruction in readme.txt in that folder diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeToNormalizedNodeBuilder.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeToNormalizedNodeBuilder.java index ce120809d7..03d632b61f 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeToNormalizedNodeBuilder.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeToNormalizedNodeBuilder.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node; import com.google.common.base.Preconditions; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeValueCodec.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeValueCodec.java index 7b6f5c46d2..14ca75b9f3 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeValueCodec.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NodeValueCodec.java @@ -1,9 +1,11 @@ /* - * 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 + * 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.cluster.datastore.node; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java index fc4b3954c5..17bdb36e56 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodec.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node; import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToProtocolBufferNode.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToProtocolBufferNode.java index fb15312665..68d3c590e0 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToProtocolBufferNode.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToProtocolBufferNode.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node; import com.google.common.base.Preconditions; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/AugmentationIdentifierGenerator.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/AugmentationIdentifierGenerator.java index a34307f6b4..e2c4c35893 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/AugmentationIdentifierGenerator.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/AugmentationIdentifierGenerator.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node.utils; import org.opendaylight.yangtools.yang.common.QName; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java index 175e242a11..ea3986f4a0 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactory.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node.utils; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierGenerator.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierGenerator.java index 9edec1e230..1b9c70867d 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierGenerator.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierGenerator.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node.utils; import org.opendaylight.yangtools.yang.common.QName; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithPredicatesGenerator.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithPredicatesGenerator.java index 4bfcf391dd..6d3a26ad77 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithPredicatesGenerator.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithPredicatesGenerator.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node.utils; import org.opendaylight.yangtools.yang.common.QName; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java index b2ec5644d4..2d434fffcf 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierWithValueGenerator.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node.utils; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java index e82a23d37f..31e6521a28 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeGetter.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node.utils; import com.google.common.base.Preconditions; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeNavigator.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeNavigator.java index 4ccc7076ff..0083b00403 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeNavigator.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeNavigator.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node.utils; import com.google.common.base.Preconditions; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java index 7735a12a8b..d370eb2deb 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodePrinter.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node.utils; import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeVisitor.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeVisitor.java index 69b00bef92..9e85ccb9ab 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeVisitor.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/NormalizedNodeVisitor.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node.utils; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java index ba81836ea8..cf5174319d 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node.utils; public class PathUtils { diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java index 8dba0563bd..002b9ff82e 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node.utils; import org.opendaylight.yangtools.yang.common.QName; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/EncoderDecoderUtil.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/EncoderDecoderUtil.java index d9a067b573..90f5cf3396 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/EncoderDecoderUtil.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/EncoderDecoderUtil.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.util; import com.google.common.base.Preconditions; @@ -44,13 +54,6 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -/* - * 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 - */ /* * * EncoderDecoderUtil helps in wrapping the NormalizedNode into a SimpleNormalizedNode diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtils.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtils.java index 5b459e7e7c..55cb341086 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtils.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtils.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.util; import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/mdsal/CompositeModificationPayload.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/mdsal/CompositeModificationPayload.java index 87b246bd7e..99f4751875 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/mdsal/CompositeModificationPayload.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/mdsal/CompositeModificationPayload.java @@ -1,3 +1,13 @@ +/* + * + * 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 + * + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: CompositeModificationPayload.proto diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessages.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessages.java index ac0701a6d8..49cb1ead9c 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessages.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessages.java @@ -1,3 +1,13 @@ +/* + * + * 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 + * + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: Cohort.proto @@ -652,7 +662,7 @@ public final class ThreePhaseCommitCohortMessages { public final boolean isInitialized() { if (!hasCanCommit()) { - + return false; } return true; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java index 81e5b462cc..f88b66bcd3 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessages.java @@ -1,3 +1,13 @@ +/* + * + * 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 + * + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: Common.proto @@ -179,7 +189,7 @@ public final class NormalizedNodeMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -195,7 +205,7 @@ public final class NormalizedNodeMessages { getNameBytes() { java.lang.Object ref = name_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); name_ = b; @@ -222,7 +232,7 @@ public final class NormalizedNodeMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -238,7 +248,7 @@ public final class NormalizedNodeMessages { getValueBytes() { java.lang.Object ref = value_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); value_ = b; @@ -265,7 +275,7 @@ public final class NormalizedNodeMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -281,7 +291,7 @@ public final class NormalizedNodeMessages { getTypeBytes() { java.lang.Object ref = type_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); type_ = b; @@ -541,7 +551,7 @@ public final class NormalizedNodeMessages { public final boolean isInitialized() { if (!hasName()) { - + return false; } return true; @@ -595,7 +605,7 @@ public final class NormalizedNodeMessages { getNameBytes() { java.lang.Object ref = name_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); name_ = b; @@ -669,7 +679,7 @@ public final class NormalizedNodeMessages { getValueBytes() { java.lang.Object ref = value_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); value_ = b; @@ -743,7 +753,7 @@ public final class NormalizedNodeMessages { getTypeBytes() { java.lang.Object ref = type_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); type_ = b; @@ -930,7 +940,7 @@ public final class NormalizedNodeMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -946,7 +956,7 @@ public final class NormalizedNodeMessages { getValueBytes() { java.lang.Object ref = value_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); value_ = b; @@ -1168,7 +1178,7 @@ public final class NormalizedNodeMessages { public final boolean isInitialized() { if (!hasValue()) { - + return false; } return true; @@ -1222,7 +1232,7 @@ public final class NormalizedNodeMessages { getValueBytes() { java.lang.Object ref = value_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); value_ = b; @@ -1341,7 +1351,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; */ - java.util.List + java.util.List getAttributesList(); /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; @@ -1354,7 +1364,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; */ - java.util.List + java.util.List getAttributesOrBuilderList(); /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; @@ -1504,7 +1514,7 @@ public final class NormalizedNodeMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -1520,7 +1530,7 @@ public final class NormalizedNodeMessages { getValueBytes() { java.lang.Object ref = value_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); value_ = b; @@ -1555,7 +1565,7 @@ public final class NormalizedNodeMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -1575,7 +1585,7 @@ public final class NormalizedNodeMessages { getTypeBytes() { java.lang.Object ref = type_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); type_ = b; @@ -1619,7 +1629,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; */ - public java.util.List + public java.util.List getAttributesOrBuilderList() { return attributes_; } @@ -1948,7 +1958,7 @@ public final class NormalizedNodeMessages { attributesBuilder_ = null; attributes_ = other.attributes_; bitField0_ = (bitField0_ & ~0x00000008); - attributesBuilder_ = + attributesBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getAttributesFieldBuilder() : null; } else { @@ -1962,18 +1972,18 @@ public final class NormalizedNodeMessages { public final boolean isInitialized() { if (!hasValue()) { - + return false; } if (hasNodeType()) { if (!getNodeType().isInitialized()) { - + return false; } } for (int i = 0; i < getAttributesCount(); i++) { if (!getAttributes(i).isInitialized()) { - + return false; } } @@ -2028,7 +2038,7 @@ public final class NormalizedNodeMessages { getValueBytes() { java.lang.Object ref = value_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); value_ = b; @@ -2114,7 +2124,7 @@ public final class NormalizedNodeMessages { getTypeBytes() { java.lang.Object ref = type_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); type_ = b; @@ -2275,7 +2285,7 @@ public final class NormalizedNodeMessages { * optional .org.opendaylight.controller.mdsal.QName nodeType = 3; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QName.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.QNameOrBuilder> getNodeTypeFieldBuilder() { if (nodeTypeBuilder_ == null) { nodeTypeBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -2483,7 +2493,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; */ - public java.util.List + public java.util.List getAttributesOrBuilderList() { if (attributesBuilder_ != null) { return attributesBuilder_.getMessageOrBuilderList(); @@ -2509,12 +2519,12 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 4; */ - public java.util.List + public java.util.List getAttributesBuilderList() { return getAttributesFieldBuilder().getBuilderList(); } private com.google.protobuf.RepeatedFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder> getAttributesFieldBuilder() { if (attributesBuilder_ == null) { attributesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< @@ -2546,7 +2556,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; */ - java.util.List + java.util.List getArgumentsList(); /** * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; @@ -2559,7 +2569,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; */ - java.util.List + java.util.List getArgumentsOrBuilderList(); /** * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; @@ -2680,7 +2690,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; */ - public java.util.List + public java.util.List getArgumentsOrBuilderList() { return arguments_; } @@ -2933,7 +2943,7 @@ public final class NormalizedNodeMessages { argumentsBuilder_ = null; arguments_ = other.arguments_; bitField0_ = (bitField0_ & ~0x00000001); - argumentsBuilder_ = + argumentsBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getArgumentsFieldBuilder() : null; } else { @@ -2948,7 +2958,7 @@ public final class NormalizedNodeMessages { public final boolean isInitialized() { for (int i = 0; i < getArgumentsCount(); i++) { if (!getArguments(i).isInitialized()) { - + return false; } } @@ -3169,7 +3179,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; */ - public java.util.List + public java.util.List getArgumentsOrBuilderList() { if (argumentsBuilder_ != null) { return argumentsBuilder_.getMessageOrBuilderList(); @@ -3195,12 +3205,12 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.PathArgument arguments = 1; */ - public java.util.List + public java.util.List getArgumentsBuilderList() { return getArgumentsFieldBuilder().getBuilderList(); } private com.google.protobuf.RepeatedFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgument.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.PathArgumentOrBuilder> getArgumentsFieldBuilder() { if (argumentsBuilder_ == null) { argumentsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< @@ -3262,7 +3272,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; */ - java.util.List + java.util.List getAttributesList(); /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; @@ -3275,7 +3285,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; */ - java.util.List + java.util.List getAttributesOrBuilderList(); /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; @@ -3287,7 +3297,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Node child = 4; */ - java.util.List + java.util.List getChildList(); /** * repeated .org.opendaylight.controller.mdsal.Node child = 4; @@ -3300,7 +3310,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Node child = 4; */ - java.util.List + java.util.List getChildOrBuilderList(); /** * repeated .org.opendaylight.controller.mdsal.Node child = 4; @@ -3546,7 +3556,7 @@ public final class NormalizedNodeMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -3562,7 +3572,7 @@ public final class NormalizedNodeMessages { getPathBytes() { java.lang.Object ref = path_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); path_ = b; @@ -3589,7 +3599,7 @@ public final class NormalizedNodeMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -3605,7 +3615,7 @@ public final class NormalizedNodeMessages { getTypeBytes() { java.lang.Object ref = type_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); type_ = b; @@ -3627,7 +3637,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; */ - public java.util.List + public java.util.List getAttributesOrBuilderList() { return attributes_; } @@ -3663,7 +3673,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Node child = 4; */ - public java.util.List + public java.util.List getChildOrBuilderList() { return child_; } @@ -3704,7 +3714,7 @@ public final class NormalizedNodeMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -3720,7 +3730,7 @@ public final class NormalizedNodeMessages { getValueBytes() { java.lang.Object ref = value_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); value_ = b; @@ -3747,7 +3757,7 @@ public final class NormalizedNodeMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -3763,7 +3773,7 @@ public final class NormalizedNodeMessages { getValueTypeBytes() { java.lang.Object ref = valueType_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); valueType_ = b; @@ -4202,7 +4212,7 @@ public final class NormalizedNodeMessages { attributesBuilder_ = null; attributes_ = other.attributes_; bitField0_ = (bitField0_ & ~0x00000004); - attributesBuilder_ = + attributesBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getAttributesFieldBuilder() : null; } else { @@ -4228,7 +4238,7 @@ public final class NormalizedNodeMessages { childBuilder_ = null; child_ = other.child_; bitField0_ = (bitField0_ & ~0x00000008); - childBuilder_ = + childBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getChildFieldBuilder() : null; } else { @@ -4266,19 +4276,19 @@ public final class NormalizedNodeMessages { public final boolean isInitialized() { for (int i = 0; i < getAttributesCount(); i++) { if (!getAttributes(i).isInitialized()) { - + return false; } } for (int i = 0; i < getChildCount(); i++) { if (!getChild(i).isInitialized()) { - + return false; } } if (hasInstanceIdentifierValue()) { if (!getInstanceIdentifierValue().isInitialized()) { - + return false; } } @@ -4333,7 +4343,7 @@ public final class NormalizedNodeMessages { getPathBytes() { java.lang.Object ref = path_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); path_ = b; @@ -4407,7 +4417,7 @@ public final class NormalizedNodeMessages { getTypeBytes() { java.lang.Object ref = type_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); type_ = b; @@ -4647,7 +4657,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; */ - public java.util.List + public java.util.List getAttributesOrBuilderList() { if (attributesBuilder_ != null) { return attributesBuilder_.getMessageOrBuilderList(); @@ -4673,12 +4683,12 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Attribute attributes = 3; */ - public java.util.List + public java.util.List getAttributesBuilderList() { return getAttributesFieldBuilder().getBuilderList(); } private com.google.protobuf.RepeatedFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Attribute.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.AttributeOrBuilder> getAttributesFieldBuilder() { if (attributesBuilder_ == null) { attributesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< @@ -4887,7 +4897,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Node child = 4; */ - public java.util.List + public java.util.List getChildOrBuilderList() { if (childBuilder_ != null) { return childBuilder_.getMessageOrBuilderList(); @@ -4913,12 +4923,12 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.Node child = 4; */ - public java.util.List + public java.util.List getChildBuilderList() { return getChildFieldBuilder().getBuilderList(); } private com.google.protobuf.RepeatedFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> getChildFieldBuilder() { if (childBuilder_ == null) { childBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< @@ -4961,7 +4971,7 @@ public final class NormalizedNodeMessages { getValueBytes() { java.lang.Object ref = value_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); value_ = b; @@ -5035,7 +5045,7 @@ public final class NormalizedNodeMessages { getValueTypeBytes() { java.lang.Object ref = valueType_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); valueType_ = b; @@ -5277,7 +5287,7 @@ public final class NormalizedNodeMessages { * optional .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierValue = 8; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> getInstanceIdentifierValueFieldBuilder() { if (instanceIdentifierValueBuilder_ == null) { instanceIdentifierValueBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -5459,7 +5469,7 @@ public final class NormalizedNodeMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -5475,7 +5485,7 @@ public final class NormalizedNodeMessages { getParentPathBytes() { java.lang.Object ref = parentPath_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); parentPath_ = b; @@ -5751,12 +5761,12 @@ public final class NormalizedNodeMessages { public final boolean isInitialized() { if (!hasParentPath()) { - + return false; } if (hasNormalizedNode()) { if (!getNormalizedNode().isInitialized()) { - + return false; } } @@ -5811,7 +5821,7 @@ public final class NormalizedNodeMessages { getParentPathBytes() { java.lang.Object ref = parentPath_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); parentPath_ = b; @@ -5960,7 +5970,7 @@ public final class NormalizedNodeMessages { * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> getNormalizedNodeFieldBuilder() { if (normalizedNodeBuilder_ == null) { normalizedNodeBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -6431,16 +6441,16 @@ public final class NormalizedNodeMessages { public final boolean isInitialized() { if (!hasInstanceIdentifierPath()) { - + return false; } if (!getInstanceIdentifierPath().isInitialized()) { - + return false; } if (hasNormalizedNode()) { if (!getNormalizedNode().isInitialized()) { - + return false; } } @@ -6570,7 +6580,7 @@ public final class NormalizedNodeMessages { * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> getInstanceIdentifierPathFieldBuilder() { if (instanceIdentifierPathBuilder_ == null) { instanceIdentifierPathBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -6687,7 +6697,7 @@ public final class NormalizedNodeMessages { * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> getNormalizedNodeFieldBuilder() { if (normalizedNodeBuilder_ == null) { normalizedNodeBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -6718,7 +6728,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; */ - java.util.List + java.util.List getMapEntriesList(); /** * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; @@ -6731,7 +6741,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; */ - java.util.List + java.util.List getMapEntriesOrBuilderList(); /** * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; @@ -6852,7 +6862,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; */ - public java.util.List + public java.util.List getMapEntriesOrBuilderList() { return mapEntries_; } @@ -7105,7 +7115,7 @@ public final class NormalizedNodeMessages { mapEntriesBuilder_ = null; mapEntries_ = other.mapEntries_; bitField0_ = (bitField0_ & ~0x00000001); - mapEntriesBuilder_ = + mapEntriesBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getMapEntriesFieldBuilder() : null; } else { @@ -7120,7 +7130,7 @@ public final class NormalizedNodeMessages { public final boolean isInitialized() { for (int i = 0; i < getMapEntriesCount(); i++) { if (!getMapEntries(i).isInitialized()) { - + return false; } } @@ -7341,7 +7351,7 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; */ - public java.util.List + public java.util.List getMapEntriesOrBuilderList() { if (mapEntriesBuilder_ != null) { return mapEntriesBuilder_.getMessageOrBuilderList(); @@ -7367,12 +7377,12 @@ public final class NormalizedNodeMessages { /** * repeated .org.opendaylight.controller.mdsal.NodeMapEntry mapEntries = 1; */ - public java.util.List + public java.util.List getMapEntriesBuilderList() { return getMapEntriesFieldBuilder().getBuilderList(); } private com.google.protobuf.RepeatedFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntryOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntry.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapEntryOrBuilder> getMapEntriesFieldBuilder() { if (mapEntriesBuilder_ == null) { mapEntriesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/SimpleNormalizedNodeMessage.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/SimpleNormalizedNodeMessage.java index 29e54571d3..7cee40df7a 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/SimpleNormalizedNodeMessage.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/common/SimpleNormalizedNodeMessage.java @@ -1,3 +1,13 @@ +/* + * + * 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 + * + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: SimpleNormalizedNode.proto @@ -159,7 +169,7 @@ public final class SimpleNormalizedNodeMessage { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -175,7 +185,7 @@ public final class SimpleNormalizedNodeMessage { getNodeIdentifierBytes() { java.lang.Object ref = nodeIdentifier_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); nodeIdentifier_ = b; @@ -202,7 +212,7 @@ public final class SimpleNormalizedNodeMessage { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -218,7 +228,7 @@ public final class SimpleNormalizedNodeMessage { getXmlStringBytes() { java.lang.Object ref = xmlString_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); xmlString_ = b; @@ -463,11 +473,11 @@ public final class SimpleNormalizedNodeMessage { public final boolean isInitialized() { if (!hasNodeIdentifier()) { - + return false; } if (!hasXmlString()) { - + return false; } return true; @@ -521,7 +531,7 @@ public final class SimpleNormalizedNodeMessage { getNodeIdentifierBytes() { java.lang.Object ref = nodeIdentifier_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); nodeIdentifier_ = b; @@ -595,7 +605,7 @@ public final class SimpleNormalizedNodeMessage { getXmlStringBytes() { java.lang.Object ref = xmlString_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); xmlString_ = b; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessages.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessages.java index 2018834768..1a98112073 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessages.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessages.java @@ -1,3 +1,13 @@ +/* + * + * 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 + * + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: DataChangeListener.proto @@ -85,7 +95,7 @@ public final class DataChangeListenerMessages { /** * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; */ - java.util.List + java.util.List getRemovedPathsList(); /** * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; @@ -98,7 +108,7 @@ public final class DataChangeListenerMessages { /** * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; */ - java.util.List + java.util.List getRemovedPathsOrBuilderList(); /** * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; @@ -395,7 +405,7 @@ public final class DataChangeListenerMessages { /** * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; */ - public java.util.List + public java.util.List getRemovedPathsOrBuilderList() { return removedPaths_; } @@ -810,7 +820,7 @@ public final class DataChangeListenerMessages { removedPathsBuilder_ = null; removedPaths_ = other.removedPaths_; bitField0_ = (bitField0_ & ~0x00000020); - removedPathsBuilder_ = + removedPathsBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getRemovedPathsFieldBuilder() : null; } else { @@ -825,37 +835,37 @@ public final class DataChangeListenerMessages { public final boolean isInitialized() { if (hasOriginalSubTree()) { if (!getOriginalSubTree().isInitialized()) { - + return false; } } if (hasUpdatedSubTree()) { if (!getUpdatedSubTree().isInitialized()) { - + return false; } } if (hasOriginalData()) { if (!getOriginalData().isInitialized()) { - + return false; } } if (hasUpdatedData()) { if (!getUpdatedData().isInitialized()) { - + return false; } } if (hasCreatedData()) { if (!getCreatedData().isInitialized()) { - + return false; } } for (int i = 0; i < getRemovedPathsCount(); i++) { if (!getRemovedPaths(i).isInitialized()) { - + return false; } } @@ -985,7 +995,7 @@ public final class DataChangeListenerMessages { * optional .org.opendaylight.controller.mdsal.Node originalSubTree = 1; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> getOriginalSubTreeFieldBuilder() { if (originalSubTreeBuilder_ == null) { originalSubTreeBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -1102,7 +1112,7 @@ public final class DataChangeListenerMessages { * optional .org.opendaylight.controller.mdsal.Node updatedSubTree = 2; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> getUpdatedSubTreeFieldBuilder() { if (updatedSubTreeBuilder_ == null) { updatedSubTreeBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -1219,7 +1229,7 @@ public final class DataChangeListenerMessages { * optional .org.opendaylight.controller.mdsal.NodeMap originalData = 3; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder> getOriginalDataFieldBuilder() { if (originalDataBuilder_ == null) { originalDataBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -1336,7 +1346,7 @@ public final class DataChangeListenerMessages { * optional .org.opendaylight.controller.mdsal.NodeMap updatedData = 4; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder> getUpdatedDataFieldBuilder() { if (updatedDataBuilder_ == null) { updatedDataBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -1453,7 +1463,7 @@ public final class DataChangeListenerMessages { * optional .org.opendaylight.controller.mdsal.NodeMap createdData = 5; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMap.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeMapOrBuilder> getCreatedDataFieldBuilder() { if (createdDataBuilder_ == null) { createdDataBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -1661,7 +1671,7 @@ public final class DataChangeListenerMessages { /** * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; */ - public java.util.List + public java.util.List getRemovedPathsOrBuilderList() { if (removedPathsBuilder_ != null) { return removedPathsBuilder_.getMessageOrBuilderList(); @@ -1687,12 +1697,12 @@ public final class DataChangeListenerMessages { /** * repeated .org.opendaylight.controller.mdsal.InstanceIdentifier removedPaths = 6; */ - public java.util.List + public java.util.List getRemovedPathsBuilderList() { return getRemovedPathsFieldBuilder().getBuilderList(); } private com.google.protobuf.RepeatedFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> getRemovedPathsFieldBuilder() { if (removedPathsBuilder_ == null) { removedPathsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessages.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessages.java index eaa90012db..088630aa32 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessages.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessages.java @@ -1,3 +1,13 @@ +/* + * + * 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 + * + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: Persistent.proto @@ -193,7 +203,7 @@ public final class PersistentMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -209,7 +219,7 @@ public final class PersistentMessages { getTypeBytes() { java.lang.Object ref = type_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); type_ = b; @@ -541,20 +551,20 @@ public final class PersistentMessages { public final boolean isInitialized() { if (!hasType()) { - + return false; } if (!hasPath()) { - + return false; } if (!getPath().isInitialized()) { - + return false; } if (hasData()) { if (!getData().isInitialized()) { - + return false; } } @@ -609,7 +619,7 @@ public final class PersistentMessages { getTypeBytes() { java.lang.Object ref = type_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); type_ = b; @@ -758,7 +768,7 @@ public final class PersistentMessages { * required .org.opendaylight.controller.mdsal.InstanceIdentifier path = 2; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> getPathFieldBuilder() { if (pathBuilder_ == null) { pathBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -875,7 +885,7 @@ public final class PersistentMessages { * optional .org.opendaylight.controller.mdsal.Node data = 3; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> getDataFieldBuilder() { if (dataBuilder_ == null) { dataBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -906,7 +916,7 @@ public final class PersistentMessages { /** * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; */ - java.util.List + java.util.List getModificationList(); /** * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; @@ -919,7 +929,7 @@ public final class PersistentMessages { /** * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; */ - java.util.List + java.util.List getModificationOrBuilderList(); /** * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; @@ -1040,7 +1050,7 @@ public final class PersistentMessages { /** * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; */ - public java.util.List + public java.util.List getModificationOrBuilderList() { return modification_; } @@ -1293,7 +1303,7 @@ public final class PersistentMessages { modificationBuilder_ = null; modification_ = other.modification_; bitField0_ = (bitField0_ & ~0x00000001); - modificationBuilder_ = + modificationBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getModificationFieldBuilder() : null; } else { @@ -1308,7 +1318,7 @@ public final class PersistentMessages { public final boolean isInitialized() { for (int i = 0; i < getModificationCount(); i++) { if (!getModification(i).isInitialized()) { - + return false; } } @@ -1529,7 +1539,7 @@ public final class PersistentMessages { /** * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; */ - public java.util.List + public java.util.List getModificationOrBuilderList() { if (modificationBuilder_ != null) { return modificationBuilder_.getMessageOrBuilderList(); @@ -1555,12 +1565,12 @@ public final class PersistentMessages { /** * repeated .org.opendaylight.controller.mdsal.Modification modification = 1; */ - public java.util.List + public java.util.List getModificationBuilderList() { return getModificationFieldBuilder().getBuilderList(); } private com.google.protobuf.RepeatedFieldBuilder< - org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.Builder, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.ModificationOrBuilder> + org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.Modification.Builder, org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages.ModificationOrBuilder> getModificationFieldBuilder() { if (modificationBuilder_ == null) { modificationBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessages.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessages.java index e06dd0d429..0f439d8c7c 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessages.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessages.java @@ -1,3 +1,13 @@ +/* + * + * 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 + * + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: ListenerRegistration.proto @@ -837,7 +847,7 @@ public final class ListenerRegistrationMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -853,7 +863,7 @@ public final class ListenerRegistrationMessages { getDataChangeListenerActorPathBytes() { java.lang.Object ref = dataChangeListenerActorPath_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); dataChangeListenerActorPath_ = b; @@ -1146,19 +1156,19 @@ public final class ListenerRegistrationMessages { public final boolean isInitialized() { if (!hasInstanceIdentifierPath()) { - + return false; } if (!hasDataChangeListenerActorPath()) { - + return false; } if (!hasDataChangeScope()) { - + return false; } if (!getInstanceIdentifierPath().isInitialized()) { - + return false; } return true; @@ -1287,7 +1297,7 @@ public final class ListenerRegistrationMessages { * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPath = 1; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> getInstanceIdentifierPathFieldBuilder() { if (instanceIdentifierPathBuilder_ == null) { instanceIdentifierPathBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -1329,7 +1339,7 @@ public final class ListenerRegistrationMessages { getDataChangeListenerActorPathBytes() { java.lang.Object ref = dataChangeListenerActorPath_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); dataChangeListenerActorPath_ = b; @@ -1556,7 +1566,7 @@ public final class ListenerRegistrationMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -1572,7 +1582,7 @@ public final class ListenerRegistrationMessages { getListenerRegistrationPathBytes() { java.lang.Object ref = listenerRegistrationPath_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); listenerRegistrationPath_ = b; @@ -1801,7 +1811,7 @@ public final class ListenerRegistrationMessages { public final boolean isInitialized() { if (!hasListenerRegistrationPath()) { - + return false; } return true; @@ -1855,7 +1865,7 @@ public final class ListenerRegistrationMessages { getListenerRegistrationPathBytes() { java.lang.Object ref = listenerRegistrationPath_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); listenerRegistrationPath_ = b; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessages.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessages.java index 7c2a47e1b0..7141863591 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessages.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessages.java @@ -1,3 +1,13 @@ +/* + * + * 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 + * + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: ShardManager.proto @@ -139,7 +149,7 @@ public final class ShardManagerMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -155,7 +165,7 @@ public final class ShardManagerMessages { getShardNameBytes() { java.lang.Object ref = shardName_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); shardName_ = b; @@ -377,7 +387,7 @@ public final class ShardManagerMessages { public final boolean isInitialized() { if (!hasShardName()) { - + return false; } return true; @@ -431,7 +441,7 @@ public final class ShardManagerMessages { getShardNameBytes() { java.lang.Object ref = shardName_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); shardName_ = b; @@ -618,7 +628,7 @@ public final class ShardManagerMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -634,7 +644,7 @@ public final class ShardManagerMessages { getPrimaryPathBytes() { java.lang.Object ref = primaryPath_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); primaryPath_ = b; @@ -856,7 +866,7 @@ public final class ShardManagerMessages { public final boolean isInitialized() { if (!hasPrimaryPath()) { - + return false; } return true; @@ -910,7 +920,7 @@ public final class ShardManagerMessages { getPrimaryPathBytes() { java.lang.Object ref = primaryPath_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); primaryPath_ = b; @@ -1097,7 +1107,7 @@ public final class ShardManagerMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -1113,7 +1123,7 @@ public final class ShardManagerMessages { getShardNameBytes() { java.lang.Object ref = shardName_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); shardName_ = b; @@ -1335,7 +1345,7 @@ public final class ShardManagerMessages { public final boolean isInitialized() { if (!hasShardName()) { - + return false; } return true; @@ -1389,7 +1399,7 @@ public final class ShardManagerMessages { getShardNameBytes() { java.lang.Object ref = shardName_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); shardName_ = b; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessages.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessages.java index 3f354ba40e..68bf325336 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessages.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessages.java @@ -1,3 +1,13 @@ +/* + * + * 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 + * + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: ShardTransactionChain.proto @@ -1066,7 +1076,7 @@ public final class ShardTransactionChainMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -1082,7 +1092,7 @@ public final class ShardTransactionChainMessages { getTransactionChainPathBytes() { java.lang.Object ref = transactionChainPath_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); transactionChainPath_ = b; @@ -1304,7 +1314,7 @@ public final class ShardTransactionChainMessages { public final boolean isInitialized() { if (!hasTransactionChainPath()) { - + return false; } return true; @@ -1358,7 +1368,7 @@ public final class ShardTransactionChainMessages { getTransactionChainPathBytes() { java.lang.Object ref = transactionChainPath_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); transactionChainPath_ = b; diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessages.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessages.java index ee2c70423e..52411f322b 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessages.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessages.java @@ -1,3 +1,13 @@ +/* + * + * 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 + * + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: ShardTransaction.proto @@ -757,7 +767,7 @@ public final class ShardTransactionMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -773,7 +783,7 @@ public final class ShardTransactionMessages { getTransactionIdBytes() { java.lang.Object ref = transactionId_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); transactionId_ = b; @@ -995,7 +1005,7 @@ public final class ShardTransactionMessages { public final boolean isInitialized() { if (!hasTransactionId()) { - + return false; } return true; @@ -1049,7 +1059,7 @@ public final class ShardTransactionMessages { getTransactionIdBytes() { java.lang.Object ref = transactionId_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); transactionId_ = b; @@ -1256,7 +1266,7 @@ public final class ShardTransactionMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -1272,7 +1282,7 @@ public final class ShardTransactionMessages { getTransactionActorPathBytes() { java.lang.Object ref = transactionActorPath_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); transactionActorPath_ = b; @@ -1299,7 +1309,7 @@ public final class ShardTransactionMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -1315,7 +1325,7 @@ public final class ShardTransactionMessages { getTransactionIdBytes() { java.lang.Object ref = transactionId_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); transactionId_ = b; @@ -1560,11 +1570,11 @@ public final class ShardTransactionMessages { public final boolean isInitialized() { if (!hasTransactionActorPath()) { - + return false; } if (!hasTransactionId()) { - + return false; } return true; @@ -1618,7 +1628,7 @@ public final class ShardTransactionMessages { getTransactionActorPathBytes() { java.lang.Object ref = transactionActorPath_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); transactionActorPath_ = b; @@ -1692,7 +1702,7 @@ public final class ShardTransactionMessages { getTransactionIdBytes() { java.lang.Object ref = transactionId_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); transactionId_ = b; @@ -2188,7 +2198,7 @@ public final class ShardTransactionMessages { if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -2204,7 +2214,7 @@ public final class ShardTransactionMessages { getActorPathBytes() { java.lang.Object ref = actorPath_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); actorPath_ = b; @@ -2426,7 +2436,7 @@ public final class ShardTransactionMessages { public final boolean isInitialized() { if (!hasActorPath()) { - + return false; } return true; @@ -2480,7 +2490,7 @@ public final class ShardTransactionMessages { getActorPathBytes() { java.lang.Object ref = actorPath_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); actorPath_ = b; @@ -2902,11 +2912,11 @@ public final class ShardTransactionMessages { public final boolean isInitialized() { if (!hasInstanceIdentifierPathArguments()) { - + return false; } if (!getInstanceIdentifierPathArguments().isInitialized()) { - + return false; } return true; @@ -3035,7 +3045,7 @@ public final class ShardTransactionMessages { * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> getInstanceIdentifierPathArgumentsFieldBuilder() { if (instanceIdentifierPathArgumentsBuilder_ == null) { instanceIdentifierPathArgumentsBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -3734,11 +3744,11 @@ public final class ShardTransactionMessages { public final boolean isInitialized() { if (!hasInstanceIdentifierPathArguments()) { - + return false; } if (!getInstanceIdentifierPathArguments().isInitialized()) { - + return false; } return true; @@ -3867,7 +3877,7 @@ public final class ShardTransactionMessages { * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> getInstanceIdentifierPathArgumentsFieldBuilder() { if (instanceIdentifierPathArgumentsBuilder_ == null) { instanceIdentifierPathArgumentsBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -4256,7 +4266,7 @@ public final class ShardTransactionMessages { public final boolean isInitialized() { if (hasNormalizedNode()) { if (!getNormalizedNode().isInitialized()) { - + return false; } } @@ -4386,7 +4396,7 @@ public final class ShardTransactionMessages { * optional .org.opendaylight.controller.mdsal.Node normalizedNode = 1; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> getNormalizedNodeFieldBuilder() { if (normalizedNodeBuilder_ == null) { normalizedNodeBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -4859,19 +4869,19 @@ public final class ShardTransactionMessages { public final boolean isInitialized() { if (!hasInstanceIdentifierPathArguments()) { - + return false; } if (!hasNormalizedNode()) { - + return false; } if (!getInstanceIdentifierPathArguments().isInitialized()) { - + return false; } if (!getNormalizedNode().isInitialized()) { - + return false; } return true; @@ -5000,7 +5010,7 @@ public final class ShardTransactionMessages { * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> getInstanceIdentifierPathArgumentsFieldBuilder() { if (instanceIdentifierPathArgumentsBuilder_ == null) { instanceIdentifierPathArgumentsBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -5117,7 +5127,7 @@ public final class ShardTransactionMessages { * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> getNormalizedNodeFieldBuilder() { if (normalizedNodeBuilder_ == null) { normalizedNodeBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -5899,19 +5909,19 @@ public final class ShardTransactionMessages { public final boolean isInitialized() { if (!hasInstanceIdentifierPathArguments()) { - + return false; } if (!hasNormalizedNode()) { - + return false; } if (!getInstanceIdentifierPathArguments().isInitialized()) { - + return false; } if (!getNormalizedNode().isInitialized()) { - + return false; } return true; @@ -6040,7 +6050,7 @@ public final class ShardTransactionMessages { * required .org.opendaylight.controller.mdsal.InstanceIdentifier instanceIdentifierPathArguments = 1; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifierOrBuilder> getInstanceIdentifierPathArgumentsFieldBuilder() { if (instanceIdentifierPathArgumentsBuilder_ == null) { instanceIdentifierPathArgumentsBuilder_ = new com.google.protobuf.SingleFieldBuilder< @@ -6157,7 +6167,7 @@ public final class ShardTransactionMessages { * required .org.opendaylight.controller.mdsal.Node normalizedNode = 2; */ private com.google.protobuf.SingleFieldBuilder< - org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> + org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node.Builder, org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.NodeOrBuilder> getNormalizedNodeFieldBuilder() { if (normalizedNodeBuilder_ == null) { normalizedNodeBuilder_ = new com.google.protobuf.SingleFieldBuilder< diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java index 4ccbc97f35..1b85d46fc6 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/NormalizedNodeToNodeCodecTest.java @@ -1,9 +1,11 @@ /* - * 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 + * 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.cluster.datastore.node; @@ -15,9 +17,9 @@ import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFa import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeGetter; import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeNavigator; import org.opendaylight.controller.cluster.datastore.util.TestModel; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Container; import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.Node; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -32,127 +34,147 @@ public class NormalizedNodeToNodeCodecTest { - private SchemaContext schemaContext; + private SchemaContext schemaContext; - @Before - public void setUp(){ - schemaContext = TestModel.createTestContext(); - assertNotNull("Schema context must not be null.", schemaContext); - } + @Before + public void setUp() { + schemaContext = TestModel.createTestContext(); + assertNotNull("Schema context must not be null.", schemaContext); + } - private YangInstanceIdentifier instanceIdentifierFromString(String s){ + private YangInstanceIdentifier instanceIdentifierFromString(String s) { - String[] ids = s.split("/"); + String[] ids = s.split("/"); - List pathArguments = new ArrayList<>(); - for(String nodeId : ids){ - if(!"".equals(nodeId)) { - pathArguments.add(NodeIdentifierFactory.getArgument(nodeId)); - } - } - final YangInstanceIdentifier instanceIdentifier = YangInstanceIdentifier.create(pathArguments); - return instanceIdentifier; + List pathArguments = new ArrayList<>(); + for (String nodeId : ids) { + if (!"".equals(nodeId)) { + pathArguments.add(NodeIdentifierFactory.getArgument(nodeId)); + } } + final YangInstanceIdentifier instanceIdentifier = + YangInstanceIdentifier.create(pathArguments); + return instanceIdentifier; + } - @Test - public void testNormalizeNodeAttributesToProtoBuffNode(){ - final NormalizedNode documentOne = TestModel.createTestContainer(); - String id = "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test" + - "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)outer-list" + - "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)outer-list[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=2}]" + - "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id"; + @Test + public void testNormalizeNodeAttributesToProtoBuffNode() { + final NormalizedNode documentOne = TestModel.createTestContainer(); + String id = + "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test" + + "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)outer-list" + + "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)outer-list[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=2}]" + + "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id"; - NormalizedNodeGetter normalizedNodeGetter = new NormalizedNodeGetter(id); - new NormalizedNodeNavigator(normalizedNodeGetter).navigate( - YangInstanceIdentifier.builder().build().toString(), documentOne); + NormalizedNodeGetter normalizedNodeGetter = new NormalizedNodeGetter(id); + new NormalizedNodeNavigator(normalizedNodeGetter).navigate( + YangInstanceIdentifier.builder().build().toString(), documentOne); - // Validate the value of id can be retrieved from the normalized node - NormalizedNode output = normalizedNodeGetter.getOutput(); - assertNotNull(output); + // Validate the value of id can be retrieved from the normalized node + NormalizedNode output = normalizedNodeGetter.getOutput(); + assertNotNull(output); - NormalizedNodeToNodeCodec codec = new NormalizedNodeToNodeCodec(schemaContext); - Container container = codec.encode(instanceIdentifierFromString(id),output); + NormalizedNodeToNodeCodec codec = + new NormalizedNodeToNodeCodec(schemaContext); + Container container = + codec.encode(instanceIdentifierFromString(id), output); - assertNotNull(container); - assertEquals(id, container.getParentPath()+"/"+container.getNormalizedNode().getPath()) ; + assertNotNull(container); + assertEquals(id, container.getParentPath() + "/" + + container.getNormalizedNode().getPath()); - // Decode the normalized node from the ProtocolBuffer form - //first get the node representation of normalized node - final Node node = container.getNormalizedNode(); + // Decode the normalized node from the ProtocolBuffer form + // first get the node representation of normalized node + final Node node = container.getNormalizedNode(); - NormalizedNode normalizedNode = codec.decode(instanceIdentifierFromString(id),node); + NormalizedNode normalizedNode = + codec.decode(instanceIdentifierFromString(id), node); - assertEquals(normalizedNode.getValue().toString(),output.getValue().toString()); - } + assertEquals(normalizedNode.getValue().toString(), output.getValue() + .toString()); + } - @Test - public void testThatANormalizedNodeToProtoBuffNodeEncodeDecode() throws Exception { - final NormalizedNode documentOne = TestModel.createTestContainer(); + @Test + public void testThatANormalizedNodeToProtoBuffNodeEncodeDecode() + throws Exception { + final NormalizedNode documentOne = TestModel.createTestContainer(); - final NormalizedNodeToNodeCodec normalizedNodeToNodeCodec = new NormalizedNodeToNodeCodec(schemaContext); + final NormalizedNodeToNodeCodec normalizedNodeToNodeCodec = + new NormalizedNodeToNodeCodec(schemaContext); - Container container = normalizedNodeToNodeCodec.encode(YangInstanceIdentifier.builder().build(), documentOne); + Container container = + normalizedNodeToNodeCodec.encode(YangInstanceIdentifier.builder() + .build(), documentOne); - final NormalizedNode decode = normalizedNodeToNodeCodec.decode(instanceIdentifierFromString("/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test"),container.getNormalizedNode()); - assertNotNull(decode != null); + final NormalizedNode decode = + normalizedNodeToNodeCodec + .decode( + instanceIdentifierFromString("/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test"), + container.getNormalizedNode()); + assertNotNull(decode != null); - //let us ensure that the return decode normalized node encode returns same container - Container containerResult = normalizedNodeToNodeCodec.encode(YangInstanceIdentifier.builder().build(), decode); + // let us ensure that the return decode normalized node encode returns same container + Container containerResult = + normalizedNodeToNodeCodec.encode(YangInstanceIdentifier.builder() + .build(), decode); - assertEquals(container.getParentPath(),containerResult.getParentPath()); - assertEquals(container.getNormalizedNode().getChildCount(),container.getNormalizedNode().getChildCount()); + assertEquals(container.getParentPath(), containerResult.getParentPath()); + assertEquals(container.getNormalizedNode().getChildCount(), container + .getNormalizedNode().getChildCount()); - Assert.assertEquals(containerResult.getNormalizedNode().getChildCount(),container.getNormalizedNode().getChildCount()); + Assert.assertEquals(containerResult.getNormalizedNode().getChildCount(), + container.getNormalizedNode().getChildCount()); - //check first level children are proper - ListchildrenResult = containerResult.getNormalizedNode().getChildList(); - ListchildrenOriginal = container.getNormalizedNode().getChildList(); + // check first level children are proper + List childrenResult = + containerResult.getNormalizedNode().getChildList(); + List childrenOriginal = container.getNormalizedNode().getChildList(); - System.out.println("-------------------------------------------------"); + System.out.println("-------------------------------------------------"); - System.out.println(childrenOriginal.toString()); + System.out.println(childrenOriginal.toString()); - System.out.println("-------------------------------------------------"); + System.out.println("-------------------------------------------------"); - System.out.println(childrenResult.toString()); + System.out.println(childrenResult.toString()); - boolean bFound; - for(Node resultChild: childrenResult){ - bFound = false; - for(Node originalChild:childrenOriginal){ - if(originalChild.getPath().equals(resultChild.getPath()) - && resultChild.getType().equals(resultChild.getType())){ - bFound=true; - break; - } - } - Assert.assertTrue(bFound); + boolean bFound; + for (Node resultChild : childrenResult) { + bFound = false; + for (Node originalChild : childrenOriginal) { + if (originalChild.getPath().equals(resultChild.getPath()) + && resultChild.getType().equals(resultChild.getType())) { + bFound = true; + break; } - + } + Assert.assertTrue(bFound); } - @Test - public void addAugmentations(){ - String stringId = "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test" + - "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)augmented-list" + - "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)augmented-list[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=1}]"; + } - YangInstanceIdentifier identifier = instanceIdentifierFromString(stringId); + @Test + public void addAugmentations() { + String stringId = + "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test" + + "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)augmented-list" + + "/(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)augmented-list[{(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)id=1}]"; - MapEntryNode uno = TestModel.createAugmentedListEntry(1, "Uno"); + YangInstanceIdentifier identifier = instanceIdentifierFromString(stringId); - NormalizedNodeToNodeCodec codec = - new NormalizedNodeToNodeCodec(schemaContext); + MapEntryNode uno = TestModel.createAugmentedListEntry(1, "Uno"); - Container encode = codec - .encode(identifier, uno); + NormalizedNodeToNodeCodec codec = + new NormalizedNodeToNodeCodec(schemaContext); - System.out.println(encode.getNormalizedNode()); + Container encode = codec.encode(identifier, uno); - codec.decode(identifier, encode.getNormalizedNode()); - } + System.out.println(encode.getNormalizedNode()); + + codec.decode(identifier, encode.getNormalizedNode()); + } } diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactoryTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactoryTest.java index 4b0bde83e0..4da7d8c483 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactoryTest.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/NodeIdentifierFactoryTest.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.node.utils; import junit.framework.Assert; @@ -6,15 +16,16 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class NodeIdentifierFactoryTest { - @Test - public void validateAugmentationIdentifier(){ - YangInstanceIdentifier.PathArgument argument = NodeIdentifierFactory - .getArgument( - "AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}"); + @Test + public void validateAugmentationIdentifier() { + YangInstanceIdentifier.PathArgument argument = + NodeIdentifierFactory + .getArgument("AugmentationIdentifier{childNames=[(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics]}"); - Assert.assertTrue(argument instanceof YangInstanceIdentifier.AugmentationIdentifier); + Assert + .assertTrue(argument instanceof YangInstanceIdentifier.AugmentationIdentifier); - } + } } diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java index bb246fb1e4..136748e341 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/InstanceIdentifierUtilsTest.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.util; import org.junit.Assert; @@ -13,129 +23,139 @@ import java.util.List; public class InstanceIdentifierUtilsTest { - private static QName TEST_QNAME = QName.create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test"); - private static QName NODE_WITH_VALUE_QNAME = QName.create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)value"); - private static QName NODE_WITH_PREDICATES_QNAME = QName.create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)pred"); - private static QName NAME_QNAME = QName.create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)name"); + private static QName TEST_QNAME = + QName + .create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)test"); + private static QName NODE_WITH_VALUE_QNAME = + QName + .create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)value"); + private static QName NODE_WITH_PREDICATES_QNAME = + QName + .create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)pred"); + private static QName NAME_QNAME = + QName + .create("(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)name"); - @Test - public void testSerializationOfNodeIdentifier(){ - YangInstanceIdentifier.PathArgument p1 = - new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME); + @Test + public void testSerializationOfNodeIdentifier() { + YangInstanceIdentifier.PathArgument p1 = + new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME); - List arguments = new ArrayList<>(); + List arguments = new ArrayList<>(); - arguments.add(p1); + arguments.add(p1); - YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments); + YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments); - NormalizedNodeMessages.InstanceIdentifier instanceIdentifier = - InstanceIdentifierUtils.toSerializable(expected); + NormalizedNodeMessages.InstanceIdentifier instanceIdentifier = + InstanceIdentifierUtils.toSerializable(expected); - YangInstanceIdentifier actual = - InstanceIdentifierUtils.fromSerializable(instanceIdentifier); + YangInstanceIdentifier actual = + InstanceIdentifierUtils.fromSerializable(instanceIdentifier); - Assert.assertEquals(expected.getLastPathArgument(), - actual.getLastPathArgument()); + Assert.assertEquals(expected.getLastPathArgument(), + actual.getLastPathArgument()); - } + } - @Test - public void testSerializationOfNodeWithValue(){ + @Test + public void testSerializationOfNodeWithValue() { - withValue((short) 1); - withValue((long) 2); - withValue(3); - withValue(true); + withValue((short) 1); + withValue((long) 2); + withValue(3); + withValue(true); - } + } - private void withValue(Object value){ - YangInstanceIdentifier.PathArgument p1 = - new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME); + private void withValue(Object value) { + YangInstanceIdentifier.PathArgument p1 = + new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME); - YangInstanceIdentifier.PathArgument p2 = - new YangInstanceIdentifier.NodeWithValue(NODE_WITH_VALUE_QNAME, value); + YangInstanceIdentifier.PathArgument p2 = + new YangInstanceIdentifier.NodeWithValue(NODE_WITH_VALUE_QNAME, value); - List arguments = new ArrayList<>(); + List arguments = new ArrayList<>(); - arguments.add(p1); - arguments.add(p2); + arguments.add(p1); + arguments.add(p2); - YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments); + YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments); - NormalizedNodeMessages.InstanceIdentifier instanceIdentifier = - InstanceIdentifierUtils.toSerializable(expected); + NormalizedNodeMessages.InstanceIdentifier instanceIdentifier = + InstanceIdentifierUtils.toSerializable(expected); - YangInstanceIdentifier actual = - InstanceIdentifierUtils.fromSerializable(instanceIdentifier); + YangInstanceIdentifier actual = + InstanceIdentifierUtils.fromSerializable(instanceIdentifier); - Assert.assertEquals(expected.getLastPathArgument(), - actual.getLastPathArgument()); - } + Assert.assertEquals(expected.getLastPathArgument(), + actual.getLastPathArgument()); + } - @Test - public void testSerializationOfNodeIdentifierWithPredicates(){ + @Test + public void testSerializationOfNodeIdentifierWithPredicates() { - withPredicates((short) 1); - withPredicates((long) 2); - withPredicates(3); - withPredicates(true); + withPredicates((short) 1); + withPredicates((long) 2); + withPredicates(3); + withPredicates(true); - } + } - private void withPredicates(Object value){ - YangInstanceIdentifier.PathArgument p1 = - new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME); + private void withPredicates(Object value) { + YangInstanceIdentifier.PathArgument p1 = + new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME); - YangInstanceIdentifier.PathArgument p2 = - new YangInstanceIdentifier.NodeIdentifierWithPredicates(NODE_WITH_PREDICATES_QNAME, NAME_QNAME, value); + YangInstanceIdentifier.PathArgument p2 = + new YangInstanceIdentifier.NodeIdentifierWithPredicates( + NODE_WITH_PREDICATES_QNAME, NAME_QNAME, value); - List arguments = new ArrayList<>(); + List arguments = new ArrayList<>(); - arguments.add(p1); - arguments.add(p2); + arguments.add(p1); + arguments.add(p2); - YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments); + YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments); - NormalizedNodeMessages.InstanceIdentifier instanceIdentifier = - InstanceIdentifierUtils.toSerializable(expected); + NormalizedNodeMessages.InstanceIdentifier instanceIdentifier = + InstanceIdentifierUtils.toSerializable(expected); - YangInstanceIdentifier actual = - InstanceIdentifierUtils.fromSerializable(instanceIdentifier); + YangInstanceIdentifier actual = + InstanceIdentifierUtils.fromSerializable(instanceIdentifier); - Assert.assertEquals(expected.getLastPathArgument(), - actual.getLastPathArgument()); - } + Assert.assertEquals(expected.getLastPathArgument(), + actual.getLastPathArgument()); + } - @Test - public void testAugmentationIdentifier(){ - YangInstanceIdentifier.PathArgument p1 = - new YangInstanceIdentifier.AugmentationIdentifier(new HashSet(Arrays.asList(TEST_QNAME))); + @Test + public void testAugmentationIdentifier() { + YangInstanceIdentifier.PathArgument p1 = + new YangInstanceIdentifier.AugmentationIdentifier(new HashSet( + Arrays.asList(TEST_QNAME))); - List arguments = new ArrayList<>(); + List arguments = new ArrayList<>(); - arguments.add(p1); + arguments.add(p1); - YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments); + YangInstanceIdentifier expected = YangInstanceIdentifier.create(arguments); - NormalizedNodeMessages.InstanceIdentifier instanceIdentifier = - InstanceIdentifierUtils.toSerializable(expected); + NormalizedNodeMessages.InstanceIdentifier instanceIdentifier = + InstanceIdentifierUtils.toSerializable(expected); - YangInstanceIdentifier actual = - InstanceIdentifierUtils.fromSerializable(instanceIdentifier); + YangInstanceIdentifier actual = + InstanceIdentifierUtils.fromSerializable(instanceIdentifier); - Assert.assertEquals(expected.getLastPathArgument(), - actual.getLastPathArgument()); + Assert.assertEquals(expected.getLastPathArgument(), + actual.getLastPathArgument()); - } + } } diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/NormalizedNodeXmlConverterTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/NormalizedNodeXmlConverterTest.java index fb28704952..853b3e264b 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/NormalizedNodeXmlConverterTest.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/NormalizedNodeXmlConverterTest.java @@ -1,9 +1,11 @@ /* - * Copyright (c) 2013 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 + * 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.cluster.datastore.util; @@ -71,8 +73,8 @@ import java.util.Set; /** - * Two of the testcases in the yangtools/yang-data-impl are leveraged (with modification) to - * create the serialization of NormalizedNode using the ProtocolBuffer + * Two of the testcases in the yangtools/yang-data-impl are leveraged (with modification) to create + * the serialization of NormalizedNode using the ProtocolBuffer * * @syedbahm * @@ -80,403 +82,402 @@ import java.util.Set; public class NormalizedNodeXmlConverterTest { - private static final Logger logger = LoggerFactory - .getLogger(NormalizedNodeXmlConverterTest.class); - public static final String NAMESPACE = - "urn:opendaylight:params:xml:ns:yang:controller:test"; - private static Date revision; - private ContainerNode expectedNode; - private ContainerSchemaNode containerNode; - private String xmlPath; - - static { - try { - revision = new SimpleDateFormat("yyyy-MM-dd").parse("2014-03-13"); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - - public static DataSchemaNode getSchemaNode(final SchemaContext context, - final String moduleName, final String childNodeName) { - for (Module module : context.getModules()) { - if (module.getName().equals(moduleName)) { - DataSchemaNode found = - findChildNode(module.getChildNodes(), childNodeName); - Preconditions.checkState(found != null, "Unable to find %s", - childNodeName); - return found; - } - } - throw new IllegalStateException("Unable to find child node " - + childNodeName); + private static final Logger logger = LoggerFactory + .getLogger(NormalizedNodeXmlConverterTest.class); + public static final String NAMESPACE = + "urn:opendaylight:params:xml:ns:yang:controller:test"; + private static Date revision; + private ContainerNode expectedNode; + private ContainerSchemaNode containerNode; + private String xmlPath; + + static { + try { + revision = new SimpleDateFormat("yyyy-MM-dd").parse("2014-03-13"); + } catch (ParseException e) { + throw new RuntimeException(e); } - - static DataSchemaNode findChildNode(final Collection children, final String name) { - List containers = Lists.newArrayList(); - - for (DataSchemaNode dataSchemaNode : children) { - if (dataSchemaNode.getQName().getLocalName().equals(name)) { - return dataSchemaNode; - } - if (dataSchemaNode instanceof DataNodeContainer) { - containers.add((DataNodeContainer) dataSchemaNode); - } else if (dataSchemaNode instanceof ChoiceNode) { - containers.addAll(((ChoiceNode) dataSchemaNode).getCases()); - } - } - - for (DataNodeContainer container : containers) { - DataSchemaNode retVal = findChildNode(container.getChildNodes(), name); - if (retVal != null) { - return retVal; - } - } - - return null; + } + + public static DataSchemaNode getSchemaNode(final SchemaContext context, + final String moduleName, final String childNodeName) { + for (Module module : context.getModules()) { + if (module.getName().equals(moduleName)) { + DataSchemaNode found = + findChildNode(module.getChildNodes(), childNodeName); + Preconditions.checkState(found != null, "Unable to find %s", + childNodeName); + return found; + } } - - public static YangInstanceIdentifier.NodeIdentifier getNodeIdentifier( - final String localName) { - return new YangInstanceIdentifier.NodeIdentifier(QName.create( - URI.create(NAMESPACE), revision, localName)); + throw new IllegalStateException("Unable to find child node " + + childNodeName); + } + + static DataSchemaNode findChildNode( + final Collection children, final String name) { + List containers = Lists.newArrayList(); + + for (DataSchemaNode dataSchemaNode : children) { + if (dataSchemaNode.getQName().getLocalName().equals(name)) { + return dataSchemaNode; + } + if (dataSchemaNode instanceof DataNodeContainer) { + containers.add((DataNodeContainer) dataSchemaNode); + } else if (dataSchemaNode instanceof ChoiceNode) { + containers.addAll(((ChoiceNode) dataSchemaNode).getCases()); + } } - public static YangInstanceIdentifier.AugmentationIdentifier getAugmentIdentifier( - final String... childNames) { - Set qn = Sets.newHashSet(); - - for (String childName : childNames) { - qn.add(getNodeIdentifier(childName).getNodeType()); - } - - return new YangInstanceIdentifier.AugmentationIdentifier(qn); + for (DataNodeContainer container : containers) { + DataSchemaNode retVal = findChildNode(container.getChildNodes(), name); + if (retVal != null) { + return retVal; + } } + return null; + } - public static ContainerNode augmentChoiceExpectedNode() { - - DataContainerNodeBuilder b = - Builders.containerBuilder(); - b.withNodeIdentifier(getNodeIdentifier("container")); - - b.withChild(Builders - .choiceBuilder() - .withNodeIdentifier(getNodeIdentifier("ch2")) - .withChild( - Builders.leafBuilder() - .withNodeIdentifier(getNodeIdentifier("c2Leaf")).withValue("2") - .build()) - .withChild( - Builders - .choiceBuilder() - .withNodeIdentifier(getNodeIdentifier("c2DeepChoice")) - .withChild( - Builders - .leafBuilder() - .withNodeIdentifier( - getNodeIdentifier("c2DeepChoiceCase1Leaf2")) - .withValue("2").build()).build()).build()); - - b.withChild(Builders - .choiceBuilder() - .withNodeIdentifier(getNodeIdentifier("ch3")) - .withChild( - Builders.leafBuilder() - .withNodeIdentifier(getNodeIdentifier("c3Leaf")).withValue("3") - .build()).build()); - - b.withChild(Builders - .augmentationBuilder() - .withNodeIdentifier(getAugmentIdentifier("augLeaf")) - .withChild( - Builders.leafBuilder() - .withNodeIdentifier(getNodeIdentifier("augLeaf")) - .withValue("augment").build()).build()); - - b.withChild(Builders - .augmentationBuilder() - .withNodeIdentifier(getAugmentIdentifier("ch")) - .withChild( - Builders - .choiceBuilder() - .withNodeIdentifier(getNodeIdentifier("ch")) - .withChild( - Builders.leafBuilder() - .withNodeIdentifier(getNodeIdentifier("c1Leaf")) - .withValue("1").build()) - .withChild( - Builders - .augmentationBuilder() - .withNodeIdentifier( - getAugmentIdentifier("c1Leaf_AnotherAugment", - "deepChoice")) - .withChild( - Builders - .leafBuilder() - .withNodeIdentifier( - getNodeIdentifier("c1Leaf_AnotherAugment")) - .withValue("1").build()) - .withChild( - Builders - .choiceBuilder() - .withNodeIdentifier( - getNodeIdentifier("deepChoice")) - .withChild( - Builders - .leafBuilder() - .withNodeIdentifier( - getNodeIdentifier("deepLeafc1")) - .withValue("1").build()).build()) - .build()).build()).build()); - - return b.build(); - } - + public static YangInstanceIdentifier.NodeIdentifier getNodeIdentifier( + final String localName) { + return new YangInstanceIdentifier.NodeIdentifier(QName.create( + URI.create(NAMESPACE), revision, localName)); + } + public static YangInstanceIdentifier.AugmentationIdentifier getAugmentIdentifier( + final String... childNames) { + Set qn = Sets.newHashSet(); - public void init(final String yangPath, final String xmlPath, final ContainerNode expectedNode) - throws Exception { - SchemaContext schema = parseTestSchema(yangPath); - this.xmlPath = xmlPath; - this.containerNode = - (ContainerSchemaNode) getSchemaNode(schema, "test", "container"); - this.expectedNode = expectedNode; + for (String childName : childNames) { + qn.add(getNodeIdentifier(childName).getNodeType()); } - SchemaContext parseTestSchema(final String yangPath) throws Exception { - - YangParserImpl yangParserImpl = new YangParserImpl(); - InputStream stream = - NormalizedNodeXmlConverterTest.class.getResourceAsStream(yangPath); - ArrayList al = new ArrayList(); - al.add(stream); - Set modules = yangParserImpl.parseYangModelsFromStreams(al); - return yangParserImpl.resolveSchemaContext(modules); - + return new YangInstanceIdentifier.AugmentationIdentifier(qn); + } + + + public static ContainerNode augmentChoiceExpectedNode() { + + DataContainerNodeBuilder b = + Builders.containerBuilder(); + b.withNodeIdentifier(getNodeIdentifier("container")); + + b.withChild(Builders + .choiceBuilder() + .withNodeIdentifier(getNodeIdentifier("ch2")) + .withChild( + Builders.leafBuilder() + .withNodeIdentifier(getNodeIdentifier("c2Leaf")).withValue("2") + .build()) + .withChild( + Builders + .choiceBuilder() + .withNodeIdentifier(getNodeIdentifier("c2DeepChoice")) + .withChild( + Builders + .leafBuilder() + .withNodeIdentifier( + getNodeIdentifier("c2DeepChoiceCase1Leaf2")) + .withValue("2").build()).build()).build()); + + b.withChild(Builders + .choiceBuilder() + .withNodeIdentifier(getNodeIdentifier("ch3")) + .withChild( + Builders.leafBuilder() + .withNodeIdentifier(getNodeIdentifier("c3Leaf")).withValue("3") + .build()).build()); + + b.withChild(Builders + .augmentationBuilder() + .withNodeIdentifier(getAugmentIdentifier("augLeaf")) + .withChild( + Builders.leafBuilder() + .withNodeIdentifier(getNodeIdentifier("augLeaf")) + .withValue("augment").build()).build()); + + b.withChild(Builders + .augmentationBuilder() + .withNodeIdentifier(getAugmentIdentifier("ch")) + .withChild( + Builders + .choiceBuilder() + .withNodeIdentifier(getNodeIdentifier("ch")) + .withChild( + Builders.leafBuilder() + .withNodeIdentifier(getNodeIdentifier("c1Leaf")) + .withValue("1").build()) + .withChild( + Builders + .augmentationBuilder() + .withNodeIdentifier( + getAugmentIdentifier("c1Leaf_AnotherAugment", + "deepChoice")) + .withChild( + Builders + .leafBuilder() + .withNodeIdentifier( + getNodeIdentifier("c1Leaf_AnotherAugment")) + .withValue("1").build()) + .withChild( + Builders + .choiceBuilder() + .withNodeIdentifier( + getNodeIdentifier("deepChoice")) + .withChild( + Builders + .leafBuilder() + .withNodeIdentifier( + getNodeIdentifier("deepLeafc1")) + .withValue("1").build()).build()) + .build()).build()).build()); + + return b.build(); + } + + + + public void init(final String yangPath, final String xmlPath, + final ContainerNode expectedNode) throws Exception { + SchemaContext schema = parseTestSchema(yangPath); + this.xmlPath = xmlPath; + this.containerNode = + (ContainerSchemaNode) getSchemaNode(schema, "test", "container"); + this.expectedNode = expectedNode; + } + + SchemaContext parseTestSchema(final String yangPath) throws Exception { + + YangParserImpl yangParserImpl = new YangParserImpl(); + InputStream stream = + NormalizedNodeXmlConverterTest.class.getResourceAsStream(yangPath); + ArrayList al = new ArrayList(); + al.add(stream); + Set modules = yangParserImpl.parseYangModelsFromStreams(al); + return yangParserImpl.resolveSchemaContext(modules); + + } + + + @Test + public void testConversionWithAugmentChoice() throws Exception { + init("/augment_choice.yang", "/augment_choice.xml", + augmentChoiceExpectedNode()); + Document doc = loadDocument(xmlPath); + + ContainerNode built = + DomToNormalizedNodeParserFactory + .getInstance(DomUtils.defaultValueCodecProvider()) + .getContainerNodeParser() + .parse(Collections.singletonList(doc.getDocumentElement()), + containerNode); + + if (expectedNode != null) { + junit.framework.Assert.assertEquals(expectedNode, built); } + logger.info("{}", built); - @Test - public void testConversionWithAugmentChoice() throws Exception { - init("/augment_choice.yang", "/augment_choice.xml", - augmentChoiceExpectedNode()); - Document doc = loadDocument(xmlPath); + Iterable els = + DomFromNormalizedNodeSerializerFactory + .getInstance(XmlDocumentUtils.getDocument(), + DomUtils.defaultValueCodecProvider()) + .getContainerNodeSerializer().serialize(containerNode, built); - ContainerNode built = - DomToNormalizedNodeParserFactory - .getInstance(DomUtils.defaultValueCodecProvider()) - .getContainerNodeParser() - .parse(Collections.singletonList(doc.getDocumentElement()), - containerNode); + Element el = els.iterator().next(); - if (expectedNode != null) { - junit.framework.Assert.assertEquals(expectedNode, built); - } + XMLUnit.setIgnoreWhitespace(true); + XMLUnit.setIgnoreComments(true); - logger.info("{}", built); + System.out.println(toString(doc.getDocumentElement())); + System.out.println(toString(el)); - Iterable els = - DomFromNormalizedNodeSerializerFactory - .getInstance(XmlDocumentUtils.getDocument(), - DomUtils.defaultValueCodecProvider()) - .getContainerNodeSerializer().serialize(containerNode, built); + new Diff(XMLUnit.buildControlDocument(toString(doc.getDocumentElement())), + XMLUnit.buildTestDocument(toString(el))).similar(); + } - Element el = els.iterator().next(); + private static ContainerNode listLeafListWithAttributes() { + DataContainerNodeBuilder b = + Builders.containerBuilder(); + b.withNodeIdentifier(getNodeIdentifier("container")); - XMLUnit.setIgnoreWhitespace(true); - XMLUnit.setIgnoreComments(true); + CollectionNodeBuilder listBuilder = + Builders.mapBuilder().withNodeIdentifier(getNodeIdentifier("list")); - System.out.println(toString(doc.getDocumentElement())); - System.out.println(toString(el)); + Map predicates = Maps.newHashMap(); + predicates.put(getNodeIdentifier("uint32InList").getNodeType(), 3L); - new Diff( - XMLUnit.buildControlDocument(toString(doc.getDocumentElement())), - XMLUnit.buildTestDocument(toString(el))).similar(); - } + DataContainerNodeBuilder list1Builder = + Builders.mapEntryBuilder().withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifierWithPredicates( + getNodeIdentifier("list").getNodeType(), predicates)); + NormalizedNodeBuilder> uint32InListBuilder = + Builders.leafBuilder().withNodeIdentifier( + getNodeIdentifier("uint32InList")); - private static ContainerNode listLeafListWithAttributes() { - DataContainerNodeBuilder b = - Builders.containerBuilder(); - b.withNodeIdentifier(getNodeIdentifier("container")); + list1Builder.withChild(uint32InListBuilder.withValue(3L).build()); - CollectionNodeBuilder listBuilder = - Builders.mapBuilder().withNodeIdentifier(getNodeIdentifier("list")); + listBuilder.withChild(list1Builder.build()); + b.withChild(listBuilder.build()); - Map predicates = Maps.newHashMap(); - predicates.put(getNodeIdentifier("uint32InList").getNodeType(), 3L); + NormalizedNodeBuilder> booleanBuilder = + Builders.leafBuilder().withNodeIdentifier(getNodeIdentifier("boolean")); + booleanBuilder.withValue(false); + b.withChild(booleanBuilder.build()); - DataContainerNodeBuilder list1Builder = - Builders.mapEntryBuilder().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifierWithPredicates( - getNodeIdentifier("list").getNodeType(), predicates)); - NormalizedNodeBuilder> uint32InListBuilder = - Builders.leafBuilder().withNodeIdentifier( - getNodeIdentifier("uint32InList")); + ListNodeBuilder> leafListBuilder = + Builders.leafSetBuilder().withNodeIdentifier( + getNodeIdentifier("leafList")); - list1Builder.withChild(uint32InListBuilder.withValue(3L).build()); + NormalizedNodeBuilder> leafList1Builder = + Builders.leafSetEntryBuilder().withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue(getNodeIdentifier( + "leafList").getNodeType(), "a")); - listBuilder.withChild(list1Builder.build()); - b.withChild(listBuilder.build()); + leafList1Builder.withValue("a"); - NormalizedNodeBuilder> booleanBuilder = - Builders.leafBuilder().withNodeIdentifier(getNodeIdentifier("boolean")); - booleanBuilder.withValue(false); - b.withChild(booleanBuilder.build()); + leafListBuilder.withChild(leafList1Builder.build()); + b.withChild(leafListBuilder.build()); - ListNodeBuilder> leafListBuilder = - Builders.leafSetBuilder().withNodeIdentifier( - getNodeIdentifier("leafList")); + return b.build(); + } - NormalizedNodeBuilder> leafList1Builder = - Builders.leafSetEntryBuilder().withNodeIdentifier( - new YangInstanceIdentifier.NodeWithValue(getNodeIdentifier("leafList") - .getNodeType(), "a")); - leafList1Builder.withValue("a"); + @Test + public void testConversionWithAttributes() throws Exception { + init("/test.yang", "/simple_xml_with_attributes.xml", + listLeafListWithAttributes()); + Document doc = loadDocument(xmlPath); - leafListBuilder.withChild(leafList1Builder.build()); - b.withChild(leafListBuilder.build()); + ContainerNode built = + DomToNormalizedNodeParserFactory + .getInstance(DomUtils.defaultValueCodecProvider()) + .getContainerNodeParser() + .parse(Collections.singletonList(doc.getDocumentElement()), + containerNode); - return b.build(); + if (expectedNode != null) { + junit.framework.Assert.assertEquals(expectedNode, built); } + logger.info("{}", built); - @Test - public void testConversionWithAttributes() throws Exception { - init("/test.yang", "/simple_xml_with_attributes.xml", - listLeafListWithAttributes()); - Document doc = loadDocument(xmlPath); + Iterable els = + DomFromNormalizedNodeSerializerFactory + .getInstance(XmlDocumentUtils.getDocument(), + DomUtils.defaultValueCodecProvider()) + .getContainerNodeSerializer().serialize(containerNode, built); - ContainerNode built = - DomToNormalizedNodeParserFactory - .getInstance(DomUtils.defaultValueCodecProvider()) - .getContainerNodeParser() - .parse(Collections.singletonList(doc.getDocumentElement()), - containerNode); + Element el = els.iterator().next(); - if (expectedNode != null) { - junit.framework.Assert.assertEquals(expectedNode, built); - } + XMLUnit.setIgnoreWhitespace(true); + XMLUnit.setIgnoreComments(true); - logger.info("{}", built); + System.out.println(toString(doc.getDocumentElement())); + System.out.println(toString(el)); - Iterable els = - DomFromNormalizedNodeSerializerFactory - .getInstance(XmlDocumentUtils.getDocument(), - DomUtils.defaultValueCodecProvider()) - .getContainerNodeSerializer().serialize(containerNode, built); + new Diff(XMLUnit.buildControlDocument(toString(doc.getDocumentElement())), + XMLUnit.buildTestDocument(toString(el))).similar(); + } - Element el = els.iterator().next(); - XMLUnit.setIgnoreWhitespace(true); - XMLUnit.setIgnoreComments(true); + private Document loadDocument(final String xmlPath) throws Exception { + InputStream resourceAsStream = + NormalizedNodeXmlConverterTest.class.getResourceAsStream(xmlPath); - System.out.println(toString(doc.getDocumentElement())); - System.out.println(toString(el)); + Document currentConfigElement = readXmlToDocument(resourceAsStream); + Preconditions.checkNotNull(currentConfigElement); + return currentConfigElement; + } - new Diff( - XMLUnit.buildControlDocument(toString(doc.getDocumentElement())), - XMLUnit.buildTestDocument(toString(el))).similar(); - } + private static final DocumentBuilderFactory BUILDERFACTORY; + static { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + factory.setCoalescing(true); + factory.setIgnoringElementContentWhitespace(true); + factory.setIgnoringComments(true); + BUILDERFACTORY = factory; + } - private Document loadDocument(final String xmlPath) throws Exception { - InputStream resourceAsStream = - NormalizedNodeXmlConverterTest.class.getResourceAsStream(xmlPath); - - Document currentConfigElement = readXmlToDocument(resourceAsStream); - Preconditions.checkNotNull(currentConfigElement); - return currentConfigElement; - } - - private static final DocumentBuilderFactory BUILDERFACTORY; - - static { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - factory.setCoalescing(true); - factory.setIgnoringElementContentWhitespace(true); - factory.setIgnoringComments(true); - BUILDERFACTORY = factory; + private Document readXmlToDocument(final InputStream xmlContent) + throws IOException, SAXException { + DocumentBuilder dBuilder; + try { + dBuilder = BUILDERFACTORY.newDocumentBuilder(); + } catch (ParserConfigurationException e) { + throw new RuntimeException("Failed to parse XML document", e); } - - private Document readXmlToDocument(final InputStream xmlContent) - throws IOException, SAXException { - DocumentBuilder dBuilder; - try { - dBuilder = BUILDERFACTORY.newDocumentBuilder(); - } catch (ParserConfigurationException e) { - throw new RuntimeException("Failed to parse XML document", e); - } - Document doc = dBuilder.parse(xmlContent); - - doc.getDocumentElement().normalize(); - return doc; - } - - public static String toString(final Element xml) { - try { - Transformer transformer = - TransformerFactory.newInstance().newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - - StreamResult result = new StreamResult(new StringWriter()); - DOMSource source = new DOMSource(xml); - transformer.transform(source, result); - - return result.getWriter().toString(); - } catch (IllegalArgumentException | TransformerFactoryConfigurationError - | TransformerException e) { - throw new RuntimeException("Unable to serialize xml element " + xml, e); - } + Document doc = dBuilder.parse(xmlContent); + + doc.getDocumentElement().normalize(); + return doc; + } + + public static String toString(final Element xml) { + try { + Transformer transformer = + TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + + StreamResult result = new StreamResult(new StringWriter()); + DOMSource source = new DOMSource(xml); + transformer.transform(source, result); + + return result.getWriter().toString(); + } catch (IllegalArgumentException | TransformerFactoryConfigurationError + | TransformerException e) { + throw new RuntimeException("Unable to serialize xml element " + xml, e); } + } - @Test - public void testConversionToNormalizedXml() throws Exception { - SimpleNormalizedNodeMessage.NormalizedNodeXml nnXml = - EncoderDecoderUtil.encode(parseTestSchema("/augment_choice.yang"), - augmentChoiceExpectedNode()); - Document expectedDoc = loadDocument("/augment_choice.xml"); - Document convertedDoc = - EncoderDecoderUtil.factory.newDocumentBuilder().parse( - new ByteArrayInputStream(nnXml.getXmlString().getBytes("utf-8"))); - System.out.println(toString(convertedDoc.getDocumentElement())); - XMLUnit.setIgnoreWhitespace(true); - XMLUnit.setIgnoreComments(true); - new Diff(XMLUnit.buildControlDocument(toString(expectedDoc - .getDocumentElement())), - XMLUnit.buildTestDocument(toString(convertedDoc - .getDocumentElement()))).similar(); - System.out.println(toString(expectedDoc.getDocumentElement())); - - } - - - @Test - public void testConversionFromXmlToNormalizedNode() throws Exception { - SimpleNormalizedNodeMessage.NormalizedNodeXml nnXml = - EncoderDecoderUtil.encode(parseTestSchema("/test.yang"), - listLeafListWithAttributes()); - Document expectedDoc = loadDocument("/simple_xml_with_attributes.xml"); - Document convertedDoc = - EncoderDecoderUtil.factory.newDocumentBuilder().parse( - new ByteArrayInputStream(nnXml.getXmlString().getBytes("utf-8"))); - System.out.println(toString(convertedDoc.getDocumentElement())); - XMLUnit.setIgnoreWhitespace(true); - XMLUnit.setIgnoreComments(true); - new Diff(XMLUnit.buildControlDocument(toString(expectedDoc - .getDocumentElement())), - XMLUnit.buildTestDocument(toString(convertedDoc - .getDocumentElement()))).similar(); - System.out.println(toString(expectedDoc.getDocumentElement())); - - // now we will try to convert xml back to normalize node. - ContainerNode cn = - (ContainerNode) EncoderDecoderUtil.decode( - parseTestSchema("/test.yang"), nnXml); - junit.framework.Assert.assertEquals(listLeafListWithAttributes(), cn); - - } + @Test + public void testConversionToNormalizedXml() throws Exception { + SimpleNormalizedNodeMessage.NormalizedNodeXml nnXml = + EncoderDecoderUtil.encode(parseTestSchema("/augment_choice.yang"), + augmentChoiceExpectedNode()); + Document expectedDoc = loadDocument("/augment_choice.xml"); + Document convertedDoc = + EncoderDecoderUtil.factory.newDocumentBuilder().parse( + new ByteArrayInputStream(nnXml.getXmlString().getBytes("utf-8"))); + System.out.println(toString(convertedDoc.getDocumentElement())); + XMLUnit.setIgnoreWhitespace(true); + XMLUnit.setIgnoreComments(true); + new Diff(XMLUnit.buildControlDocument(toString(expectedDoc + .getDocumentElement())), + XMLUnit.buildTestDocument(toString(convertedDoc.getDocumentElement()))) + .similar(); + System.out.println(toString(expectedDoc.getDocumentElement())); + + } + + + @Test + public void testConversionFromXmlToNormalizedNode() throws Exception { + SimpleNormalizedNodeMessage.NormalizedNodeXml nnXml = + EncoderDecoderUtil.encode(parseTestSchema("/test.yang"), + listLeafListWithAttributes()); + Document expectedDoc = loadDocument("/simple_xml_with_attributes.xml"); + Document convertedDoc = + EncoderDecoderUtil.factory.newDocumentBuilder().parse( + new ByteArrayInputStream(nnXml.getXmlString().getBytes("utf-8"))); + System.out.println(toString(convertedDoc.getDocumentElement())); + XMLUnit.setIgnoreWhitespace(true); + XMLUnit.setIgnoreComments(true); + new Diff(XMLUnit.buildControlDocument(toString(expectedDoc + .getDocumentElement())), + XMLUnit.buildTestDocument(toString(convertedDoc.getDocumentElement()))) + .similar(); + System.out.println(toString(expectedDoc.getDocumentElement())); + + // now we will try to convert xml back to normalize node. + ContainerNode cn = + (ContainerNode) EncoderDecoderUtil.decode( + parseTestSchema("/test.yang"), nnXml); + junit.framework.Assert.assertEquals(listLeafListWithAttributes(), cn); + + } } diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java index bef4057aa2..3eeb06f93c 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java @@ -1,3 +1,13 @@ +/* + * + * 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.cluster.datastore.util; import org.opendaylight.yangtools.yang.common.QName; @@ -34,453 +44,427 @@ import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.ma public class TestModel { - public static final QName TEST_QNAME = QName.create( - "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", - "2014-03-13", "test"); - - public static final QName AUG_NAME_QNAME = QName.create( - "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug", - "2014-03-13", "name"); - - public static final QName AUG_CONT_QNAME = QName.create( - "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug", - "2014-03-13", "cont"); - - - public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc"); - public static final QName POINTER_QNAME = - QName.create(TEST_QNAME, "pointer"); - public static final QName SOME_REF_QNAME = - QName.create(TEST_QNAME, "some-ref"); - public static final QName MYIDENTITY_QNAME = - QName.create(TEST_QNAME, "myidentity"); - public static final QName SWITCH_FEATURES_QNAME = - QName.create(TEST_QNAME, "switch-features"); - - public static final QName AUGMENTED_LIST_QNAME = - QName.create(TEST_QNAME, "augmented-list"); - - public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, - "outer-list"); - public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, - "inner-list"); - public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, - "outer-choice"); - public static final QName ID_QNAME = QName.create(TEST_QNAME, "id"); - public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name"); - public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value"); - private static final String DATASTORE_TEST_YANG = - "/odl-datastore-test.yang"; - private static final String DATASTORE_AUG_YANG = - "/odl-datastore-augmentation.yang"; - private static final String DATASTORE_TEST_NOTIFICATION_YANG = - "/odl-datastore-test-notification.yang"; - - - public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier - .of(TEST_QNAME); - public static final YangInstanceIdentifier DESC_PATH = YangInstanceIdentifier - .builder(TEST_PATH).node(DESC_QNAME).build(); - public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier - .builder(TEST_PATH).node(OUTER_LIST_QNAME).build(); - public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two"); - public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three"); - - private static final Integer ONE_ID = 1; - private static final Integer TWO_ID = 2; - private static final String TWO_ONE_NAME = "one"; - private static final String TWO_TWO_NAME = "two"; - private static final String DESC = "Hello there"; - - // Family specific constants - public static final QName FAMILY_QNAME = - QName - .create( - "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test", - "2014-04-17", "family"); - public static final QName CHILDREN_QNAME = QName.create(FAMILY_QNAME, - "children"); - public static final QName GRAND_CHILDREN_QNAME = QName.create(FAMILY_QNAME, - "grand-children"); - public static final QName CHILD_NUMBER_QNAME = QName.create(FAMILY_QNAME, - "child-number"); - public static final QName CHILD_NAME_QNAME = QName.create(FAMILY_QNAME, - "child-name"); - public static final QName GRAND_CHILD_NUMBER_QNAME = QName.create( - FAMILY_QNAME, "grand-child-number"); - public static final QName GRAND_CHILD_NAME_QNAME = - QName.create(FAMILY_QNAME, - "grand-child-name"); - - public static final YangInstanceIdentifier FAMILY_PATH = YangInstanceIdentifier - .of(FAMILY_QNAME); - public static final YangInstanceIdentifier FAMILY_DESC_PATH = YangInstanceIdentifier - .builder(FAMILY_PATH).node(DESC_QNAME).build(); - public static final YangInstanceIdentifier CHILDREN_PATH = YangInstanceIdentifier - .builder(FAMILY_PATH).node(CHILDREN_QNAME).build(); - - private static final Integer FIRST_CHILD_ID = 1; - private static final Integer SECOND_CHILD_ID = 2; - - private static final String FIRST_CHILD_NAME = "first child"; - private static final String SECOND_CHILD_NAME = "second child"; - - private static final Integer FIRST_GRAND_CHILD_ID = 1; - private static final Integer SECOND_GRAND_CHILD_ID = 2; - - private static final String FIRST_GRAND_CHILD_NAME = "first grand child"; - private static final String SECOND_GRAND_CHILD_NAME = "second grand child"; - - // first child - private static final YangInstanceIdentifier CHILDREN_1_PATH = YangInstanceIdentifier - .builder(CHILDREN_PATH) - .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID) // - .build(); - private static final YangInstanceIdentifier CHILDREN_1_NAME_PATH = - YangInstanceIdentifier.builder(CHILDREN_PATH) - .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, FIRST_CHILD_NAME) // - .build(); + public static final QName TEST_QNAME = QName.create( + "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", + "2014-03-13", "test"); + + public static final QName AUG_NAME_QNAME = QName.create( + "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug", + "2014-03-13", "name"); + + public static final QName AUG_CONT_QNAME = QName.create( + "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug", + "2014-03-13", "cont"); + + + public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc"); + public static final QName POINTER_QNAME = QName.create(TEST_QNAME, "pointer"); + public static final QName SOME_REF_QNAME = QName.create(TEST_QNAME, + "some-ref"); + public static final QName MYIDENTITY_QNAME = QName.create(TEST_QNAME, + "myidentity"); + public static final QName SWITCH_FEATURES_QNAME = QName.create(TEST_QNAME, + "switch-features"); + + public static final QName AUGMENTED_LIST_QNAME = QName.create(TEST_QNAME, + "augmented-list"); + + public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, + "outer-list"); + public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, + "inner-list"); + public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, + "outer-choice"); + public static final QName ID_QNAME = QName.create(TEST_QNAME, "id"); + public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name"); + public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value"); + private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang"; + private static final String DATASTORE_AUG_YANG = + "/odl-datastore-augmentation.yang"; + private static final String DATASTORE_TEST_NOTIFICATION_YANG = + "/odl-datastore-test-notification.yang"; + + + public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier + .of(TEST_QNAME); + public static final YangInstanceIdentifier DESC_PATH = YangInstanceIdentifier + .builder(TEST_PATH).node(DESC_QNAME).build(); + public static final YangInstanceIdentifier OUTER_LIST_PATH = + YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build(); + public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two"); + public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three"); + + private static final Integer ONE_ID = 1; + private static final Integer TWO_ID = 2; + private static final String TWO_ONE_NAME = "one"; + private static final String TWO_TWO_NAME = "two"; + private static final String DESC = "Hello there"; + + // Family specific constants + public static final QName FAMILY_QNAME = + QName + .create( + "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test", + "2014-04-17", "family"); + public static final QName CHILDREN_QNAME = QName.create(FAMILY_QNAME, + "children"); + public static final QName GRAND_CHILDREN_QNAME = QName.create(FAMILY_QNAME, + "grand-children"); + public static final QName CHILD_NUMBER_QNAME = QName.create(FAMILY_QNAME, + "child-number"); + public static final QName CHILD_NAME_QNAME = QName.create(FAMILY_QNAME, + "child-name"); + public static final QName GRAND_CHILD_NUMBER_QNAME = QName.create( + FAMILY_QNAME, "grand-child-number"); + public static final QName GRAND_CHILD_NAME_QNAME = QName.create(FAMILY_QNAME, + "grand-child-name"); + + public static final YangInstanceIdentifier FAMILY_PATH = + YangInstanceIdentifier.of(FAMILY_QNAME); + public static final YangInstanceIdentifier FAMILY_DESC_PATH = + YangInstanceIdentifier.builder(FAMILY_PATH).node(DESC_QNAME).build(); + public static final YangInstanceIdentifier CHILDREN_PATH = + YangInstanceIdentifier.builder(FAMILY_PATH).node(CHILDREN_QNAME).build(); + + private static final Integer FIRST_CHILD_ID = 1; + private static final Integer SECOND_CHILD_ID = 2; + + private static final String FIRST_CHILD_NAME = "first child"; + private static final String SECOND_CHILD_NAME = "second child"; + + private static final Integer FIRST_GRAND_CHILD_ID = 1; + private static final Integer SECOND_GRAND_CHILD_ID = 2; + + private static final String FIRST_GRAND_CHILD_NAME = "first grand child"; + private static final String SECOND_GRAND_CHILD_NAME = "second grand child"; + + // first child + private static final YangInstanceIdentifier CHILDREN_1_PATH = + YangInstanceIdentifier.builder(CHILDREN_PATH) + .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID) // + .build(); + private static final YangInstanceIdentifier CHILDREN_1_NAME_PATH = + YangInstanceIdentifier.builder(CHILDREN_PATH) + .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, FIRST_CHILD_NAME) // + .build(); + + private static final YangInstanceIdentifier CHILDREN_2_PATH = + YangInstanceIdentifier.builder(CHILDREN_PATH) + .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID) // + .build(); + private static final YangInstanceIdentifier CHILDREN_2_NAME_PATH = + YangInstanceIdentifier.builder(CHILDREN_PATH) + .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, SECOND_CHILD_NAME) // + .build(); + + + private static final YangInstanceIdentifier GRAND_CHILD_1_PATH = + YangInstanceIdentifier + .builder(CHILDREN_1_PATH) + .node(GRAND_CHILDREN_QNAME) + // + .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, + FIRST_GRAND_CHILD_ID) // + .build(); + + private static final YangInstanceIdentifier GRAND_CHILD_1_NAME_PATH = + YangInstanceIdentifier + .builder(CHILDREN_1_PATH) + .node(GRAND_CHILDREN_QNAME) + // + .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME, + FIRST_GRAND_CHILD_NAME) // + .build(); + + private static final YangInstanceIdentifier GRAND_CHILD_2_PATH = + YangInstanceIdentifier + .builder(CHILDREN_2_PATH) + .node(GRAND_CHILDREN_QNAME) + // + .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, + SECOND_GRAND_CHILD_ID) // + .build(); + + private static final YangInstanceIdentifier GRAND_CHILD_2_NAME_PATH = + YangInstanceIdentifier + .builder(CHILDREN_2_PATH) + .node(GRAND_CHILDREN_QNAME) + // + .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME, + SECOND_GRAND_CHILD_NAME) // + .build(); + + private static final YangInstanceIdentifier DESC_PATH_ID = + YangInstanceIdentifier.builder(DESC_PATH).build(); + private static final YangInstanceIdentifier OUTER_LIST_1_PATH = + YangInstanceIdentifier.builder(OUTER_LIST_PATH) + .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, ONE_ID) // + .build(); + + private static final YangInstanceIdentifier OUTER_LIST_2_PATH = + YangInstanceIdentifier.builder(OUTER_LIST_PATH) + .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) // + .build(); + + private static final YangInstanceIdentifier TWO_TWO_PATH = + YangInstanceIdentifier.builder(OUTER_LIST_2_PATH).node(INNER_LIST_QNAME) // + .nodeWithKey(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME) // + .build(); + + private static final YangInstanceIdentifier TWO_TWO_VALUE_PATH = + YangInstanceIdentifier.builder(TWO_TWO_PATH).node(VALUE_QNAME) // + .build(); + + private static final MapEntryNode BAR_NODE = mapEntryBuilder( + OUTER_LIST_QNAME, ID_QNAME, TWO_ID) // + .withChild(mapNodeBuilder(INNER_LIST_QNAME) // + .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) // + .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) // + .build()) // + .build(); + + public static final InputStream getDatastoreTestInputStream() { + return getInputStream(DATASTORE_TEST_YANG); + } + + public static final InputStream getDatastoreAugInputStream() { + return getInputStream(DATASTORE_AUG_YANG); + } + + public static final InputStream getDatastoreTestNotificationInputStream() { + return getInputStream(DATASTORE_TEST_NOTIFICATION_YANG); + } + + private static InputStream getInputStream(final String resourceName) { + return TestModel.class.getResourceAsStream(resourceName); + } + + public static SchemaContext createTestContext() { + List inputStreams = new ArrayList<>(); + inputStreams.add(getDatastoreTestInputStream()); + inputStreams.add(getDatastoreAugInputStream()); + inputStreams.add(getDatastoreTestNotificationInputStream()); + + YangParserImpl parser = new YangParserImpl(); + Set modules = parser.parseYangModelsFromStreams(inputStreams); + return parser.resolveSchemaContext(modules); + } + + /** + * Returns a test document + *

+ * + *

+   * test
+   *     outer-list
+   *          id 1
+   *     outer-list
+   *          id 2
+   *          inner-list
+   *                  name "one"
+   *          inner-list
+   *                  name "two"
+   *
+   * 
+ * + * @return + */ + public static NormalizedNode createDocumentOne( + SchemaContext schemaContext) { + return ImmutableContainerNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(schemaContext.getQName())) + .withChild(createTestContainer()).build(); + + } + + public static ContainerNode createTestContainer() { + + + // Create a list of shoes + // This is to test leaf list entry + final LeafSetEntryNode nike = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue(QName.create( + TEST_QNAME, "shoe"), "nike")).withValue("nike").build(); + + final LeafSetEntryNode puma = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue(QName.create( + TEST_QNAME, "shoe"), "puma")).withValue("puma").build(); - private static final YangInstanceIdentifier CHILDREN_2_PATH = YangInstanceIdentifier - .builder(CHILDREN_PATH) - .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID) // - .build(); - private static final YangInstanceIdentifier CHILDREN_2_NAME_PATH = - YangInstanceIdentifier.builder(CHILDREN_PATH) - .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, SECOND_CHILD_NAME) // + final LeafSetNode shoes = + ImmutableLeafSetNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(QName.create( + TEST_QNAME, "shoe"))).withChild(nike).withChild(puma) .build(); - private static final YangInstanceIdentifier GRAND_CHILD_1_PATH = - YangInstanceIdentifier.builder(CHILDREN_1_PATH) - .node(GRAND_CHILDREN_QNAME) - // - .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, - FIRST_GRAND_CHILD_ID) // - .build(); + // Test a leaf-list where each entry contains an identity + final LeafSetEntryNode cap1 = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue(QName.create( + TEST_QNAME, "capability"), DESC_QNAME)) + .withValue(DESC_QNAME).build(); - private static final YangInstanceIdentifier GRAND_CHILD_1_NAME_PATH = - YangInstanceIdentifier.builder(CHILDREN_1_PATH) - .node(GRAND_CHILDREN_QNAME) - // - .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME, - FIRST_GRAND_CHILD_NAME) // - .build(); + final LeafSetNode capabilities = + ImmutableLeafSetNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(QName.create( + TEST_QNAME, "capability"))).withChild(cap1).build(); - private static final YangInstanceIdentifier GRAND_CHILD_2_PATH = - YangInstanceIdentifier.builder(CHILDREN_2_PATH) - .node(GRAND_CHILDREN_QNAME) - // - .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, - SECOND_GRAND_CHILD_ID) // - .build(); + ContainerNode switchFeatures = + ImmutableContainerNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(SWITCH_FEATURES_QNAME)) + .withChild(capabilities).build(); - private static final YangInstanceIdentifier GRAND_CHILD_2_NAME_PATH = - YangInstanceIdentifier.builder(CHILDREN_2_PATH) - .node(GRAND_CHILDREN_QNAME) - // - .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME, - SECOND_GRAND_CHILD_NAME) // + // Create a leaf list with numbers + final LeafSetEntryNode five = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + (new YangInstanceIdentifier.NodeWithValue(QName.create( + TEST_QNAME, "number"), 5))).withValue(5).build(); + final LeafSetEntryNode fifteen = + ImmutableLeafSetEntryNodeBuilder + .create() + .withNodeIdentifier( + (new YangInstanceIdentifier.NodeWithValue(QName.create( + TEST_QNAME, "number"), 15))).withValue(15).build(); + final LeafSetNode numbers = + ImmutableLeafSetNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(QName.create( + TEST_QNAME, "number"))).withChild(five).withChild(fifteen) .build(); - private static final YangInstanceIdentifier DESC_PATH_ID = YangInstanceIdentifier - .builder(DESC_PATH).build(); - private static final YangInstanceIdentifier OUTER_LIST_1_PATH = - YangInstanceIdentifier.builder(OUTER_LIST_PATH) - .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, ONE_ID) // - .build(); - private static final YangInstanceIdentifier OUTER_LIST_2_PATH = - YangInstanceIdentifier.builder(OUTER_LIST_PATH) - .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) // - .build(); + // Create augmentations + MapEntryNode mapEntry = createAugmentedListEntry(1, "First Test"); - private static final YangInstanceIdentifier TWO_TWO_PATH = YangInstanceIdentifier - .builder(OUTER_LIST_2_PATH).node(INNER_LIST_QNAME) // - .nodeWithKey(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME) // - .build(); - private static final YangInstanceIdentifier TWO_TWO_VALUE_PATH = - YangInstanceIdentifier.builder(TWO_TWO_PATH).node(VALUE_QNAME) // - .build(); + // Create the document + return ImmutableContainerNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC)) + .withChild(ImmutableNodes.leafNode(POINTER_QNAME, "pointer")) + .withChild( + ImmutableNodes.leafNode(SOME_REF_QNAME, YangInstanceIdentifier + .builder().build())) + .withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME)) - private static final MapEntryNode BAR_NODE = mapEntryBuilder( - OUTER_LIST_QNAME, ID_QNAME, TWO_ID) // - .withChild(mapNodeBuilder(INNER_LIST_QNAME) // - .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) // - .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) // - .build()) // - .build(); - - public static final InputStream getDatastoreTestInputStream() { - return getInputStream(DATASTORE_TEST_YANG); - } - - public static final InputStream getDatastoreAugInputStream() { - return getInputStream(DATASTORE_AUG_YANG); - } - - public static final InputStream getDatastoreTestNotificationInputStream() { - return getInputStream(DATASTORE_TEST_NOTIFICATION_YANG); - } - - private static InputStream getInputStream(final String resourceName) { - return TestModel.class.getResourceAsStream(resourceName); - } - - public static SchemaContext createTestContext() { - List inputStreams = new ArrayList<>(); - inputStreams.add(getDatastoreTestInputStream()); - inputStreams.add(getDatastoreAugInputStream()); - inputStreams.add(getDatastoreTestNotificationInputStream()); - - YangParserImpl parser = new YangParserImpl(); - Set modules = parser.parseYangModelsFromStreams(inputStreams); - return parser.resolveSchemaContext(modules); - } - - /** - * Returns a test document - *

- *

-     * test
-     *     outer-list
-     *          id 1
-     *     outer-list
-     *          id 2
-     *          inner-list
-     *                  name "one"
-     *          inner-list
-     *                  name "two"
-     *
-     * 
- * - * @return - */ - public static NormalizedNode createDocumentOne( - SchemaContext schemaContext) { - return ImmutableContainerNodeBuilder - .create() - .withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(schemaContext.getQName())) - .withChild(createTestContainer()).build(); - - } - - public static ContainerNode createTestContainer() { - - - // Create a list of shoes - // This is to test leaf list entry - final LeafSetEntryNode nike = - ImmutableLeafSetEntryNodeBuilder - .create() - .withNodeIdentifier( - new YangInstanceIdentifier.NodeWithValue( - QName.create(TEST_QNAME, - "shoe"), "nike") - ).withValue("nike").build(); - - final LeafSetEntryNode puma = - ImmutableLeafSetEntryNodeBuilder - .create() - .withNodeIdentifier( - new YangInstanceIdentifier.NodeWithValue( - QName.create(TEST_QNAME, - "shoe"), "puma") - ).withValue("puma").build(); - - final LeafSetNode shoes = - ImmutableLeafSetNodeBuilder - .create() - .withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier( - QName.create(TEST_QNAME, - "shoe")) - ).withChild(nike).withChild(puma).build(); - - - // Test a leaf-list where each entry contains an identity - final LeafSetEntryNode cap1 = - ImmutableLeafSetEntryNodeBuilder - .create() - .withNodeIdentifier( - new YangInstanceIdentifier.NodeWithValue( - QName.create(TEST_QNAME, - "capability"), DESC_QNAME) - ).withValue(DESC_QNAME).build(); - - final LeafSetNode capabilities = - ImmutableLeafSetNodeBuilder - .create() - .withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier( - QName.create(TEST_QNAME, - "capability")) - ).withChild(cap1).build(); - - ContainerNode switchFeatures = ImmutableContainerNodeBuilder - .create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier( - SWITCH_FEATURES_QNAME)) - .withChild(capabilities) - .build(); + // .withChild(augmentationNode) + .withChild(shoes) + .withChild(numbers) + .withChild(switchFeatures) + .withChild( + mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(mapEntry).build()) + .withChild( + mapNodeBuilder(OUTER_LIST_QNAME) + .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)) + .withChild(BAR_NODE).build()).build(); + + } - // Create a leaf list with numbers - final LeafSetEntryNode five = - ImmutableLeafSetEntryNodeBuilder - .create() - .withNodeIdentifier( - (new YangInstanceIdentifier.NodeWithValue( - QName.create(TEST_QNAME, - "number"), 5)) - ).withValue(5).build(); - final LeafSetEntryNode fifteen = - ImmutableLeafSetEntryNodeBuilder - .create() - .withNodeIdentifier( - (new YangInstanceIdentifier.NodeWithValue( - QName.create(TEST_QNAME, - "number"), 15)) - ).withValue(15).build(); - final LeafSetNode numbers = - ImmutableLeafSetNodeBuilder - .create() - .withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier( - QName.create(TEST_QNAME, - "number")) - ).withChild(five).withChild(fifteen).build(); - - - // Create augmentations - MapEntryNode mapEntry = createAugmentedListEntry(1, "First Test"); - - - // Create the document - return ImmutableContainerNodeBuilder + public static MapEntryNode createAugmentedListEntry(int id, String name) { + + Set childAugmentations = new HashSet<>(); + childAugmentations.add(AUG_CONT_QNAME); + + ContainerNode augCont = + ImmutableContainerNodeBuilder .create() .withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC)) - .withChild(ImmutableNodes.leafNode(POINTER_QNAME, "pointer")) - .withChild(ImmutableNodes.leafNode(SOME_REF_QNAME, - YangInstanceIdentifier.builder().build())) - .withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME)) - - //.withChild(augmentationNode) - .withChild(shoes) - .withChild(numbers) - .withChild(switchFeatures) - .withChild(mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(mapEntry).build()) - .withChild( - mapNodeBuilder(OUTER_LIST_QNAME) - .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)) - .withChild(BAR_NODE).build() - ).build(); - - } - - public static MapEntryNode createAugmentedListEntry(int id, String name) { - - Set childAugmentations = new HashSet<>(); - childAugmentations.add(AUG_CONT_QNAME); - - ContainerNode augCont = ImmutableContainerNodeBuilder - .create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(AUG_CONT_QNAME)) - .withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name)) - .build(); + new YangInstanceIdentifier.NodeIdentifier(AUG_CONT_QNAME)) + .withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name)).build(); - final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier = - new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations); + final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier = + new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations); - final AugmentationNode augmentationNode = - Builders.augmentationBuilder() - .withNodeIdentifier(augmentationIdentifier) - .withChild(augCont) - .build(); + final AugmentationNode augmentationNode = + Builders.augmentationBuilder() + .withNodeIdentifier(augmentationIdentifier).withChild(augCont) + .build(); - return ImmutableMapEntryNodeBuilder.create() - .withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifierWithPredicates( - AUGMENTED_LIST_QNAME, ID_QNAME, id)) - .withChild(ImmutableNodes.leafNode(ID_QNAME, id)) - .withChild(augmentationNode).build(); - } - - - public static ContainerNode createFamily() { - final DataContainerNodeAttrBuilder - familyContainerBuilder = - ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(FAMILY_QNAME)); - - final CollectionNodeBuilder childrenBuilder = - mapNodeBuilder(CHILDREN_QNAME); - - final DataContainerNodeBuilder - firstChildBuilder = - mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID); - final DataContainerNodeBuilder - secondChildBuilder = - mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, - SECOND_CHILD_ID); - - final DataContainerNodeBuilder - firstGrandChildBuilder = - mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, - FIRST_GRAND_CHILD_ID); - final DataContainerNodeBuilder - secondGrandChildBuilder = - mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, - SECOND_GRAND_CHILD_ID); - - firstGrandChildBuilder - .withChild( - ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME, - FIRST_GRAND_CHILD_ID) - ).withChild( + return ImmutableMapEntryNodeBuilder + .create() + .withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifierWithPredicates( + AUGMENTED_LIST_QNAME, ID_QNAME, id)) + .withChild(ImmutableNodes.leafNode(ID_QNAME, id)) + .withChild(augmentationNode).build(); + } + + + public static ContainerNode createFamily() { + final DataContainerNodeAttrBuilder familyContainerBuilder = + ImmutableContainerNodeBuilder.create().withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(FAMILY_QNAME)); + + final CollectionNodeBuilder childrenBuilder = + mapNodeBuilder(CHILDREN_QNAME); + + final DataContainerNodeBuilder firstChildBuilder = + mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID); + final DataContainerNodeBuilder secondChildBuilder = + mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID); + + final DataContainerNodeBuilder firstGrandChildBuilder = + mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, + FIRST_GRAND_CHILD_ID); + final DataContainerNodeBuilder secondGrandChildBuilder = + mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, + SECOND_GRAND_CHILD_ID); + + firstGrandChildBuilder + .withChild( + ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME, + FIRST_GRAND_CHILD_ID)).withChild( ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, - FIRST_GRAND_CHILD_NAME) - ); - - secondGrandChildBuilder.withChild( - ImmutableNodes - .leafNode(GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID) - ) - .withChild( - ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, - SECOND_GRAND_CHILD_NAME) - ); - - firstChildBuilder - .withChild( - ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID)) - .withChild( - ImmutableNodes.leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME)) - .withChild( - mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild( - firstGrandChildBuilder.build()).build() - ); - - - secondChildBuilder - .withChild( - ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID)) - .withChild( - ImmutableNodes.leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME)) - .withChild( - mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild( - firstGrandChildBuilder.build()).build() - ); - - childrenBuilder.withChild(firstChildBuilder.build()); - childrenBuilder.withChild(secondChildBuilder.build()); - - return familyContainerBuilder.withChild(childrenBuilder.build()) - .build(); - } + FIRST_GRAND_CHILD_NAME)); + + secondGrandChildBuilder.withChild( + ImmutableNodes + .leafNode(GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID)) + .withChild( + ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, + SECOND_GRAND_CHILD_NAME)); + + firstChildBuilder + .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID)) + .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME)) + .withChild( + mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild( + firstGrandChildBuilder.build()).build()); + + + secondChildBuilder + .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID)) + .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME)) + .withChild( + mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild( + firstGrandChildBuilder.build()).build()); + + childrenBuilder.withChild(firstChildBuilder.build()); + childrenBuilder.withChild(secondChildBuilder.build()); + + return familyContainerBuilder.withChild(childrenBuilder.build()).build(); + } } diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/AbstractMessagesTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/AbstractMessagesTest.java new file mode 100644 index 0000000000..c6c4afd505 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/AbstractMessagesTest.java @@ -0,0 +1,77 @@ +/* + * + * 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.protobuff.messages; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; + +/** + * @author: syedbahm Date: 7/31/14 + */ +public abstract class AbstractMessagesTest { + public final String VERSION_COMPATIBILTY_TEST_DATA_PATH = "." + + File.separator + "src" + File.separator + "test" + File.separator + + "resources" + File.separator + "version-compatibility-serialized-data"; + private File file; + private File testDataFile; + + protected AbstractMessagesTest() { + init(); + } + + protected void init() { + file = new File(getTestFileName()); + testDataFile = + new File(VERSION_COMPATIBILTY_TEST_DATA_PATH + File.separator + + getTestFileName() + "Data"); + } + + + + abstract public void verifySerialization() throws Exception; + + + protected void writeToFile( + com.google.protobuf.GeneratedMessage.Builder builder) throws Exception { + + FileOutputStream output = new FileOutputStream(file); + builder.build().writeTo(output); + output.close();; + + } + + protected com.google.protobuf.GeneratedMessage readFromFile( + com.google.protobuf.Parser parser) throws Exception { + com.google.protobuf.GeneratedMessage message = + (com.google.protobuf.GeneratedMessage) parser + .parseFrom(new FileInputStream(file)); + + /*Note: we will delete only the test file -- comment below if you want to capture the + version-compatibility-serialized-data test data file.The file will be generated at root of the + sal-protocolbuffer-encoding + and you need to move it to test/resources/version-compatbility-serialized-data folder renaming the file to include suffix "Data" + */ + file.delete(); + return message; + } + + protected com.google.protobuf.GeneratedMessage readFromTestDataFile( + com.google.protobuf.Parser parser) throws Exception { + return (com.google.protobuf.GeneratedMessage) parser + .parseFrom(new FileInputStream(testDataFile)); + } + + + public abstract String getTestFileName(); + + +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/ShardManagerMessagesTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/ShardManagerMessagesTest.java deleted file mode 100644 index b0758da9d1..0000000000 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/ShardManagerMessagesTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.opendaylight.controller.protobuff.messages; - -/** - * This test case is present to ensure that if others have used proper version of protocol buffer. - * - * If a different version of protocol buffer is used then it would generate different java sources - * and would result in breaking of this test case. - * - * @author: syedbahm Date: 6/20/14 - * - */ - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; - -public class ShardManagerMessagesTest { - - @Test - public void verifySerialization() throws Exception { - ShardManagerMessages.FindPrimary.Builder builder = - ShardManagerMessages.FindPrimary.newBuilder(); - builder.setShardName("Inventory"); - File testFile = new File("./test"); - FileOutputStream output = new FileOutputStream(testFile); - builder.build().writeTo(output); - output.close(); - - // Here we will read the same and check we got back what we had saved - ShardManagerMessages.FindPrimary findPrimary = - ShardManagerMessages.FindPrimary - .parseFrom(new FileInputStream(testFile)); - Assert.assertEquals("Inventory", findPrimary.getShardName()); - - testFile.delete(); - - } -} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessagesTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessagesTest.java new file mode 100644 index 0000000000..a01ccb88c7 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/cohort3pc/ThreePhaseCommitCohortMessagesTest.java @@ -0,0 +1,68 @@ +/* + * + * 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.protobuff.messages.cohort3pc; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.protobuff.messages.AbstractMessagesTest; + +/** + * This test case is present to ensure that if others have used proper version of protocol buffer + * for the cohort.proto messages + * + * If a different version of protocol buffer and there is change in serializaiton format + * this test would break as we are comparing with protocol buffer 2.5 generated + * serialized data. + * + * @author: syedbahm + * + */ + + +public class ThreePhaseCommitCohortMessagesTest extends AbstractMessagesTest { + + + @Test + public void verifySerialization() throws Exception { + + + + ThreePhaseCommitCohortMessages.CanCommitTransactionReply.Builder builder = + ThreePhaseCommitCohortMessages.CanCommitTransactionReply.newBuilder(); + builder.setCanCommit(true); + + writeToFile((com.google.protobuf.GeneratedMessage.Builder) builder); + + // Here we will read from the just serialized data + + ThreePhaseCommitCohortMessages.CanCommitTransactionReply newCanCommitTransactionReply = + (ThreePhaseCommitCohortMessages.CanCommitTransactionReply) readFromFile(ThreePhaseCommitCohortMessages.CanCommitTransactionReply.PARSER); + + Assert.assertTrue(newCanCommitTransactionReply.getCanCommit()); + + + // Here we will read the same from our test-data file and check we got back what we had saved + // earlier + ThreePhaseCommitCohortMessages.CanCommitTransactionReply originalCanCommitTransactionReply = + (ThreePhaseCommitCohortMessages.CanCommitTransactionReply) readFromTestDataFile(ThreePhaseCommitCohortMessages.CanCommitTransactionReply.PARSER); + + Assert.assertEquals(newCanCommitTransactionReply.getCanCommit(), + originalCanCommitTransactionReply.getCanCommit()); + + } + + @Override + public String getTestFileName() { + return ThreePhaseCommitCohortMessagesTest.class.getSimpleName(); + } + + +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessagesTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessagesTest.java new file mode 100644 index 0000000000..c68eceace4 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/common/NormalizedNodeMessagesTest.java @@ -0,0 +1,58 @@ +/* + * + * 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.protobuff.messages.common; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.protobuff.messages.AbstractMessagesTest; + +/** + * This test case is present to ensure that if others have used proper version of protocol buffer + * for the common.proto messages + * + * If a different version of protocol buffer and there is change in serializaiton format + * this test would break as we are comparing with protocol buffer 2.5 generated + * serialized data. + * + * @author: syedbahm + * + */ + +public class NormalizedNodeMessagesTest extends AbstractMessagesTest { + + @Override + @Test + public void verifySerialization() throws Exception { + NormalizedNodeMessages.Attribute.Builder builder = + NormalizedNodeMessages.Attribute.newBuilder(); + builder.setName("test"); + builder.setType("fake"); + builder.setValue("testValue"); + writeToFile((com.google.protobuf.GeneratedMessage.Builder) builder); + + NormalizedNodeMessages.Attribute attributeNew = + (NormalizedNodeMessages.Attribute) readFromFile(NormalizedNodeMessages.Attribute.PARSER); + Assert.assertEquals("test", attributeNew.getName()); + Assert.assertEquals("fake", attributeNew.getType()); + Assert.assertEquals("testValue", attributeNew.getValue()); + + NormalizedNodeMessages.Attribute attributeOriginal = + (NormalizedNodeMessages.Attribute) readFromTestDataFile(NormalizedNodeMessages.Attribute.PARSER); + Assert.assertEquals(attributeNew.getName(), attributeOriginal.getName()); + } + + @Override + public String getTestFileName() { + return NormalizedNodeMessagesTest.class.getSimpleName(); + } + + +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessagesTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessagesTest.java new file mode 100644 index 0000000000..e9339286f9 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/datachange/notification/DataChangeListenerMessagesTest.java @@ -0,0 +1,78 @@ +/* + * + * 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.protobuff.messages.datachange.notification; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.protobuff.messages.AbstractMessagesTest; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.yangtools.yang.common.QName; + +/** + * This test case is present to ensure that if others have used proper version of protocol buffer + * for the DataChangeListener.proto messages + * + * If a different version of protocol buffer and there is change in serializaiton format + * this test would break as we are comparing with protocol buffer 2.5 generated + * serialized data. + * + * @author: syedbahm + * + */ + +public class DataChangeListenerMessagesTest extends AbstractMessagesTest { + + private final String namespace = "urn:protobuff", revision = "2014-07-31", + localName = "test"; + + @Override + @Test + public void verifySerialization() throws Exception { + NormalizedNodeMessages.InstanceIdentifier.Builder instanceIdentifierBuilder = + NormalizedNodeMessages.InstanceIdentifier.newBuilder(); + NormalizedNodeMessages.PathArgument.Builder pathArgument = + NormalizedNodeMessages.PathArgument.newBuilder(); + pathArgument.setNodeType(NormalizedNodeMessages.QName.newBuilder() + .setValue(QName.create(namespace, revision, localName).toString()) + .build()); + pathArgument.setValue("test"); + instanceIdentifierBuilder.addArguments(pathArgument.build()); + + NormalizedNodeMessages.InstanceIdentifier expectedOne = + instanceIdentifierBuilder.build(); + DataChangeListenerMessages.DataChanged.Builder builder = + DataChangeListenerMessages.DataChanged.newBuilder(); + builder.addRemovedPaths(expectedOne); + + writeToFile((com.google.protobuf.GeneratedMessage.Builder) builder); + + DataChangeListenerMessages.DataChanged dataChangedNew = + (DataChangeListenerMessages.DataChanged) readFromFile(DataChangeListenerMessages.DataChanged.PARSER); + Assert.assertEquals(expectedOne.getArgumentsCount(), dataChangedNew + .getRemovedPaths(0).getArgumentsCount()); + Assert.assertEquals(expectedOne.getArguments(0).getType(), dataChangedNew + .getRemovedPaths(0).getArguments(0).getType()); + + DataChangeListenerMessages.DataChanged dataChangedOriginal = + (DataChangeListenerMessages.DataChanged) readFromTestDataFile(DataChangeListenerMessages.DataChanged.PARSER); + Assert.assertEquals(dataChangedNew.getRemovedPathsCount(), + dataChangedOriginal.getRemovedPathsCount()); + Assert.assertEquals(dataChangedNew.getRemovedPaths(0).getArguments(0) + .getValue(), dataChangedOriginal.getRemovedPaths(0).getArguments(0) + .getValue()); + + } + + @Override + public String getTestFileName() { + return DataChangeListenerMessages.class.getSimpleName(); + } +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessagesTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessagesTest.java new file mode 100644 index 0000000000..a8ade30099 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/persistent/PersistentMessagesTest.java @@ -0,0 +1,82 @@ +/* + * + * 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.protobuff.messages.persistent; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.protobuff.messages.AbstractMessagesTest; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.yangtools.yang.common.QName; + + +/** + * This test case is present to ensure that if others have used proper version of protocol buffer + * for the peristent.proto messages + * + * If a different version of protocol buffer and there is change in serializaiton format + * this test would break as we are comparing with protocol buffer 2.5 generated + * serialized data. + * + * @author: syedbahm + * + */ + +public class PersistentMessagesTest extends AbstractMessagesTest { + + private final String namespace = "urn:protobuff", revision = "2014-07-31", + localName = "test"; + + @Override + @Test + public void verifySerialization() throws Exception { + NormalizedNodeMessages.InstanceIdentifier.Builder instanceIdentifierBuilder = + NormalizedNodeMessages.InstanceIdentifier.newBuilder(); + NormalizedNodeMessages.PathArgument.Builder pathArgument = + NormalizedNodeMessages.PathArgument.newBuilder(); + pathArgument.setNodeType(NormalizedNodeMessages.QName.newBuilder() + .setValue(QName.create(namespace, revision, localName).toString()) + .build()); + pathArgument.setValue("test"); + instanceIdentifierBuilder.addArguments(pathArgument.build()); + NormalizedNodeMessages.InstanceIdentifier expectedOne = + instanceIdentifierBuilder.build(); + + PersistentMessages.Modification.Builder builder = + PersistentMessages.Modification.newBuilder(); + builder.setType("test"); + builder.setPath(expectedOne); + + writeToFile((com.google.protobuf.GeneratedMessage.Builder) builder); + + PersistentMessages.Modification modificationNew = + (PersistentMessages.Modification) readFromFile(PersistentMessages.Modification.PARSER); + Assert.assertEquals("test", modificationNew.getType()); + Assert.assertEquals(expectedOne.getArguments(0).getValue(), modificationNew + .getPath().getArguments(0).getValue()); + Assert.assertEquals(expectedOne.getArguments(0).getType(), modificationNew + .getPath().getArguments(0).getType()); + + // we will compare with the serialized data that we had shipped + PersistentMessages.Modification modificationOriginal = + (PersistentMessages.Modification) readFromTestDataFile(PersistentMessages.Modification.PARSER); + Assert.assertEquals(modificationOriginal.getPath().getArguments(0) + .getValue(), modificationNew.getPath().getArguments(0).getValue()); + Assert.assertEquals(modificationOriginal.getPath().getArguments(0) + .getType(), modificationNew.getPath().getArguments(0).getType()); + + + } + + @Override + public String getTestFileName() { + return PersistentMessagesTest.class.getSimpleName(); + } +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessagesTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessagesTest.java new file mode 100644 index 0000000000..1d50872a66 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/registration/ListenerRegistrationMessagesTest.java @@ -0,0 +1,58 @@ +/* + * + * 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.protobuff.messages.registration; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.protobuff.messages.AbstractMessagesTest; + +/** + * This test case is present to ensure that if others have used proper version of protocol buffer + * for the ListenerRegistration.proto messages + * + * If a different version of protocol buffer and there is change in serializaiton format + * this test would break as we are comparing with protocol buffer 2.5 generated + * serialized data. + * + * @author: syedbahm + * + */ + +public class ListenerRegistrationMessagesTest extends AbstractMessagesTest { + + @Override + @Test + public void verifySerialization() throws Exception { + String testListenerRegistrationPath = + "(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test?revision=2014-04-15)family"; + ListenerRegistrationMessages.RegisterChangeListenerReply.Builder builder = + ListenerRegistrationMessages.RegisterChangeListenerReply.newBuilder(); + builder.setListenerRegistrationPath(testListenerRegistrationPath); + + writeToFile((com.google.protobuf.GeneratedMessage.Builder) builder); + + ListenerRegistrationMessages.RegisterChangeListenerReply rclrNew = + (ListenerRegistrationMessages.RegisterChangeListenerReply) readFromFile(ListenerRegistrationMessages.RegisterChangeListenerReply.PARSER); + Assert.assertEquals(testListenerRegistrationPath, + rclrNew.getListenerRegistrationPath()); + + ListenerRegistrationMessages.RegisterChangeListenerReply rclrOriginal = + (ListenerRegistrationMessages.RegisterChangeListenerReply) readFromTestDataFile(ListenerRegistrationMessages.RegisterChangeListenerReply.PARSER); + Assert.assertEquals(rclrOriginal.getListenerRegistrationPath(), + rclrNew.getListenerRegistrationPath()); + + } + + @Override + public String getTestFileName() { + return ListenerRegistrationMessages.class.getSimpleName(); + } +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessagesTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessagesTest.java new file mode 100644 index 0000000000..45dcd12d05 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/shard/ShardManagerMessagesTest.java @@ -0,0 +1,61 @@ +/* + * + * 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.protobuff.messages.shard; + +/** + * This test case is present to ensure that if others have used proper version of protocol buffer + * for the ShardManager.proto messages + * + * If a different version of protocol buffer and there is change in serializaiton format + * this test would break as we are comparing with protocol buffer 2.5 generated + * serialized data. + * + * @author: syedbahm + * + */ + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.protobuff.messages.AbstractMessagesTest; + +public class ShardManagerMessagesTest extends AbstractMessagesTest { + + @Test + public void verifySerialization() throws Exception { + ShardManagerMessages.FindPrimary.Builder builder = + ShardManagerMessages.FindPrimary.newBuilder(); + builder.setShardName("Inventory"); + + writeToFile((com.google.protobuf.GeneratedMessage.Builder) builder); + + + // Here we will read the same and check we got back what we had saved + ShardManagerMessages.FindPrimary findPrimaryNew = + (ShardManagerMessages.FindPrimary) readFromFile(ShardManagerMessages.FindPrimary.PARSER); + + Assert.assertEquals("Inventory", findPrimaryNew.getShardName()); + + // Here we compare with the version we had shipped to catch any protobuff compiler version + // changes + ShardManagerMessages.FindPrimary findPrimaryOriginal = + (ShardManagerMessages.FindPrimary) readFromTestDataFile(ShardManagerMessages.FindPrimary.PARSER); + + Assert.assertEquals(findPrimaryNew.getShardName(), + findPrimaryOriginal.getShardName()); + + } + + @Override + public String getTestFileName() { + return ShardManagerMessagesTest.class.getSimpleName(); + } + +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessagesTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessagesTest.java new file mode 100644 index 0000000000..c0e91ab0d0 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionChainMessagesTest.java @@ -0,0 +1,69 @@ +/* + * + * 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.protobuff.messages.transaction; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.protobuff.messages.AbstractMessagesTest; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.yangtools.yang.common.QName; + +/** + * This test case is present to ensure that if others have used proper version of protocol buffer + * for the ShardTransactionChain.proto messages + * + * If a different version of protocol buffer and there is change in serializaiton format + * this test would break as we are comparing with protocol buffer 2.5 generated + * serialized data. + * + * @author: syedbahm + * + */ + + +public class ShardTransactionChainMessagesTest extends AbstractMessagesTest { + + @Override + @Test + public void verifySerialization() throws Exception { + String testTransactionChainPath = + "/actor/path"; + + ShardTransactionChainMessages.CreateTransactionChainReply.Builder builder = + ShardTransactionChainMessages.CreateTransactionChainReply.newBuilder(); + builder.setTransactionChainPath(testTransactionChainPath); + + writeToFile((com.google.protobuf.GeneratedMessage.Builder) builder); + + // Here we will read the same and check we got back what we had saved + ShardTransactionChainMessages.CreateTransactionChainReply replyNew = + (ShardTransactionChainMessages.CreateTransactionChainReply) readFromFile(ShardTransactionChainMessages.CreateTransactionChainReply.PARSER); + + Assert.assertEquals(replyNew.getTransactionChainPath(),testTransactionChainPath); + + // the following will compare with the version we had shipped + ShardTransactionChainMessages.CreateTransactionChainReply replyOriginal = + (ShardTransactionChainMessages.CreateTransactionChainReply) readFromTestDataFile(ShardTransactionChainMessages.CreateTransactionChainReply.PARSER); + + + Assert.assertEquals(replyOriginal.getTransactionChainPath(), + replyNew.getTransactionChainPath()); + + } + + @Override + public String getTestFileName() { + return ShardTransactionChainMessagesTest.class.getSimpleName(); + } + + + +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessagesTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessagesTest.java index 2b1ee5630c..6b538dab0d 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessagesTest.java +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/protobuff/messages/transaction/ShardTransactionMessagesTest.java @@ -1,10 +1,85 @@ +/* + * + * 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.protobuff.messages.transaction; +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.protobuff.messages.AbstractMessagesTest; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.yangtools.yang.common.QName; + /** + * This test case is present to ensure that if others have used proper version of protocol buffer + * for the ShardTransaction.proto messages + * + * If a different version of protocol buffer and there is change in serializaiton format + * this test would break as we are comparing with protocol buffer 2.5 generated + * serialized data. + * * @author: syedbahm - * Date: 7/7/14 + * */ -public class ShardTransactionMessagesTest { + + +public class ShardTransactionMessagesTest extends AbstractMessagesTest { + + private final String namespace = "urn:protobuff", revision = "2014-07-31", + localName = "test"; + + @Test + public void verifySerialization() throws Exception { + NormalizedNodeMessages.InstanceIdentifier.Builder instanceIdentifierBuilder = + NormalizedNodeMessages.InstanceIdentifier.newBuilder(); + NormalizedNodeMessages.PathArgument.Builder pathArgument = + NormalizedNodeMessages.PathArgument.newBuilder(); + pathArgument.setNodeType(NormalizedNodeMessages.QName.newBuilder() + .setValue(QName.create(namespace, revision, localName).toString()) + .build()); + pathArgument.setValue("test"); + instanceIdentifierBuilder.addArguments(pathArgument.build()); + ShardTransactionMessages.ReadData.Builder builder = + ShardTransactionMessages.ReadData.newBuilder(); + NormalizedNodeMessages.InstanceIdentifier expectedOne = + instanceIdentifierBuilder.build(); + builder.setInstanceIdentifierPathArguments(expectedOne); + + writeToFile((com.google.protobuf.GeneratedMessage.Builder) builder); + + // Here we will read the same and check we got back what we had saved + ShardTransactionMessages.ReadData readDataNew = + (ShardTransactionMessages.ReadData) readFromFile(ShardTransactionMessages.ReadData.PARSER); + + + Assert.assertEquals(expectedOne.getArgumentsCount(), readDataNew + .getInstanceIdentifierPathArguments().getArgumentsCount()); + Assert.assertEquals(expectedOne.getArguments(0), readDataNew + .getInstanceIdentifierPathArguments().getArguments(0)); + + + // the following will compare with the version we had shipped + ShardTransactionMessages.ReadData readDataOriginal = + (ShardTransactionMessages.ReadData) readFromTestDataFile(ShardTransactionMessages.ReadData.PARSER); + + + Assert.assertEquals(readDataNew.getInstanceIdentifierPathArguments() + .getArguments(0), readDataOriginal.getInstanceIdentifierPathArguments() + .getArguments(0)); + + } + + @Override + public String getTestFileName() { + return ShardTransactionMessagesTest.class.getSimpleName(); + } + } diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/augment_choice.xml b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/augment_choice.xml index c5a581cecc..7de3d077b4 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/augment_choice.xml +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/augment_choice.xml @@ -1,3 +1,13 @@ + + 2 diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/simple_xml_with_attributes.xml b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/simple_xml_with_attributes.xml index 0316d7a4a8..934d876747 100644 --- a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/simple_xml_with_attributes.xml +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/simple_xml_with_attributes.xml @@ -1,3 +1,13 @@ + + diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/DataChangeListenerMessagesData b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/DataChangeListenerMessagesData new file mode 100644 index 0000000000..883bcad86c --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/DataChangeListenerMessagesData @@ -0,0 +1,4 @@ +23 +1 +test) +'(urn:protobuff?revision=2014-07-31)test \ No newline at end of file diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ListenerRegistrationMessagesData b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ListenerRegistrationMessagesData new file mode 100644 index 0000000000..1718a01d48 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ListenerRegistrationMessagesData @@ -0,0 +1,2 @@ + +m(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test?revision=2014-04-15)family \ No newline at end of file diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/NormalizedNodeMessagesTestData b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/NormalizedNodeMessagesTestData new file mode 100644 index 0000000000..c4ec3776d2 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/NormalizedNodeMessagesTestData @@ -0,0 +1,2 @@ + +test testValuefake \ No newline at end of file diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/PersistentMessagesTestData b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/PersistentMessagesTestData new file mode 100644 index 0000000000..efb8e15bcc --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/PersistentMessagesTestData @@ -0,0 +1,5 @@ + +test3 +1 +test) +'(urn:protobuff?revision=2014-07-31)test \ No newline at end of file diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardManagerMessagesTestData b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardManagerMessagesTestData new file mode 100644 index 0000000000..82eea07964 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardManagerMessagesTestData @@ -0,0 +1,2 @@ + + Inventory \ No newline at end of file diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardTransactionChainMessagesTestData b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardTransactionChainMessagesTestData new file mode 100644 index 0000000000..577d9c4efc --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardTransactionChainMessagesTestData @@ -0,0 +1,2 @@ + + /actor/path \ No newline at end of file diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardTransactionMessagesTestData b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardTransactionMessagesTestData new file mode 100644 index 0000000000..db43fa48f4 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ShardTransactionMessagesTestData @@ -0,0 +1,5 @@ + +3 +1 +test) +'(urn:protobuff?revision=2014-07-31)test \ No newline at end of file diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ThreePhaseCommitCohortMessagesTestData b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ThreePhaseCommitCohortMessagesTestData new file mode 100644 index 0000000000..e19a122a54 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/ThreePhaseCommitCohortMessagesTestData @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/readme.txt b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/readme.txt new file mode 100644 index 0000000000..06a561e36c --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/resources/version-compatibility-serialized-data/readme.txt @@ -0,0 +1,18 @@ +This directory contains one serialized test data file for one of the messages in each .proto file. +These files are utilized as part of the test cases, mostly to fail the test cases in case some engineer has used +a different version of protocol buffer than what we ship with (Protocol Buffer 2.5.0) to generate the messages source f +file. + +1. If you see protocolbuffer version/invalid message exception in the test case + 1. ensure you are using the right version of protocol buffer/protoc compiler i.e protocol + +2. If you have knowingly updated an existing .proto message than please update the corresponding version-compatibility-serialized-data +file. You can get the file by commenting out the test file deletion in AbstractMessagesTest look for comments + + /* we will delete only the test file -- comment below if you want to capture the + version-compatibility-serialized-data test data file.The file will be generated at root of the sal-protocolbuffer-encoding + and you need to move it to version-compatbility-serialized-data folder renaming the file to include suffix "Data" + */ + +3. If you are creating a new .proto file -- Follow an existing test case e.g. ThreePhaseCommitCohortMessagesTest to + check how the test case is created and create the corresponding serialized test data file in version-compatibility-serialized-data -- 2.36.6