summaryrefslogtreecommitdiffstats
path: root/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java
diff options
context:
space:
mode:
Diffstat (limited to 'feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java')
-rw-r--r--feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java
new file mode 100644
index 00000000..a0af2e6c
--- /dev/null
+++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * feature-session-persistence
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.policy.drools.persistence;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Generates the schema DDL files.
+ */
+public class GenSchema {
+
+ private static final Logger logger = LoggerFactory.getLogger(PersistenceFeatureTest.class);
+
+ private EntityManagerFactory emf;
+
+ /**
+ * Opens the EMF, which generates the schema, as a side-effect.
+ *
+ * @throws Exception
+ */
+ private GenSchema() throws Exception {
+ Map<String, Object> propMap = new HashMap<>();
+
+ propMap.put("javax.persistence.jdbc.driver", "org.h2.Driver");
+ propMap.put("javax.persistence.jdbc.url", "jdbc:h2:mem:JpaDroolsSessionConnectorTest");
+
+ emf = Persistence.createEntityManagerFactory("schemaDroolsPU", propMap);
+
+ emf.close();
+ }
+
+ /**
+ * This is is provided as a utility for producing a basic ddl schema file in
+ * the sql directory.
+ */
+ public static void main(String[] args) {
+ try {
+ new GenSchema();
+
+ } catch (Exception e) {
+ logger.error("failed to generate schema", e);
+ }
+ }
+}