summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-04-16 11:20:08 +0000
committerliamfallon <liam.fallon@est.tech>2019-04-16 11:20:08 +0000
commit3cb682fa71a1749fb99a47d7c8ede2b8984e2c07 (patch)
tree08aa6b83f985cfefcb0618d146b2e77428110055 /examples
parent2ba499f11094cfd1321e59789869a0c475406b58 (diff)
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 <liam.fallon@est.tech>
Diffstat (limited to 'examples')
-rw-r--r--examples/examples-aadm/pom.xml6
-rw-r--r--examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmDbWriteTest.java15
-rw-r--r--examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java15
-rw-r--r--examples/examples-aadm/src/test/resources/META-INF/persistence.xml6
-rw-r--r--examples/examples-adaptive/pom.xml6
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionDbWriteTest.java15
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java15
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnDbWriteTest.java15
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java15
-rw-r--r--examples/examples-adaptive/src/test/resources/META-INF/persistence.xml6
-rw-r--r--examples/examples-myfirstpolicy/pom.xml6
-rw-r--r--examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java20
-rw-r--r--examples/examples-myfirstpolicy/src/test/resources/META-INF/persistence.xml6
-rw-r--r--examples/examples-pcvs/pom.xml6
-rw-r--r--examples/examples-servlet/pom.xml5
-rw-r--r--examples/pom.xml9
16 files changed, 14 insertions, 152 deletions
diff --git a/examples/examples-aadm/pom.xml b/examples/examples-aadm/pom.xml
index d1a8223b5..f478119f8 100644
--- a/examples/examples-aadm/pom.xml
+++ b/examples/examples-aadm/pom.xml
@@ -53,12 +53,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${version.derby}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmDbWriteTest.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmDbWriteTest.java
index 1cc379938..58987533a 100644
--- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmDbWriteTest.java
+++ b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmDbWriteTest.java
@@ -20,11 +20,6 @@
package org.onap.policy.apex.examples.aadm;
-import java.io.File;
-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;
@@ -32,7 +27,6 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class AadmDbWriteTest {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -41,18 +35,9 @@ public class AadmDbWriteTest {
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new TestAadmModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelWriteReadJpa() throws Exception {
final DaoParameters DaoParameters = new DaoParameters();
diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java
index b0aa23949..a44a4cc1a 100644
--- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java
+++ b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java
@@ -22,11 +22,6 @@ package org.onap.policy.apex.examples.aadm;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-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;
@@ -35,7 +30,6 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class AadmModelTest {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -44,18 +38,9 @@ public class AadmModelTest {
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new TestAadmModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
diff --git a/examples/examples-aadm/src/test/resources/META-INF/persistence.xml b/examples/examples-aadm/src/test/resources/META-INF/persistence.xml
index eb28ad809..10a720dd7 100644
--- a/examples/examples-aadm/src/test/resources/META-INF/persistence.xml
+++ b/examples/examples-aadm/src/test/resources/META-INF/persistence.xml
@@ -57,10 +57,8 @@
<class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</class>
<properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.logging.level" value="INFO" />
diff --git a/examples/examples-adaptive/pom.xml b/examples/examples-adaptive/pom.xml
index 1104ca932..cff709239 100644
--- a/examples/examples-adaptive/pom.xml
+++ b/examples/examples-adaptive/pom.xml
@@ -63,12 +63,6 @@
<artifactId>commons-math3</artifactId>
<version>3.2</version>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${version.derby}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionDbWriteTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionDbWriteTest.java
index 885704497..3004bccb3 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionDbWriteTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionDbWriteTest.java
@@ -20,11 +20,6 @@
package org.onap.policy.apex.examples.adaptive;
-import java.io.File;
-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;
@@ -32,7 +27,6 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class AnomalyDetectionDbWriteTest {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -41,18 +35,9 @@ public class AnomalyDetectionDbWriteTest {
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<>(AxPolicyModel.class, new TestAnomalyDetectionModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelWriteReadJpa() throws Exception {
final DaoParameters DaoParameters = new DaoParameters();
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java
index 552ca2f37..5a36d4070 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java
@@ -22,11 +22,6 @@ package org.onap.policy.apex.examples.adaptive;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-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;
@@ -35,7 +30,6 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class AnomalyDetectionModelTest {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -44,18 +38,9 @@ public class AnomalyDetectionModelTest {
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<>(AxPolicyModel.class, new TestAnomalyDetectionModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnDbWriteTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnDbWriteTest.java
index 828a56133..b72514f49 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnDbWriteTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnDbWriteTest.java
@@ -20,11 +20,6 @@
package org.onap.policy.apex.examples.adaptive;
-import java.io.File;
-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;
@@ -32,7 +27,6 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class AutoLearnDbWriteTest {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -41,18 +35,9 @@ public class AutoLearnDbWriteTest {
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<>(AxPolicyModel.class, new TestAutoLearnModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelWriteReadJpa() throws Exception {
final DaoParameters DaoParameters = new DaoParameters();
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java
index f4cddc580..1823f9871 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java
@@ -22,11 +22,6 @@ package org.onap.policy.apex.examples.adaptive;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-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;
@@ -35,7 +30,6 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class AutoLearnModelTest {
- private Connection connection;
TestApexModel<AxPolicyModel> testApexModel;
/**
@@ -44,18 +38,9 @@ public class AutoLearnModelTest {
*/
@Before
public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
testApexModel = new TestApexModel<>(AxPolicyModel.class, new TestAutoLearnModelCreator());
}
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
diff --git a/examples/examples-adaptive/src/test/resources/META-INF/persistence.xml b/examples/examples-adaptive/src/test/resources/META-INF/persistence.xml
index 4dcd879b6..1e70abc6d 100644
--- a/examples/examples-adaptive/src/test/resources/META-INF/persistence.xml
+++ b/examples/examples-adaptive/src/test/resources/META-INF/persistence.xml
@@ -57,10 +57,8 @@
<class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</class>
<properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.logging.level" value="INFO" />
diff --git a/examples/examples-myfirstpolicy/pom.xml b/examples/examples-myfirstpolicy/pom.xml
index 8ce34c027..e56a5b12b 100644
--- a/examples/examples-myfirstpolicy/pom.xml
+++ b/examples/examples-myfirstpolicy/pom.xml
@@ -69,12 +69,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${version.derby}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java
index d6ec2bb8d..1bd67f961 100644
--- a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java
+++ b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/MfpModelTest.java
@@ -22,11 +22,6 @@ package org.onap.policy.apex.examples.myfirstpolicy;
import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -39,8 +34,6 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
* @author John Keeney (john.keeney@ericsson.com)
*/
public class MfpModelTest {
-
- private static Connection connection;
private static TestApexModel<AxPolicyModel> testApexModel1;
private static TestApexModel<AxPolicyModel> testApexModel2;
@@ -51,24 +44,11 @@ public class MfpModelTest {
*/
@BeforeClass
public static void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
testApexModel1 = new TestApexModel<>(AxPolicyModel.class, new TestMfpModelCreator.TestMfp1ModelCreator());
testApexModel2 = new TestApexModel<>(AxPolicyModel.class, new TestMfpModelCreator.TestMfp2ModelCreator());
}
/**
- * Teardown.
- *
- * @throws Exception if there is an error
- */
- @AfterClass
- public static void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
- /**
* Test model is valid.
*
* @throws Exception if there is an error
diff --git a/examples/examples-myfirstpolicy/src/test/resources/META-INF/persistence.xml b/examples/examples-myfirstpolicy/src/test/resources/META-INF/persistence.xml
index 7acc7a0e9..909f413eb 100644
--- a/examples/examples-myfirstpolicy/src/test/resources/META-INF/persistence.xml
+++ b/examples/examples-myfirstpolicy/src/test/resources/META-INF/persistence.xml
@@ -57,10 +57,8 @@
<class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</class>
<properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
- <property name="javax.persistence.target-database" value="Derby" />
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
-
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.logging.level" value="INFO" />
diff --git a/examples/examples-pcvs/pom.xml b/examples/examples-pcvs/pom.xml
index 5cc65e6a1..7b5b92c77 100644
--- a/examples/examples-pcvs/pom.xml
+++ b/examples/examples-pcvs/pom.xml
@@ -71,12 +71,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${version.derby}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/examples/examples-servlet/pom.xml b/examples/examples-servlet/pom.xml
index d1bd0a28c..fcf773022 100644
--- a/examples/examples-servlet/pom.xml
+++ b/examples/examples-servlet/pom.xml
@@ -56,11 +56,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.onap.policy.apex-pdp.context</groupId>
- <artifactId>context-test-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
<artifactId>integration-common</artifactId>
<version>${project.version}</version>
diff --git a/examples/pom.xml b/examples/pom.xml
index a8dca24b2..acba94098 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -32,7 +32,6 @@
<name>${project.artifactId}</name>
<description>Specific source code and other artifacts for Apex example applications.</description>
-
<modules>
<module>examples-myfirstpolicy</module>
<module>examples-aadm</module>
@@ -44,6 +43,14 @@
<module>examples-servlet</module>
</modules>
+ <dependencies>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
<profiles>
<profile>
<id>apexSite</id>