import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServiceWrapper;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final DOMSchemaService domSchemaService;
private final TransactionChainHandler transactionChainHandler;
private final DOMDataBroker dataBroker;
-
- private ListenerRegistration<SchemaContextListener> listenerRegistration;
- private SchemaContextHandler schemaCtxHandler;
+ private final SchemaContextHandler schemaCtxHandler;
private final T wrapperServices;
public RestConnectorProvider(final DOMDataBroker domDataBroker, final DOMSchemaService domSchemaService,
final DOMRpcService rpcService, final DOMNotificationService notificationService,
final DOMMountPointService mountPointService, final TransactionChainHandler transactionChainHandler,
- final T wrapperServices) {
+ final SchemaContextHandler schemaCtxHandler, final T wrapperServices) {
this.wrapperServices = wrapperServices;
this.domSchemaService = Preconditions.checkNotNull(domSchemaService);
this.rpcService = Preconditions.checkNotNull(rpcService);
this.mountPointService = Preconditions.checkNotNull(mountPointService);
this.transactionChainHandler = Preconditions.checkNotNull(transactionChainHandler);
this.dataBroker = Preconditions.checkNotNull(domDataBroker);
+ this.schemaCtxHandler = Preconditions.checkNotNull(schemaCtxHandler);
}
public synchronized void start() {
final DOMDataBrokerHandler brokerHandler = new DOMDataBrokerHandler(dataBroker);
- this.schemaCtxHandler = new SchemaContextHandler(transactionChainHandler);
- this.listenerRegistration = domSchemaService.registerSchemaContextListener(this.schemaCtxHandler);
-
final RpcServiceHandler rpcServiceHandler = new RpcServiceHandler(rpcService);
final NotificationServiceHandler notificationServiceHandler =
}
@Override
- public void close() throws Exception {
- // close registration
- if (this.listenerRegistration != null) {
- this.listenerRegistration.close();
- }
-
+ public void close() {
mountPointServiceHandler = null;
}
}
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.core.Application;
+import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyReader;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.NormalizedNodeJsonBodyWriter;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.NormalizedNodeXmlBodyWriter;
import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapperImpl;
public class RestconfApplication extends Application {
+ private final SchemaContextHandler schemaContextHandler = SchemaContextHandler.instance();
@Override
public Set<Class<?>> getClasses() {
return ImmutableSet.<Class<?>>builder()
.add(NormalizedNodeJsonBodyWriter.class).add(NormalizedNodeXmlBodyWriter.class)
- .add(JsonNormalizedNodeBodyReader.class).add(XmlNormalizedNodeBodyReader.class)
.add(SchemaExportContentYinBodyWriter.class).add(SchemaExportContentYangBodyWriter.class)
- .add(JsonToPatchBodyReader.class).add(XmlToPatchBodyReader.class)
.add(PatchJsonBodyWriter.class).add(PatchXmlBodyWriter.class)
.build();
}
public Set<Object> getSingletons() {
final Set<Object> singletons = new HashSet<>();
singletons.add(ServicesWrapperImpl.getInstance());
+ singletons.add(new JsonNormalizedNodeBodyReader(schemaContextHandler));
+ singletons.add(new JsonToPatchBodyReader(schemaContextHandler));
+ singletons.add(new XmlNormalizedNodeBodyReader(schemaContextHandler));
+ singletons.add(new XmlToPatchBodyReader(schemaContextHandler));
return singletons;
}
}
package org.opendaylight.restconf.nb.rfc8040.handlers;
import com.google.common.base.Preconditions;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicInteger;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040.IetfYangLibrary;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040.MonitoringModule;
import org.opendaylight.restconf.nb.rfc8040.utils.mapping.RestconfMappingNodeUtil;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* Implementation of {@link SchemaContextHandler}.
*
*/
-public class SchemaContextHandler implements SchemaContextListenerHandler {
+@SuppressWarnings("checkstyle:FinalClass")
+public class SchemaContextHandler implements SchemaContextListenerHandler, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(SchemaContextHandler.class);
- @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
- private static volatile SchemaContext schemaContext;
-
- private final TransactionChainHandler transactionChainHandler;
+ private static final SchemaContextHandler INSTANCE = new SchemaContextHandler();
private final AtomicInteger moduleSetId = new AtomicInteger(0);
+ private TransactionChainHandler transactionChainHandler;
+ private DOMSchemaService domSchemaService;
+ private ListenerRegistration<SchemaContextListener> listenerRegistration;
+
+ private volatile SchemaContext schemaContext;
+
/**
* Constructor.
*
* @param transactionChainHandler Transaction chain handler
*/
- public SchemaContextHandler(final TransactionChainHandler transactionChainHandler) {
+ private SchemaContextHandler(final TransactionChainHandler transactionChainHandler,
+ final DOMSchemaService domSchemaService) {
this.transactionChainHandler = transactionChainHandler;
- schemaContext = null;
+ this.domSchemaService = domSchemaService;
+ }
+
+ @Deprecated
+ private SchemaContextHandler() {
+ }
+
+ @Deprecated
+ public static SchemaContextHandler instance() {
+ return INSTANCE;
+ }
+
+ public static SchemaContextHandler newInstance(TransactionChainHandler transactionChainHandler,
+ DOMSchemaService domSchemaService) {
+ INSTANCE.transactionChainHandler = transactionChainHandler;
+ INSTANCE.domSchemaService = domSchemaService;
+ return INSTANCE;
+ }
+
+ public void init() {
+ listenerRegistration = domSchemaService.registerSchemaContextListener(this);
+ }
+
+ @Override
+ public void close() {
+ if (listenerRegistration != null) {
+ listenerRegistration.close();
+ }
}
@Override
final Module ietfYangLibraryModule =
context.findModule(IetfYangLibrary.MODULE_QNAME).orElse(null);
- NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> normNode =
- RestconfMappingNodeUtil.mapModulesByIetfYangLibraryYang(context.getModules(), ietfYangLibraryModule,
- context, String.valueOf(this.moduleSetId.incrementAndGet()));
- putData(normNode);
+ if (ietfYangLibraryModule != null) {
+ NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> normNode =
+ RestconfMappingNodeUtil.mapModulesByIetfYangLibraryYang(context.getModules(), ietfYangLibraryModule,
+ context, String.valueOf(this.moduleSetId.incrementAndGet()));
+ putData(normNode);
+ }
final Module monitoringModule =
schemaContext.findModule(MonitoringModule.MODULE_QNAME).orElse(null);
- normNode = RestconfMappingNodeUtil.mapCapabilites(monitoringModule);
- putData(normNode);
+ if (monitoringModule != null) {
+ NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> normNode =
+ RestconfMappingNodeUtil.mapCapabilites(monitoringModule);
+ putData(normNode);
+ }
}
@Override
return schemaContext;
}
- public static SchemaContext getSchemaContext() {
- return schemaContext;
- }
-
- public static void setSchemaContext(final SchemaContext context) {
- schemaContext = context;
- }
-
private void putData(
final NormalizedNode<NodeIdentifier, Collection<DataContainerChild<? extends PathArgument, ?>>> normNode) {
final DOMDataWriteTransaction wTx = this.transactionChainHandler.get().newWriteOnlyTransaction();
import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
+import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractNormalizedNodeBodyReader;
import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@Provider
@Consumes({ Rfc8040.MediaTypes.DATA + RestconfConstants.JSON, MediaType.APPLICATION_JSON })
public class JsonNormalizedNodeBodyReader extends AbstractNormalizedNodeBodyReader {
-
private static final Logger LOG = LoggerFactory.getLogger(JsonNormalizedNodeBodyReader.class);
+ public JsonNormalizedNodeBodyReader(SchemaContextHandler schemaContextHandler) {
+ super(schemaContextHandler);
+ }
+
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
protected NormalizedNodeContext readBody(final InstanceIdentifierContext<?> path, final InputStream entityStream)
import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
+import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractNormalizedNodeBodyReader;
import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
import org.opendaylight.yangtools.util.xml.UntrustedXML;
public class XmlNormalizedNodeBodyReader extends AbstractNormalizedNodeBodyReader {
private static final Logger LOG = LoggerFactory.getLogger(XmlNormalizedNodeBodyReader.class);
+ public XmlNormalizedNodeBodyReader(SchemaContextHandler schemaContextHandler) {
+ super(schemaContextHandler);
+ }
+
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
protected NormalizedNodeContext readBody(final InstanceIdentifierContext<?> path, final InputStream entityStream)
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.patch.PatchContext;
+import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractIdentifierAwareJaxRsProvider;
/**
* @author Robert Varga
*/
abstract class AbstractToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider<PatchContext> {
+ protected AbstractToPatchBodyReader(SchemaContextHandler schemaContextHandler) {
+ super(schemaContextHandler);
+ }
@Override
protected final PatchContext emptyBody(final InstanceIdentifierContext<?> path) {
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
+import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Nonnull;
import javax.ws.rs.Consumes;
import javax.ws.rs.WebApplicationException;
public class JsonToPatchBodyReader extends AbstractToPatchBodyReader {
private static final Logger LOG = LoggerFactory.getLogger(JsonToPatchBodyReader.class);
- private String patchId;
+ public JsonToPatchBodyReader(SchemaContextHandler schemaContextHandler) {
+ super(schemaContextHandler);
+ }
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
private PatchContext readFrom(final InstanceIdentifierContext<?> path, final InputStream entityStream)
throws IOException {
final JsonReader jsonReader = new JsonReader(new InputStreamReader(entityStream, StandardCharsets.UTF_8));
- final List<PatchEntity> resultList = read(jsonReader, path);
+ AtomicReference<String> patchId = new AtomicReference<>();
+ final List<PatchEntity> resultList = read(jsonReader, path, patchId);
jsonReader.close();
- return new PatchContext(path, resultList, patchId);
+ return new PatchContext(path, resultList, patchId.get());
}
@SuppressWarnings("checkstyle:IllegalCatch")
RestconfDocumentedException {
try {
return readFrom(
- ParserIdentifier.toInstanceIdentifier(uriPath, SchemaContextHandler.getSchemaContext(),
+ ParserIdentifier.toInstanceIdentifier(uriPath, getSchemaContext(),
Optional.of(RestConnectorProvider.getMountPointService())), entityStream);
} catch (final Exception e) {
propagateExceptionAs(e);
ErrorTag.MALFORMED_MESSAGE, exception);
}
- private List<PatchEntity> read(final JsonReader in, final InstanceIdentifierContext<?> path) throws IOException {
+ private List<PatchEntity> read(final JsonReader in, final InstanceIdentifierContext<?> path,
+ final AtomicReference<String> patchId) throws IOException {
final List<PatchEntity> resultCollection = new ArrayList<>();
final StringModuleInstanceIdentifierCodec codec = new StringModuleInstanceIdentifierCodec(
path.getSchemaContext());
case END_DOCUMENT:
break;
case NAME:
- parseByName(in.nextName(), edit, in, path, codec, resultCollection);
+ parseByName(in.nextName(), edit, in, path, codec, resultCollection, patchId);
break;
case END_OBJECT:
in.endObject();
private void parseByName(@Nonnull final String name, @Nonnull final PatchEdit edit,
@Nonnull final JsonReader in, @Nonnull final InstanceIdentifierContext<?> path,
@Nonnull final StringModuleInstanceIdentifierCodec codec,
- @Nonnull final List<PatchEntity> resultCollection) throws IOException {
+ @Nonnull final List<PatchEntity> resultCollection,
+ @Nonnull final AtomicReference<String> patchId) throws IOException {
switch (name) {
case "edit":
if (in.peek() == JsonToken.BEGIN_ARRAY) {
break;
case "patch-id":
- this.patchId = in.nextString();
+ patchId.set(in.nextString());
break;
default:
break;
import org.opendaylight.restconf.common.patch.PatchEntity;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
import org.opendaylight.restconf.nb.rfc8040.codecs.StringModuleInstanceIdentifierCodec;
+import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
import org.opendaylight.yangtools.util.xml.UntrustedXML;
import org.opendaylight.yangtools.yang.common.QName;
private static final Logger LOG = LoggerFactory.getLogger(XmlToPatchBodyReader.class);
private static final Splitter SLASH_SPLITTER = Splitter.on('/');
+ public XmlToPatchBodyReader(SchemaContextHandler schemaContextHandler) {
+ super(schemaContextHandler);
+ }
+
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
protected PatchContext readBody(final InstanceIdentifierContext<?> path, final InputStream entityStream)
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public abstract class AbstractIdentifierAwareJaxRsProvider<T> implements MessageBodyReader<T> {
@Context
private Request request;
+ private final SchemaContextHandler schemaContextHandler;
+
+ protected AbstractIdentifierAwareJaxRsProvider(SchemaContextHandler schemaContextHandler) {
+ this.schemaContextHandler = schemaContextHandler;
+ }
+
@Override
public final boolean isReadable(final Class<?> type, final Type genericType, final Annotation[] annotations,
final MediaType mediaType) {
}
private InstanceIdentifierContext<?> getInstanceIdentifierContext() {
- return ParserIdentifier.toInstanceIdentifier(
- getIdentifier(),
- SchemaContextHandler.getSchemaContext(),
+ return ParserIdentifier.toInstanceIdentifier(getIdentifier(), getSchemaContext(),
Optional.of(RestConnectorProvider.getMountPointService()));
}
return this.uriInfo;
}
+ protected SchemaContext getSchemaContext() {
+ return schemaContextHandler.get();
+ }
+
protected boolean isPost() {
return HttpMethod.POST.equals(this.request.getMethod());
}
import javax.ws.rs.core.UriInfo;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
+import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
/**
* Common superclass for readers producing {@link NormalizedNodeContext}.
@Beta
public abstract class AbstractNormalizedNodeBodyReader
extends AbstractIdentifierAwareJaxRsProvider<NormalizedNodeContext> {
+ protected AbstractNormalizedNodeBodyReader(SchemaContextHandler schemaContextHandler) {
+ super(schemaContextHandler);
+ }
public final void injectParams(final UriInfo uriInfo, final Request request) {
setUriInfo(uriInfo);
private final TransactionServicesWrapper services;
private final DOMMountPointServiceHandler mountPointServiceHandler;
+ private final SchemaContextHandler schemaContextHandler;
public JSONRestconfServiceRfc8040Impl(final TransactionServicesWrapper services,
- final DOMMountPointServiceHandler mountPointServiceHandler) {
+ final DOMMountPointServiceHandler mountPointServiceHandler,
+ final SchemaContextHandler schemaContextHandler) {
this.services = services;
this.mountPointServiceHandler = mountPointServiceHandler;
+ this.schemaContextHandler = schemaContextHandler;
}
@SuppressWarnings("checkstyle:IllegalCatch")
final InputStream entityStream = new ByteArrayInputStream(payload.getBytes(StandardCharsets.UTF_8));
- JsonToPatchBodyReader jsonToPatchBodyReader = new JsonToPatchBodyReader();
+ JsonToPatchBodyReader jsonToPatchBodyReader = new JsonToPatchBodyReader(schemaContextHandler);
final PatchContext context = jsonToPatchBodyReader.readFrom(uriPath, entityStream);
LOG.debug("Parsed YangInstanceIdentifier: {}", context.getInstanceIdentifierContext().getInstanceIdentifier());
private NormalizedNodeContext toNormalizedNodeContext(final String uriPath, @Nullable final String payload,
final boolean isPost) throws OperationFailedException {
final InstanceIdentifierContext<?> instanceIdentifierContext = ParserIdentifier.toInstanceIdentifier(
- uriPath, SchemaContextHandler.getSchemaContext(),
- Optional.of(mountPointServiceHandler.get()));
+ uriPath, schemaContextHandler.get(), Optional.of(mountPointServiceHandler.get()));
if (payload == null) {
return new NormalizedNodeContext(instanceIdentifierContext, null);
<argument ref="domDataBroker"/>
</bean>
+ <bean id="schemaContextHandler" class="org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler"
+ factory-method="newInstance" init-method="init" destroy-method="close">
+ <argument ref="transactionChainHandler"/>
+ <argument ref="domSchemaService"/>
+ </bean>
+
<bean id="restconfProvider" class="org.opendaylight.restconf.nb.rfc8040.RestConnectorProvider"
init-method="start" destroy-method="close">
<argument ref="domDataBroker"/>
<argument ref="domNotificationService"/>
<argument ref="domMountPointService"/>
<argument ref="transactionChainHandler"/>
+ <argument ref="schemaContextHandler"/>
<argument ref="wrapper"/>
</bean>
<argument>
<bean factory-ref="restconfProvider" factory-method="getMountPointServiceHandler" />
</argument>
+ <argument ref="schemaContextHandler"/>
</bean>
<service ref="jsonRestconfService" odl:type="rfc8040"
doReturn(mockRegistration).when(domSchemaService).registerSchemaContextListener(
Mockito.any(SchemaContextHandler.class));
+ final TransactionChainHandler transactionChainHandler = new TransactionChainHandler(mockDataBroker);
this.connectorProvider = new RestConnectorProvider<>(mockDataBroker, domSchemaService, mockRpcService,
- mockNotificationService, mockMountPointService,
- new TransactionChainHandler(mockDataBroker), ServicesWrapperImpl.getInstance());
+ mockNotificationService, mockMountPointService, transactionChainHandler,
+ SchemaContextHandler.newInstance(transactionChainHandler, domSchemaService),
+ ServicesWrapperImpl.getInstance());
}
/**
// verify interactions
verify(mockDataBroker).createTransactionChain(Mockito.any());
- verify(domSchemaService).registerSchemaContextListener(Mockito.any(SchemaContextHandler.class));
}
/**
// close
this.connectorProvider.close();
-
- // verify interaction
- verify(this.mockRegistration).close();
}
}
package org.opendaylight.restconf.nb.rfc8040;
import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.Futures;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.mockito.Mockito;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
+import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
import org.opendaylight.yangtools.util.xml.UntrustedXML;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Revision;
return mapEntryNode.build();
}
+
+ public static SchemaContextHandler newSchemaContextHandler(SchemaContext schemaContext) {
+ DOMDataBroker mockDataBroker = mock(DOMDataBroker.class);
+ DOMTransactionChain mockChain = mock(DOMTransactionChain.class);
+ DOMDataWriteTransaction mockTx = mock(DOMDataWriteTransaction.class);
+ doReturn(Futures.immediateCheckedFuture(null)).when(mockTx).submit();
+ doReturn(mockTx).when(mockChain).newWriteOnlyTransaction();
+
+ doReturn(mockChain).when(mockDataBroker).createTransactionChain(any());
+ SchemaContextHandler schemaContextHandler = SchemaContextHandler.newInstance(
+ new TransactionChainHandler(mockDataBroker), Mockito.mock(DOMSchemaService.class));
+ schemaContextHandler.onGlobalContextUpdated(schemaContext);
+ return schemaContextHandler;
+ }
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
import com.google.common.util.concurrent.CheckedFuture;
import org.junit.Before;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
private SchemaContextHandler schemaContextHandler;
private SchemaContext schemaContext;
+ private final DOMSchemaService mockDOMSchemaService = Mockito.mock(DOMSchemaService.class);
@Before
public void setup() throws Exception {
final CheckedFuture<Void,TransactionCommitFailedException> checked = Mockito.mock(CheckedFuture.class);
Mockito.when(wTx.submit()).thenReturn(checked);
Mockito.when(checked.checkedGet()).thenReturn(null);
- this.schemaContextHandler = new SchemaContextHandler(txHandler);
+
+
+ this.schemaContextHandler = SchemaContextHandler.newInstance(txHandler, mockDOMSchemaService);
this.schemaContext =
YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_ACTUAL_SCHEMA_CONTEXT));
}
/**
- * Testing init of {@link SchemaContextHandler}.
+ * Testing init and close.
*/
@Test
- public void schemaContextHandlerImplInitTest() {
- assertNotNull("Handler should be created and not null", this.schemaContextHandler);
+ public void testInitAndClose() {
+ ListenerRegistration<?> mockListenerReg = Mockito.mock(ListenerRegistration.class);
+ Mockito.doReturn(mockListenerReg).when(mockDOMSchemaService)
+ .registerSchemaContextListener(schemaContextHandler);
+
+ schemaContextHandler.init();
+
+ Mockito.verify(mockDOMSchemaService).registerSchemaContextListener(schemaContextHandler);
+
+ schemaContextHandler.close();
+
+ Mockito.verify(mockListenerReg).close();
}
/**
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
-import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest;
import org.opendaylight.yangtools.yang.common.QName;
URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
public XmlBodyReaderMountPointTest() throws Exception {
- this.xmlBodyReader = new XmlNormalizedNodeBodyReader();
+ super(schemaContext);
+ this.xmlBodyReader = new XmlNormalizedNodeBodyReader(schemaContextHandler);
}
@Override
when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mountPointService);
when(mountPointService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountPoint));
when(mountPoint.getSchemaContext()).thenReturn(schemaContext);
- SchemaContextHandler.setSchemaContext(schemaContext);
}
@Test
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.JsonBodyReaderTest;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
private final JsonToPatchBodyReader jsonToPatchBodyReader;
public JsonPatchBodyReaderMountPointTest() throws Exception {
- jsonToPatchBodyReader = new JsonToPatchBodyReader();
+ super(schemaContext);
+ jsonToPatchBodyReader = new JsonToPatchBodyReader(schemaContextHandler);
}
@Override
when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mountPointService);
when(mountPointService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountPoint));
when(mountPoint.getSchemaContext()).thenReturn(schemaContext);
- SchemaContextHandler.setSchemaContext(schemaContext);
}
@Test
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.JsonBodyReaderTest;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
private static SchemaContext schemaContext;
public JsonPatchBodyReaderTest() throws Exception {
- jsonToPatchBodyReader = new JsonToPatchBodyReader();
+ super(schemaContext);
+ jsonToPatchBodyReader = new JsonToPatchBodyReader(schemaContextHandler);
}
@Override
public static void initialization() {
schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class));
- SchemaContextHandler.setSchemaContext(schemaContext);
}
@Test
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
private static final String MOUNT_POINT = "instance-identifier-module:cont/yang-ext:mount/";
public XmlPatchBodyReaderMountPointTest() throws Exception {
- xmlToPatchBodyReader = new XmlToPatchBodyReader();
+ super(schemaContext);
+ xmlToPatchBodyReader = new XmlToPatchBodyReader(schemaContextHandler);
}
@Override
when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mountPointService);
when(mountPointService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountPoint));
when(mountPoint.getSchemaContext()).thenReturn(schemaContext);
- SchemaContextHandler.setSchemaContext(schemaContext);
}
@Test
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
private static SchemaContext schemaContext;
public XmlPatchBodyReaderTest() throws Exception {
- xmlToPatchBodyReader = new XmlToPatchBodyReader();
+ super(schemaContext);
+ xmlToPatchBodyReader = new XmlToPatchBodyReader(schemaContextHandler);
}
@Override
public static void initialization() {
schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class));
- SchemaContextHandler.setSchemaContext(schemaContext);
}
@Test
import org.opendaylight.restconf.common.patch.PatchContext;
import org.opendaylight.restconf.nb.rfc8040.RestConnectorProvider;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
+import org.opendaylight.restconf.nb.rfc8040.TestUtils;
import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
+import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractIdentifierAwareJaxRsProvider;
import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
mock(DOMMountPointServiceHandler.class);
protected final MediaType mediaType;
+ protected final SchemaContextHandler schemaContextHandler;
- protected AbstractBodyReaderTest() throws NoSuchFieldException, IllegalAccessException {
+ protected AbstractBodyReaderTest(SchemaContext schemaContext) throws NoSuchFieldException, IllegalAccessException {
mediaType = getMediaType();
final Field mountPointServiceHandlerField =
RestConnectorProvider.class.getDeclaredField("mountPointServiceHandler");
mountPointServiceHandlerField.setAccessible(true);
mountPointServiceHandlerField.set(RestConnectorProvider.class, MOUNT_POINT_SERVICE_HANDLER);
+
+ schemaContextHandler = TestUtils.newSchemaContextHandler(schemaContext);
}
protected abstract MediaType getMediaType();
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
-import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyReader;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
public JsonBodyReaderTest() throws Exception {
- this.jsonBodyReader = new JsonNormalizedNodeBodyReader();
+ super(schemaContext);
+ this.jsonBodyReader = new JsonNormalizedNodeBodyReader(schemaContextHandler);
}
@Override
testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class));
- SchemaContextHandler.setSchemaContext(schemaContext);
}
@Test
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
-import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.XmlNormalizedNodeBodyReader;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
public XmlBodyReaderTest() throws Exception {
- this.xmlBodyReader = new XmlNormalizedNodeBodyReader();
+ super(schemaContext);
+ this.xmlBodyReader = new XmlNormalizedNodeBodyReader(schemaContextHandler);
}
@Override
testFiles.addAll(TestRestconfUtils.loadFiles("/foo-xml-test/yang"));
schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class));
- SchemaContextHandler.setSchemaContext(schemaContext);
}
@Test
@Mock
private DOMMountPointService mockMountPointService;
- @Mock
- private SchemaContextHandler mockSchemaContextHandler;
-
@Mock
private DOMDataBroker mockDOMDataBroker;
private JSONRestconfServiceRfc8040Impl service;
+ private final SchemaContextHandler schemaContextHandler = TestUtils.newSchemaContextHandler(schemaContext);
+
@BeforeClass
public static void init() throws IOException, ReactorException {
schemaContext = TestUtils.loadSchemaContext("/full-versions/yangs");
- SchemaContextHandler.setSchemaContext(schemaContext);
}
@SuppressWarnings("resource")
doReturn(mockTxChain).when(mockDOMDataBroker).createTransactionChain(any());
- doReturn(schemaContext).when(mockSchemaContextHandler).get();
-
final TransactionChainHandler txChainHandler = new TransactionChainHandler(mockDOMDataBroker);
final DOMMountPointServiceHandler mountPointServiceHandler =
new DOMMountPointServiceHandler(mockMountPointService);
final DOMNotificationService mockNotificationService = mock(DOMNotificationService.class);
- ServicesWrapperImpl.getInstance().setHandlers(mockSchemaContextHandler, mountPointServiceHandler,
+ ServicesWrapperImpl.getInstance().setHandlers(schemaContextHandler, mountPointServiceHandler,
txChainHandler, new DOMDataBrokerHandler(mockDOMDataBroker),
new RpcServiceHandler(mockRpcService),
new NotificationServiceHandler(mockNotificationService), domSchemaService);
- service = new JSONRestconfServiceRfc8040Impl(ServicesWrapperImpl.getInstance(), mountPointServiceHandler);
+ service = new JSONRestconfServiceRfc8040Impl(ServicesWrapperImpl.getInstance(), mountPointServiceHandler,
+ schemaContextHandler);
new RestConnectorProvider<>(mockDOMDataBroker, domSchemaService, mockRpcService, mockNotificationService,
- mockMountPointService, txChainHandler, null).start();
-
- SchemaContextHandler.setSchemaContext(schemaContext);
+ mockMountPointService, txChainHandler, schemaContextHandler, null).start();
}
private static String loadData(final String path) throws IOException {
import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
transactionChainHandler = new TransactionChainHandler(mockDataBroker);
- final SchemaContextHandler schemaContextHandler = new SchemaContextHandler(transactionChainHandler);
+ final SchemaContextHandler schemaContextHandler = SchemaContextHandler.newInstance(transactionChainHandler,
+ Mockito.mock(DOMSchemaService.class));
schemaContextHandler.onGlobalContextUpdated(this.contextRef.get());
this.dataService = new RestconfDataServiceImpl(schemaContextHandler, this.transactionChainHandler,
import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
final CheckedFuture<Void, TransactionCommitFailedException> checked = Mockito.mock(CheckedFuture.class);
Mockito.when(wTx.submit()).thenReturn(checked);
Mockito.when(checked.checkedGet()).thenReturn(null);
- final SchemaContextHandler schemaContextHandler = new SchemaContextHandler(txHandler);
+ final SchemaContextHandler schemaContextHandler =
+ SchemaContextHandler.newInstance(txHandler, Mockito.mock(DOMSchemaService.class));
schemaContextHandler.onGlobalContextUpdated(contextRef.get());
this.invokeOperationsService =
new RestconfInvokeOperationsServiceImpl(this.rpcServiceHandler, schemaContextHandler);
import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.util.SimpleUriInfo;
private UriInfo uriInfo;
@Mock
private NotificationServiceHandler notificationServiceHandler;
- @Mock
- private TransactionChainHandler transactionHandler;
+ private TransactionChainHandler transactionHandler;
private SchemaContextHandler schemaHandler;
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- final TransactionChainHandler txHandler = mock(TransactionChainHandler.class);
final DOMTransactionChain domTx = mock(DOMTransactionChain.class);
- Mockito.when(this.transactionHandler.get()).thenReturn(domTx);
- Mockito.when(txHandler.get()).thenReturn(domTx);
final DOMDataWriteTransaction wTx = Mockito.mock(DOMDataWriteTransaction.class);
Mockito.when(domTx.newWriteOnlyTransaction()).thenReturn(wTx);
final DOMDataReadWriteTransaction rwTx = Mockito.mock(DOMDataReadWriteTransaction.class);
final CheckedFuture<Void, TransactionCommitFailedException> checked = mock(CheckedFuture.class);
Mockito.when(wTx.submit()).thenReturn(checked);
Mockito.when(checked.checkedGet()).thenReturn(null);
- this.schemaHandler = new SchemaContextHandler(txHandler);
final DOMDataBroker dataBroker = mock(DOMDataBroker.class);
+ doReturn(domTx).when(dataBroker).createTransactionChain(any());
+
+ transactionHandler = new TransactionChainHandler(dataBroker);
+ schemaHandler = SchemaContextHandler.newInstance(transactionHandler, Mockito.mock(DOMSchemaService.class));
DOMDataTreeChangeService dataTreeChangeService = mock(DOMDataTreeChangeService.class);
doReturn(mock(ListenerRegistration.class)).when(dataTreeChangeService)
*/
package org.opendaylight.restconf.nb.rfc8040.services.simple.impl;
-import com.google.common.util.concurrent.CheckedFuture;
import org.junit.Assert;
import org.junit.Test;
-import org.mockito.Mockito;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040.IetfYangLibrary;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
+import org.opendaylight.restconf.nb.rfc8040.TestUtils;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
-import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public void restImplTest() throws Exception {
final SchemaContext schemaContext =
YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/restconf/impl"));
-
- final TransactionChainHandler txHandler = Mockito.mock(TransactionChainHandler.class);
- final DOMTransactionChain domTx = Mockito.mock(DOMTransactionChain.class);
- Mockito.when(txHandler.get()).thenReturn(domTx);
- final DOMDataWriteTransaction wTx = Mockito.mock(DOMDataWriteTransaction.class);
- Mockito.when(domTx.newWriteOnlyTransaction()).thenReturn(wTx);
- final CheckedFuture<Void, TransactionCommitFailedException> checked = Mockito.mock(CheckedFuture.class);
- Mockito.when(wTx.submit()).thenReturn(checked);
- Mockito.when(checked.checkedGet()).thenReturn(null);
- final SchemaContextHandler schemaContextHandler = new SchemaContextHandler(txHandler);
- schemaContextHandler.onGlobalContextUpdated(schemaContext);
-
+ final SchemaContextHandler schemaContextHandler = TestUtils.newSchemaContextHandler(schemaContext);
final RestconfImpl restconfImpl = new RestconfImpl(schemaContextHandler);
final NormalizedNodeContext libraryVersion = restconfImpl.getLibraryVersion();
final LeafNode<?> value = (LeafNode<?>) libraryVersion.getData();
import static org.junit.Assert.assertTrue;
import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.Futures;
import java.net.URI;
import java.util.Set;
import javax.ws.rs.core.UriInfo;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
+import org.opendaylight.restconf.nb.rfc8040.TestUtils;
import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
-import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
public void init() throws Exception {
MockitoAnnotations.initMocks(this);
this.schemaContext = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules"));
-
- final TransactionChainHandler txHandler = Mockito.mock(TransactionChainHandler.class);
- final DOMTransactionChain domTx = Mockito.mock(DOMTransactionChain.class);
- Mockito.when(txHandler.get()).thenReturn(domTx);
- final DOMDataWriteTransaction wTx = Mockito.mock(DOMDataWriteTransaction.class);
- Mockito.when(domTx.newWriteOnlyTransaction()).thenReturn(wTx);
- Mockito.when(wTx.submit()).thenReturn(Futures.immediateCheckedFuture(null));
- this.schemaContextHandler = new SchemaContextHandler(txHandler);
- this.schemaContextHandler.onGlobalContextUpdated(this.schemaContext);
+ this.schemaContextHandler = TestUtils.newSchemaContextHandler(schemaContext);
this.domMountPointServiceHandler = new DOMMountPointServiceHandler(this.domMountPointService);
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
import org.opendaylight.yang.gen.v1.instance.identifier.patch.module.rev151121.PatchCont;
"/instanceidentifier/yang/instance-identifier-patch-module.yang");
transactionChainHandler = new TransactionChainHandler(domDataBroker);
- schemaContextHandler = new SchemaContextHandler(transactionChainHandler);
- SchemaContextHandler.setSchemaContext(sc);
+ schemaContextHandler = SchemaContextHandler.newInstance(transactionChainHandler,
+ Mockito.mock(DOMSchemaService.class));
+ schemaContextHandler.onGlobalContextUpdated(sc);
}
class ListenerAdapterTester extends ListenerAdapter {