- @Before
- public void setup() throws Exception {
- final List<InputStream> modelsToParse = Collections
- .singletonList(getClass().getResourceAsStream("/schemas/rpc-notification-subscription.yang"));
- final YangContextParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModelsFromStreams(modelsToParse);
- assertTrue(!modules.isEmpty());
- final SchemaContext schemaContext = parser.resolveSchemaContext(modules);
- assertNotNull(schemaContext);
-
- messageTransformer = new NetconfMessageTransformer();
- messageTransformer.onGlobalContextUpdated(schemaContext);
+ @BeforeClass
+ public static void setup() throws Exception {
+ List<InputStream> modelsToParse = Collections
+ .singletonList(NetconfToRpcRequestTest.class.getResourceAsStream("/schemas/rpc-notification-subscription.yang"));
+ YangContextParser parser = new YangParserImpl();
+ final Set<Module> notifModules = parser.parseYangModelsFromStreams(modelsToParse);
+ assertTrue(!notifModules.isEmpty());
+
+ modelsToParse = Collections
+ .singletonList(NetconfToRpcRequestTest.class.getResourceAsStream("/schemas/config-test-rpc.yang"));
+ parser = new YangParserImpl();
+ final Set<Module> configModules = parser.parseYangModelsFromStreams(modelsToParse);
+ cfgCtx = parser.resolveSchemaContext(Sets.union(configModules, notifModules));
+ assertNotNull(cfgCtx);
+
+ messageTransformer = new NetconfMessageTransformer(cfgCtx);
+ }
+
+ private LeafNode<Object> buildLeaf(final QName running, final Object value) {
+ return Builders.leafBuilder().withNodeIdentifier(toId(running)).withValue(value).build();