Skip to content

Commit

Permalink
Merge pull request #1746 from arjantijms/entityManagerFactoryCloseExc…
Browse files Browse the repository at this point in the history
…eptions

Fix entityManagerFactoryCloseExceptions.ClientPmservletTest
  • Loading branch information
arjantijms authored Jan 12, 2025
2 parents bfef1be + a3aacb1 commit b64a390
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 109 deletions.
2 changes: 1 addition & 1 deletion glassfish-runner/persistence-platform-tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@
</goals>
<configuration>
<includes>
<include>ee/jakarta/tck/persistence/core/StoredProcedureQuery/Client1PmservletTest.java</include>
<include>ee/jakarta/tck/persistence/**/*Test.java</include>
</includes>
<groups>tck-javatest</groups>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
package ee.jakarta.tck.persistence.core.entityManagerFactoryCloseExceptions;

import ee.jakarta.tck.persistence.core.entityManagerFactoryCloseExceptions.Client;
import com.sun.ts.lib.harness.EETest;
import com.sun.ts.lib.harness.ServiceEETest;
import com.sun.ts.tests.common.vehicle.VehicleClient;
import com.sun.ts.tests.common.vehicle.VehicleRunnable;
import com.sun.ts.tests.common.vehicle.VehicleRunnerFactory;
import com.sun.ts.tests.common.vehicle.ejb3share.EJB3ShareBaseBean;
import com.sun.ts.tests.common.vehicle.ejb3share.EJB3ShareIF;
import com.sun.ts.tests.common.vehicle.ejb3share.EntityTransactionWrapper;
import com.sun.ts.tests.common.vehicle.ejb3share.NoopTransactionWrapper;
import com.sun.ts.tests.common.vehicle.ejb3share.UseEntityManager;
import com.sun.ts.tests.common.vehicle.ejb3share.UseEntityManagerFactory;
import com.sun.ts.tests.common.vehicle.ejb3share.UserTransactionWrapper;
import com.sun.ts.tests.common.vehicle.pmservlet.PMServletVehicle;
import com.sun.ts.tests.common.vehicle.servlet.ServletVehicle;

import java.net.URL;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.container.test.api.OverProtocol;
import org.jboss.arquillian.container.test.api.TargetsContainer;
import org.jboss.arquillian.junit5.ArquillianExtension;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
Expand All @@ -19,131 +31,129 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;

import ee.jakarta.tck.persistence.common.PMClientBase;
import tck.arquillian.porting.lib.spi.TestArchiveProcessor;
import tck.arquillian.protocol.common.TargetVehicle;



@ExtendWith(ArquillianExtension.class)
@Tag("persistence")
@Tag("platform")
@Tag("web")
@Tag("tck-javatest")

