From 3cb682fa71a1749fb99a47d7c8ede2b8984e2c07 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 16 Apr 2019 11:20:08 +0000 Subject: Fix Security and Unit Test DB issues This review removes more links to the Zookeeper version 3.5.4-beta with Zookeeper version 3.4.14. It also replaces the Derby in-memory database with the H2 in memory database for unit tests. Issue-ID: POLICY-1540 Change-Id: Ic44f2e866644114b7c0cf66aac7e528017b8206b Signed-off-by: liamfallon --- .../handling/TestApexSamplePolicyDbWrite.java | 22 +++++--------------- .../handling/TestApexSamplePolicyModel.java | 24 ++++++---------------- .../src/test/resources/META-INF/persistence.xml | 6 ++---- 3 files changed, 13 insertions(+), 39 deletions(-) (limited to 'testsuites/integration/integration-executor-test/src') diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyDbWrite.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyDbWrite.java index e863a990a..426db8328 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyDbWrite.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyDbWrite.java @@ -5,15 +5,15 @@ * 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========================================================= */ @@ -23,7 +23,6 @@ package org.onap.policy.apex.testsuites.integration.executor.handling; import java.sql.Connection; import java.sql.DriverManager; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.policy.apex.model.basicmodel.dao.DaoParameters; @@ -35,7 +34,6 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; * The Class TestApexSamplePolicyDbWrite. */ public class TestApexSamplePolicyDbWrite { - private Connection connection; TestApexModel testApexModel; /** @@ -45,22 +43,10 @@ public class TestApexSamplePolicyDbWrite { */ @Before public void setup() throws Exception { - connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true"); - final TestApexSamplePolicyModelCreator apexPolicyModelCreator = new TestApexSamplePolicyModelCreator("MVEL"); testApexModel = new TestApexModel(AxPolicyModel.class, apexPolicyModelCreator); } - /** - * Teardown. - * - * @throws Exception the exception - */ - @After - public void teardown() throws Exception { - connection.close(); - } - /** * Test model write read jpa. * @@ -72,6 +58,8 @@ public class TestApexSamplePolicyDbWrite { DaoParameters.setPluginClass(DefaultApexDao.class.getCanonicalName()); DaoParameters.setPersistenceUnit("SampleModelTest"); + Connection connection = DriverManager.getConnection("jdbc:h2:mem:testdb"); testApexModel.testApexModelWriteReadJpa(DaoParameters); + connection.close(); } } diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java index 1e7daad03..a5800956d 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java @@ -5,15 +5,15 @@ * 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========================================================= */ @@ -25,7 +25,6 @@ import static org.junit.Assert.assertTrue; import java.sql.Connection; import java.sql.DriverManager; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; @@ -39,7 +38,6 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; */ public class TestApexSamplePolicyModel { private static final String VALID_MODEL_STRING = "***validation of model successful***"; - private Connection connection; private TestApexModel testApexModel; /** @@ -49,22 +47,10 @@ public class TestApexSamplePolicyModel { */ @Before public void setup() throws Exception { - connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true"); - testApexModel = new TestApexModel(AxPolicyModel.class, new TestApexSamplePolicyModelCreator("MVEL")); } - /** - * Teardown. - * - * @throws Exception the exception - */ - @After - public void teardown() throws Exception { - connection.close(); - } - /** * Test model valid. * @@ -107,8 +93,10 @@ public class TestApexSamplePolicyModel { DaoParameters.setPluginClass(DefaultApexDao.class.getCanonicalName()); DaoParameters.setPersistenceUnit("SampleModelTest"); + Connection connection = DriverManager.getConnection("jdbc:h2:mem:testdb"); testApexModel.testApexModelWriteReadJpa(DaoParameters); + connection.close(); } - + } diff --git a/testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml b/testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml index 40773a4d4..b2d6a96ed 100644 --- a/testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml +++ b/testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml @@ -57,10 +57,8 @@ org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel - - - - + + -- cgit 1.2.3-korg