11 Replies Latest reply on Jan 12, 2014 1:04 PM by Bartosz Majsak

    How to use a sql script to populate test database before test

    claudinei Newbie

      I'm using Arquillian with TestNG I have created a test-persistence.xml and a MySQL test Database like this:

       

      test-persistence.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="2.0"
                xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
                              http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
      
      
                <persistence-unit name="ERPSystem-PU" transaction-type="JTA">
                          <provider>org.hibernate.ejb.HibernatePersistence</provider>
                          <jta-data-source>java:/jdbc/ERPSystemTest</jta-data-source>
      
                           <properties>
                                    <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
        
                                    <property name="hibernate.hbm2ddl.auto" value="create-drop" />
                          </properties>
                </persistence-unit>
      </persistence>
      
      

       

      The test Database schema is created and droped like it should be, but how i can auto populate the database with the sql script like this:

       

      import.sql

      INSERT INTO language(name, locale) VALUES('Português', 'pt');
      INSERT INTO language(name, locale) VALUES('Inglês', 'en');
      INSERT INTO language(name, locale) VALUES('Espanhol', 'es');
      INSERT INTO language(name, locale) VALUES('Chinês', 'ch');
      

       

      How I configure Arquillian to run a sql script?