bump netty to version 4.0.10.Final 67/2067/2
authorMartin Bobak <martin.bobak@pantheon.sk>
Mon, 21 Oct 2013 14:18:41 +0000 (16:18 +0200)
committerMartin Bobak <mbobak@cisco.com>
Tue, 22 Oct 2013 09:31:30 +0000 (11:31 +0200)
Change-Id: Ia3cd0b6a0443d252971cfd0beb59bd5ccc800116
Signed-off-by: Martin Bobak <mbobak@cisco.com>
30 files changed:
opendaylight/commons/opendaylight/pom.xml
opendaylight/config/config-api/pom.xml
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ModuleIdentifier.java
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/Module.java
opendaylight/config/config-manager/pom.xml
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DestroyedModule.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ModuleInternalInfo.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ModuleInternalTransactionalInfo.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/TransactionIdentifier.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelperTest.java
opendaylight/config/config-persister-file-adapter/pom.xml
opendaylight/config/logback-config/pom.xml
opendaylight/config/yang-jmx-generator-it/pom.xml
opendaylight/config/yang-jmx-generator-plugin/pom.xml
opendaylight/config/yang-jmx-generator/pom.xml
opendaylight/config/yang-store-impl/pom.xml
opendaylight/netconf/config-netconf-connector/pom.xml
opendaylight/netconf/config-persister-impl/pom.xml
opendaylight/netconf/netconf-api/pom.xml
opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfMessage.java
opendaylight/netconf/netconf-client/pom.xml
opendaylight/netconf/netconf-impl/pom.xml
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/MessageParserTest.java
opendaylight/netconf/netconf-it/pom.xml
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java
opendaylight/netconf/netconf-util/pom.xml
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageFactory.java
opendaylight/netconf/pom.xml

index 471ad2b..5a72997 100644 (file)
@@ -70,7 +70,7 @@
     <enforcer.version>1.3.1</enforcer.version>
     <bundle.plugin.version>2.3.7</bundle.plugin.version>
     <junit.version>4.8.1</junit.version>
-    <bgpcep.version>0.2.0-SNAPSHOT</bgpcep.version>
+    <bgpcep.version>0.3.0-SNAPSHOT</bgpcep.version>
     <yangtools.version>0.5.9-SNAPSHOT</yangtools.version>
     <yangtools.binding.version>0.6.0-SNAPSHOT</yangtools.binding.version>
     <!--versions for bits of the controller -->
index 4dbc31f..e0f2749 100644 (file)
             <groupId>com.google.code.findbugs</groupId>
             <artifactId>jsr305</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.bgpcep</groupId>
-            <artifactId>concepts</artifactId>
-            <version>0.2.0-SNAPSHOT</version>
-        </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
index d162ca0..f5ccb4a 100644 (file)
@@ -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;
 
index b11d5f8..01f81a3 100644 (file)
@@ -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;
  * </p>
  */
 @NotThreadSafe
