Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
functional test use mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed Dec 17, 2013
1 parent 20297da commit d967cd6
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 11 deletions.
78 changes: 70 additions & 8 deletions functional-test/pom.xml
Expand Up @@ -28,17 +28,18 @@
<context.path>zanata</context.path>

<!--data source-->
<jdbc.groupId>com.h2database</jdbc.groupId>
<jdbc.artifactId>h2</jdbc.artifactId>
<jdbc.groupId>mysql</jdbc.groupId>
<jdbc.artifactId>mysql-connector-java</jdbc.artifactId>
<!-- This version must match the version used in JBoss. -->
<jdbc.version>1.3.168</jdbc.version>
<jdbc.version>5.1.9</jdbc.version>

<ds.jndi.name>zanataDatasource</ds.jndi.name>
<ds.database>zanata_functional</ds.database>
<!--<ds.hibernate.dialect>org.hibernate.dialect.H2Dialect</ds.hibernate.dialect>-->
<ds.driver.class>org.h2.Driver</ds.driver.class>
<ds.connection.url>jdbc:h2:file:${project.build.directory}/h2/zanata;AUTO_SERVER=TRUE;</ds.connection.url>
<ds.username>sa</ds.username>
<ds.password />
<ds.connection.url>jdbc:mysql://localhost:${mysql.port}/${ds.database}?characterEncoding=UTF-8</ds.connection.url>
<ds.driver.class>com.mysql.jdbc.Driver</ds.driver.class>
<ds.username>root</ds.username>
<ds.password ></ds.password>

<!--target zanata instance-->
<zanata.target.version>${project.parent.version}</zanata.target.version>
Expand Down Expand Up @@ -322,6 +323,62 @@
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-mysql-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<dependencies>
<!-- specify the dependent JDBC driver here -->
<dependency>
<groupId>${jdbc.groupId}</groupId>
<artifactId>${jdbc.artifactId}</artifactId>
<version>${jdbc.version}</version>
</dependency>
</dependencies>

<!-- common configuration shared by all executions -->
<configuration>
<driver>${ds.driver.class}</driver>
<url>jdbc:mysql://localhost:${mysql.port}/test?characterEncoding=UTF-8</url>
<username>${ds.username}</username>
<password>${ds.password}</password>
</configuration>

<executions>
<execution>
<id>drop-database</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<sqlCommand>drop database if exists ${ds.database}</sqlCommand>
<onError>continue</onError>
</configuration>
</execution>
<execution>
<id>create-database</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<sqlCommand>create database ${ds.database}</sqlCommand>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
Expand Down Expand Up @@ -358,7 +415,7 @@
<type>war</type>
<location>${zanata.target.war}</location>
<pingURL>http://${cargo.host}:${cargo.servlet.port}/${context.path}/</pingURL>
<pingTimeout>60000</pingTimeout>
<pingTimeout>120000</pingTimeout>
<properties>
<context>${context.path}</context>
</properties>
Expand Down Expand Up @@ -410,6 +467,11 @@
<file>${settings.localRepository}/org/hibernate/hibernate-envers/${hibernate.version}/hibernate-envers-${hibernate.version}.jar</file>
<tofile>${cargo.install.relative.to.container.home}/modules/system/layers/base/org/hibernate/envers/main/hibernate-envers-4.2.0.CR1.jar</tofile>
</file>

<file>
<file>${settings.localRepository}/${jdbc.groupId}/${jdbc.artifactId}/${jdbc.version}/${jdbc.artifactId}-${jdbc.version}.jar</file>
<tofile>deployments/${jdbc.artifactId}.jar</tofile>
</file>
</files>

<properties>
Expand Down
Expand Up @@ -24,6 +24,11 @@ private EntityManagerFactoryHolder() {
overrideProps
.put("hibernate.connection.provider_class",
"org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl");
overrideProps.put("hibernate.connection.driver_class",
"com.mysql.jdbc.Driver");
overrideProps.put("hibernate.connection.username", "root");
overrideProps.put("hibernate.dialect",
"org.zanata.util.ZanataMySQL5InnoDBDialect");
overrideProps.put("hibernate.connection.url",
PropertiesHolder.getProperty("hibernate.connection.url"));
overrideProps.put("hibernate.search.default.indexBase",
Expand Down
Expand Up @@ -27,6 +27,7 @@
import org.zanata.model.HPerson;
import org.zanata.model.HProject;
import org.zanata.model.HProjectIteration;
import org.zanata.model.HTermComment;
import org.zanata.model.HTextFlow;
import org.zanata.model.HTextFlowTarget;
import org.zanata.model.HTextFlowTargetHistory;
Expand Down Expand Up @@ -69,7 +70,7 @@ public void deleteExceptEssentialData() {
EntityCleaner.deleteAll(entityManager, Lists.<Class>newArrayList(
Activity.class,
// glossary
HGlossaryEntry.class, HGlossaryTerm.class,
HTermComment.class, HGlossaryTerm.class, HGlossaryEntry.class,
// tex flows and targets
HPoTargetHeader.class, HTextFlowTargetHistory.class,
HTextFlowTarget.class, HTextFlow.class, HDocument.class,
Expand Down
Expand Up @@ -11,7 +11,7 @@ See http://jaitechwriteups.blogspot.com/2012/02/jboss-as-710final-thunder-releas
enabled="true" use-java-context="true" pool-name="zanataDatasource"
use-ccm="true">
<connection-url>${ds.connection.url}</connection-url>
<driver>h2</driver>
<driver>${jdbc.artifactId}.jar</driver>
<security>
<user-name>${ds.username}</user-name>
<!--<password>${ds.password}</password>-->
Expand Down
2 changes: 1 addition & 1 deletion functional-test/src/test/resources/setup.properties
Expand Up @@ -12,5 +12,5 @@ zanata.sample.projects.basedir=${zanata.sample.projects.basedir}
zanata.apikey=${zanata.apikey}

#persistence.xml
hibernate.connection.url=${ds.connection.url};DB_CLOSE_ON_EXIT=FALSE
hibernate.connection.url=${ds.connection.url}
hibernate.search.default.indexBase=${hibernate.search.default.indexBase}
71 changes: 71 additions & 0 deletions pom.xml
Expand Up @@ -53,6 +53,10 @@

<!-- JBoss version for dependencies (arquillian, jboss-as-parent) -->
<jboss.as.version>7.2.0.Final</jboss.as.version>

<!-- mysql maven plugin-->
<mysql.classifier>linux-amd64</mysql.classifier>
<mysql.port>13306</mysql.port>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -706,6 +710,73 @@
<skip>true</skip>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<goals>
<goal>reserve-network-port</goal>
</goals>
<configuration>
<portNames>
<portName>mysql.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.jcabi</groupId>
<artifactId>mysql-dist</artifactId>
<version>5.5.34</version>
<classifier>${mysql.classifier}</classifier>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/mysql-dist</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-mysql-maven-plugin</artifactId>
<version>0.3</version>
<executions>
<execution>
<id>mysql-test</id>
<goals>
<goal>classify</goal>
<goal>start</goal>
<goal>stop</goal>
</goals>
<configuration>
<classifier>mysql.classifier</classifier>
<port>${mysql.port}</port>
<data>${project.build.directory}/mdb</data>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down

0 comments on commit d967cd6

Please sign in to comment.