X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2Ftest%2FTestUtils.java;h=853c19f93530c16449840b1043ac07d30edaab4f;hb=48814d6a264b8f13e5db1422336d9ef25cb05fa9;hp=4295c29a22cea2f538d0006d94c70957163fabf9;hpb=79eba117e59f10c8bff34d0dd6bbb67b8ccc3e10;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java index 4295c29a22..853c19f935 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java @@ -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 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(); + + } }