import com.google.common.io.ByteSource;
import com.google.common.util.concurrent.Futures;
-import java.io.InputStream;
import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.EnumMap;
-import java.util.List;
import java.util.concurrent.ExecutorService;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreAttributeOrder(true);
- this.schemaContext = YangParserTestUtils.parseYangStreams(getYangSchemas());
+ this.schemaContext = YangParserTestUtils.parseYangResources(NetconfMDSalMappingTest.class,
+ "/META-INF/yang/config@2013-04-05.yang", "/yang/mdsal-netconf-mapping-test.yang");
schemaContext.getModules();
final SchemaService schemaService = createSchemaService();
datastores.put(LogicalDatastoreType.OPERATIONAL, operStore);
final ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
- 16, 16, "CommitFutures");
+ 16, 16, "CommitFutures", NetconfMDSalMappingTest.class);
final ConcurrentDOMDataBroker cdb = new ConcurrentDOMDataBroker(datastores, listenableFutureExecutor);
this.transactionProvider = new TransactionProvider(cdb, SESSION_ID_FOR_REPORTING);
final SourceIdentifier sId = (SourceIdentifier) invocationOnMock.getArguments()[0];
final YangTextSchemaSource yangTextSchemaSource =
YangTextSchemaSource.delegateForByteSource(sId, ByteSource.wrap("module test".getBytes()));
- return Futures.immediateCheckedFuture(yangTextSchemaSource);
+ return Futures.immediateFuture(yangTextSchemaSource);
}).when(sourceProvider).getSource(any(SourceIdentifier.class));
+ " </edit-config>\n"
+ "</rpc>";
XmlElement xe = getXmlElement(stringWithoutPrefix);
- NodeList nodeList = editConfig.getElementsByTagName(xe, TARGET_KEY);
+ NodeList nodeList = EditConfig.getElementsByTagName(xe, TARGET_KEY);
Assert.assertEquals(1, nodeList.getLength());
String stringWithPrefix =
+ "</nc:rpc>";
xe = getXmlElement(stringWithPrefix);
- nodeList = editConfig.getElementsByTagName(xe, TARGET_KEY);
+ nodeList = EditConfig.getElementsByTagName(xe, TARGET_KEY);
Assert.assertEquals(1, nodeList.getLength());
String stringWithoutTarget =
xe = getXmlElement(stringWithoutTarget);
try {
- nodeList = editConfig.getElementsByTagName(xe, TARGET_KEY);
+ nodeList = EditConfig.getElementsByTagName(xe, TARGET_KEY);
XmlElement.fromDomElement((Element) nodeList.item(0)).getOnlyChildElement();
Assert.fail("Not specified target, we should fail");
} catch (DocumentedException documentedException) {
}
- private XmlElement getXmlElement(final String elementAsString) throws Exception {
+ private static XmlElement getXmlElement(final String elementAsString) throws Exception {
Document document = XmlUtil.readXmlToDocument(elementAsString);
Element element = document.getDocumentElement();
return XmlElement.fromDomElement(element);
return response;
}
- private List<InputStream> getYangSchemas() {
- final List<String> schemaPaths = Arrays.asList("/META-INF/yang/config@2013-04-05.yang",
- "/yang/mdsal-netconf-mapping-test.yang");
- final List<InputStream> schemas = new ArrayList<>();
-
- for (final String schemaPath : schemaPaths) {
- final InputStream resourceAsStream = getClass().getResourceAsStream(schemaPath);
- schemas.add(resourceAsStream);
- }
-
- return schemas;
- }
-
private SchemaService createSchemaService() {
return new SchemaService() {