Skip to content

Commit a8bd799

Browse files
Simplification. No need for @SesssionScope bean. Inject @stateful to arq test
1 parent 7868a8c commit a8bd799

File tree

2 files changed

+14
-39
lines changed

2 files changed

+14
-39
lines changed

jpa/extended-pc/src/main/java/org/javaee7/jpa/extended/pc/BigBangTheoryService.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

jpa/extended-pc/src/test/java/org/javaee7/jpa/extended/pc/ExtendedPersistenceContextSpecification.groovy

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package org.javaee7.jpa.extended.pc
2-
32
import org.jboss.arquillian.container.test.api.Deployment
43
import org.jboss.arquillian.spock.ArquillianSputnik
54
import org.jboss.shrinkwrap.api.ShrinkWrap
65
import org.jboss.shrinkwrap.api.spec.WebArchive
76
import org.junit.runner.RunWith
87
import spock.lang.Specification
98

10-
import javax.inject.Inject
9+
import javax.ejb.EJB
1110
import javax.persistence.EntityManager
1211
import javax.persistence.PersistenceContext
13-
1412
/**
1513
* @author Kuba Marchwicki
1614
*/
@@ -20,8 +18,8 @@ class ExtendedPersistenceContextSpecification extends Specification {
2018
@PersistenceContext
2119
EntityManager em;
2220

23-
@Inject
24-
BigBangTheoryService service;
21+
@EJB
22+
CharactersBean bean;
2523

2624
@Deployment
2725
def static WebArchive deploy() {
@@ -30,12 +28,19 @@ class ExtendedPersistenceContextSpecification extends Specification {
3028
.addAsResource("META-INF/persistence.xml")
3129
.addAsResource("META-INF/create.sql")
3230
.addAsResource("META-INF/drop.sql")
33-
.addAsResource("META-INF/load.sql");
31+
.addAsResource("META-INF/load.sql")
3432
}
3533

3634
def setup() {
37-
service.addWilWheaton();
38-
service.updateRaj();
35+
Character wil = new Character(8, "Wil Wheaton")
36+
bean.save(wil)
37+
38+
for (Character c : bean.get()) {
39+
if ("Raj".equals(c.getName())) {
40+
c.setName("Rajesh Ramayan")
41+
bean.save(c)
42+
}
43+
}
3944
}
4045

4146
def "should not persist changes without transaction flush"() {
@@ -46,7 +51,7 @@ class ExtendedPersistenceContextSpecification extends Specification {
4651

4752
def "should update characters after transaction flush"() {
4853
when:
49-
service.proceed();
54+
bean.commitChanges()
5055

5156
then:
5257
8 == em.createNamedQuery(Character.FIND_ALL, Character.class).getResultList().size();

0 commit comments

Comments
 (0)