From 397cc9012f67596848019ca7874f3a303523b7e6 Mon Sep 17 00:00:00 2001 From: Martin Bobak Date: Mon, 21 Oct 2013 16:18:41 +0200 Subject: [PATCH] bump netty to version 4.0.10.Final Change-Id: Ia3cd0b6a0443d252971cfd0beb59bd5ccc800116 Signed-off-by: Martin Bobak --- opendaylight/commons/opendaylight/pom.xml | 2 +- opendaylight/config/config-api/pom.xml | 5 - .../config/api/ModuleIdentifier.java | 4 +- .../controller/config/spi/Module.java | 6 +- opendaylight/config/config-manager/pom.xml | 2 +- .../impl/ConfigTransactionControllerImpl.java | 5 +- .../config/manager/impl/DestroyedModule.java | 6 +- .../manager/impl/ModuleInternalInfo.java | 5 +- .../impl/ModuleInternalTransactionalInfo.java | 5 +- .../manager/impl/TransactionIdentifier.java | 4 +- .../DependencyResolverImpl.java | 4 +- .../impl/util/InterfacesHelperTest.java | 2 +- .../config-persister-file-adapter/pom.xml | 2 +- opendaylight/config/logback-config/pom.xml | 8 +- .../config/yang-jmx-generator-it/pom.xml | 2 +- .../config/yang-jmx-generator-plugin/pom.xml | 2 +- .../config/yang-jmx-generator/pom.xml | 2 +- opendaylight/config/yang-store-impl/pom.xml | 2 +- .../netconf/config-netconf-connector/pom.xml | 1 + .../netconf/config-persister-impl/pom.xml | 1 + opendaylight/netconf/netconf-api/pom.xml | 1 + .../netconf/api/NetconfMessage.java | 3 +- opendaylight/netconf/netconf-client/pom.xml | 1 + opendaylight/netconf/netconf-impl/pom.xml | 3 + .../netconf/impl/MessageParserTest.java | 128 ++++++++---------- opendaylight/netconf/netconf-it/pom.xml | 2 + .../controller/netconf/it/NetconfITTest.java | 1 - opendaylight/netconf/netconf-util/pom.xml | 7 + .../util/messages/NetconfMessageFactory.java | 62 +++++++-- opendaylight/netconf/pom.xml | 1 + 30 files changed, 147 insertions(+), 132 deletions(-) diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index 471ad2bf04..5a729970fa 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -70,7 +70,7 @@ 1.3.1 2.3.7 4.8.1 - 0.2.0-SNAPSHOT + 0.3.0-SNAPSHOT 0.5.9-SNAPSHOT 0.6.0-SNAPSHOT diff --git a/opendaylight/config/config-api/pom.xml b/opendaylight/config/config-api/pom.xml index 4dbc31f062..e0f274950d 100644 --- a/opendaylight/config/config-api/pom.xml +++ b/opendaylight/config/config-api/pom.xml @@ -18,11 +18,6 @@ com.google.code.findbugs jsr305 - - org.opendaylight.bgpcep - concepts - 0.2.0-SNAPSHOT - org.osgi org.osgi.core diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ModuleIdentifier.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ModuleIdentifier.java index d162ca07d9..f5ccb4a53c 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ModuleIdentifier.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ModuleIdentifier.java @@ -7,9 +7,7 @@ */ package org.opendaylight.controller.config.api; -import org.opendaylight.protocol.concepts.Identifier; - -public class ModuleIdentifier implements Identifier { +public class ModuleIdentifier { private static final long serialVersionUID = 1L; private final String factoryName, instanceName; diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/Module.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/Module.java index b11d5f8beb..01f81a3d56 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/Module.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/Module.java @@ -11,7 +11,7 @@ import javax.annotation.concurrent.NotThreadSafe; import org.opendaylight.controller.config.api.ModuleIdentifier; import org.opendaylight.controller.config.api.annotations.RequireInterface; -import org.opendaylight.protocol.concepts.NamedObject; + /** * Represents one service that is to be configured. These methods need to be @@ -28,7 +28,7 @@ import org.opendaylight.protocol.concepts.NamedObject; *

*/ @NotThreadSafe -public interface Module extends NamedObject { +public interface Module { /** * This method will be called as first phase in two phase commit. Instance * can check attributes, but is not allowed to do any kind of work that @@ -55,4 +55,6 @@ public interface Module extends NamedObject { */ AutoCloseable getInstance(); + ModuleIdentifier getName(); + } diff --git a/opendaylight/config/config-manager/pom.xml b/opendaylight/config/config-manager/pom.xml index f722d62b02..b3a04633aa 100644 --- a/opendaylight/config/config-manager/pom.xml +++ b/opendaylight/config/config-manager/pom.xml @@ -44,7 +44,7 @@ org.opendaylight.bgpcep mockito-configuration - 0.2.0-SNAPSHOT + ${bgpcep.version} test diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java index 4fe4b319a5..5038079c22 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java @@ -39,7 +39,6 @@ import org.opendaylight.controller.config.manager.impl.jmx.TransactionModuleJMXR import org.opendaylight.controller.config.manager.impl.util.LookupBeansUtil; import org.opendaylight.controller.config.spi.Module; import org.opendaylight.controller.config.spi.ModuleFactory; -import org.opendaylight.protocol.concepts.NamedObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,8 +49,7 @@ import org.slf4j.LoggerFactory; */ class ConfigTransactionControllerImpl implements ConfigTransactionControllerInternal, - ConfigTransactionControllerImplMXBean, - NamedObject { + ConfigTransactionControllerImplMXBean { private static final Logger logger = LoggerFactory .getLogger(ConfigTransactionControllerImpl.class); @@ -394,7 +392,6 @@ class ConfigTransactionControllerImpl implements return txModuleJMXRegistrator; } - @Override public TransactionIdentifier getName() { return transactionIdentifier; } diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DestroyedModule.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DestroyedModule.java index 47f34e25f8..4913604512 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DestroyedModule.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DestroyedModule.java @@ -10,7 +10,6 @@ package org.opendaylight.controller.config.manager.impl; import org.opendaylight.controller.config.api.ModuleIdentifier; import org.opendaylight.controller.config.manager.impl.jmx.ModuleJMXRegistrator; import org.opendaylight.controller.config.manager.impl.osgi.BeanToOsgiServiceManager.OsgiRegistration; -import org.opendaylight.protocol.concepts.NamedObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,8 +19,8 @@ import org.slf4j.LoggerFactory; * were created. Module instances should be closed in order defined by the * compareTo method. */ -public class DestroyedModule implements NamedObject, - AutoCloseable, Comparable { +public class DestroyedModule implements AutoCloseable, + Comparable { private static final Logger logger = LoggerFactory .getLogger(DestroyedModule.class); @@ -41,7 +40,6 @@ public class DestroyedModule implements NamedObject, this.orderingIdx = orderingIdx; } - @Override public ModuleIdentifier getName() { return name; } diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ModuleInternalInfo.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ModuleInternalInfo.java index fefc88651c..0d5f18eff0 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ModuleInternalInfo.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ModuleInternalInfo.java @@ -14,13 +14,11 @@ import org.opendaylight.controller.config.manager.impl.dynamicmbean.DynamicReada import org.opendaylight.controller.config.manager.impl.jmx.ModuleJMXRegistrator; import org.opendaylight.controller.config.manager.impl.jmx.RootRuntimeBeanRegistratorImpl; import org.opendaylight.controller.config.manager.impl.osgi.BeanToOsgiServiceManager.OsgiRegistration; -import org.opendaylight.protocol.concepts.NamedObject; /** * Provides metadata about Module from controller to registry. */ -public class ModuleInternalInfo implements NamedObject, - Comparable { +public class ModuleInternalInfo implements Comparable { private final ModuleIdentifier name; // this registrator is passed to runtime bean registrator and config @@ -87,7 +85,6 @@ public class ModuleInternalInfo implements NamedObject, return osgiRegistration; } - @Override public ModuleIdentifier getName() { return name; } diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ModuleInternalTransactionalInfo.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ModuleInternalTransactionalInfo.java index c71c3bb470..a1bc59f5d5 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ModuleInternalTransactionalInfo.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ModuleInternalTransactionalInfo.java @@ -16,10 +16,8 @@ import org.opendaylight.controller.config.manager.impl.jmx.TransactionModuleJMXR .TransactionModuleJMXRegistration; import org.opendaylight.controller.config.spi.Module; import org.opendaylight.controller.config.spi.ModuleFactory; -import org.opendaylight.protocol.concepts.NamedObject; -public class ModuleInternalTransactionalInfo implements - NamedObject { +public class ModuleInternalTransactionalInfo { private final ModuleIdentifier name; private final Module module; private final ModuleFactory moduleFactory; @@ -38,7 +36,6 @@ public class ModuleInternalTransactionalInfo implements this.transactionModuleJMXRegistration = transactionModuleJMXRegistration; } - @Override public ModuleIdentifier getName() { return name; } diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/TransactionIdentifier.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/TransactionIdentifier.java index 3e2b8926a6..de8440cc66 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/TransactionIdentifier.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/TransactionIdentifier.java @@ -7,9 +7,7 @@ */ package org.opendaylight.controller.config.manager.impl; -import org.opendaylight.protocol.concepts.Identifier; - -public class TransactionIdentifier implements Identifier { +public class TransactionIdentifier { private final String name; public TransactionIdentifier(String name) { diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java index b355a5e365..ecb02a1c4f 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java @@ -25,7 +25,6 @@ import org.opendaylight.controller.config.api.jmx.ObjectNameUtil; import org.opendaylight.controller.config.manager.impl.TransactionStatus; import org.opendaylight.controller.config.spi.Module; import org.opendaylight.controller.config.spi.ModuleFactory; -import org.opendaylight.protocol.concepts.NamedObject; /** * Protect {@link org.opendaylight.controller.config.spi.Module#getInstance()} @@ -33,7 +32,7 @@ import org.opendaylight.protocol.concepts.NamedObject; * during validation. Tracks dependencies for ordering purposes. */ final class DependencyResolverImpl implements DependencyResolver, - NamedObject, Comparable { + Comparable { private final ModulesHolder modulesHolder; private final ModuleIdentifier name; private final TransactionStatus transactionStatus; @@ -47,7 +46,6 @@ final class DependencyResolverImpl implements DependencyResolver, this.modulesHolder = modulesHolder; } - @Override public ModuleIdentifier getName() { return name; } diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelperTest.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelperTest.java index 6736ba1111..2509750e57 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelperTest.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelperTest.java @@ -48,7 +48,7 @@ public class InterfacesHelperTest { @Test public void testGetAllInterfaces() { Set> expected = Sets.> newHashSet(SuperA.class, SuperBMXBean.class, SuperC.class, - SubA.class, Module.class, org.opendaylight.protocol.concepts.NamedObject.class); + SubA.class, Module.class); assertEquals(expected, InterfacesHelper.getAllInterfaces(SubClass.class)); } diff --git a/opendaylight/config/config-persister-file-adapter/pom.xml b/opendaylight/config/config-persister-file-adapter/pom.xml index 51fcf8641a..45683f578e 100644 --- a/opendaylight/config/config-persister-file-adapter/pom.xml +++ b/opendaylight/config/config-persister-file-adapter/pom.xml @@ -37,7 +37,7 @@ org.opendaylight.bgpcep mockito-configuration - 0.2.0-SNAPSHOT + ${bgpcep.version} test diff --git a/opendaylight/config/logback-config/pom.xml b/opendaylight/config/logback-config/pom.xml index 697c3a258d..7b38737411 100644 --- a/opendaylight/config/logback-config/pom.xml +++ b/opendaylight/config/logback-config/pom.xml @@ -21,11 +21,6 @@ config-api 0.2.1-SNAPSHOT - - org.opendaylight.bgpcep - concepts - 0.2.0-SNAPSHOT - org.slf4j slf4j-api @@ -74,7 +69,7 @@ org.opendaylight.bgpcep mockito-configuration - 0.2.0-SNAPSHOT + ${bgpcep.version} test @@ -100,7 +95,6 @@ ch.qos.logback.core.status, ch.qos.logback.core.encoder, ch.qos.logback.core.rolling, - org.opendaylight.protocol.concepts, org.opendaylight.controller.config.api, org.opendaylight.controller.config.api.runtime, org.opendaylight.controller.config.api.annotations, diff --git a/opendaylight/config/yang-jmx-generator-it/pom.xml b/opendaylight/config/yang-jmx-generator-it/pom.xml index 9825d2b17e..6168ea6139 100644 --- a/opendaylight/config/yang-jmx-generator-it/pom.xml +++ b/opendaylight/config/yang-jmx-generator-it/pom.xml @@ -47,7 +47,7 @@ org.opendaylight.bgpcep mockito-configuration - 0.2.0-SNAPSHOT + ${bgpcep.version} test diff --git a/opendaylight/config/yang-jmx-generator-plugin/pom.xml b/opendaylight/config/yang-jmx-generator-plugin/pom.xml index 81d55efeaf..48fbe05514 100644 --- a/opendaylight/config/yang-jmx-generator-plugin/pom.xml +++ b/opendaylight/config/yang-jmx-generator-plugin/pom.xml @@ -87,7 +87,7 @@ org.opendaylight.bgpcep mockito-configuration - 0.2.0-SNAPSHOT + ${bgpcep.version} test diff --git a/opendaylight/config/yang-jmx-generator/pom.xml b/opendaylight/config/yang-jmx-generator/pom.xml index 67a1c80b9c..0f7fe6e781 100644 --- a/opendaylight/config/yang-jmx-generator/pom.xml +++ b/opendaylight/config/yang-jmx-generator/pom.xml @@ -39,7 +39,7 @@ org.opendaylight.bgpcep mockito-configuration - 0.2.0-SNAPSHOT + ${bgpcep.version} test diff --git a/opendaylight/config/yang-store-impl/pom.xml b/opendaylight/config/yang-store-impl/pom.xml index 97285c1f22..11224cef22 100644 --- a/opendaylight/config/yang-store-impl/pom.xml +++ b/opendaylight/config/yang-store-impl/pom.xml @@ -46,7 +46,7 @@ org.opendaylight.bgpcep mockito-configuration - 0.2.0-SNAPSHOT + ${bgpcep.version} test diff --git a/opendaylight/netconf/config-netconf-connector/pom.xml b/opendaylight/netconf/config-netconf-connector/pom.xml index 0386378321..f8bc7720d1 100755 --- a/opendaylight/netconf/config-netconf-connector/pom.xml +++ b/opendaylight/netconf/config-netconf-connector/pom.xml @@ -103,6 +103,7 @@ org.opendaylight.bgpcep mockito-configuration + ${bgpcep.version} test diff --git a/opendaylight/netconf/config-persister-impl/pom.xml b/opendaylight/netconf/config-persister-impl/pom.xml index c86202b6fb..a69c87f0a4 100644 --- a/opendaylight/netconf/config-persister-impl/pom.xml +++ b/opendaylight/netconf/config-persister-impl/pom.xml @@ -55,6 +55,7 @@ org.opendaylight.bgpcep mockito-configuration + ${bgpcep.version} test diff --git a/opendaylight/netconf/netconf-api/pom.xml b/opendaylight/netconf/netconf-api/pom.xml index 57e77cc945..5c18eddcf5 100644 --- a/opendaylight/netconf/netconf-api/pom.xml +++ b/opendaylight/netconf/netconf-api/pom.xml @@ -22,6 +22,7 @@ org.opendaylight.bgpcep framework + ${bgpcep.version} diff --git a/opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfMessage.java b/opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfMessage.java index 33d41b0470..e5a9e18576 100644 --- a/opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfMessage.java +++ b/opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfMessage.java @@ -8,14 +8,13 @@ package org.opendaylight.controller.netconf.api; -import org.opendaylight.protocol.framework.ProtocolMessage; import org.w3c.dom.Document; /** * NetconfMessage represents a wrapper around org.w3c.dom.Document. Needed for * implementing ProtocolMessage interface. */ -public final class NetconfMessage implements ProtocolMessage { +public final class NetconfMessage { private static final long serialVersionUID = 462175939836367285L; diff --git a/opendaylight/netconf/netconf-client/pom.xml b/opendaylight/netconf/netconf-client/pom.xml index ac949f5445..d8dee68253 100644 --- a/opendaylight/netconf/netconf-client/pom.xml +++ b/opendaylight/netconf/netconf-client/pom.xml @@ -26,6 +26,7 @@ org.opendaylight.bgpcep framework + ${bgpcep.version} diff --git a/opendaylight/netconf/netconf-impl/pom.xml b/opendaylight/netconf/netconf-impl/pom.xml index dd1c91ee51..8e0d493c27 100644 --- a/opendaylight/netconf/netconf-impl/pom.xml +++ b/opendaylight/netconf/netconf-impl/pom.xml @@ -39,11 +39,13 @@ org.opendaylight.bgpcep util + ${bgpcep.version} org.opendaylight.bgpcep framework + ${bgpcep.version} @@ -63,6 +65,7 @@ org.opendaylight.bgpcep mockito-configuration + ${bgpcep.version} test diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/MessageParserTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/MessageParserTest.java index 3b88a23108..7e9318e0d6 100644 --- a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/MessageParserTest.java +++ b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/MessageParserTest.java @@ -10,100 +10,82 @@ package org.opendaylight.controller.netconf.impl; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import java.util.Queue; +import java.io.IOException; -import io.netty.buffer.ByteBuf; -import io.netty.channel.embedded.EmbeddedChannel; +import javax.xml.parsers.ParserConfigurationException; +import org.custommonkey.xmlunit.XMLAssert; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.opendaylight.controller.netconf.api.NetconfMessage; -import org.opendaylight.controller.netconf.util.handler.FramingMechanismHandlerFactory; -import org.opendaylight.controller.netconf.util.handler.NetconfMessageAggregator; -import org.opendaylight.controller.netconf.util.handler.NetconfMessageChunkDecoder; import org.opendaylight.controller.netconf.util.messages.FramingMechanism; import org.opendaylight.controller.netconf.util.messages.NetconfMessageFactory; -import org.opendaylight.controller.netconf.util.messages.NetconfMessageHeader; import org.opendaylight.controller.netconf.util.test.XmlFileLoader; -import org.opendaylight.protocol.framework.ProtocolMessageDecoder; -import org.opendaylight.protocol.framework.ProtocolMessageEncoder; +import org.opendaylight.controller.netconf.util.xml.XmlUtil; +import org.opendaylight.protocol.framework.DeserializerException; +import org.opendaylight.protocol.framework.DocumentedException; +import org.opendaylight.protocol.util.ByteArray; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; public class MessageParserTest { - private NetconfMessage msg; - private NetconfMessageFactory msgFactory = new NetconfMessageFactory(); + private NetconfMessageFactory parser = null; @Before - public void setUp() throws Exception { - this.msg = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/getConfig.xml"); + public void setUp() { + this.parser = new NetconfMessageFactory(); } @Test - public void testChunkedFramingMechanismOnPipeline() throws Exception { - EmbeddedChannel testChunkChannel = new EmbeddedChannel( - FramingMechanismHandlerFactory.createHandler(FramingMechanism.CHUNK), - new ProtocolMessageEncoder(msgFactory), - - new NetconfMessageAggregator(FramingMechanism.CHUNK), new NetconfMessageChunkDecoder(), - new ProtocolMessageDecoder(msgFactory)); - - testChunkChannel.writeOutbound(this.msg); - Queue messages = testChunkChannel.outboundMessages(); - assertFalse(messages.isEmpty()); - - int msgLength = msgFactory.put(this.msg).length; - int chunkCount = msgLength / NetconfMessageFactory.MAX_CHUNK_SIZE; - if ((msgLength % NetconfMessageFactory.MAX_CHUNK_SIZE) != 0) { - chunkCount++; - } - for (int i = 1; i <= chunkCount; i++) { - ByteBuf recievedOutbound = (ByteBuf) messages.poll(); - int exptHeaderLength = NetconfMessageFactory.MAX_CHUNK_SIZE; - if (i == chunkCount) { - exptHeaderLength = msgLength - (NetconfMessageFactory.MAX_CHUNK_SIZE * (i - 1)); - byte[] eom = new byte[NetconfMessageFactory.endOfChunk.length]; - recievedOutbound.getBytes(recievedOutbound.readableBytes() - NetconfMessageFactory.endOfChunk.length, - eom); - assertArrayEquals(NetconfMessageFactory.endOfChunk, eom); - } - - byte[] header = new byte[String.valueOf(exptHeaderLength).length() + NetconfMessageHeader.MIN_HEADER_LENGTH - - 1]; - recievedOutbound.getBytes(0, header); - NetconfMessageHeader messageHeader = new NetconfMessageHeader(); - messageHeader.fromBytes(header); - assertEquals(exptHeaderLength, messageHeader.getLength()); - - testChunkChannel.writeInbound(recievedOutbound); - } - assertTrue(messages.isEmpty()); - - NetconfMessage receivedMessage = (NetconfMessage) testChunkChannel.readInbound(); - assertNotNull(receivedMessage); - assertTrue(this.msg.getDocument().isEqualNode(receivedMessage.getDocument())); + public void testPutEOM() throws IOException, SAXException, ParserConfigurationException { + final NetconfMessage msg = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/client_hello.xml"); + final byte[] bytes = this.parser.put(msg); + assertArrayEquals(NetconfMessageFactory.endOfMessage, ByteArray.subByte(bytes, bytes.length + - NetconfMessageFactory.endOfMessage.length, NetconfMessageFactory.endOfMessage.length)); } + @Ignore @Test - public void testEOMFramingMechanismOnPipeline() throws Exception { - EmbeddedChannel testChunkChannel = new EmbeddedChannel( - FramingMechanismHandlerFactory.createHandler(FramingMechanism.EOM), - new ProtocolMessageEncoder(msgFactory), new NetconfMessageAggregator( - FramingMechanism.EOM), new ProtocolMessageDecoder(msgFactory)); - - testChunkChannel.writeOutbound(this.msg); - ByteBuf recievedOutbound = (ByteBuf) testChunkChannel.readOutbound(); + // TODO not working on WINDOWS + // arrays first differed at element [4]; expected:<49> but was:<53> + // at + // org.junit.internal.ComparisonCriteria.arrayEquals(ComparisonCriteria.java:52) + public void testPutChunk() throws IOException, SAXException, ParserConfigurationException { + final NetconfMessage msg = XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/client_hello.xml"); + this.parser.setFramingMechanism(FramingMechanism.CHUNK); + final byte[] bytes = this.parser.put(msg); + final byte[] header = new byte[] { (byte) 0x0a, (byte) 0x23 , (byte) 0x32, (byte) 0x31, (byte) 0x31, (byte) 0x0a}; + assertArrayEquals(header, ByteArray.subByte(bytes, 0, header.length)); + assertArrayEquals(NetconfMessageFactory.endOfChunk, ByteArray.subByte(bytes, bytes.length + - NetconfMessageFactory.endOfChunk.length, NetconfMessageFactory.endOfChunk.length)); + } - byte[] eom = new byte[NetconfMessageFactory.endOfMessage.length]; - recievedOutbound.getBytes(recievedOutbound.readableBytes() - NetconfMessageFactory.endOfMessage.length, eom); - assertArrayEquals(NetconfMessageFactory.endOfMessage, eom); + @Test + public void testParseEOM() throws IOException, SAXException, DeserializerException, DocumentedException, + ParserConfigurationException { + final Document msg = XmlFileLoader.xmlFileToDocument("netconfMessages/client_hello.xml"); + final byte[] bytes = this.parser.put(new NetconfMessage(msg)); + final Document doc = this.parser + .parse(ByteArray.subByte(bytes, 0, bytes.length - NetconfMessageFactory.endOfMessage.length)) + .getDocument(); + assertEquals(XmlUtil.toString(msg), XmlUtil.toString(doc)); + XMLAssert.assertXMLEqual(msg, doc); + } - testChunkChannel.writeInbound(recievedOutbound); - NetconfMessage receivedMessage = (NetconfMessage) testChunkChannel.readInbound(); - assertNotNull(receivedMessage); - assertTrue(this.msg.getDocument().isEqualNode(receivedMessage.getDocument())); + @Test + public void testParseChunk() throws IOException, SAXException, DeserializerException, DocumentedException, + ParserConfigurationException { + final Document msg = XmlFileLoader.xmlFileToDocument("netconfMessages/client_hello.xml"); + this.parser.setFramingMechanism(FramingMechanism.CHUNK); + final byte[] bytes = this.parser.put(new NetconfMessage(msg)); + final Document doc = this.parser + .parse(ByteArray.subByte(bytes, 6, bytes.length - NetconfMessageFactory.endOfChunk.length - 6)) + .getDocument(); + assertEquals(XmlUtil.toString(msg), XmlUtil.toString(doc)); + XMLAssert.assertXMLEqual(msg, doc); } + } diff --git a/opendaylight/netconf/netconf-it/pom.xml b/opendaylight/netconf/netconf-it/pom.xml index a3377d7501..fc777bc885 100644 --- a/opendaylight/netconf/netconf-it/pom.xml +++ b/opendaylight/netconf/netconf-it/pom.xml @@ -42,6 +42,7 @@ org.opendaylight.bgpcep util + ${bgpcep.version} test @@ -124,6 +125,7 @@ org.opendaylight.bgpcep mockito-configuration + ${bgpcep.version} test diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java index d7f96a8761..117735dd1c 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java @@ -171,7 +171,6 @@ public class NetconfITTest extends AbstractConfigTest { protected List getModuleFactories() { return getModuleFactoriesS(); } - static List getModuleFactoriesS() { return Lists.newArrayList(new TestImplModuleFactory(), new DepTestImplModuleFactory(), new NetconfTestImplModuleFactory()); diff --git a/opendaylight/netconf/netconf-util/pom.xml b/opendaylight/netconf/netconf-util/pom.xml index cb198e7361..f9b4fddb25 100644 --- a/opendaylight/netconf/netconf-util/pom.xml +++ b/opendaylight/netconf/netconf-util/pom.xml @@ -32,10 +32,12 @@ org.opendaylight.bgpcep framework + ${bgpcep.version} org.opendaylight.bgpcep util + ${bgpcep.version} @@ -50,6 +52,11 @@ org.slf4j slf4j-api + + io.netty + netty-handler + ${netconf.netty.version} + diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageFactory.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageFactory.java index 029d2ba759..f7a2eb54cb 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageFactory.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageFactory.java @@ -10,7 +10,9 @@ package org.opendaylight.controller.netconf.util.messages; import com.google.common.base.Charsets; import com.google.common.base.Optional; -import com.google.common.collect.Lists; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandler; +import io.netty.handler.codec.DelimiterBasedFrameDecoder; import org.opendaylight.controller.netconf.api.NetconfDeserializerException; import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.util.xml.XmlUtil; @@ -43,6 +45,8 @@ public final class NetconfMessageFactory implements ProtocolMessageFactory clientId; public NetconfMessageFactory() { @@ -53,8 +57,12 @@ public final class NetconfMessageFactory implements ProtocolMessageFactory parse(byte[] bytes) throws DeserializerException, DocumentedException { + public NetconfMessage parse(byte[] bytes) throws DeserializerException, DocumentedException { String s = Charsets.UTF_8.decode(ByteBuffer.wrap(bytes)).toString(); logger.debug("Parsing message \n{}", s); if (bytes[0] == '[') { @@ -65,14 +73,14 @@ public final class NetconfMessageFactory implements ProtocolMessageFactory messages = Lists.newArrayList(); + NetconfMessage message = null; try { Document doc = XmlUtil.readXmlToDocument(new ByteArrayInputStream(bytes)); - messages.add(new NetconfMessage(doc)); + message = new NetconfMessage(doc); } catch (final SAXException | IOException | IllegalStateException e) { throw new NetconfDeserializerException("Could not parse message from " + new String(bytes), e); } - return messages; + return message; } @Override @@ -81,16 +89,52 @@ public final class NetconfMessageFactory implements ProtocolMessageFactory MAX_CHUNK_SIZE) + logger.warn("Netconf message too long, should be split."); + h.setLength(msgBytes.limit()); + final byte[] headerBytes = h.toBytes(); + final ByteBuffer result = ByteBuffer.allocate(headerBytes.length + msgBytes.limit() + endOfChunk.length); + result.put(headerBytes); + result.put(msgBytes); + result.put(endOfChunk); + return result.array(); } private String xmlToString(Document doc) { return XmlUtil.toString(doc, false); } + + /** + * For Hello message the framing is always EOM, but the framing mechanism + * may change. + * + * @param fm + * new framing mechanism + */ + public void setFramingMechanism(final FramingMechanism fm) { + logger.debug("Framing mechanism changed to {}", fm); + this.framing = fm; + } } diff --git a/opendaylight/netconf/pom.xml b/opendaylight/netconf/pom.xml index cff6dfa538..1d7d552094 100644 --- a/opendaylight/netconf/pom.xml +++ b/opendaylight/netconf/pom.xml @@ -36,6 +36,7 @@ 1.7.2 1.7 1.7 + 4.0.10.Final -- 2.36.6