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);
}
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);
}
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());
}
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;
}
Aggregations