// Path: src/test/java/com/wakaleo/schemaspy/util/DatabaseHelper.java
// public class DatabaseHelper {
// 
//     private static Boolean databaseSetupDone = false;
// 
//     /**
//      * Create an embedded Derby database using a simple SQL script. The SQL
//      * commands should each be on a single line. "--" and "//" can be used for
//      * comments.
//      * 
//      * @param sqlCreateScript
//      *            Path to a file containing the SQL creation script.
//      */
//     public static final void setupDatabase(String sqlCreateScript)
//             throws SQLException, FileNotFoundException, IOException,
//             ClassNotFoundException {
//         if (!databaseSetupDone) {
//             synchronized (databaseSetupDone) {
//                 BufferedReader input = null;
//                 try {
//                     Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
//                     java.sql.Connection connection = java.sql.DriverManager
//                             .getConnection("jdbc:derby:testdb;create=true");
// 
//                     input = new BufferedReader(new FileReader(sqlCreateScript));
//                     String line = null;
// 
//                     while ((line = input.readLine()) != null) {
//                         if (!isSQLComment(line)) {
//                             Logger.getLogger("global").log(Level.INFO, line);
//                             Statement st = connection.createStatement();
//                             try {
//                                 int i = st.executeUpdate(line); // run the query
//                                 if (i == -1) {
//                                     Logger.getLogger("global").log(
//                                             Level.SEVERE, "SQL Error: " + line);
//                                 }
//                             } catch (SQLException e) {
//                                 String msg = e.getMessage();
//                                 if (msg.contains("DROP TABLE")) {
//                                     continue; // Ignore errors when trying to
//                                                 // drop tables
//                                 }
//                                 Logger.getLogger("global").log(Level.SEVERE,
//                                         "SQL Error: ", e);
//                             }
//                             st.close();
//                         }
//                     }
//                     connection.commit();
//                     connection.close();
//                     databaseSetupDone = true;
//                 } finally {
//                     try {
//                         if (input != null) {
//                             // flush and close both "input" and its underlying
//                             // FileReader
//                             input.close();
//                         }
//                     } catch (IOException ex) {
//                         ex.printStackTrace();
//                     }
//                 }
//             }
//         }
//     }
// 
//     private static boolean isSQLComment(String line) {
//         return ((line.startsWith("//")) || (line.startsWith("--")));
//     }
// }


import com.wakaleo.schemaspy.util.DatabaseHelper;
import org.apache.maven.plugin.testing.MojoRule;
import org.apache.maven.plugin.testing.resources.TestResources;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.io.File;
import java.util.Locale;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;
package com.wakaleo.schemaspy;




/**
 * SchemaSpyReport unit tests Test POM files is kept in test/resources/unit
 * directory.
 * 
 * @author john
 */
public class SchemaSpyMojoTest  {

    /**
     * Test resources.
     */
    @Rule
    public TestResources resources = new TestResources();

    /**
     * test rule.
     */
    @Rule
    public MojoRule rule = new MojoRule();

    @Before
    public void setUp() throws Exception {
// Path: src/test/java/com/wakaleo/schemaspy/util/DatabaseHelper.java
// public class DatabaseHelper {
// 
//     private static Boolean databaseSetupDone = false;
// 
//     /**
//      * Create an embedded Derby database using a simple SQL script. The SQL
//      * commands should each be on a single line. "--" and "//" can be used for
//      * comments.
//      * 
//      * @param sqlCreateScript
//      *            Path to a file containing the SQL creation script.
//      */
//     public static final void setupDatabase(String sqlCreateScript)
//             throws SQLException, FileNotFoundException, IOException,
//             ClassNotFoundException {
//         if (!databaseSetupDone) {
//             synchronized (databaseSetupDone) {
//                 BufferedReader input = null;
//                 try {
//                     Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
//                     java.sql.Connection connection = java.sql.DriverManager
//                             .getConnection("jdbc:derby:testdb;create=true");
// 
//                     input = new BufferedReader(new FileReader(sqlCreateScript));
//                     String line = null;
// 
//                     while ((line = input.readLine()) != null) {
//                         if (!isSQLComment(line)) {
//                             Logger.getLogger("global").log(Level.INFO, line);
//                             Statement st = connection.createStatement();
//                             try {
//                                 int i = st.executeUpdate(line); // run the query
//                                 if (i == -1) {
//                                     Logger.getLogger("global").log(
//                                             Level.SEVERE, "SQL Error: " + line);
//                                 }
//                             } catch (SQLException e) {
//                                 String msg = e.getMessage();
//                                 if (msg.contains("DROP TABLE")) {
//                                     continue; // Ignore errors when trying to
//                                                 // drop tables
//                                 }
//                                 Logger.getLogger("global").log(Level.SEVERE,
//                                         "SQL Error: ", e);
//                             }
//                             st.close();
//                         }
//                     }
//                     connection.commit();
//                     connection.close();
//                     databaseSetupDone = true;
//                 } finally {
//                     try {
//                         if (input != null) {
//                             // flush and close both "input" and its underlying
//                             // FileReader
//                             input.close();
//                         }
//                     } catch (IOException ex) {
//                         ex.printStackTrace();
//                     }
//                 }
//             }
//         }
//     }
// 
//     private static boolean isSQLComment(String line) {
//         return ((line.startsWith("//")) || (line.startsWith("--")));
//     }
// }


// Path: src/test/java/com/wakaleo/schemaspy/SchemaSpyMojoTest.java
import com.wakaleo.schemaspy.util.DatabaseHelper;
import org.apache.maven.plugin.testing.MojoRule;
import org.apache.maven.plugin.testing.resources.TestResources;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.io.File;
import java.util.Locale;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;

package com.wakaleo.schemaspy;




/**
 * SchemaSpyReport unit tests Test POM files is kept in test/resources/unit
 * directory.
 * 
 * @author john
 */
public class SchemaSpyMojoTest  {

    /**
     * Test resources.
     */
    @Rule
    public TestResources resources = new TestResources();

    /**
     * test rule.
     */
    @Rule
    public MojoRule rule = new MojoRule();

    @Before
    public void setUp() throws Exception {
        DatabaseHelper.setupDatabase("src/test/resources/sql/testdb.sql");