Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Arquillian test environment #140

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Introduce Arquillian test environment #140

wants to merge 8 commits into from

Conversation

cghislai
Copy link
Contributor

I set up the Arquillian environment for comptoir-ejb
It is bound to a maven profile 'test'.
I launch the maven test goal with the following settings:

  • WorkDir: comptoir-ejb
  • command line arguments: test -Ddb.napo.driver=com.mysql.jdbc.Driver -Ddb.napo.url=jdbc:mysql://localhost:3306/petitnapo -Ddb.napo.username=... -Ddb.napo.password=...
    -P test

The plugins in the POM will download a wildfly and start it as the Arquilllian container. I took Wildfly because it looked like the only JEE7 container supported.
The persistence.xml point to the default datasource enabled in the wildfly default config.
The persistence provider is Hibernate, so I had to make some small changes to support it.
I created a StockEntries test to ensure stock entries are correctly updated when sales are open/closed.

The embedded wildfly will bind to port 8080, so it cannot be used when running the test suite.

@cghislai cghislai changed the title Introduce Arquillian test environment + some fixes for hibernate JPA Introduce Arquillian test environment Mar 31, 2016
@ymajoros
Copy link
Contributor

Cool, but I'm sure GF 4 is supported, as I'm using it in some project. It's cool to see all of this works in Wildfly and Hibernate, but I'd rather have tests that "prove" that our production works. I'll need to check it and get back to you :-/

@ymajoros
Copy link
Contributor

ymajoros commented Apr 1, 2016

Ok, I checked some of my other projects, and I'm just using this:

    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-glassfish-managed-3.1</artifactId>
        <version>1.0.0.CR4</version>
        <scope>test</scope>
    </dependency> 

Don't focus on -3.1, it doesn't mean it requires a gf 3.1 and it works fine with 4.1.

I think it's better to use some specifically installed glassfish for tests. It's also faster: it won't start it once per test. And all stuff will work out of the box: jndi properties, auth module, ...

Anyway, anything build parameters should be in a maven profile in your settings.xml, so you don't have to specify them each time. I usually create a profile for that that's activated by default, or by some property.

@cghislai
Copy link
Contributor Author

cghislai commented Apr 2, 2016

Updated.
I used a different connection pool to ensure we won't overwrite the database (in local environment) as I set the ddl-generation to drop-and-create-tables.
For docker container, we create a single glassfish+mysql docker-compose for running test; it should set up databases and connection pools for each applications and be part of the jenkins network. Tell me if I'm wrong.

@ymajoros
Copy link
Contributor

ymajoros commented Apr 5, 2016

Please do use the same database :-)

That way, you don't need to populate one. That also means: only one way to create a database, the test one is not different.

Those tests won't ever run on production. They will run on a copy of it, from time to time, which is a good thing.

if (saleCustomerLoyaltyEntry != null) {
removeCustomerLoyaltyAccountingEntry(saleCustomerLoyaltyEntry);
}
} catch (IllegalStateException e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever we catch something like this, we can now the Exception type isn't appropriate.

@ymajoros
Copy link
Contributor

ymajoros commented Apr 5, 2016

I'll need to work on it too to have a common first test we agree on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants