Arquillian @UsingScript problem
mano_seba Apr 12, 2012 9:37 AMHello,
I have a problem whit the arquillian h2 database, the @UsingScript("import.sql") it doesn't insert the data into prjtest database. I can save in the prjtest database but cant add data using import.sql
Can someone give me an idea how can I make this work?
I added the dependecy arquillian-persistence-api and if I comment the @UsingScript("import.sql") it will give me error....and this makes me realize that the annotaions is working...so what might be the problem?
//pom.xml
<dependency>
<groupId>org.jboss.arquillian.testng</groupId>
<artifactId>arquillian-testng-container</artifactId>
<version>1.0.0.CR7</version> <!-- 1.0.0.CR7 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-persistence-api</artifactId>
<version>1.0.0.Alpha3</version>
<scope>test</scope>
</dependency>
//Location.java
public class LocationServiceTest extends Arquillian{
private final String TEST_VALUE = "test";
@Deployment
public static WebArchive createTestArchive() {
return ShrinkWrap.create( WebArchive.class,"test.war").addPackages(true,"org.joda.time").addPackages(true, "javax.jcr").addClasses(com.mysql.jdbc.log.Log.class,com.project.Location).addPackage("org.slf4j").addPackage("org.slf4j.spi").addPackage("org.slf4j.helpers").addAsWebInfResource("test-persistence.xml", "classes/META-INF/persistence.xml").addAsWebInfResource("beans.xml", "META-INF/beans.xml");
}
@BeforeTest
@UsingScript("import.sql")
public void setUp()
{}
@EJB
private Location loc;
@Test
public void LocationTest(){
Marking mk = new Marking();
loc.save(mk);
}
//test-persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for dev profile -->
<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="prj-unit">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/prjtest</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
//standalone.xml
<datasource jndi-name="java:jboss/datasources/prjtest" pool-name="prjtest" enabled="true">
<connection-url>
jdbc:h2:mem:prjtest;MODE=MYSQL;TRACE_LEVEL_FILE=2;TRACE_LEVEL_SYSTEM_OUT=2
</connection-url>
<driver>
h2
</driver>
<security>
<user-name>
sa
</user-name>
<password>
sa
</password>
</security>
</datasource>
driver name="h2" module="com.h2database.h2">
<xa-datasource-class>
org.h2.jdbcx.JdbcDataSource
</xa-datasource-class>
</driver>
//import.sql
INSERT INTO `TEMPLATE` (`TEMPLATE_ID`, `NAME`) VALUES (1,'Template');
How can I insert the data from TEMPLATE into the prjtest h2 database.
Best Regards