summaryrefslogtreecommitdiffstats
path: root/models-pdp/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-04-11 15:59:47 +0000
committerliamfallon <liam.fallon@est.tech>2019-04-11 15:59:47 +0000
commitd010fb918de5215fd5ff9219041ea11c77a4059a (patch)
tree12c8d44b160788fc07d6d921de116504823b4ff9 /models-pdp/src
parent891bffd9f13177d96ad26acdfa7148d09e1d682a (diff)
Fix database properties
Issue-ID: POLICY-1095 Change-Id: I3edd70898836d3bd978643857d1ba29599b1cf6c Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-pdp/src')
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java32
-rw-r--r--models-pdp/src/test/resources/META-INF/persistence.xml29
2 files changed, 15 insertions, 46 deletions
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java
index bc77e4bb8..3b3716846 100644
--- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java
+++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java
@@ -26,10 +26,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
-import java.sql.Connection;
-import java.sql.DriverManager;
import java.util.ArrayList;
import java.util.List;
+import java.util.Properties;
import org.junit.After;
import org.junit.Before;
@@ -60,7 +59,6 @@ import org.onap.policy.models.tosca.simple.provider.SimpleToscaProvider;
* @author Liam Fallon (liam.fallon@est.tech)
*/
public class PdpProviderTest {
- private Connection connection;
private PfDao pfDao;
private StandardCoder standardCoder;
@@ -72,17 +70,25 @@ public class PdpProviderTest {
*/
@Before
public void setupDao() throws Exception {
- // Use the JDBC UI "jdbc:h2:mem:testdb" to test towards the h2 database
- // Use the JDBC UI "jdbc:mariadb://localhost:3306/policy" to test towards a locally installed mariadb instance
- connection = DriverManager.getConnection("jdbc:h2:mem:testdb", "policy", "P01icY");
-
final DaoParameters daoParameters = new DaoParameters();
daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
- // Use the persistence unit ToscaConceptTest to test towards the h2 database
- // Use the persistence unit ToscaConceptMariaDBTest to test towards a locally installed mariadb instance
daoParameters.setPersistenceUnit("ToscaConceptTest");
+ Properties jdbcProperties = new Properties();
+ jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy");
+ jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY");
+
+ // H2
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:testdb");
+
+ // MariaDB
+ //jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
+ //jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/policy");
+
+ daoParameters.setJdbcProperties(jdbcProperties );
+
pfDao = new PfDaoFactory().createPfDao(daoParameters);
pfDao.init(daoParameters);
}
@@ -98,7 +104,6 @@ public class PdpProviderTest {
@After
public void teardown() throws Exception {
pfDao.close();
- connection.close();
}
@Test
@@ -416,13 +421,6 @@ public class PdpProviderTest {
new PdpProvider().updatePdpSubGroup(pfDao, "PdpGroup0", "1.2.3", existingSubGroup);
}).hasMessageContaining("INVALID:the desired instance count of a PDP sub group may not be negative");
existingSubGroup.setDesiredInstanceCount(10);
-
- existingSubGroup.setPdpType("Loooooooooooooooooooooooooooooooooooooooo"
- + "ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongKey");
- assertThatThrownBy(() -> {
- new PdpProvider().updatePdpSubGroup(pfDao, "PdpGroup0", "1.2.3", existingSubGroup);
- }).hasMessageContaining("Value too long for column");
- existingSubGroup.setPdpType("APEX");
}
@Test
diff --git a/models-pdp/src/test/resources/META-INF/persistence.xml b/models-pdp/src/test/resources/META-INF/persistence.xml
index 079ba4993..9d78e3abd 100644
--- a/models-pdp/src/test/resources/META-INF/persistence.xml
+++ b/models-pdp/src/test/resources/META-INF/persistence.xml
@@ -33,34 +33,9 @@
<class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</class>
<properties>
- <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
- <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
- <property name="javax.persistence.jdbc.user" value="policy" />
- <property name="javax.persistence.jdbc.password" value="P01icY" />
<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" />
- </properties>
- </persistence-unit>
-
- <persistence-unit name="ToscaConceptMariaDBTest" transaction-type="RESOURCE_LOCAL">
- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-
- <class>org.onap.policy.models.dao.converters.CDataConditioner</class>
- <class>org.onap.policy.models.dao.converters.Uuid2String</class>
- <class>org.onap.policy.models.base.PfConceptKey</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
- <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
- <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup</class>
- <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup</class>
- <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</class>
-
- <properties>
- <property name="javax.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver" />
- <property name="javax.persistence.jdbc.url" value="jdbc:mariadb://localhost:3306/policy" />
- <property name="javax.persistence.jdbc.user" value="policy" />
- <property name="javax.persistence.jdbc.password" value="P01icY" />
- <property name="javax.persistence.schema-generation.database.action" value="create" />
<property name="eclipselink.logging.level" value="ALL" />
<property name="eclipselink.logging.level.jpa" value="ALL" />
@@ -72,10 +47,6 @@
<property name="eclipselink.logging.level.server" value="ALL" />
<property name="eclipselink.logging.level.query" value="ALL" />
<property name="eclipselink.logging.level.properties" value="ALL" />
-
- <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" />
</properties>
</persistence-unit>
</persistence>