Skip to content

Commit

Permalink
Add sigtest-maven-plugin to war deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Marlow <[email protected]>
  • Loading branch information
scottmarlow committed Jan 23, 2025
1 parent 4303670 commit 8fd916b
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 107 deletions.
6 changes: 6 additions & 0 deletions tcks/profiles/platform/signaturevalidation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<properties>
<arquillian.junit>1.9.3.Final</arquillian.junit>
<jakarta.ee.version>11.0.0-SNAPSHOT</jakarta.ee.version>
<jakarta.tck.sigtest.version>2.4</jakarta.tck.sigtest.version>
<junit.jupiter.version>5.9.1</junit.jupiter.version>
<maven.compiler.release>17</maven.compiler.release>
</properties>
Expand Down Expand Up @@ -125,6 +126,11 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>jakarta.tck</groupId>
<artifactId>sigtest-maven-plugin</artifactId>
<version>${jakarta.tck.sigtest.version}</version>
</dependency>
</dependencies>
<build>
<!-- Include the container descriptors in the output artifact -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@

package com.sun.ts.tests.signaturetest;

import java.io.File;
import java.io.Serializable;
import java.net.URL;
import java.util.Arrays;
import java.util.Properties;

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.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
Expand All @@ -48,112 +51,117 @@
@Tag("web")
@TestMethodOrder(MethodOrderer.MethodName.class)
public class ClientServlet extends JakartaEESigTest implements Serializable {
static final String VEHICLE_ARCHIVE = "jpa_jpa22_repeatable_attroverride_pmservlet_vehicle";

/**
* Servlet container test
*
* Only generate the war for this test since it needs to deploy to both Platform + Web Profile.
*
* EE 10 JavaEESigTest_servlet_vehicle.ear contents
*
* META-INF/MANIFEST.MF
* JavaEESigTest_servlet_vehicle_web.war
*
* JavaEESigTest_servlet_vehicle_web.war contents
*
* META-INF/MANIFEST.MF
* WEB-INF/classes/com/sun/ts/tests/signaturetest/javaee/JavaEESigTest$Containers.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/javaee/JavaEESigTest.class
* WEB-INF/classes/com/sun/ts/lib/harness/EETest$Fault.class
* WEB-INF/classes/com/sun/ts/lib/harness/EETest$SetupException.class
* WEB-INF/classes/com/sun/ts/lib/harness/EETest.class
* WEB-INF/classes/com/sun/ts/lib/harness/ServiceEETest.class
* WEB-INF/classes/com/sun/ts/tests/common/vehicle/VehicleClient.class
* WEB-INF/classes/com/sun/ts/tests/common/vehicle/VehicleRunnable.class
* WEB-INF/classes/com/sun/ts/tests/common/vehicle/VehicleRunnerFactory.class
* WEB-INF/classes/com/sun/ts/tests/common/vehicle/servlet/ServletVehicle.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/ApiCheckDriver.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/PackageList.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SigTest.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SigTestData.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SigTestDriver.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SigTestEE.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SigTestResult.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SignatureTestDriver$SignatureFileInfo.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SignatureTestDriver.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SignatureTestDriverFactory.class
* WEB-INF/lib/sigtest.jar
* WEB-INF/web.xml
*/

public static WebArchive createDeploymentVehicle(@ArquillianResource TestArchiveProcessor archiveProcessor) {
// War
// the war with the correct archive name
WebArchive signaturetest_servlet_vehicle_web = ShrinkWrap.create(WebArchive.class, "SigTest_servlet_vehicle_web.war");
// The class files
signaturetest_servlet_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,
ClientServlet.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,
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 = ClientServlet.class.getResource("/com/sun/ts/tests/common/vehicle/servlet/servlet_vehicle_web.xml");
if(warResURL != null) {
signaturetest_servlet_vehicle_web.addAsWebInfResource(warResURL, "web.xml");
}

// add sigtest.jar to the war

// Web content
warResURL = ClientServlet.class.getResource("sigtest.jar");
if(warResURL != null) {
signaturetest_servlet_vehicle_web.addAsWebResource(warResURL, "/WEB-INF/lib/sigtest.jar");
}

// Call the archive processor
archiveProcessor.processWebArchive(signaturetest_servlet_vehicle_web, ClientServlet.class, warResURL);
return signaturetest_servlet_vehicle_web;
}


/* Test setup: */

/*
* @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial;
*
* @class.testArgs: -ap tssql.stmt
*/
public void setup(String args[], Properties p) throws Exception {
super.setup(args,p);
TestUtil.logMsg("Setup signature tests");
}

/* Test cleanup */

public void cleanup() throws Exception {
TestUtil.logMsg("Cleanup ok");
}

@Test
@Override
@TargetVehicle("servlet")
public void signatureTest() throws java.lang.Exception {
super.signatureTest();
}
static final String VEHICLE_ARCHIVE = "jpa_jpa22_repeatable_attroverride_pmservlet_vehicle";

/**
* Servlet container test
* <p>
* Only generate the war for this test since it needs to deploy to both Platform + Web Profile.
* <p>
* EE 10 JavaEESigTest_servlet_vehicle.ear contents
* <p>
* META-INF/MANIFEST.MF
* JavaEESigTest_servlet_vehicle_web.war
* <p>
* JavaEESigTest_servlet_vehicle_web.war contents
* <p>
* META-INF/MANIFEST.MF
* WEB-INF/classes/com/sun/ts/tests/signaturetest/javaee/JavaEESigTest$Containers.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/javaee/JavaEESigTest.class
* WEB-INF/classes/com/sun/ts/lib/harness/EETest$Fault.class
* WEB-INF/classes/com/sun/ts/lib/harness/EETest$SetupException.class
* WEB-INF/classes/com/sun/ts/lib/harness/EETest.class
* WEB-INF/classes/com/sun/ts/lib/harness/ServiceEETest.class
* WEB-INF/classes/com/sun/ts/tests/common/vehicle/VehicleClient.class
* WEB-INF/classes/com/sun/ts/tests/common/vehicle/VehicleRunnable.class
* WEB-INF/classes/com/sun/ts/tests/common/vehicle/VehicleRunnerFactory.class
* WEB-INF/classes/com/sun/ts/tests/common/vehicle/servlet/ServletVehicle.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/ApiCheckDriver.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/PackageList.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SigTest.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SigTestData.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SigTestDriver.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SigTestEE.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SigTestResult.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SignatureTestDriver$SignatureFileInfo.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SignatureTestDriver.class
* WEB-INF/classes/com/sun/ts/tests/signaturetest/SignatureTestDriverFactory.class
* WEB-INF/lib/sigtest.jar
* WEB-INF/web.xml
*/

public static WebArchive createDeploymentVehicle(@ArquillianResource TestArchiveProcessor archiveProcessor) {
// War
// the war with the correct archive name
WebArchive signaturetest_servlet_vehicle_web = ShrinkWrap.create(WebArchive.class, "SigTest_servlet_vehicle_web.war");
// The class files
signaturetest_servlet_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,
ClientServlet.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,
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 = ClientServlet.class.getResource("/com/sun/ts/tests/common/vehicle/servlet/servlet_vehicle_web.xml");
if (warResURL != null) {
signaturetest_servlet_vehicle_web.addAsWebInfResource(warResURL, "web.xml");
}

// add jakarta.tck:sigtest-maven-plugin jar to the war
// Import Maven runtime dependencies
File[] files = Maven.resolver()
.loadPomFromFile("pom.xml")
.importRuntimeDependencies()
.resolve()
.withTransitivity()
.asFile();
// add signature test artifact
Arrays.stream(files).filter(file -> file.getName().contains("sigtest-maven-plugin"))
.forEach(file -> {
signaturetest_servlet_vehicle_web.addAsLibrary(file);
});
// Call the archive processor
archiveProcessor.processWebArchive(signaturetest_servlet_vehicle_web, ClientServlet.class, warResURL);
return signaturetest_servlet_vehicle_web;
}


/* Test setup: */

/*
* @class.setup_props: org.omg.CORBA.ORBClass; java.naming.factory.initial;
*
* @class.testArgs: -ap tssql.stmt
*/
public void setup(String args[], Properties p) throws Exception {
super.setup(args, p);
TestUtil.logMsg("Setup signature tests");
}

/* Test cleanup */

public void cleanup() throws Exception {
TestUtil.logMsg("Cleanup ok");
}

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

}

0 comments on commit 8fd916b

Please sign in to comment.