summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/database/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/database/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/database/src/test')
-rw-r--r--sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestConfig.java59
-rw-r--r--sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNetconfNodeBuilder.java56
-rw-r--r--sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNuMappings.java57
-rw-r--r--sdnr/wt/data-provider/database/src/test/resources/log4j2.xml17
-rw-r--r--sdnr/wt/data-provider/database/src/test/resources/simplelogger.properties6
5 files changed, 195 insertions, 0 deletions
diff --git a/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestConfig.java b/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestConfig.java
new file mode 100644
index 000000000..ecc7edf6a
--- /dev/null
+++ b/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestConfig.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * ============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.database.test;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.database.config.EsConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestConfig {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TestConfig.class);
+
+ private static final String TESTFILENAME = "testconfig.properties";
+
+ @After
+ @Before
+ public void afterAndBefore() {
+ File f=new File(TESTFILENAME);
+ if(f.exists()) {
+ LOG.info("Remove {}", f.getAbsolutePath());
+ f.delete();
+ }
+ }
+ @Test
+ public void test() {
+ ConfigurationFileRepresentation configuration=new ConfigurationFileRepresentation(TESTFILENAME);
+
+ EsConfig esConfig = new EsConfig(configuration);
+ LOG.info("Defaultconfiguration: {}", esConfig.toString());
+ assertEquals("http", esConfig.getHosts()[0].protocol.getValue());
+ assertEquals(9200, esConfig.getHosts()[0].port);
+ assertEquals("sdnrdb", esConfig.getHosts()[0].hostname);
+
+ }
+
+}
diff --git a/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNetconfNodeBuilder.java b/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNetconfNodeBuilder.java
new file mode 100644
index 000000000..9237aaf1f
--- /dev/null
+++ b/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNetconfNodeBuilder.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * ============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.database.test;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder;
+
+public class TestNetconfNodeBuilder {
+
+ @SuppressWarnings("deprecation")
+ //@Test
+ public void test() {
+
+ NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
+
+ LoginPasswordBuilder loginPasswordBuilder = new LoginPasswordBuilder();
+ loginPasswordBuilder.setUsername("myTestUsername");
+ loginPasswordBuilder.setPassword("myTestPassword");
+ netconfNodeBuilder.setCredentials(loginPasswordBuilder.build());
+
+ NetconfNode netconfNode = netconfNodeBuilder.build();
+ System.out.println(netconfNode);
+
+ Credentials credentials = netconfNode.getCredentials();
+ System.out.println("Class: "+credentials.getClass()+"\nContent: "+credentials);
+
+ if (credentials instanceof LoginPassword) {
+ LoginPassword loginPassword = (LoginPassword)credentials;
+ System.out.println("User: "+loginPassword.getUsername()+" Password"+loginPassword.getPassword());
+ } else {
+ System.out.println("Not expected class");
+ }
+ }
+
+}
diff --git a/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNuMappings.java b/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNuMappings.java
new file mode 100644
index 000000000..b7d0620ca
--- /dev/null
+++ b/sdnr/wt/data-provider/database/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/test/TestNuMappings.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * ============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.database.test;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import java.io.IOException;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.yangtools.YangToolsMapper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Faultcurrent;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType;
+
+public class TestNuMappings {
+
+ @Test
+ public void test33() {
+ Faultcurrent c = new FaultcurrentBuilder().setSeverity(SeverityType.Critical).build();
+ YangToolsMapper mapper = new YangToolsMapper();
+ try {
+ System.out.println(mapper.writeValueAsString(c)+"<=>"+SeverityType.Critical.getName());
+ } catch (JsonProcessingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ Faultcurrent f=mapper.readValue( "{\"severity\":\"Critical\"}", Faultcurrent.class);
+ System.out.println(f);
+ System.out.println(mapper.writeValueAsString(f));
+ } catch (JsonParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (JsonMappingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sdnr/wt/data-provider/database/src/test/resources/log4j2.xml b/sdnr/wt/data-provider/database/src/test/resources/log4j2.xml
new file mode 100644
index 000000000..164e93f54
--- /dev/null
+++ b/sdnr/wt/data-provider/database/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/database/src/test/resources/simplelogger.properties b/sdnr/wt/data-provider/database/src/test/resources/simplelogger.properties
new file mode 100644
index 000000000..a2f1e7e76
--- /dev/null
+++ b/sdnr/wt/data-provider/database/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