aboutsummaryrefslogtreecommitdiffstats
path: root/datarouter-prov/src/test
diff options
context:
space:
mode:
authorefiacor <fiachra.corcoran@est.tech>2019-07-23 16:22:03 +0000
committerefiacor <fiachra.corcoran@est.tech>2019-07-23 16:22:03 +0000
commitf20778ffa99aa9c6f30a0f84112a5392b259ea63 (patch)
tree7c58a50f8b327a5f7f9580dbfb97fe24532ed777 /datarouter-prov/src/test
parentd6302cb0b3db8043598e8b6bc3dc5ed436f848cb (diff)
More unit test coverage and code cleanup
Change-Id: Ie28b50803c60cc79221a5c8aa08cf029f7a8486c Issue-ID: DMAAP-1226 Signed-off-by: efiacor <fiachra.corcoran@est.tech>
Diffstat (limited to 'datarouter-prov/src/test')
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java28
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java90
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java96
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/DbTest.java61
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObjectTest.java182
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTaskTest.java87
-rwxr-xr-xdatarouter-prov/src/test/resources/META-INF/persistence.xml14
-rwxr-xr-xdatarouter-prov/src/test/resources/create.sql4
-rwxr-xr-xdatarouter-prov/src/test/resources/h2Database.properties1
-rwxr-xr-xdatarouter-prov/src/test/resources/sql_init_01.sql146
10 files changed, 565 insertions, 144 deletions
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java
index edf9ef52..5239b800 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java
@@ -44,6 +44,7 @@ import javax.servlet.http.HttpServletResponse;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
import org.apache.commons.lang3.reflect.FieldUtils;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -54,6 +55,7 @@ import org.mockito.Mock;
import org.onap.dmaap.datarouter.provisioning.beans.Deleteable;
import org.onap.dmaap.datarouter.provisioning.beans.Insertable;
import org.onap.dmaap.datarouter.provisioning.beans.LogRecord;
+import org.onap.dmaap.datarouter.provisioning.beans.Parameters;
import org.onap.dmaap.datarouter.provisioning.beans.Updateable;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
@@ -277,6 +279,16 @@ public class InternalServletTest extends DrServletTestBase {
}
@Test
+ public void Given_Request_Is_HTTP_DELETE_With_LogRollInterval_Api_In_Endpoint_Request_Succeeds() {
+ when(request.getPathInfo()).thenReturn("/api/LOGROLL_INTERVAL");
+ internalServlet.doDelete(request, response);
+ verify(response).setStatus(eq(HttpServletResponse.SC_OK));
+ Parameters p1 = Parameters.getParameter("NODES");
+ Assert.assertEquals("{\"keyname\":\"NODES\",\"value\":\"dmaap-dr-node\"}", p1.asJSONObject().toString());
+ Assert.assertEquals("PARAM: keyname=NODES, value=dmaap-dr-node", p1.toString());
+ }
+
+ @Test
public void Given_Request_Is_HTTP_DELETE_With_Api_In_Endpoint_And_Delete_Fails_Then_Internal_Server_Error_Is_Generated()
throws Exception {
when(request.getPathInfo()).thenReturn("/api/NODES");
@@ -332,8 +344,7 @@ public class InternalServletTest extends DrServletTestBase {
}
@Test
- public void Given_Request_Is_HTTP_POST_To_Logs_And_Content_Header_Is_Not_Supported_Type_Then_Unsupported_Media_Type_Response_Is_Generated()
- throws Exception {
+ public void Given_Request_Is_HTTP_POST_To_Logs_And_Content_Header_Is_Not_Supported_Type_Then_Unsupported_Media_Type_Response_Is_Generated() {
when(request.getHeader("Content-Type")).thenReturn("stub_contentType");
when(request.getPathInfo()).thenReturn("/logs/");
internalServlet.doPost(request, response);
@@ -341,8 +352,7 @@ public class InternalServletTest extends DrServletTestBase {
}
@Test
- public void Given_Request_Is_HTTP_POST_To_Logs_And_Content_Encoding_Is_Not_Supported_Type_Then_Unsupported_Media_Type_Response_Is_Generated()
- throws Exception {
+ public void Given_Request_Is_HTTP_POST_To_Logs_And_Content_Encoding_Is_Not_Supported_Type_Then_Unsupported_Media_Type_Response_Is_Generated() {
when(request.getHeader("Content-Encoding")).thenReturn("not-supported");
when(request.getPathInfo()).thenReturn("/logs/");
internalServlet.doPost(request, response);
@@ -364,8 +374,7 @@ public class InternalServletTest extends DrServletTestBase {
}
@Test
- public void Given_Request_Is_HTTP_POST_To_Drlogs_And_Then_Unsupported_Media_Type_Response_Is_Generated()
- throws Exception {
+ public void Given_Request_Is_HTTP_POST_To_Drlogs_And_Then_Unsupported_Media_Type_Response_Is_Generated() {
when(request.getHeader("Content-Type")).thenReturn("stub_contentType");
when(request.getPathInfo()).thenReturn("/drlogs/");
internalServlet.doPost(request, response);
@@ -384,6 +393,13 @@ public class InternalServletTest extends DrServletTestBase {
}
@Test
+ public void Given_Request_Is_HTTP_POST_To_Api_And_Request_Succeeds() {
+ when(request.getPathInfo()).thenReturn("/api/NEW_PARAM?val=blah");
+ internalServlet.doPost(request, response);
+ verify(response).setStatus(eq(HttpServletResponse.SC_OK));
+ }
+
+ @Test
public void Given_Request_Is_HTTP_POST_With_Incorrect_Endpoint_Then_Not_Found_Error_Is_Generated()
throws Exception {
when(request.getPathInfo()).thenReturn("/incorrect/");
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java
new file mode 100644
index 00000000..7ef52ff8
--- /dev/null
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dmaap.datarouter.provisioning.beans;
+
+import java.sql.SQLException;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.dmaap.datarouter.provisioning.utils.DB;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class EgressRouteTest {
+
+ private EgressRoute egressRoute;
+
+ private static EntityManagerFactory emf;
+ private static EntityManager em;
+ private DB db;
+
+ @BeforeClass
+ public static void init() {
+ emf = Persistence.createEntityManagerFactory("dr-unit-tests");
+ em = emf.createEntityManager();
+ System.setProperty(
+ "org.onap.dmaap.datarouter.provserver.properties",
+ "src/test/resources/h2Database.properties");
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ em.clear();
+ em.close();
+ emf.close();
+ }
+ @Before
+ public void setUp() throws Exception {
+ db = new DB();
+ egressRoute = new EgressRoute(2, 1);
+ }
+
+ @Test
+ public void Verify_NetworkRoute_Is_Added_Successfully() throws SQLException {
+ Assert.assertEquals(1, EgressRoute.getAllEgressRoutes().size());
+ egressRoute.doInsert(db.getConnection());
+ Assert.assertEquals(2, EgressRoute.getAllEgressRoutes().size());
+ egressRoute.doDelete(db.getConnection());
+ }
+
+ @Test
+ public void Verify_NetworkRoute_Is_Removed_Successfully() throws SQLException {
+ Assert.assertEquals(1, EgressRoute.getAllEgressRoutes().size());
+ EgressRoute egressRoute = new EgressRoute(1, 1);
+ egressRoute.doDelete(db.getConnection());
+ Assert.assertEquals(0, EgressRoute.getAllEgressRoutes().size());
+ }
+
+ @Test
+ public void Verify_NetworkRoute_Is_Updated_Successfully() throws SQLException {
+ EgressRoute egressRoute = new EgressRoute(1, 1);
+ EgressRoute egressRoute1 = new EgressRoute(1, 1);
+ Assert.assertEquals(egressRoute.hashCode(), egressRoute1.hashCode());
+ Assert.assertEquals(egressRoute, egressRoute1);
+ Assert.assertEquals(egressRoute.toString(), egressRoute1.toString());
+ }
+} \ No newline at end of file
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java
new file mode 100644
index 00000000..df786b55
--- /dev/null
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java
@@ -0,0 +1,96 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dmaap.datarouter.provisioning.beans;
+
+import java.sql.SQLException;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.dmaap.datarouter.provisioning.utils.DB;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class NetworkRouteTest {
+
+ private NetworkRoute networkRoute;
+
+ private static EntityManagerFactory emf;
+ private static EntityManager em;
+ private DB db;
+
+ @BeforeClass
+ public static void init() {
+ emf = Persistence.createEntityManagerFactory("dr-unit-tests");
+ em = emf.createEntityManager();
+ System.setProperty(
+ "org.onap.dmaap.datarouter.provserver.properties",
+ "src/test/resources/h2Database.properties");
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ em.clear();
+ em.close();
+ emf.close();
+ }
+ @Before
+ public void setUp() throws Exception {
+ db = new DB();
+ networkRoute = new NetworkRoute("node01.","node03.","node02.");
+ }
+
+ @Test
+ public void Verify_NetworkRoute_Is_Added_Successfully() throws SQLException {
+ Assert.assertEquals(1, NetworkRoute.getAllNetworkRoutes().size());
+ networkRoute.doInsert(db.getConnection());
+ Assert.assertEquals(2, NetworkRoute.getAllNetworkRoutes().size());
+ networkRoute.doDelete(db.getConnection());
+ }
+
+ @Test
+ public void Verify_NetworkRoute_Is_Removed_Successfully() throws SQLException {
+ Assert.assertEquals(1, NetworkRoute.getAllNetworkRoutes().size());
+ NetworkRoute networkRoute = new NetworkRoute("stub_from.", "stub_to.");
+ networkRoute.doDelete(db.getConnection());
+ Assert.assertEquals(0, NetworkRoute.getAllNetworkRoutes().size());
+ }
+
+ @Test
+ public void Verify_NetworkRoute_Is_Updated_Successfully() throws SQLException {
+ NetworkRoute networkRoute = new NetworkRoute("stub_from.", "stub_to.", "node02.");
+ networkRoute.doUpdate(db.getConnection());
+ //Assert.assertTrue(NetworkRoute.getAllNetworkRoutes().contains(networkRoute));
+ for (NetworkRoute net :
+ NetworkRoute.getAllNetworkRoutes()) {
+ Assert.assertEquals(5, net.getVianode());
+ }
+ NetworkRoute networkRoute1 = new NetworkRoute("stub_from.", "stub_to.", "node02.");
+ Assert.assertEquals(networkRoute.hashCode(), networkRoute1.hashCode());
+ Assert.assertEquals(networkRoute, networkRoute1);
+ Assert.assertEquals(networkRoute.toString(), networkRoute1.toString());
+ }
+} \ No newline at end of file
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/DbTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/DbTest.java
new file mode 100644
index 00000000..056469a8
--- /dev/null
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/DbTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dmaap.datarouter.provisioning.utils;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class DbTest {
+ private static EntityManagerFactory emf;
+ private static EntityManager em;
+
+ private DB db = new DB();
+
+ @BeforeClass
+ public static void init() {
+ emf = Persistence.createEntityManagerFactory("db-unit-tests");
+ em = emf.createEntityManager();
+ System.setProperty(
+ "org.onap.dmaap.datarouter.provserver.properties",
+ "src/test/resources/h2Database.properties");
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ em.clear();
+ em.close();
+ emf.close();
+ }
+
+ @Test
+ public void Verify_DB_Is_Initialised_Successfully() {
+ Assert.assertTrue(db.runRetroFits());
+ }
+
+}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObjectTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObjectTest.java
index 4dd1b471..ae81f15d 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObjectTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/LOGJSONObjectTest.java
@@ -24,6 +24,7 @@
package org.onap.dmaap.datarouter.provisioning.utils;
import java.io.CharArrayWriter;
+import java.io.IOException;
import java.io.Writer;
import org.json.JSONArray;
import org.json.JSONTokener;
@@ -50,8 +51,7 @@ public class LOGJSONObjectTest {
}
@Test
- public void Construct_JSONObject_From_A_Subset_Of_Values_From_Another_JSONObject()
- throws Exception {
+ public void Construct_JSONObject_From_A_Subset_Of_Values_From_Another_JSONObject() {
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
map.put("key2", "value2");
@@ -63,48 +63,41 @@ public class LOGJSONObjectTest {
}
@Test
- public void Construct_JSONObject_From_A_JSONTokener()
- throws Exception {
+ public void Construct_JSONObject_From_A_JSONTokener() {
JSONTokener x = new JSONTokener("{\"key1\":\"value1\",\"key3\":\"value3\"}");
LOGJSONObject logJObject = new LOGJSONObject(x);
assertThat(logJObject.toString(), is("{\"key1\":\"value1\",\"key3\":\"value3\"}"));
}
@Test
- public void Construct_JSONObject_From_A_Bean_Object_And_Populate_From_Its_Getters_And_Setters()
- throws Exception {
+ public void Construct_JSONObject_From_A_Bean_Object_And_Populate_From_Its_Getters_And_Setters() {
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
map.put("key2", "value2");
map.put("key3", "value3");
- Object bean = map;
- LOGJSONObject logJObject = new LOGJSONObject(bean);
+ LOGJSONObject logJObject = new LOGJSONObject((Object) map);
assertThat(logJObject.toString(), is("{\"empty\":false}"));
}
@Test
- public void Given_Method_Is_Accumulate_And_Value_Is_Valid_Put_Value_Into_New_JSONArray()
- throws Exception {
+ public void Given_Method_Is_Accumulate_And_Value_Is_Valid_Put_Value_Into_New_JSONArray() {
Map<String, Object> map = new HashMap<>();
map.put("key", 3);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
logJObject.accumulate(s, null);
assertThat(logJObject.get("key").toString(), is("[3,null]"));
}
@Test
- public void Given_Method_Is_Accumulate_And_Value_Is_Null_Dont_Add_Key_Value_Pair()
- throws Exception {
+ public void Given_Method_Is_Accumulate_And_Value_Is_Null_Dont_Add_Key_Value_Pair() {
String s = "key";
logJO.accumulate(s, null);
assertThat(logJO.has("key"), is(false));
}
@Test
- public void Given_Method_Is_Append_And_Value_Is_Null_Append_New_Value()
- throws Exception {
+ public void Given_Method_Is_Append_And_Value_Is_Null_Append_New_Value() {
String s = "key";
double d = 2.0;
logJO.append(s, d);
@@ -113,417 +106,334 @@ public class LOGJSONObjectTest {
@Test
- public void Given_Method_Is_DoubleToString_And_Value_Is_NaN_Return_Null()
- throws Exception {
+ public void Given_Method_Is_DoubleToString_And_Value_Is_NaN_Return_Null() {
double d = 2.0;
- assertThat(logJO.doubleToString(d), is("2"));
+ assertThat(LOGJSONObject.doubleToString(d), is("2"));
}
@Test
- public void Given_Method_Is_GetBoolean_And_Value_Is_False_Return_False()
- throws Exception {
+ public void Given_Method_Is_GetBoolean_And_Value_Is_False_Return_False() {
Map<String, Object> map = new HashMap<>();
map.put("key", false);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.getBoolean(s), is(false));
}
@Test
- public void Given_Method_Is_GetBoolean_And_Value_Is_True_Return_True()
- throws Exception {
+ public void Given_Method_Is_GetBoolean_And_Value_Is_True_Return_True() {
Map<String, Object> map = new HashMap<>();
map.put("key", true);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.getBoolean(s), is(true));
}
@Test
- public void Given_Method_Is_GetDouble_And_Value_Is_A_Double_Return_Value()
- throws Exception {
+ public void Given_Method_Is_GetDouble_And_Value_Is_A_Double_Return_Value() {
Map<String, Object> map = new HashMap<>();
map.put("key", 2.0);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.getDouble(s), is(2.0));
}
@Test
- public void Given_Method_Is_GetInt_And_Value_Is_An_Int_Return_Value()
- throws Exception {
+ public void Given_Method_Is_GetInt_And_Value_Is_An_Int_Return_Value() {
Map<String, Object> map = new HashMap<>();
map.put("key", 3);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.getInt(s), is(3));
}
@Test
- public void Given_Method_Is_GetJSONArray_And_Value_Is_A_JSONArray_Return_Value()
- throws Exception {
+ public void Given_Method_Is_GetJSONArray_And_Value_Is_A_JSONArray_Return_Value() {
JSONArray jA = new JSONArray();
Map<String, Object> map = new HashMap<>();
map.put("key", jA);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.getJSONArray(s), is(jA));
}
@Test
- public void Given_Method_Is_GetJSONObject_And_Value_Is_A_JSONObject_Return_Value()
- throws Exception {
+ public void Given_Method_Is_GetJSONObject_And_Value_Is_A_JSONObject_Return_Value() {
LOGJSONObject logJObj = new LOGJSONObject();
logJObj.put("stub_key", 1);
Map<String, Object> map = new HashMap<>();
map.put("key", logJObj);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.getJSONObject(s), is(logJObj));
}
@Test
- public void Given_Method_Is_GetLong_And_Value_Is_A_Long_Return_Value()
- throws Exception {
+ public void Given_Method_Is_GetLong_And_Value_Is_A_Long_Return_Value() {
long l = 5;
Map<String, Object> map = new HashMap<>();
map.put("key", l);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.getLong(s), is(5L));
}
@Test
- public void Given_Method_Is_getNames_And_Value_Is_A_LOGJSONObject_Return_StringArray()
- throws Exception {
+ public void Given_Method_Is_getNames_And_Value_Is_A_LOGJSONObject_Return_StringArray() {
LOGJSONObject logJObj = new LOGJSONObject();
logJObj.put("name1", "elyk");
String[] sArray = new String[logJObj.length()];
sArray[0] = "name1";
- LOGJSONObject logJObject = new LOGJSONObject();
-
- assertThat(logJObject.getNames(logJObj), is(sArray));
+ assertThat(LOGJSONObject.getNames(logJObj), is(sArray));
}
@Test
- public void Given_Method_Is_GetString_And_Value_Is_A_String_Return_Value()
- throws Exception {
+ public void Given_Method_Is_GetString_And_Value_Is_A_String_Return_Value() {
String val = "value";
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.getString(s), is("value"));
}
@Test
- public void Given_Method_Is_Increment_And_Value_Is_Null_Put_Defualt_Value()
- throws Exception {
+ public void Given_Method_Is_Increment_And_Value_Is_Null_Put_Defualt_Value() {
Map<String, Object> mapResult = new HashMap<>();
mapResult.put("key", 1);
LOGJSONObject logJObjectResult = new LOGJSONObject(mapResult);
-
String val = null;
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
logJObject.increment(s);
assertThat(logJObject.get("key"), is(logJObjectResult.get("key")));
}
@Test
- public void Given_Method_Is_Increment_And_Value_Is_An_Int_Put_Value_Plus_One()
- throws Exception {
+ public void Given_Method_Is_Increment_And_Value_Is_An_Int_Put_Value_Plus_One() {
Map<String, Object> mapResult = new HashMap<>();
mapResult.put("key", 3);
LOGJSONObject logJObjectResult = new LOGJSONObject(mapResult);
-
int val = 2;
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
logJObject.increment(s);
assertThat(logJObject.get("key"), is(logJObjectResult.get("key")));
}
@Test
- public void Given_Method_Is_Increment_And_Value_Is_A_Long_Put_Value_Plus_One()
- throws Exception {
+ public void Given_Method_Is_Increment_And_Value_Is_A_Long_Put_Value_Plus_One() {
Map<String, Object> mapResult = new HashMap<>();
mapResult.put("key", 4L);
LOGJSONObject logJObjectResult = new LOGJSONObject(mapResult);
-
long val = 3;
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
logJObject.increment(s);
assertThat(logJObject.get("key"), is(logJObjectResult.get("key")));
}
@Test
- public void Given_Method_Is_Increment_And_Value_Is_A_Double_Put_Value_Plus_One()
- throws Exception {
+ public void Given_Method_Is_Increment_And_Value_Is_A_Double_Put_Value_Plus_One() {
Map<String, Object> mapResult = new HashMap<>();
mapResult.put("key", 5.0);
LOGJSONObject logJObjectResult = new LOGJSONObject(mapResult);
-
double val = 4.0;
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
logJObject.increment(s);
assertThat(logJObject.get("key"), is(logJObjectResult.get("key")));
}
@Test
- public void Given_Method_Is_Increment_And_Value_Is_A_Float_Put_Value_Plus_One()
- throws Exception {
+ public void Given_Method_Is_Increment_And_Value_Is_A_Float_Put_Value_Plus_One() {
Map<String, Object> mapResult = new HashMap<>();
mapResult.put("key", 5.0);
LOGJSONObject logJObjectResult = new LOGJSONObject(mapResult);
-
float val = 4.0f;
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
logJObject.increment(s);
assertThat(logJObject.get("key"), is(logJObjectResult.get("key")));
}
@Test
- public void Given_Method_Is_Names_And_Object_Contains_Keys_Put_Keys_Into_New_JSONArray()
- throws Exception {
+ public void Given_Method_Is_Names_And_Object_Contains_Keys_Put_Keys_Into_New_JSONArray() {
JSONArray ja = new JSONArray();
ja.put("key");
-
String val = "value";
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
- String s = "key";
assertThat(logJObject.names().get(0), is(ja.get(0)));
}
@Test
- public void Given_Method_Is_NumberToString_And_Number_is_Not_Null_Return_Reformatted_Number_As_String()
- throws Exception {
+ public void Given_Method_Is_NumberToString_And_Number_is_Not_Null_Return_Reformatted_Number_As_String() {
Number num = 3.0;
-
String val = "value";
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.numberToString(num), is("3"));
}
@Test
- public void Given_Method_Is_OptBoolean_And_Value_is_Boolean_Return_Value()
- throws Exception {
+ public void Given_Method_Is_OptBoolean_And_Value_is_Boolean_Return_Value() {
boolean val = true;
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.optBoolean(s, false), is(true));
}
@Test
- public void Given_Method_Is_OptBoolean_And_Value_is_Not_Boolean_Return_Default_Value()
- throws Exception {
+ public void Given_Method_Is_OptBoolean_And_Value_is_Not_Boolean_Return_Default_Value() {
String val = "not_boolean";
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.optBoolean(s, false), is(false));
}
@Test
- public void Given_Method_Is_OptDouble_And_Value_is_Double_Return_Value()
- throws Exception {
+ public void Given_Method_Is_OptDouble_And_Value_is_Double_Return_Value() {
double val = 2.0;
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.optDouble(s, 0.0), is(2.0));
}
@Test
- public void Given_Method_Is_OptDouble_And_Value_is_Not_Double_Return_Default_Value()
- throws Exception {
+ public void Given_Method_Is_OptDouble_And_Value_is_Not_Double_Return_Default_Value() {
String val = "not_double";
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.optDouble(s, 0.0), is(0.0));
}
@Test
- public void Given_Method_Is_OptInt_And_Value_is_Int_Return_Value()
- throws Exception {
+ public void Given_Method_Is_OptInt_And_Value_is_Int_Return_Value() {
int val = 1;
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.optInt(s, 0), is(1));
}
@Test
- public void Given_Method_Is_OptInt_And_Value_Is_Null_Return_Default_Value()
- throws Exception {
+ public void Given_Method_Is_OptInt_And_Value_Is_Null_Return_Default_Value() {
Map<String, Object> map = new HashMap<>();
map.put("key", null);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.optInt(s, 0), is(0));
}
@Test
- public void Given_Method_Is_OptLong_And_Value_is_Long_Return_Value()
- throws Exception {
+ public void Given_Method_Is_OptLong_And_Value_is_Long_Return_Value() {
long val = 4;
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.optLong(s, 0), is(4L));
}
@Test
- public void Given_Method_Is_OptLong_And_Value_is_Not_Long_Return_Default_Value()
- throws Exception {
+ public void Given_Method_Is_OptLong_And_Value_is_Not_Long_Return_Default_Value() {
Map<String, Object> map = new HashMap<>();
map.put("key", null);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.optLong(s, 0), is(0L));
}
@Test
- public void Given_Method_Is_OptString_And_Value_is_String_Return_Value()
- throws Exception {
+ public void Given_Method_Is_OptString_And_Value_is_String_Return_Value() {
String val = "value";
Map<String, Object> map = new HashMap<>();
map.put("key", val);
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.optString(s, "default_value"), is("value"));
}
@Test
- public void Given_Method_Is_putOnce_And_KeyValuePair_Does_Not_Exist_In_logJObject_Put_KeyValuePair_Into_logJObject()
- throws Exception {
+ public void Given_Method_Is_putOnce_And_KeyValuePair_Does_Not_Exist_In_logJObject_Put_KeyValuePair_Into_logJObject() {
String val = "value";
Map<String, Object> map = new HashMap<>();
LOGJSONObject logJObject = new LOGJSONObject(map);
-
String s = "key";
assertThat(logJObject.putOnce(s, val).get("key"), is("value"));
}
@Test
- public void Given_Method_Is_StringToValue_And_Value_Is_Number_Return_Number()
- throws Exception {
+ public void Given_Method_Is_StringToValue_And_Value_Is_Number_Return_Number() {
String val = "312";
Map<String, Object> map = new HashMap<>();
- LOGJSONObject logJObject = new LOGJSONObject(map);
-
- assertThat(logJObject.stringToValue(val), is(312));
+ assertThat(LOGJSONObject.stringToValue(val), is(312));
}
@Test
- public void Given_Method_Is_ToJSONArray_And_KeyValue_Exists_Return_Value_Array()
- throws Exception {
+ public void Given_Method_Is_ToJSONArray_And_KeyValue_Exists_Return_Value_Array() {
JSONArray names = new JSONArray();
Map<String, Object> map = new HashMap<>();
map.put("name", "value");
names.put("name");
LOGJSONObject logJObject = new LOGJSONObject(map);
-
assertThat(logJObject.toJSONArray(names).get(0), is("value"));
}
@Test
- public void Given_Method_Is_ValueToString_And_Value_Is_JSONArray_Return_Value_To_String()
- throws Exception {
+ public void Given_Method_Is_ValueToString_And_Value_Is_JSONArray_Return_Value_To_String() {
JSONArray val = new JSONArray();
- Map<String, Object> map = new HashMap<>();
- map.put("key", "value");
val.put("value");
- LOGJSONObject logJObject = new LOGJSONObject(map);
-
- assertThat(logJObject.valueToString(val), is("[\"value\"]"));
+ assertThat(LOGJSONObject.valueToString(val), is("[\"value\"]"));
}
@Test
- public void Given_Method_Is_writeValue_And_Value_IS_Not_Null_Return_Writer_With_Value()
- throws Exception {
+ public void Given_Method_Is_writeValue_And_Value_IS_Not_Null_Return_Writer_With_Value() throws IOException {
Writer writer = new CharArrayWriter();
String val = "value";
- Map<String, Object> map = new HashMap<>();
- map.put("key", "value");
- LOGJSONObject logJObject = new LOGJSONObject(map);
-
- assertThat(logJObject.writeValue(writer, val, 3, 1).toString(), is("\"value\""));
+ assertThat(LOGJSONObject.writeValue(writer, val, 3, 1).toString(), is("\"value\""));
}
@Test
- public void Given_Method_Is_write_And_Length_Of_logJObject_Is_One_Write_Value_With_Indent()
- throws Exception {
+ public void Given_Method_Is_write_And_Length_Of_logJObject_Is_One_Write_Value_With_Indent() {
Writer writer = new CharArrayWriter();
- String val = "value";
Map<String, Object> map = new HashMap<>();
map.put("key", "value");
LOGJSONObject logJObject = new LOGJSONObject(map);
-
assertThat(logJObject.write(writer, 3, 1).toString(), is("{\"key\": \"value\"}"));
}
@Test
- public void Given_Method_Is_write_And_Length_Of_logJObject_Is_Not_One_Or_Zero_Write_Value_With_New_Indent()
- throws Exception {
+ public void Given_Method_Is_write_And_Length_Of_logJObject_Is_Not_One_Or_Zero_Write_Value_With_New_Indent() {
Writer writer = new CharArrayWriter();
- String val = "value";
Map<String, Object> map = new HashMap<>();
map.put("key", "value");
map.put("key1", "value1");
LOGJSONObject logJObject = new LOGJSONObject(map);
-
assertThat(logJObject.write(writer, 3, 1).toString(), is("{\n \"key1\": \"value1\",\n \"key\": \"value\"\n }"));
}
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTaskTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTaskTest.java
new file mode 100644
index 00000000..604b4c0a
--- /dev/null
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTaskTest.java
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dmaap.datarouter.provisioning.utils;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Files;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class PurgeLogDirTaskTest {
+
+ private static EntityManagerFactory emf;
+ private static EntityManager em;
+ private PurgeLogDirTask purgeLogDirTask = new PurgeLogDirTask();
+ private File testLog;
+
+ @Before
+ public void setUp() throws Exception {
+ testLog = new File(System.getProperty("user.dir") + "/src/test/resources/IN.test_prov_logs");
+ prepFile(testLog);
+ }
+
+ @After
+ public void tearDown() throws IOException {
+ Files.deleteIfExists(testLog.toPath());
+ }
+
+ @BeforeClass
+ public static void init() {
+ emf = Persistence.createEntityManagerFactory("dr-unit-tests");
+ em = emf.createEntityManager();
+ System.setProperty(
+ "org.onap.dmaap.datarouter.provserver.properties",
+ "src/test/resources/h2Database.properties");
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ em.clear();
+ em.close();
+ emf.close();
+ }
+
+ @Test
+ public void Verify_Logs_Are_Purged() {
+ purgeLogDirTask.run();
+ }
+
+ private void prepFile(File logFile) {
+ try (FileWriter fileWriter = new FileWriter(logFile)) {
+ fileWriter.write("2018-08-29-10-10-10-543.|LOG|1|1|https://dmaap-dr-prov:/url/file123|POST|application/vnd.att-dr.feed|100|mockType|file123|https://dmaap-dr-prov|user123|200|1|1|200|2|2\n");
+ }
+ catch (IOException e){
+ System.out.println(e.getMessage());
+ }
+ }
+}
diff --git a/datarouter-prov/src/test/resources/META-INF/persistence.xml b/datarouter-prov/src/test/resources/META-INF/persistence.xml
index 83813e23..2cb798af 100755
--- a/datarouter-prov/src/test/resources/META-INF/persistence.xml
+++ b/datarouter-prov/src/test/resources/META-INF/persistence.xml
@@ -18,4 +18,18 @@
</properties>
</persistence-unit>
+ <persistence-unit name="db-unit-tests" transaction-type="RESOURCE_LOCAL">
+ <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+ <properties>
+ <!-- Configuring JDBC properties -->
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:test1;DB_CLOSE_DELAY=-1"/>
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
+ <!-- Hibernate properties -->
+ <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.format_sql" value="false"/>
+ <property name="hibernate.show_sql" value="true"/>
+
+ </properties>
+ </persistence-unit>
</persistence>
diff --git a/datarouter-prov/src/test/resources/create.sql b/datarouter-prov/src/test/resources/create.sql
index a811847c..74b63242 100755
--- a/datarouter-prov/src/test/resources/create.sql
+++ b/datarouter-prov/src/test/resources/create.sql
@@ -180,10 +180,10 @@ INSERT INTO FEEDS(FEEDID, GROUPID, NAME, VERSION, DESCRIPTION, BUSINESS_DESCRIPT
VALUES (3, 1,'DeleteableAafFeed','v0.1', 'AAF Feed3 for testing', 'AAF Feed3 for testing', 'auth_class', 'pub','self_link','publish_link','subscribe_link','log_link','*');
insert into INGRESS_ROUTES(SEQUENCE, FEEDID , USERID, SUBNET, NODESET)
-VALUES (1,1,'user',null,2);
+VALUES (1,1,'user','172.100.0.0/25',2);
insert into INGRESS_ROUTES(SEQUENCE, FEEDID , USERID, SUBNET, NODESET)
-VALUES (2,1,'user',null,2);
+VALUES (2,1,'user2',null,2);
insert into NODESETS(SETID, NODEID)
VALUES (1,1);
diff --git a/datarouter-prov/src/test/resources/h2Database.properties b/datarouter-prov/src/test/resources/h2Database.properties
index cb472419..991fadc5 100755
--- a/datarouter-prov/src/test/resources/h2Database.properties
+++ b/datarouter-prov/src/test/resources/h2Database.properties
@@ -28,6 +28,7 @@ org.onap.dmaap.datarouter.provserver.isaddressauthenabled = true
org.onap.dmaap.datarouter.provserver.https.relaxation = false
org.onap.dmaap.datarouter.provserver.accesslog.dir = unit-test-logs
org.onap.dmaap.datarouter.provserver.spooldir = src/test/resources
+org.onap.dmaap.datarouter.provserver.dbscripts = src/test/resources
org.onap.dmaap.datarouter.provserver.localhost = 127.0.0.1
org.onap.dmaap.datarouter.provserver.passwordencryption = PasswordEncryptionKey#@$%^&1234#
diff --git a/datarouter-prov/src/test/resources/sql_init_01.sql b/datarouter-prov/src/test/resources/sql_init_01.sql
new file mode 100755
index 00000000..1ac74a03
--- /dev/null
+++ b/datarouter-prov/src/test/resources/sql_init_01.sql
@@ -0,0 +1,146 @@
+CREATE TABLE FEEDS (
+ FEEDID INT UNSIGNED NOT NULL PRIMARY KEY,
+ GROUPID INT(10) UNSIGNED NOT NULL DEFAULT 0,
+ NAME VARCHAR(256) NOT NULL,
+ VERSION VARCHAR(20) NULL,
+ DESCRIPTION VARCHAR(1000),
+ BUSINESS_DESCRIPTION VARCHAR(1000) DEFAULT NULL,
+ AUTH_CLASS VARCHAR(32) NOT NULL,
+ PUBLISHER VARCHAR(8) NOT NULL,
+ SELF_LINK VARCHAR(256),
+ PUBLISH_LINK VARCHAR(256),
+ SUBSCRIBE_LINK VARCHAR(256),
+ LOG_LINK VARCHAR(256),
+ DELETED BOOLEAN DEFAULT FALSE,
+ LAST_MOD TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ SUSPENDED BOOLEAN DEFAULT FALSE,
+ CREATED_DATE TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ AAF_INSTANCE VARCHAR(256)
+);
+
+CREATE TABLE FEED_ENDPOINT_IDS (
+ FEEDID INT UNSIGNED NOT NULL,
+ USERID VARCHAR(60) NOT NULL,
+ PASSWORD VARCHAR(100) NOT NULL
+);
+
+CREATE TABLE FEED_ENDPOINT_ADDRS (
+ FEEDID INT UNSIGNED NOT NULL,
+ ADDR VARCHAR(44) NOT NULL
+);
+
+CREATE TABLE SUBSCRIPTIONS (
+ SUBID INT UNSIGNED NOT NULL PRIMARY KEY,
+ FEEDID INT UNSIGNED NOT NULL,
+ GROUPID INT(10) UNSIGNED NOT NULL DEFAULT 0,
+ DELIVERY_URL VARCHAR(256),
+ FOLLOW_REDIRECTS TINYINT(1) NOT NULL DEFAULT 0,
+ DELIVERY_USER VARCHAR(60),
+ DELIVERY_PASSWORD VARCHAR(100),
+ DELIVERY_USE100 BOOLEAN DEFAULT FALSE,
+ METADATA_ONLY BOOLEAN DEFAULT FALSE,
+ SUBSCRIBER VARCHAR(8) NOT NULL,
+ SELF_LINK VARCHAR(256),
+ LOG_LINK VARCHAR(256),
+ LAST_MOD TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ SUSPENDED BOOLEAN DEFAULT FALSE,
+ PRIVILEGED_SUBSCRIBER BOOLEAN DEFAULT FALSE,
+ CREATED_DATE TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ DECOMPRESS BOOLEAN DEFAULT FALSE,
+ AAF_INSTANCE VARCHAR(256)
+
+);
+
+CREATE TABLE PARAMETERS (
+ KEYNAME VARCHAR(32) NOT NULL PRIMARY KEY,
+ VALUE VARCHAR(4096) NOT NULL
+);
+
+CREATE TABLE LOG_RECORDS (
+ TYPE ENUM('pub', 'del', 'exp', 'pbf', 'dlx') NOT NULL,
+ EVENT_TIME BIGINT NOT NULL, /* time of the publish request */
+ PUBLISH_ID VARCHAR(64) NOT NULL, /* unique ID assigned to this publish attempt */
+ FEEDID INT UNSIGNED NOT NULL, /* pointer to feed in FEEDS */
+ REQURI VARCHAR(256) NOT NULL, /* request URI */
+ METHOD ENUM('DELETE', 'GET', 'HEAD', 'OPTIONS', 'PUT', 'POST', 'TRACE') NOT NULL, /* HTTP method */
+ CONTENT_TYPE VARCHAR(256) NOT NULL, /* content type of published file */
+ CONTENT_LENGTH BIGINT NOT NULL, /* content length of published file */
+
+ FEED_FILEID VARCHAR(256), /* file ID of published file */
+ REMOTE_ADDR VARCHAR(40), /* IP address of publishing endpoint */
+ USER VARCHAR(50), /* user name of publishing endpoint */
+ STATUS SMALLINT, /* status code returned to delivering agent */
+
+ DELIVERY_SUBID INT UNSIGNED, /* pointer to subscription in SUBSCRIPTIONS */
+ DELIVERY_FILEID VARCHAR(256), /* file ID of file being delivered */
+ RESULT SMALLINT, /* result received from subscribing agent */
+
+ ATTEMPTS INT, /* deliveries attempted */
+ REASON ENUM('notRetryable', 'retriesExhausted', 'diskFull', 'other'),
+
+ RECORD_ID BIGINT UNSIGNED NOT NULL PRIMARY KEY, /* unique ID for this record */
+ CONTENT_LENGTH_2 BIGINT,
+ FILENAME VARCHAR(256), /* Name of the file being published on DR */
+
+) ENGINE = MyISAM;
+
+CREATE TABLE INGRESS_ROUTES (
+ SEQUENCE INT UNSIGNED NOT NULL,
+ FEEDID INT UNSIGNED NOT NULL,
+ USERID VARCHAR(50),
+ SUBNET VARCHAR(44),
+ NODESET INT UNSIGNED NOT NULL
+);
+
+CREATE TABLE EGRESS_ROUTES (
+ SUBID INT UNSIGNED NOT NULL PRIMARY KEY,
+ NODEID INT UNSIGNED NOT NULL
+);
+
+CREATE TABLE NETWORK_ROUTES (
+ FROMNODE INT UNSIGNED NOT NULL,
+ TONODE INT UNSIGNED NOT NULL,
+ VIANODE INT UNSIGNED NOT NULL
+);
+
+CREATE TABLE NODESETS (
+ SETID INT UNSIGNED NOT NULL,
+ NODEID INT UNSIGNED NOT NULL
+);
+
+CREATE TABLE NODES (
+ NODEID INT UNSIGNED NOT NULL PRIMARY KEY,
+ NAME VARCHAR(255) NOT NULL,
+ ACTIVE BOOLEAN DEFAULT TRUE
+);
+
+CREATE TABLE GROUPS (
+ GROUPID INT UNSIGNED NOT NULL PRIMARY KEY,
+ AUTHID VARCHAR(100) NOT NULL,
+ NAME VARCHAR(50) NOT NULL,
+ DESCRIPTION VARCHAR(255),
+ CLASSIFICATION VARCHAR(20) NOT NULL,
+ MEMBERS TINYTEXT,
+ LAST_MOD TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+
+INSERT INTO PARAMETERS VALUES
+ ('ACTIVE_POD', 'dmaap-dr-prov'),
+ ('PROV_ACTIVE_NAME', 'dmaap-dr-prov'),
+ ('STANDBY_POD', ''),
+ ('PROV_NAME', 'dmaap-dr-prov'),
+ ('NODES', 'dmaap-dr-node'),
+ ('PROV_DOMAIN', ''),
+ ('DELIVERY_INIT_RETRY_INTERVAL', '10'),
+ ('DELIVERY_MAX_AGE', '86400'),
+ ('DELIVERY_MAX_RETRY_INTERVAL', '3600'),
+ ('DELIVERY_FILE_PROCESS_INTERVAL', '600'),
+ ('DELIVERY_RETRY_RATIO', '2'),
+ ('LOGROLL_INTERVAL', '30'),
+ ('PROV_AUTH_ADDRESSES', 'dmaap-dr-prov|dmaap-dr-node'),
+ ('PROV_AUTH_SUBJECTS', ''),
+ ('PROV_MAXFEED_COUNT', '10000'),
+ ('PROV_MAXSUB_COUNT', '100000'),
+ ('PROV_REQUIRE_CERT', 'false'),
+ ('PROV_REQUIRE_SECURE', 'true'),
+ ('_INT_VALUES', 'LOGROLL_INTERVAL|PROV_MAXFEED_COUNT|PROV_MAXSUB_COUNT|DELIVERY_INIT_RETRY_INTERVAL|DELIVERY_MAX_RETRY_INTERVAL|DELIVERY_RETRY_RATIO|DELIVERY_MAX_AGE|DELIVERY_FILE_PROCESS_INTERVAL'); \ No newline at end of file