import java.io.InputStream;
import javax.ws.rs.core.MediaType;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
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.common.ErrorTag;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
private static final String MOUNT_POINT = "instance-identifier-module:cont/yang-ext:mount/";
- private static EffectiveModelContext schemaContext;
private final JsonPatchBodyReader jsonToPatchBodyReader;
public JsonPatchBodyReaderMountPointTest() {
- super(schemaContext);
jsonToPatchBodyReader = new JsonPatchBodyReader(databindProvider, mountPointService);
}
return new MediaType(APPLICATION_JSON, null);
}
- @BeforeClass
- public static void initialization() {
- schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
- }
-
@Test
public void modulePatchDataTest() throws Exception {
final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import javax.ws.rs.core.MediaType;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.patch.PatchContext;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest {
-
private final JsonPatchBodyReader jsonToPatchBodyReader;
- private static EffectiveModelContext schemaContext;
public JsonPatchBodyReaderTest() {
- super(schemaContext);
jsonToPatchBodyReader = new JsonPatchBodyReader(databindProvider, mountPointService);
}
return new MediaType(APPLICATION_JSON, null);
}
- @BeforeClass
- public static void initialization() {
- schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
- }
-
@Test
public void modulePatchDataTest() throws Exception {
final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
import java.io.InputStream;
import javax.ws.rs.core.MediaType;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.patch.PatchContext;
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.ErrorTag;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
private static final String MOUNT_POINT = "instance-identifier-module:cont/yang-ext:mount/";
- private static EffectiveModelContext schemaContext;
-
private final XmlPatchBodyReader xmlToPatchBodyReader;
public XmlPatchBodyReaderMountPointTest() {
- super(schemaContext);
xmlToPatchBodyReader = new XmlPatchBodyReader(databindProvider, mountPointService);
}
return new MediaType(MediaType.APPLICATION_XML, null);
}
- @BeforeClass
- public static void initialization() {
- schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
- }
-
@Test
public void moduleDataTest() throws Exception {
final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import javax.ws.rs.core.MediaType;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.patch.PatchContext;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest {
- private static EffectiveModelContext schemaContext;
-
private final XmlPatchBodyReader xmlToPatchBodyReader;
public XmlPatchBodyReaderTest() {
- super(schemaContext);
xmlToPatchBodyReader = new XmlPatchBodyReader(databindProvider, mountPointService);
}
return new MediaType(MediaType.APPLICATION_XML, null);
}
- @BeforeClass
- public static void initialization() {
- schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
- }
-
@Test
public void moduleDataTest() throws Exception {
mockBodyReader("instance-identifier-patch-module:patch-cont/my-list1=leaf1", xmlToPatchBodyReader, false);
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
+import org.junit.BeforeClass;
import org.junit.function.ThrowingRunnable;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError;
import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
import org.opendaylight.restconf.nb.rfc8040.databind.DatabindContext;
import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractIdentifierAwareJaxRsProvider;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public abstract class AbstractBodyReaderTest {
protected static final QName CONT_AUG_QNAME = QName.create("test-ns-aug", "container-aug").intern();
protected static final QName MY_LEAF12_QNAME = QName.create("instance:identifier:patch:module",
"2015-11-21", "my-leaf12").intern();
+ private static EffectiveModelContext BASELINE_CONTEXT;
+
protected final MediaType mediaType;
protected final DatabindProvider databindProvider;
protected final DOMMountPointService mountPointService;
+ protected AbstractBodyReaderTest() {
+ this(BASELINE_CONTEXT);
+ }
+
protected AbstractBodyReaderTest(final EffectiveModelContext schemaContext) {
mediaType = getMediaType();
.getService(DOMSchemaService.class);
}
- protected abstract MediaType getMediaType();
-
- protected static EffectiveModelContext schemaContextLoader(final String yangPath,
- final EffectiveModelContext schemaContext) {
- return TestRestconfUtils.loadSchemaContext(yangPath, schemaContext);
+ @BeforeClass
+ public static final void initBaselineContext() {
+ BASELINE_CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/instanceidentifier/yang");
}
+ protected abstract MediaType getMediaType();
+
protected static <T extends AbstractIdentifierAwareJaxRsProvider<?>> void mockBodyReader(
final String identifier, final T normalizedNodeProvider, final boolean isPost) {
final UriInfo uriInfoMock = mock(UriInfo.class);