Search in sources :

Example 1 with TransactionProvider

use of org.opendaylight.netconf.mdsal.connector.TransactionProvider in project netconf by opendaylight.

the class AbstractNetconfOperationTest method setUp.

@Before
public void setUp() {
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    final DOMSchemaService schemaService = new SchemaServiceStub(SCHEMA_CONTEXT);
    final DOMStore operStore = InMemoryDOMDataStoreFactory.create("DOM-OPER", schemaService);
    final DOMStore configStore = InMemoryDOMDataStoreFactory.create("DOM-CFG", schemaService);
    currentSchemaContext = new CurrentSchemaContext(schemaService, sourceIdentifier -> {
        final YangTextSchemaSource yangTextSchemaSource = YangTextSchemaSource.delegateForByteSource(sourceIdentifier, ByteSource.wrap("module test".getBytes()));
        return Futures.immediateFuture(yangTextSchemaSource);
    });
    final EnumMap<LogicalDatastoreType, DOMStore> datastores = new EnumMap<>(LogicalDatastoreType.class);
    datastores.put(LogicalDatastoreType.CONFIGURATION, configStore);
    datastores.put(LogicalDatastoreType.OPERATIONAL, operStore);
    final ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(16, 16, "CommitFutures", CopyConfigTest.class);
    final SerializedDOMDataBroker sdb = new SerializedDOMDataBroker(datastores, MoreExecutors.listeningDecorator(listenableFutureExecutor));
    this.transactionProvider = new TransactionProvider(sdb, SESSION_ID_FOR_REPORTING);
}
Also used : YangParserTestUtils.parseYangResources(org.opendaylight.yangtools.yang.test.util.YangParserTestUtils.parseYangResources) Transformer(javax.xml.transform.Transformer) XMLUnit(org.custommonkey.xmlunit.XMLUnit) StreamResult(javax.xml.transform.stream.StreamResult) LoggerFactory(org.slf4j.LoggerFactory) CurrentSchemaContext(org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext) GetConfig(org.opendaylight.netconf.mdsal.connector.ops.get.GetConfig) SpecialExecutors(org.opendaylight.yangtools.util.concurrent.SpecialExecutors) Document(org.w3c.dom.Document) Assert.fail(org.junit.Assert.fail) DetailedDiff(org.custommonkey.xmlunit.DetailedDiff) NetconfOperation(org.opendaylight.netconf.mapping.api.NetconfOperation) DOMStore(org.opendaylight.mdsal.dom.spi.store.DOMStore) XmlUtil(org.opendaylight.netconf.api.xml.XmlUtil) AfterClass(org.junit.AfterClass) XmlFileLoader(org.opendaylight.netconf.util.test.XmlFileLoader) EnumMap(java.util.EnumMap) Get(org.opendaylight.netconf.mdsal.connector.ops.get.Get) Assert.assertFalse(org.junit.Assert.assertFalse) SAXException(org.xml.sax.SAXException) DOMSchemaService(org.opendaylight.mdsal.dom.api.DOMSchemaService) InMemoryDOMDataStoreFactory(org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStoreFactory) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) YangTextSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource) DOMSource(javax.xml.transform.dom.DOMSource) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) BeforeClass(org.junit.BeforeClass) RunWith(org.junit.runner.RunWith) TransactionProvider(org.opendaylight.netconf.mdsal.connector.TransactionProvider) NetconfOperationChainedExecution(org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution) NetconfXmlUnitRecursiveQualifier(org.opendaylight.netconf.util.test.NetconfXmlUnitRecursiveQualifier) Node(org.w3c.dom.Node) ByteSource(com.google.common.io.ByteSource) SerializedDOMDataBroker(org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker) ExecutorService(java.util.concurrent.ExecutorService) Before(org.junit.Before) Logger(org.slf4j.Logger) NodeList(org.w3c.dom.NodeList) StringWriter(java.io.StringWriter) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) OutputKeys(javax.xml.transform.OutputKeys) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Futures(com.google.common.util.concurrent.Futures) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) TransformerFactory(javax.xml.transform.TransformerFactory) Assert.assertEquals(org.junit.Assert.assertEquals) Diff(org.custommonkey.xmlunit.Diff) YangTextSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource) DOMStore(org.opendaylight.mdsal.dom.spi.store.DOMStore) TransactionProvider(org.opendaylight.netconf.mdsal.connector.TransactionProvider) ExecutorService(java.util.concurrent.ExecutorService) CurrentSchemaContext(org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) EnumMap(java.util.EnumMap) SerializedDOMDataBroker(org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker) DOMSchemaService(org.opendaylight.mdsal.dom.api.DOMSchemaService) Before(org.junit.Before)

