BUG 4589 : Handle writing and reading large strings
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / test / java / org / opendaylight / controller / cluster / datastore / node / utils / stream / NormalizedNodeStreamReaderWriterTest.java
index 67a342b440666e3febfd6e5b390953fa3d54bebf..6dbb0f8e64e7ec143fa54d993c1c802353601702 100644 (file)
@@ -1,12 +1,11 @@
 /*
+ * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
  *
- *  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
- *
+ * 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.stream;
 
 import java.io.ByteArrayInputStream;
@@ -44,9 +43,12 @@ public class NormalizedNodeStreamReaderWriterTest {
 
         QName toaster = QName.create("http://netconfcentral.org/ns/toaster","2009-11-20","toaster");
         QName darknessFactor = QName.create("http://netconfcentral.org/ns/toaster","2009-11-20","darknessFactor");
+        QName description = QName.create("http://netconfcentral.org/ns/toaster","2009-11-20","description");
         ContainerNode toasterNode = Builders.containerBuilder().
                 withNodeIdentifier(new NodeIdentifier(toaster)).
-                withChild(ImmutableNodes.leafNode(darknessFactor, "1000")).build();
+                withChild(ImmutableNodes.leafNode(darknessFactor, "1000")).
+                withChild(ImmutableNodes.leafNode(description, largeString(20)))
+                .build();
 
         ContainerNode toasterContainer = Builders.containerBuilder().
                 withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME)).
@@ -65,7 +67,7 @@ public class NormalizedNodeStreamReaderWriterTest {
         writer.close();
     }
 
-    private NormalizedNode<?, ?> createTestContainer() {
+    private static NormalizedNode<?, ?> createTestContainer() {
         byte[] bytes1 = {1,2,3};
         LeafSetEntryNode<Object> entry1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
                 new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)).
@@ -173,4 +175,14 @@ public class NormalizedNodeStreamReaderWriterTest {
         Assert.assertEquals(input, clone.getInput());
 
     }
+
+    private String largeString(int pow){
+        String s = "X";
+        for(int i=0;i<pow;i++){
+            StringBuilder b = new StringBuilder();
+            b.append(s).append(s);
+            s = b.toString();
+        }
+        return s;
+    }
 }