Repository: cayenne
Updated Branches:
  refs/heads/master ab23e9cee -> 44642ea58


add tests derby managment


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/84dd1c98
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/84dd1c98
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/84dd1c98

Branch: refs/heads/master
Commit: 84dd1c98215601343fc28929a0b72e5157f2fea1
Parents: ab23e9c
Author: alexkolonitsky <alex.kolonit...@gmail.com>
Authored: Fri Dec 26 18:03:50 2014 +0300
Committer: alexkolonitsky <alex.kolonit...@gmail.com>
Committed: Fri Dec 26 18:03:50 2014 +0300

----------------------------------------------------------------------
 .../org/apache/cayenne/tools/DerbyManager.java  | 63 ++++++++++++++++++++
 1 file changed, 63 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/84dd1c98/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DerbyManager.java
----------------------------------------------------------------------
diff --git 
a/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DerbyManager.java
 
b/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DerbyManager.java
new file mode 100644
index 0000000..82faace
--- /dev/null
+++ 
b/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DerbyManager.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.cayenne.tools;
+
+/**
+ * @since 4.0
+ */
+
+import org.apache.commons.io.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+public class DerbyManager {
+
+    public static final OutputStream DEV_NULL = new OutputStream() {
+
+        @Override
+        public void write(int b) {
+        }
+    };
+
+    DerbyManager(String location) {
+
+        System.setProperty("derby.stream.error.field", 
DerbyManager.class.getName() + ".DEV_NULL");
+
+        File derbyDir = new File(location);
+        if (derbyDir.isDirectory()) {
+            try {
+                FileUtils.deleteDirectory(derbyDir);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+
+    void shutdown() {
+        try {
+            DriverManager.getConnection("jdbc:derby:;shutdown=true");
+        } catch (SQLException e) {
+            // the exception is actually expected on shutdown... go figure...
+        }
+    }
+}

Reply via email to