@TestMethodOrder(MethodOrderer.MethodName.class)
public class ClientPmservletTest extends ee.jakarta.tck.persistence.core.entityManagerFactoryCloseExceptions.Client {
public class ClientPmservletTest extends Client {

private static final long serialVersionUID = 1L;
static final String VEHICLE_ARCHIVE = "jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle";

/**
EE10 Deployment Descriptors:
jpa_core_entityManagerFactoryCloseException: META-INF/persistence.xml
jpa_core_entityManagerFactoryCloseException_appmanaged_vehicle_client: META-INF/application-client.xml
jpa_core_entityManagerFactoryCloseException_appmanaged_vehicle_ejb: jar.sun-ejb-jar.xml
jpa_core_entityManagerFactoryCloseException_appmanagedNoTx_vehicle_client: META-INF/application-client.xml
jpa_core_entityManagerFactoryCloseException_appmanagedNoTx_vehicle_ejb: jar.sun-ejb-jar.xml
jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web: WEB-INF/web.xml
jpa_core_entityManagerFactoryCloseException_puservlet_vehicle_web: WEB-INF/web.xml
jpa_core_entityManagerFactoryCloseException_stateful3_vehicle_client: META-INF/application-client.xml
jpa_core_entityManagerFactoryCloseException_stateful3_vehicle_ejb: jar.sun-ejb-jar.xml
jpa_core_entityManagerFactoryCloseException_stateless3_vehicle_client: META-INF/application-client.xml
jpa_core_entityManagerFactoryCloseException_stateless3_vehicle_ejb: jar.sun-ejb-jar.xml
jpa_core_entityManagerFactoryCloseException_vehicles:
Found Descriptors:
War:
/com/sun/ts/tests/common/vehicle/pmservlet/pmservlet_vehicle_web.xml
Ear:
*/
@TargetsContainer("tck-javatest")
@OverProtocol("javatest")
@Deployment(name = VEHICLE_ARCHIVE, order = 2)
public static EnterpriseArchive createDeploymentVehicle(@ArquillianResource TestArchiveProcessor archiveProcessor) {
/**
* EE10 Deployment Descriptors: jpa_core_entityManagerFactoryCloseException: META-INF/persistence.xml
* jpa_core_entityManagerFactoryCloseException_appmanaged_vehicle_client: META-INF/application-client.xml
* jpa_core_entityManagerFactoryCloseException_appmanaged_vehicle_ejb: jar.sun-ejb-jar.xml
* jpa_core_entityManagerFactoryCloseException_appmanagedNoTx_vehicle_client: META-INF/application-client.xml
* jpa_core_entityManagerFactoryCloseException_appmanagedNoTx_vehicle_ejb: jar.sun-ejb-jar.xml
* jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web: WEB-INF/web.xml
* jpa_core_entityManagerFactoryCloseException_puservlet_vehicle_web: WEB-INF/web.xml
* jpa_core_entityManagerFactoryCloseException_stateful3_vehicle_client: META-INF/application-client.xml
* jpa_core_entityManagerFactoryCloseException_stateful3_vehicle_ejb: jar.sun-ejb-jar.xml
* jpa_core_entityManagerFactoryCloseException_stateless3_vehicle_client: META-INF/application-client.xml
* jpa_core_entityManagerFactoryCloseException_stateless3_vehicle_ejb: jar.sun-ejb-jar.xml
* jpa_core_entityManagerFactoryCloseException_vehicles:
*
* Found Descriptors: War:
*
* /com/sun/ts/tests/common/vehicle/pmservlet/pmservlet_vehicle_web.xml Ear:
*
*/
@TargetsContainer("tck-javatest")
@OverProtocol("javatest")
@Deployment(name = VEHICLE_ARCHIVE, order = 2)
public static EnterpriseArchive createDeploymentVehicle(@ArquillianResource TestArchiveProcessor archiveProcessor) {
// War
// the war with the correct archive name
WebArchive jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web = ShrinkWrap.create(WebArchive.class, "jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web.war");
// The class files
jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web.addClasses(
com.sun.ts.tests.common.vehicle.ejb3share.EJB3ShareBaseBean.class,
com.sun.ts.tests.common.vehicle.VehicleRunnerFactory.class,
com.sun.ts.tests.common.vehicle.ejb3share.UseEntityManager.class,
com.sun.ts.tests.common.vehicle.ejb3share.EJB3ShareIF.class,
com.sun.ts.lib.harness.EETest.Fault.class,
com.sun.ts.tests.common.vehicle.ejb3share.UseEntityManagerFactory.class,
ee.jakarta.tck.persistence.common.PMClientBase.class,
com.sun.ts.tests.common.vehicle.servlet.ServletVehicle.class,
com.sun.ts.tests.common.vehicle.VehicleRunnable.class,
com.sun.ts.tests.common.vehicle.ejb3share.UserTransactionWrapper.class,
com.sun.ts.lib.harness.EETest.class,
com.sun.ts.lib.harness.ServiceEETest.class,
com.sun.ts.tests.common.vehicle.ejb3share.EntityTransactionWrapper.class,
com.sun.ts.tests.common.vehicle.pmservlet.PMServletVehicle.class,
ee.jakarta.tck.persistence.core.entityManagerFactoryCloseExceptions.Client.class,
com.sun.ts.lib.harness.EETest.SetupException.class,
com.sun.ts.tests.common.vehicle.VehicleClient.class,
com.sun.ts.tests.common.vehicle.ejb3share.NoopTransactionWrapper.class
);
// The web.xml descriptor
URL warResURL = Client.class.getResource("/com/sun/ts/tests/common/vehicle/pmservlet/pmservlet_vehicle_web.xml");
if(warResURL != null) {
jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web.addAsWebInfResource(warResURL, "web.xml");
}
// The sun-web.xml descriptor
warResURL = Client.class.getResource("/com/sun/ts/tests/common/vehicle/pmservlet/pmservlet_vehicle_web.war.sun-web.xml");
if(warResURL != null) {
jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web.addAsWebInfResource(warResURL, "sun-web.xml");
}

// Any libraries added to the war
URL libURL;
JavaArchive jpa_core_entityManagerFactoryCloseException_lib = ShrinkWrap.create(JavaArchive.class, "jpa_core_entityManagerFactoryCloseException.jar");

// The resources
libURL = Client.class.getResource("persistence.xml");
jpa_core_entityManagerFactoryCloseException_lib.addAsResource(libURL, "persistence.xml");

jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web.addAsLibrary(jpa_core_entityManagerFactoryCloseException_lib);


// Web content
warResURL = Client.class.getResource("/com/sun/ts/tests/common/vehicle/pmservlet/pmservlet_vehicle_web.xml");
if(warResURL != null) {
jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web.addAsWebResource(warResURL, "/WEB-INF/pmservlet_vehicle_web.xml");
}

// Call the archive processor
archiveProcessor.processWebArchive(jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web, Client.class, warResURL);
// the war with the correct archive name
WebArchive jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web =
ShrinkWrap.create(WebArchive.class, "jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web.war");

// The class files
jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web.addClasses(
EJB3ShareBaseBean.class,
VehicleRunnerFactory.class,
UseEntityManager.class,
EJB3ShareIF.class,
Fault.class,
UseEntityManagerFactory.class,
PMClientBase.class,
ServletVehicle.class,
VehicleRunnable.class,
UserTransactionWrapper.class,
EETest.class,
ServiceEETest.class,
EntityTransactionWrapper.class,
PMServletVehicle.class,
Client.class,
SetupException.class, VehicleClient.class,
NoopTransactionWrapper.class);

// The web.xml descriptor
URL warResURL = Client.class.getResource("/com/sun/ts/tests/common/vehicle/pmservlet/pmservlet_vehicle_web.xml");
if (warResURL != null) {
jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web.addAsWebInfResource(warResURL, "web.xml");
}

// The sun-web.xml descriptor
warResURL = Client.class.getResource("/com/sun/ts/tests/common/vehicle/pmservlet/pmservlet_vehicle_web.war.sun-web.xml");
if (warResURL != null) {
jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web.addAsWebInfResource(warResURL, "sun-web.xml");
}

// Any libraries added to the war
JavaArchive jpa_core_entityManagerFactoryCloseException_lib =
ShrinkWrap.create(JavaArchive.class, "jpa_core_entityManagerFactoryCloseException.jar");

// Ear
EnterpriseArchive jpa_core_entityManagerFactoryCloseException_vehicles_ear = ShrinkWrap.create(EnterpriseArchive.class, "jpa_core_entityManagerFactoryCloseException_vehicles.ear");
// The resources
URL libURL = Client.class.getResource("persistence.xml");
jpa_core_entityManagerFactoryCloseException_lib.addAsManifestResource(libURL, "persistence.xml");

// Any libraries added to the ear
jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web.addAsLibrary(jpa_core_entityManagerFactoryCloseException_lib);

// The component jars built by the package target
jpa_core_entityManagerFactoryCloseException_vehicles_ear.addAsModule(jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web);
// Web content
warResURL = Client.class.getResource("/com/sun/ts/tests/common/vehicle/pmservlet/pmservlet_vehicle_web.xml");
if (warResURL != null) {
jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web.addAsWebResource(warResURL,
"/WEB-INF/pmservlet_vehicle_web.xml");
}

// Call the archive processor
archiveProcessor.processWebArchive(jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web, Client.class, warResURL);

// Ear
EnterpriseArchive jpa_core_entityManagerFactoryCloseException_vehicles_ear =
ShrinkWrap.create(EnterpriseArchive.class, "jpa_core_entityManagerFactoryCloseException_vehicles.ear");

// The application.xml descriptor
URL earResURL = null;
// The sun-application.xml descriptor
earResURL = Client.class.getResource("/.ear.sun-application.xml");
if(earResURL != null) {
jpa_core_entityManagerFactoryCloseException_vehicles_ear.addAsManifestResource(earResURL, "sun-application.xml");
}
// Call the archive processor
archiveProcessor.processEarArchive(jpa_core_entityManagerFactoryCloseException_vehicles_ear, Client.class, earResURL);
return jpa_core_entityManagerFactoryCloseException_vehicles_ear;
}
// Any libraries added to the ear

// The component jars built by the package target
jpa_core_entityManagerFactoryCloseException_vehicles_ear
.addAsModule(jpa_core_entityManagerFactoryCloseException_pmservlet_vehicle_web);

@Test
@Override
@TargetVehicle("pmservlet")
public void exceptionsTest() throws java.lang.Exception {
super.exceptionsTest();
// The sun-application.xml descriptor
URL earResURL = Client.class.getResource("/.ear.sun-application.xml");
if (earResURL != null) {
jpa_core_entityManagerFactoryCloseException_vehicles_ear.addAsManifestResource(earResURL, "sun-application.xml");
}

// Call the archive processor
archiveProcessor.processEarArchive(jpa_core_entityManagerFactoryCloseException_vehicles_ear, Client.class, earResURL);

return jpa_core_entityManagerFactoryCloseException_vehicles_ear;
}

@Test
@Override
@TargetVehicle("pmservlet")
public void exceptionsTest() throws java.lang.Exception {
super.exceptionsTest();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->

<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence
https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="3.0">

<persistence-unit name="CTS-EM" transaction-type="JTA">
<description>Persistence Unit for CTS Vehicle Tests</description>
<jta-data-source>jdbc/DB1</jta-data-source>
</persistence-unit>

<persistence-unit name="CTS-EM2" transaction-type="JTA">
<description>Persistence Unit for CTS Vehicle Tests</description>
<jta-data-source>jdbc/DB1</jta-data-source>
</persistence-unit>

<persistence-unit name="CTS-EM-NOTX" transaction-type="RESOURCE_LOCAL">
<description>
The persistence.xml file may be used to designate more than one persistence
unit within the same scope.

Persistence Unit for Application Managed Resource Local</description>
<non-jta-data-source>jdbc/DB_no_tx</non-jta-data-source>
</persistence-unit>
</persistence>

0 comments on commit b64a390

Please sign in to comment.