Code Review
/
yangtools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "BUG-869: added proper handling of nullable parameter"
[yangtools.git]
/
yang
/
yang-data-codec-gson
/
src
/
test
/
java
/
org
/
opendaylight
/
yangtools
/
yang
/
data
/
codec
/
gson
/
StreamToNormalizedNodeTest.java
diff --git
a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/StreamToNormalizedNodeTest.java
b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/StreamToNormalizedNodeTest.java
index 1010989bc890300f56ea7ad540d80c384688351e..06f661dd1fa04fd32e46ae652a11a80d100a3e28 100644
(file)
--- a/
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/StreamToNormalizedNodeTest.java
+++ b/
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/StreamToNormalizedNodeTest.java
@@
-16,6
+16,8
@@
import java.io.FileReader;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
@@
-32,6
+34,7
@@
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStre
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
@@
-45,10
+48,10
@@
public class StreamToNormalizedNodeTest {
private static String streamAsString;
@BeforeClass
private static String streamAsString;
@BeforeClass
- public static void initialization() throws IOException {
+ public static void initialization() throws IOException
, URISyntaxException
{
schemaContext = loadModules("/complexjson/yang");
schemaContext = loadModules("/complexjson/yang");
- streamAsString = loadTextFile(
StreamToNormalizedNodeTest.class.getResource("/complexjson/complex-json.json")
-
.getPath(
));
+ streamAsString = loadTextFile(
new File(StreamToNormalizedNodeTest.class.getResource(
+
"/complexjson/complex-json.json").toURI()
));
}
/**
}
/**
@@
-83,11
+86,10
@@
public class StreamToNormalizedNodeTest {
* This is the parsing part
*/
// This is where we will output the nodes
* This is the parsing part
*/
// This is where we will output the nodes
- final NormalizedNodeContainerBuilder<NodeIdentifier, ?, ?, ? extends NormalizedNode<?, ?>> parent =
- Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(QName.create("dummy", "2014-12-31", "dummy")));
+ NormalizedNodeResult result = new NormalizedNodeResult();
// StreamWriter which attaches NormalizedNode under parent
// StreamWriter which attaches NormalizedNode under parent
- final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(
paren
t);
+ final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(
resul
t);
// JSON -> StreamWriter parser
try (JsonParserStream handler = JsonParserStream.create(streamWriter, schemaContext)) {
// JSON -> StreamWriter parser
try (JsonParserStream handler = JsonParserStream.create(streamWriter, schemaContext)) {
@@
-95,14
+97,14
@@
public class StreamToNormalizedNodeTest {
}
// Finally build the node
}
// Finally build the node
- final NormalizedNode<?, ?> parsedData =
parent.build
();
+ final NormalizedNode<?, ?> parsedData =
result.getResult
();
LOG.debug("Parsed NormalizedNodes: {}", parsedData);
/*
* This is the serialization part.
*/
// We want to write the first child out
LOG.debug("Parsed NormalizedNodes: {}", parsedData);
/*
* This is the serialization part.
*/
// We want to write the first child out
- final DataContainerChild<? extends PathArgument, ?> firstChild = (
(ContainerNode) parsedData).getValue().iterator().next()
;
+ final DataContainerChild<? extends PathArgument, ?> firstChild = (
DataContainerChild<? extends PathArgument, ?>) parsedData
;
LOG.debug("Serializing first child: {}", firstChild);
// String holder
LOG.debug("Serializing first child: {}", firstChild);
// String holder
@@
-121,9
+123,9
@@
public class StreamToNormalizedNodeTest {
LOG.debug("Serialized JSON: {}", writer.toString());
}
LOG.debug("Serialized JSON: {}", writer.toString());
}
- private static SchemaContext loadModules(final String resourceDirectory) throws IOException {
+ private static SchemaContext loadModules(final String resourceDirectory) throws IOException
, URISyntaxException
{
YangContextParser parser = new YangParserImpl();
YangContextParser parser = new YangParserImpl();
-
String path = StreamToNormalizedNodeTest.class.getResource(resourceDirectory).getPath
();
+
URI path = StreamToNormalizedNodeTest.class.getResource(resourceDirectory).toURI
();
final File testDir = new File(path);
final String[] fileList = testDir.list();
final List<File> testFiles = new ArrayList<File>();
final File testDir = new File(path);
final String[] fileList = testDir.list();
final List<File> testFiles = new ArrayList<File>();
@@
-138,8
+140,8
@@
public class StreamToNormalizedNodeTest {
return parser.parseFiles(testFiles);
}
return parser.parseFiles(testFiles);
}
- private static String loadTextFile(final
String filePath
) throws IOException {
- FileReader fileReader = new FileReader(file
Path
);
+ private static String loadTextFile(final
File file
) throws IOException {
+ FileReader fileReader = new FileReader(file);
BufferedReader bufReader = new BufferedReader(fileReader);
String line = null;
BufferedReader bufReader = new BufferedReader(fileReader);
String line = null;