summaryrefslogtreecommitdiffstats
path: root/infra
diff options
context:
space:
mode:
Diffstat (limited to 'infra')
-rw-r--r--infra/data-impl/pom.xml5
-rw-r--r--infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationBaseTest.java10
-rw-r--r--infra/translate-utils/pom.xml5
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/JsonUtilsTest.java22
4 files changed, 22 insertions, 20 deletions
diff --git a/infra/data-impl/pom.xml b/infra/data-impl/pom.xml
index 55e646a5c..3e5b4b92d 100644
--- a/infra/data-impl/pom.xml
+++ b/infra/data-impl/pom.xml
@@ -74,6 +74,11 @@
<artifactId>skinny-logback</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-test-util</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationBaseTest.java b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationBaseTest.java
index c7d78faf6..7e9c34dfa 100644
--- a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationBaseTest.java
+++ b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationBaseTest.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@@ -46,9 +47,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuil
import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
abstract class ModificationBaseTest extends ModificationMetadata {
@@ -127,10 +126,7 @@ abstract class ModificationBaseTest extends ModificationMetadata {
}
SchemaContext getSchemaCtx() throws ReactorException {
- final CrossSourceStatementReactor.BuildAction buildAction = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- buildAction.addSource(
- new YangStatementSourceImpl(ModificationDiffTest.class.getResourceAsStream("/test-diff.yang")));
- return buildAction.buildEffective();
+ return YangParserTestUtils.parseYangSources(Collections.singletonList("/test-diff.yang"));
}
DataTreeModification getModification(final TipProducingDataTree dataTree) {
diff --git a/infra/translate-utils/pom.xml b/infra/translate-utils/pom.xml
index d05d88520..8b4701454 100644
--- a/infra/translate-utils/pom.xml
+++ b/infra/translate-utils/pom.xml
@@ -83,6 +83,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-test-util</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/JsonUtilsTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/JsonUtilsTest.java
index e1b2b3c0e..70717d2e8 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/JsonUtilsTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/JsonUtilsTest.java
@@ -23,6 +23,7 @@ import com.google.common.io.ByteStreams;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
+import java.util.Collections;
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
@@ -32,10 +33,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveSchemaContext;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class JsonUtilsTest {
@@ -47,23 +46,20 @@ public class JsonUtilsTest {
private static final QName STRING_LEAF_QNAME = QName.create(TOP_CONTAINER_NAME, "string");
private Path tmpPersistFile;
- private EffectiveSchemaContext effectiveSchemaContext;
+ private SchemaContext schemaContext;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
tmpPersistFile = Files.createTempFile("testing-hc-persistence", "json");
-
- final CrossSourceStatementReactor.BuildAction buildAction = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- buildAction.addSource(new YangStatementSourceImpl(getClass().getResourceAsStream("/test-persistence.yang")));
- effectiveSchemaContext = buildAction.buildEffective();
+ schemaContext = YangParserTestUtils.parseYangSources(Collections.singletonList("/test-persistence.yang"));
}
@Test
public void testPersist() throws Exception {
NormalizedNode<?, ?> data = getData("testing");
- JsonUtils.writeJsonRoot(data, effectiveSchemaContext, Files.newOutputStream(tmpPersistFile, StandardOpenOption.CREATE));
+ JsonUtils.writeJsonRoot(data, schemaContext, Files.newOutputStream(tmpPersistFile, StandardOpenOption.CREATE));
assertTrue(Files.exists(tmpPersistFile));
String persisted = new String(Files.readAllBytes(tmpPersistFile));
@@ -73,7 +69,7 @@ public class JsonUtilsTest {
assertEquals(expected, persisted);
data = getData("testing2");
- JsonUtils.writeJsonRoot(data, effectiveSchemaContext, Files.newOutputStream(tmpPersistFile, StandardOpenOption.CREATE));
+ JsonUtils.writeJsonRoot(data, schemaContext, Files.newOutputStream(tmpPersistFile, StandardOpenOption.CREATE));
persisted = new String(Files.readAllBytes(tmpPersistFile));
assertEquals(expected.replace("testing", "testing2"), persisted);
@@ -84,13 +80,13 @@ public class JsonUtilsTest {
@Test
public void testRestore() throws Exception {
final ContainerNode normalizedNodeOptional = JsonUtils
- .readJsonRoot(effectiveSchemaContext, getClass().getResourceAsStream("/expected-persisted-output.txt"));
+ .readJsonRoot(schemaContext, getClass().getResourceAsStream("/expected-persisted-output.txt"));
assertEquals(getData("testing"), normalizedNodeOptional);
}
@Test(expected = IllegalArgumentException.class)
public void testRestoreInvalidFile() throws Exception {
- JsonUtils.readJsonRoot(effectiveSchemaContext, getClass().getResourceAsStream("/test-persistence.yang"));
+ JsonUtils.readJsonRoot(schemaContext, getClass().getResourceAsStream("/test-persistence.yang"));
}
private ContainerNode getData(final String stringValue) {