Merge "Added move of branding jar to assembly"
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / TestUtils.java
index 4295c29a22cea2f538d0006d94c70957163fabf9..853c19f93530c16449840b1043ac07d30edaab4f 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.controller.sal.restconf.impl.test;
 
 import static org.junit.Assert.assertNotNull;
@@ -6,9 +13,11 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
@@ -138,7 +147,7 @@ public final class TestUtils {
     }
 
     /**
-     * 
+     *
      * Fill missing data (namespaces) and build correct data type in
      * {@code compositeNode} according to {@code dataSchemaNode}. The method
      * {@link RestconfImpl#createConfigurationData createConfigurationData} is
@@ -149,14 +158,14 @@ public final class TestUtils {
         ControllerContext.getInstance().setSchemas(TestUtils.loadSchemaContext(modules));
 
         prepareMocksForRestconf(modules, restconf);
-        restconf.createConfigurationData(schemaNodePath, compositeNode);
+        restconf.updateConfigurationData(schemaNodePath, compositeNode);
     }
 
     /**
      * Searches module with name {@code searchedModuleName} in {@code modules}.
      * If module name isn't specified and module set has only one element then
      * this element is returned.
-     * 
+     *
      */
     public static Module resolveModule(String searchedModuleName, Set<Module> modules) {
         assertNotNull("Modules can't be null.", modules);
@@ -271,9 +280,23 @@ public final class TestUtils {
 
         ControllerContext.getInstance().setSchemas(loadSchemaContext(modules));
 
-        messageBodyWriter.writeTo(new StructuredData(compositeNode, dataSchemaNode), null, null, null, null, null,
+        messageBodyWriter.writeTo(new StructuredData(compositeNode, dataSchemaNode, null), null, null, null, null, null,
                 byteArrayOS);
 
         return byteArrayOS.toString();
     }
+
+    public static String loadTextFile(String filePath) throws IOException {
+        FileReader fileReader = new FileReader(filePath);
+        BufferedReader bufReader = new BufferedReader(fileReader);
+
+        String line = null;
+        StringBuilder result = new StringBuilder();
+        while ((line = bufReader.readLine()) != null) {
+            result.append(line);
+        }
+        bufReader.close();
+        return result.toString();
+
+    }
 }