Example 2 with TransactionProvider

use of org.opendaylight.netconf.mdsal.connector.TransactionProvider in project netconf by opendaylight.

the class ValidateTest method testValidate.

@Test
public void testValidate() throws Exception {
    whenUsingValidator(noopValidator);
    final TransactionProvider transactionProvider = initCandidateTransaction();
    verifyResponse(validate("messages/mapping/validate/validate.xml", transactionProvider), RPC_REPLY_OK);
    verify(noopValidator).validate(readWriteTx);
}
Also used : TransactionProvider(org.opendaylight.netconf.mdsal.connector.TransactionProvider) Test(org.junit.Test)

Example 3 with TransactionProvider

use of org.opendaylight.netconf.mdsal.connector.TransactionProvider in project netconf by opendaylight.

the class ValidateTest method testValidateFailed.

@Test
public void testValidateFailed() throws Exception {
    whenUsingValidator(failingValidator);
    final TransactionProvider transactionProvider = initCandidateTransaction();
    final DocumentedException e = assertThrows(DocumentedException.class, () -> validate("messages/mapping/validate/validate.xml", transactionProvider));
    assertEquals(ErrorSeverity.ERROR, e.getErrorSeverity());
    assertEquals(ErrorTag.OPERATION_FAILED, e.getErrorTag());
    assertEquals(ErrorType.APPLICATION, e.getErrorType());
}
Also used : TransactionProvider(org.opendaylight.netconf.mdsal.connector.TransactionProvider) DocumentedException(org.opendaylight.netconf.api.DocumentedException) Test(org.junit.Test)

Example 4 with TransactionProvider

use of org.opendaylight.netconf.mdsal.connector.TransactionProvider in project netconf by opendaylight.

the class ValidateTest method initCandidateTransaction.

private TransactionProvider initCandidateTransaction() {
    final TransactionProvider transactionProvider = new TransactionProvider(dataBroker, SESSION_ID_FOR_REPORTING);
    transactionProvider.getOrCreateTransaction();
    return transactionProvider;
}
Also used : TransactionProvider(org.opendaylight.netconf.mdsal.connector.TransactionProvider)

Aggregations

TransactionProvider (org.opendaylight.netconf.mdsal.connector.TransactionProvider)4 Test (org.junit.Test)2 ByteSource (com.google.common.io.ByteSource)1 Futures (com.google.common.util.concurrent.Futures)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 EnumMap (java.util.EnumMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 OutputKeys (javax.xml.transform.OutputKeys)1 Transformer (javax.xml.transform.Transformer)1 TransformerFactory (javax.xml.transform.TransformerFactory)1 DOMSource (javax.xml.transform.dom.DOMSource)1 StreamResult (javax.xml.transform.stream.StreamResult)1 DetailedDiff (org.custommonkey.xmlunit.DetailedDiff)1 Diff (org.custommonkey.xmlunit.Diff)1 XMLUnit (org.custommonkey.xmlunit.XMLUnit)1 AfterClass (org.junit.AfterClass)1 Assert.assertEquals (org.junit.Assert.assertEquals)1