-public interface Module extends NamedObject<ModuleIdentifier> {
+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<ModuleIdentifier> {
      */
     AutoCloseable getInstance();
 
+    ModuleIdentifier getName();
+
 }
index f722d62..b3a0463 100644 (file)
@@ -44,7 +44,7 @@
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>mockito-configuration</artifactId>
-            <version>0.2.0-SNAPSHOT</version>
+            <version>${bgpcep.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
index 4fe4b31..5038079 100644 (file)
@@ -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<TransactionIdentifier> {
+        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;
     }
index 47f34e2..4913604 100644 (file)
@@ -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<ModuleIdentifier>,
-        AutoCloseable, Comparable<DestroyedModule> {
+public class DestroyedModule implements AutoCloseable,
+        Comparable<DestroyedModule> {
     private static final Logger logger = LoggerFactory
             .getLogger(DestroyedModule.class);
 
@@ -41,7 +40,6 @@ public class DestroyedModule implements NamedObject<ModuleIdentifier>,
         this.orderingIdx = orderingIdx;
     }
 
-    @Override
     public ModuleIdentifier getName() {
         return name;
     }
index fefc886..0d5f18e 100644 (file)
@@ -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<ModuleIdentifier>,
-        Comparable<ModuleInternalInfo> {
+public class ModuleInternalInfo implements Comparable<ModuleInternalInfo> {
 
     private final ModuleIdentifier name;
     // this registrator is passed to runtime bean registrator and config
@@ -87,7 +85,6 @@ public class ModuleInternalInfo implements NamedObject<ModuleIdentifier>,
         return osgiRegistration;
     }
 
-    @Override
     public ModuleIdentifier getName() {
         return name;
     }
index c71c3bb..a1bc59f 100644 (file)
@@ -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<ModuleIdentifier> {
+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;
     }
index 3e2b892..de8440c 100644 (file)
@@ -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) {
index b355a5e..ecb02a1 100644 (file)
@@ -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<ModuleIdentifier>, Comparable<DependencyResolverImpl> {
+       Comparable<DependencyResolverImpl> {
     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;
     }
index 6736ba1..2509750 100644 (file)
@@ -48,7 +48,7 @@ public class InterfacesHelperTest {
     @Test
     public void testGetAllInterfaces() {
         Set<Class<?>> expected = Sets.<Class<?>> 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));
     }
index 51fcf86..45683f5 100644 (file)
@@ -37,7 +37,7 @@
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>mockito-configuration</artifactId>
-            <version>0.2.0-SNAPSHOT</version>
+            <version>${bgpcep.version}</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
index 697c3a2..7b38737 100644 (file)
             <artifactId>config-api</artifactId>
             <version>0.2.1-SNAPSHOT</version>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.bgpcep</groupId>
-            <artifactId>concepts</artifactId>
-            <version>0.2.0-SNAPSHOT</version>
-        </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
@@ -74,7 +69,7 @@
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>mockito-configuration</artifactId>
-            <version>0.2.0-SNAPSHOT</version>
+            <version>${bgpcep.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
                             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,
index 9825d2b..6168ea6 100644 (file)
@@ -47,7 +47,7 @@
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>mockito-configuration</artifactId>
-            <version>0.2.0-SNAPSHOT</version>
+            <version>${bgpcep.version}</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
index 81d55ef..48fbe05 100644 (file)
@@ -87,7 +87,7 @@
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>mockito-configuration</artifactId>
-            <version>0.2.0-SNAPSHOT</version>
+            <version>${bgpcep.version}</version>
             <scope>test</scope>
         </dependency>
 
index 67a1c80..0f7fe6e 100644 (file)
@@ -39,7 +39,7 @@
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>mockito-configuration</artifactId>
-            <version>0.2.0-SNAPSHOT</version>
+            <version>${bgpcep.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
index 97285c1..11224ce 100644 (file)
@@ -46,7 +46,7 @@
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>mockito-configuration</artifactId>
-            <version>0.2.0-SNAPSHOT</version>
+            <version>${bgpcep.version}</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
index 0386378..f8bc772 100755 (executable)
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>mockito-configuration</artifactId>
+            <version>${bgpcep.version}</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
index c86202b..a69c87f 100644 (file)
@@ -55,6 +55,7 @@
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>mockito-configuration</artifactId>
+            <version>${bgpcep.version}</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
index 57e77cc..5c18edd 100644 (file)
@@ -22,6 +22,7 @@
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>framework</artifactId>
+            <version>${bgpcep.version}</version>
         </dependency>
     </dependencies>
 
index 33d41b0..e5a9e18 100644 (file)
@@ -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;
 
index ac949f5..d8dee68 100644 (file)
@@ -26,6 +26,7 @@
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>framework</artifactId>
+            <version>${bgpcep.version}</version>
         </dependency>
 
         <dependency>
index dd1c91e..8e0d493 100644 (file)
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>util</artifactId>
+            <version>${bgpcep.version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>framework</artifactId>
+            <version>${bgpcep.version}</version>
         </dependency>
 
         <dependency>
@@ -63,6 +65,7 @@
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>mockito-configuration</artifactId>
+            <version>${bgpcep.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
index 3b88a23..7e9318e 100644 (file)
@@ -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<NetconfMessage>(msgFactory),
-
-                new NetconfMessageAggregator(FramingMechanism.CHUNK), new NetconfMessageChunkDecoder(),
-                new ProtocolMessageDecoder<NetconfMessage>(msgFactory));
-
-        testChunkChannel.writeOutbound(this.msg);
-        Queue<Object> 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<NetconfMessage>(msgFactory), new NetconfMessageAggregator(
-                        FramingMechanism.EOM), new ProtocolMessageDecoder<NetconfMessage>(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);
     }
+
 }
index a3377d7..fc777bc 100644 (file)
@@ -42,6 +42,7 @@
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>util</artifactId>
+            <version>${bgpcep.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>mockito-configuration</artifactId>
+            <version>${bgpcep.version}</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
index d7f96a8..117735d 100644 (file)
@@ -171,7 +171,6 @@ public class NetconfITTest extends AbstractConfigTest {
     protected List<ModuleFactory> getModuleFactories() {
         return getModuleFactoriesS();
     }
-
     static List<ModuleFactory> getModuleFactoriesS() {
         return Lists.newArrayList(new TestImplModuleFactory(), new DepTestImplModuleFactory(),
                 new NetconfTestImplModuleFactory());
index cb198e7..f9b4fdd 100644 (file)
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>framework</artifactId>
+            <version>${bgpcep.version}</version>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>util</artifactId>
+            <version>${bgpcep.version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-handler</artifactId>
+            <version>${netconf.netty.version}</version>
+        </dependency>
     </dependencies>
 
     <build>
index 029d2ba..f7a2eb5 100644 (file)
@@ -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<Netco
 
     public static final int MAX_CHUNK_SIZE = 1024; // Bytes
 
+    private FramingMechanism framing = FramingMechanism.EOM;
+
     private final Optional<String> clientId;
 
     public NetconfMessageFactory() {
@@ -53,8 +57,12 @@ public final class NetconfMessageFactory implements ProtocolMessageFactory<Netco
         this.clientId = clientId;
     }
 
+    public static ChannelHandler getDelimiterFrameDecoder() {
+        return new DelimiterBasedFrameDecoder(Integer.MAX_VALUE, Unpooled.copiedBuffer(endOfMessage));
+    }
+
     @Override
-    public List<NetconfMessage> 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<Netco
                 bytes = Arrays.copyOfRange(bytes, endOfAuthHeader + 2, bytes.length);
             }
         }
-        List<NetconfMessage> 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<Netco
             Comment comment = netconfMessage.getDocument().createComment("clientId:" + clientId.get());
             netconfMessage.getDocument().appendChild(comment);
         }
-        final ByteBuffer msgBytes = Charsets.UTF_8.encode(xmlToString(netconfMessage.getDocument()));
+        byte[] bytes = (this.framing == FramingMechanism.EOM) ? this.putEOM(netconfMessage) : this
+                .putChunked(netconfMessage);
         String content = xmlToString(netconfMessage.getDocument());
 
         logger.trace("Putting message \n{}", content);
-        byte[] b = new byte[msgBytes.remaining()];
-        msgBytes.get(b);
-        return b;
+        return bytes;
+    }
+
+    private byte[] putEOM(NetconfMessage msg) {
+        // create byte buffer from the String XML
+        // all Netconf messages are encoded using UTF-8
+        final ByteBuffer msgBytes = Charsets.UTF_8.encode(xmlToString(msg.getDocument()));
+        final ByteBuffer result = ByteBuffer.allocate(msgBytes.limit() + endOfMessage.length);
+        result.put(msgBytes);
+        // put end of message
+        result.put(endOfMessage);
+        return result.array();
+    }
+
+    private byte[] putChunked(NetconfMessage msg) {
+        final ByteBuffer msgBytes = Charsets.UTF_8.encode(xmlToString(msg.getDocument()));
+        final NetconfMessageHeader h = new NetconfMessageHeader();
+        if (msgBytes.limit() > 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;
+    }
 }
index cff6dfa..1d7d552 100644 (file)
@@ -36,6 +36,7 @@
         <slf4j.version>1.7.2</slf4j.version>
         <java.version.source>1.7</java.version.source>
         <java.version.target>1.7</java.version.target>
+        <netconf.netty.version>4.0.10.Final</netconf.netty.version>
     </properties>
 
     <dependencies>