Skip to content

Latest commit

 

History

History
129 lines (98 loc) · 5.21 KB

README.adoc

File metadata and controls

129 lines (98 loc) · 5.21 KB

tasks: Test JPA with Arquillian

The tasks quickstart includes a persistence unit and sample persistence code to demonstrate how to use JPA for database access in WildFly.

What is it?

The tasks quickstart demonstrates how to use JPA in WildFly Application Server.

It includes a persistence unit and some sample persistence code to demonstrate database access in enterprise Java.

It does not contain a user interface layer. The purpose of the project is to show you how to test JPA with Arquillian.

Investigate the Console Output

When you run the Arquillian tests, Maven prints summary of the performed tests to the console. You should see the following results.

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.jboss.as.quickstarts.tasks.UserDaoTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.084 sec
Running org.jboss.as.quickstarts.tasks.TaskDaoTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.31 sec

Results :

Tests run: 8, Failures: 0, Errors: 0, Skipped: 0

Server log

SQL statements generated by Hibernate are written into the server log.

Server Log: Expected warnings and errors

You will see the following warnings in the server log. You can ignore these warnings.

WFLYJCA0091: -ds.xml file deployments are deprecated. Support may be removed in a future version.

HHH000431: Unable to determine H2 database version, certain features may not work

Example Output from the tests

Creating the database schema:

INFO  [stdout] (ServerService Thread Pool -- 104) Hibernate: drop table Task if exists
INFO  [stdout] (ServerService Thread Pool -- 104) Hibernate: drop table User if exists
INFO  [stdout] (ServerService Thread Pool -- 104) Hibernate: create table Task (id bigint generated by default as identity, title varchar(255), owner_id bigint, primary key (id))
INFO  [stdout] (ServerService Thread Pool -- 104) Hibernate: create table User (id bigint generated by default as identity, username varchar(255), primary key (id))
INFO  [stdout] (ServerService Thread Pool -- 104) Hibernate: alter table Task add constraint FK46hwvn8nayomwr7k7h13l0uxe foreign key (owner_id) references User
INFO  [stdout] (ServerService Thread Pool -- 104) Hibernate: alter table User add constraint UK_jreodf78a7pl5qidfh43axdfb unique (username)

Generating ID for a new entity and inserting the entity into the database:

INFO  [stdout] (default task-83) Hibernate: select user0_.id as id1_1_, user0_.username as username2_1_ from User user0_ where user0_.username=?
INFO  [stdout] (default task-88) Hibernate: select user0_.id as id1_1_, user0_.username as username2_1_ from User user0_ where user0_.username=?
INFO  [stdout] (default task-90) Hibernate: insert into User (id, username) values (null, ?)
INFO  [stdout] (default task-90) Hibernate: select user0_.id as id1_1_, user0_.username as username2_1_ from User user0_ where user0_.username=?