summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/provider/src/test
diff options
context:
space:
mode:
authorherbert <herbert.eiselt@highstreet-technologies.com>2019-12-11 15:06:19 +0100
committerTimoney, Dan (dt5972) <dtimoney@att.com>2019-12-13 14:56:50 -0500
commit58f412ad18c1daf622e54ed36db6014f4e04f3f7 (patch)
tree91cc5f6630b4bf6a0ef12c1dee5a03fa2ebbb6cc /sdnr/wt/data-provider/provider/src/test
parent05e4277510b9947e3cdcbab8c7bb3846a4211af6 (diff)
Add data-provider
data-provider and change to avoid heap overflow Issue-ID: SDNC-994 Signed-off-by: herbert <herbert.eiselt@highstreet-technologies.com> Change-Id: Ifcc6ce1198442e4b48fc08ba71108cfd5b5ca8aa
Diffstat (limited to 'sdnr/wt/data-provider/provider/src/test')
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java98
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java22
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java137
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java195
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/log4j.properties12
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/log4j2.xml17
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties6
7 files changed, 487 insertions, 0 deletions
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java
new file mode 100644
index 000000000..e87ef9d9b
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.AboutHttpServlet;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class TestAbout {
+
+ @Test
+ public void testReadmeRequest() throws IOException, ServletException {
+ AboutHelperServlet servlet =new AboutHelperServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ when(request.getRequestURI()).thenReturn("/about");
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(response.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(request,response);
+ verify(response).setStatus(200);
+ verify(response).setContentType("text/plain");
+ System.out.println(out.getBuffer().toString());
+ assertTrue(out.getBuffer().length()>0);
+ }
+
+ @Test
+ public void testReadmeResourceRequest() throws IOException, ServletException {
+ AboutHelperServlet servlet =new AboutHelperServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ when(request.getRequestURI()).thenReturn("/about/test.bmp");
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(response.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(request,response);
+ verify(response).setStatus(200);
+ verify(response).setContentType("image/bmp");
+ assertTrue(out.size()>0);
+ }
+
+
+ private class AboutHelperServlet extends AboutHttpServlet{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java
new file mode 100644
index 000000000..51fe76d92
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java
@@ -0,0 +1,22 @@
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.QueryByFilter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Filter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.FilterBuilder;
+
+public class TestFilterConversion {
+
+ private static final String PROPERTY = "node-id";
+
+ @Test
+ public void testQuestionMark() {
+ List<Filter> filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build());
+ QueryBuilder query = QueryByFilter.fromFilter(filters );
+ System.out.println(query.toJSON());
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java
new file mode 100644
index 000000000..c32149ba5
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.json.JSONObject;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.QueryByFilter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Filter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.FilterBuilder;
+
+public class TestTimestampFilter {
+
+
+
+ @Test
+ public void testTimestampRange() {
+ final String PROPERTY_TIMESTAMP = "timestamp";
+ List<Filter> filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2017*").build());
+ QueryBuilder query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2017-01-01T00:00:00.0Z", "2018-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2000-01-01T00:00:00.0Z", "3000-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("20*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2000-01-01T00:00:00.0Z", "2100-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("205*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2060-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-1*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-11-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-11-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-0*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-10-10T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-02*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-02T00:00:00.0Z", "2050-10-03T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T00:00:00.0Z", "2050-10-15T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T00:00:00.0Z", "2050-10-15T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T1*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T10:00:00.0Z", "2050-10-14T20:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:00:00.0Z", "2050-10-14T13:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:00:00.0Z", "2050-10-14T13:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:4*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:40:00.0Z", "2050-10-14T12:50:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:00.0Z", "2050-10-14T12:43:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:00.0Z", "2050-10-14T12:43:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:5*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:50.0Z", "2050-10-14T12:43:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:56*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:56.0Z", "2050-10-14T12:42:57.0Z");
+ }
+ private void assertRange(JSONObject rangeQuery,String property,String lower,String upper) {
+ System.out.println("==test for "+rangeQuery.toString());
+ assertTrue(rangeQuery.has("range"));
+ assertTrue(rangeQuery.getJSONObject("range").has(property));
+ JSONObject o=rangeQuery.getJSONObject("range").getJSONObject(property);
+ assertNotNull(o);
+ assertTrue(o.has("lt"));
+ assertEquals(upper, o.getString("lt"));
+ assertTrue(o.has("gte"));
+ assertEquals(lower, o.getString("gte"));
+ System.out.println("succeeded");
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
new file mode 100644
index 000000000..c911100ef
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.attribute.PosixFilePermission;
+import java.nio.file.attribute.PosixFilePermissions;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Comparator;
+import java.util.EnumSet;
+import java.util.Set;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.YangFileProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.YangFilename;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.YangSchemaHttpServlet;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class TestYangProvider {
+
+ private static final String TESTPATH = "cache/schema/";
+
+
+ @BeforeClass
+ public static void init() {
+ Set<PosixFilePermission> perms;
+ FileAttribute<?> attr;
+ perms = EnumSet.noneOf(PosixFilePermission.class);
+
+ perms.add(PosixFilePermission.OWNER_READ);
+ perms.add(PosixFilePermission.OWNER_WRITE);
+ perms.add(PosixFilePermission.OWNER_EXECUTE);
+
+ attr = PosixFilePermissions.asFileAttribute(perms);
+ try {
+ Files.createDirectories(new File(TESTPATH).toPath(),attr);
+ new File(TESTPATH+new YangFilename("module1","2010-01-01").getFilename()).createNewFile();
+ new File(TESTPATH+new YangFilename("module2","2010-01-01").getFilename()).createNewFile();
+ new File(TESTPATH+new YangFilename("module2","2010-04-01").getFilename()).createNewFile();
+ new File(TESTPATH+new YangFilename("module3","2010-01-01").getFilename()).createNewFile();
+ new File(TESTPATH+new YangFilename("module4","2010-05-01").getFilename()).createNewFile();
+ new File(TESTPATH+new YangFilename("module5","2010-01-11").getFilename()).createNewFile();
+ new File(TESTPATH+new YangFilename("module6","2010-01-01").getFilename()).createNewFile();
+ } catch (IOException | ParseException e) {
+
+ }
+ }
+ @AfterClass
+ public static void deinit() {
+ try {
+ Files.walk(new File("cache").toPath())
+ .sorted(Comparator.reverseOrder())
+ .map(Path::toFile)
+ .forEach(File::delete);
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+ }
+ @Test
+ public void testExisting() {
+ YangFileProvider provider= new YangFileProvider(TESTPATH);
+ assertTrue(provider.hasFileForModule("module1","2010-01-01"));
+ assertTrue(provider.hasFileForModule("module2"));
+ assertTrue(provider.hasFileForModule("module3"));
+ assertFalse(provider.hasFileForModule("module5","2010-01-01"));
+ }
+ @Test
+ public void testRevision() throws ParseException {
+ SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");
+ YangFileProvider provider= new YangFileProvider(TESTPATH);
+ YangFilename f1 = provider.getFileForModule("module1","2010-01-01");
+ assertEquals("module1",f1.getModule());
+ assertEquals(sdf.parse("2010-01-01"),f1.getRevision());
+ YangFilename f2 = provider.getFileForModule("module2");
+ assertEquals("module2",f2.getModule());
+ assertEquals(sdf.parse("2010-04-01"),f2.getRevision());
+ f2 = provider.getFileForModule("module2","2010-02-01");
+ assertEquals("module2",f2.getModule());
+ assertEquals(sdf.parse("2010-04-01"),f2.getRevision());
+ YangFilename f3 = provider.getFileForModule("module3");
+ assertEquals("module3",f3.getModule());
+ assertEquals(sdf.parse("2010-01-01"),f3.getRevision());
+ f3 = provider.getFileForModule("module3","2010-04-01");
+ assertNull(f3);
+ }
+ @Test
+ public void testServlet() throws IOException, ServletException {
+ HelpYangSchemaHttpServlet servlet = new HelpYangSchemaHttpServlet();
+ HttpServletRequest req = mock(HttpServletRequest.class);
+ HttpServletResponse resp = mock(HttpServletResponse.class);
+
+ when(req.getRequestURI()).thenReturn("/yang-schema/module1");
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(resp.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(req,resp);
+ verify(resp).setStatus(200);
+ verify(resp).setContentType("text/plain");
+
+ }
+ @Test
+ public void testServletBad() throws IOException, ServletException {
+ HelpYangSchemaHttpServlet servlet = new HelpYangSchemaHttpServlet();
+ HttpServletRequest req = mock(HttpServletRequest.class);
+ HttpServletResponse resp = mock(HttpServletResponse.class);
+
+ when(req.getRequestURI()).thenReturn("/yang-schema/module1/2020-01-01");
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(resp.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(req,resp);
+ verify(resp).sendError(HttpServletResponse.SC_NOT_FOUND);
+
+ }
+ @Test
+ public void testServletNear() throws IOException, ServletException {
+ HelpYangSchemaHttpServlet servlet = new HelpYangSchemaHttpServlet();
+ HttpServletRequest req = mock(HttpServletRequest.class);
+ HttpServletResponse resp = mock(HttpServletResponse.class);
+
+ when(req.getRequestURI()).thenReturn("/yang-schema/module2/2010-03-01");
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(resp.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(req,resp);
+ verify(resp).setStatus(200);
+ verify(resp).setContentType("text/plain");
+
+ }
+ private static class HelpYangSchemaHttpServlet extends YangSchemaHttpServlet{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+ }
+
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/log4j.properties b/sdnr/wt/data-provider/provider/src/test/resources/log4j.properties
new file mode 100644
index 000000000..142663bd2
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/log4j.properties
@@ -0,0 +1,12 @@
+log4j.rootLogger=INFO, out
+
+log4j.logger.org.apache.camel.impl.converter=WARN
+log4j.logger.org.apache.camel.management=WARN
+log4j.logger.org.apache.camel.impl.DefaultPackageScanClassResolver=WARN
+log4j.logger.org.springframework=ERROR
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/log4j2.xml b/sdnr/wt/data-provider/provider/src/test/resources/log4j2.xml
new file mode 100644
index 000000000..164e93f54
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/log4j2.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration package="log4j.test"
+ status="WARN">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Logger name="log4j.test.Log4jTest" level="debug">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Root level="trace">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration> \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties b/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties
new file mode 100644
index 000000000..a2f1e7e76
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties
@@ -0,0 +1,6 @@
+org.slf4j.simpleLogger.defaultLogLevel=debug
+org.slf4j.simpleLogger.showDateTime=true
+#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
+#org.slf4j.simpleLogger.showThreadName=true
+org.slf4j.simpleLogger.showLogName=true
+org.slf4j.simpleLogger.showShortLogName=false \ No newline at end of file