Skip to content
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

Standalone Persistence TCK runner inside Glassfish #1319

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"asciidoc.antora.enableAntoraSupport": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2021,2024 Contributors to the Eclipse Foundation

See the NOTICE file distributed with this work for additional information
regarding copyright ownership. Licensed under the Apache License,
Version 2.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

SPDX-License-Identifier: Apache-2.0
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.eclipse.ee4j</groupId>
<artifactId>project</artifactId>
<version>1.0.9</version>
</parent>

<groupId>jakarta.tck</groupId>
<artifactId>persistence-tck-arquillian-extension</artifactId>
<version>3.2.0</version>
<packaging>jar</packaging>
<name>Extension for running Persistence TCK in GlassFish</name>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.8.0.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.1</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-reporting</artifactId>
<version>1.10.2</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-container-test-spi</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
<version>3.3.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>3.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<version>4.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.tck</groupId>
<artifactId>persistence-tck-common</artifactId>
<version>3.2.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<!-- Sets minimal Maven version to 3.8.6 -->
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.8.6</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>

<!-- Restricts the Java version to 17 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<release>17</release>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. Licensed under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.glassfish.persistence.tck;

import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor;
import org.jboss.arquillian.container.test.spi.client.deployment.DeploymentScenarioGenerator;
import org.jboss.arquillian.container.test.spi.client.deployment.ProtocolArchiveProcessor;
import org.jboss.arquillian.core.spi.LoadableExtension;
import org.jboss.arquillian.core.spi.LoadableExtension.ExtensionBuilder;

public class ArquillianExtension implements LoadableExtension {

public static final String PROPERTY_PREFIX = "arquillian.extension.";

@Override
public void register(ExtensionBuilder builder) {
builder.service(DeploymentScenarioGenerator.class, MavenTestDependenciesDeploymentPackager.class);
builder.service(ApplicationArchiveProcessor.class, SystemPropertiesArchiveProcessor.class);
builder.service(ProtocolArchiveProcessor.class, RemoveClassesArchiveProcessor.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. Licensed under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.glassfish.persistence.tck;

import java.io.File;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;

/**
*
* @author omihalyi
*/
public enum DeploymentPackageType {
WAR {
@Override
protected PackageBuilder getPackageBuilder(Archive<?> archive) {
return new WarPackageBuilder(archive);
}
}, EAR {
@Override
protected PackageBuilder getPackageBuilder(Archive<?> archive) {
throw new UnsupportedOperationException("Not supported yet.");
}
};

public static DeploymentPackageType fromString(String value) {
if (value == null || value.isEmpty()) {
return null;
}
String upperCaseValue = value.toUpperCase();
// remove special chars, e.g. ejb-jar is turned into EJBJAR
upperCaseValue = upperCaseValue.replaceAll("-|_|\\.| ", "");
return DeploymentPackageType.valueOf(upperCaseValue);
}

public static DeploymentPackageType fromArchive(Archive<?> archive) {
if (archive == null) {
return null;
}
if (archive instanceof WebArchive) {
return WAR;
} else if (archive instanceof EnterpriseArchive) {
return EAR;
} else {
throw new RuntimeException("Unsupported archive type: " + archive.getClass());
}
}

protected PackageBuilder getPackageBuilder() {
return getPackageBuilder(null);
}

// create builder from an existing archive - modifies the existing archive
protected abstract PackageBuilder getPackageBuilder(Archive<?> archive);

interface PackageBuilder {

PackageBuilder addArtifact(File artifactFile);

PackageBuilder addResource(Asset resourceAsset, String resourceName);

PackageBuilder addClass(Class<?> cls);

Archive<?> build();
}

class WarPackageBuilder implements PackageBuilder {

WebArchive archive;

public WarPackageBuilder(Archive<?> archive) {
if (archive == null) {
this.archive = ShrinkWrap.create(WebArchive.class, "package.war").as(WebArchive.class);
} else {
this.archive = archive.as(WebArchive.class);
}
}

@Override
public WarPackageBuilder addArtifact(File artifactFile) {
final JavaArchive artifactArchive = ShrinkWrap.createFromZipFile(JavaArchive.class, artifactFile);
artifactArchive.delete("/com/sun/ts/tests/jms/commonee/MDB_Q_TestEJB.class");
artifactArchive.delete("/com/sun/ts/tests/jms/commonee/MDB_T_TestEJB.class");
archive.addAsLibrary(artifactArchive);
return this;
}

@Override
public WarPackageBuilder addResource(Asset resourceAsset, String resourceName) {
archive.addAsResource(resourceAsset, resourceName);
return this;
}

public WarPackageBuilder addClass(Class<?> cls) {
archive.addClass(cls);
return this;
}

@Override
public Archive<?> build() {
return archive;
}
}

}
Loading