-
Notifications
You must be signed in to change notification settings - Fork 109
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
Initial draft of Jakarta Persistence/CDI EE integration tests #1623
Draft
starksm64
wants to merge
4
commits into
main
Choose a base branch
from
issue1405
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 22 additions & 0 deletions
22
glassfish-runner/jpa-platform-tck/src/test/resources/rest-arquillian.xml
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,22 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://jboss.org/schema/arquillian" | ||
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> | ||
|
||
<defaultProtocol type="Servlet 5.0" /> | ||
<engine> | ||
<property name="deploymentExportPath">target/deployments</property> | ||
</engine> | ||
<extension qualifier="glassfish-descriptors"> | ||
<property name="descriptorDir">target/</property> | ||
</extension> | ||
|
||
<group qualifier="glassfish-servers" default="true"> | ||
<container qualifier="tck-rest" default="true"> | ||
<configuration> | ||
<property name="glassFishHome">target/glassfish8</property> | ||
</configuration> | ||
</container> | ||
</group> | ||
|
||
</arquillian> |
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
21 changes: 21 additions & 0 deletions
21
jpa/platform-tests/src/main/java/ee/jakarta/tck/persistence/ee/cdi/CtsEmNoTxQualifier.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,21 @@ | ||
package ee.jakarta.tck.persistence.ee.cdi; | ||
|
||
import jakarta.inject.Qualifier; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
/** | ||
* Qualifier for selecting the CTS-EM persistence unit. | ||
*/ | ||
@Qualifier | ||
@Documented | ||
@Retention(RUNTIME) | ||
@Target({ FIELD, METHOD }) | ||
public @interface CtsEmNoTxQualifier { | ||
} |
21 changes: 21 additions & 0 deletions
21
jpa/platform-tests/src/main/java/ee/jakarta/tck/persistence/ee/cdi/CtsEmQualifier.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,21 @@ | ||
package ee.jakarta.tck.persistence.ee.cdi; | ||
|
||
import jakarta.inject.Qualifier; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
/** | ||
* Qualifier for selecting the CTS-EM persistence unit. | ||
*/ | ||
@Qualifier | ||
@Documented | ||
@Retention(RUNTIME) | ||
@Target({ FIELD, METHOD }) | ||
public @interface CtsEmQualifier { | ||
} |
9 changes: 9 additions & 0 deletions
9
jpa/platform-tests/src/main/java/ee/jakarta/tck/persistence/ee/cdi/JaxRsActivator.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,9 @@ | ||
package ee.jakarta.tck.persistence.ee.cdi; | ||
|
||
import jakarta.ws.rs.ApplicationPath; | ||
import jakarta.ws.rs.core.Application; | ||
|
||
@ApplicationPath("/rest") | ||
public class JaxRsActivator extends Application { | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
jpa/platform-tests/src/main/java/ee/jakarta/tck/persistence/ee/cdi/RestEndpoint.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 ee.jakarta.tck.persistence.ee.cdi; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
/** | ||
* Called by test client using the arquillian rest protocol | ||
*/ | ||
@Path("/cdi-jpa") | ||
public class RestEndpoint { | ||
@Inject | ||
TestBeanEM testBean; | ||
|
||
@GET | ||
@Path("/injectEmUsingQualifier") | ||
public String injectEmUsingQualifier() throws Exception { | ||
testBean.injectEmUsingQualifier(); | ||
return "PASSED"; | ||
} | ||
|
||
|
||
} |
76 changes: 76 additions & 0 deletions
76
jpa/platform-tests/src/main/java/ee/jakarta/tck/persistence/ee/cdi/ServletEMLookupTest.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,76 @@ | ||
package ee.jakarta.tck.persistence.ee.cdi; | ||
|
||
import jakarta.ws.rs.client.Client; | ||
import jakarta.ws.rs.client.ClientBuilder; | ||
import jakarta.ws.rs.core.Response; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit5.ArquillianExtension; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import tck.arquillian.porting.lib.spi.TestArchiveProcessor; | ||
|
||
import java.net.URI; | ||
import java.net.URL; | ||
|
||
import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON_TYPE; | ||
|
||
/** | ||
* Test for EntityManager lookup via CDI | ||
*/ | ||
@ExtendWith(ArquillianExtension.class) | ||
public class ServletEMLookupTest { | ||
@ArquillianResource | ||
URL contextPath; | ||
|
||
@Deployment(name = "jpa-cdi-em-inject", testable = false) | ||
public static WebArchive deployment(@ArquillianResource TestArchiveProcessor archiveProcessor) { | ||
WebArchive war = ShrinkWrap.create(WebArchive.class) | ||
.addClasses(CtsEmQualifier.class, CtsEmNoTxQualifier.class, JaxRsActivator.class, | ||
TestBeanEM.class, RestEndpoint.class); | ||
|
||
// Par | ||
// the jar with the correct archive name | ||
JavaArchive jpa_ee_entityManager = ShrinkWrap.create(JavaArchive.class, "jpa_ee_entityManager.jar"); | ||
// The class files | ||
jpa_ee_entityManager.addClasses( | ||
ee.jakarta.tck.persistence.ee.entityManager.Order.class | ||
); | ||
// The persistence.xml descriptor | ||
URL parURL = ServletEMLookupTest.class.getResource("persistence.xml"); | ||
jpa_ee_entityManager.addAsManifestResource(parURL, "persistence.xml"); | ||
// Call the archive processor | ||
archiveProcessor.processParArchive(jpa_ee_entityManager, ServletEMLookupTest.class, parURL); | ||
|
||
// Web content | ||
war.addAsLibrary(jpa_ee_entityManager); | ||
|
||
// Call the archive processor | ||
archiveProcessor.processWebArchive(war, ServletEMLookupTest.class, null); | ||
return war; | ||
} | ||
|
||
/* | ||
* @testName: injectEmUsingQualifierTest | ||
* | ||
* @assertion_ids: PERSISTENCE:JAVADOC:3318; PERSISTENCE:SPEC:1801; | ||
* PERSISTENCE:SPEC:1804; PERSISTENCE:SPEC:1883.2; | ||
* | ||
* @test_Strategy: Inject an EntityManager using a qualifier and injection | ||
*/ | ||
@Test | ||
public void injectEmUsingQualifierTest() throws Exception { | ||
URI appIdURI = contextPath.toURI().resolve("rest/cdi-jpa/injectEmUsingQualifier"); | ||
final Client client = ClientBuilder.newBuilder().build(); | ||
final Response response = client.target(appIdURI) | ||
.request(APPLICATION_JSON_TYPE) | ||
.get(); | ||
int status = response.getStatus(); | ||
Assertions.assertEquals(200, status); | ||
response.close(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just temp to help with debugging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, leftover from looking at adding a glassfish annotation handler to the test deployment.