-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7208 from gastaldi/integrator
Fixed support for Integrators and ServiceContributors in Hibernate ORM
- Loading branch information
Showing
6 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
integration-tests/jpa/src/main/java/io/quarkus/it/jpa/integrator/IntegratorResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.quarkus.it.jpa.integrator; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
import javax.persistence.EntityManager; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
@Path("/integrator") | ||
@ApplicationScoped | ||
public class IntegratorResource { | ||
|
||
@Inject | ||
EntityManager em; | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public int create() { | ||
return TestIntegrator.COUNTER.get(); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
integration-tests/jpa/src/main/java/io/quarkus/it/jpa/integrator/TestIntegrator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.quarkus.it.jpa.integrator; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import org.hibernate.boot.Metadata; | ||
import org.hibernate.engine.spi.SessionFactoryImplementor; | ||
import org.hibernate.integrator.spi.Integrator; | ||
import org.hibernate.service.spi.SessionFactoryServiceRegistry; | ||
|
||
public class TestIntegrator implements Integrator { | ||
public static final AtomicInteger COUNTER = new AtomicInteger(); | ||
|
||
@Override | ||
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, | ||
SessionFactoryServiceRegistry serviceRegistry) { | ||
COUNTER.incrementAndGet(); | ||
} | ||
|
||
@Override | ||
public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { | ||
COUNTER.decrementAndGet(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...on-tests/jpa/src/main/resources/META-INF/services/org.hibernate.integrator.spi.Integrator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
io.quarkus.it.jpa.integrator.TestIntegrator |
20 changes: 20 additions & 0 deletions
20
integration-tests/jpa/src/test/java/io/quarkus/it/jpa/integrator/JPAIntegratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.quarkus.it.jpa.integrator; | ||
|
||
import static io.restassured.RestAssured.when; | ||
import static org.hamcrest.core.Is.is; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
public class JPAIntegratorTest { | ||
|
||
@Test | ||
public void testInjection() { | ||
when().get("/jpa-test/integrator").then() | ||
.statusCode(200) | ||
.body(is("1")); | ||
} | ||
|
||
} |