Skip to content

Commit

Permalink
JSONB appclient tests running with glassfish (#1564)
Browse files Browse the repository at this point in the history
* jsonb appclient tests running with glassfish

* fix 4 pluggability appclient tests that uses jsonb_alternate_provider jar
  • Loading branch information
alwin-joseph authored Oct 9, 2024
1 parent 9db8649 commit 1d3acfb
Show file tree
Hide file tree
Showing 14 changed files with 2,993 additions and 138 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2,463 changes: 2,463 additions & 0 deletions glassfish-runner/jsonb-platform-tck/jakartaeetck/bin/ts.jte

Large diffs are not rendered by default.

133 changes: 126 additions & 7 deletions glassfish-runner/jsonb-platform-tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<arquillian.junit>1.9.1.Final</arquillian.junit>
<!-- Use JDK17 to run with GF 8.0.0-JDK17-M5 -->
<glassfish.container.version>8.0.0-JDK17-M5</glassfish.container.version>
<glassfish.home>${project.build.directory}/${glassfish.toplevel.dir}</glassfish.home>
<glassfish.lib.dir>${glassfish.home}/glassfish/lib</glassfish.lib.dir>
<!-- Use JDK21 to run with GF 8.0.0-M5 -->
<!-- <glassfish.container.version>8.0.0-M5</glassfish.container.version> -->
<glassfish.toplevel.dir>glassfish8</glassfish.toplevel.dir>
Expand All @@ -39,6 +41,7 @@
<tck.version>11.0.0-SNAPSHOT</tck.version>
<ts.home>/jakartaeetck</ts.home>
<version.jakarta.tck>11.0.0-SNAPSHOT</version.jakarta.tck>
<version.jakarta.tck.arquillian>1.0.0-M17</version.jakarta.tck.arquillian>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -107,14 +110,29 @@
<dependency>
<groupId>org.omnifaces.arquillian</groupId>
<artifactId>arquillian-glassfish-server-managed</artifactId>
<version>1.4</version>
<version>1.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.tck.arquillian</groupId>
<artifactId>arquillian-protocol-appclient</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-container-spi</artifactId>
<version>${arquillian.junit}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.core</groupId>
<artifactId>arquillian-core-spi</artifactId>
<version>${arquillian.junit}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.test</groupId>
<artifactId>arquillian-test-impl-base</artifactId>
<version>${arquillian.junit}</version>
</dependency>

<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
Expand Down Expand Up @@ -179,6 +197,38 @@
<artifactId>tck-porting-lib</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>jakarta.tck</groupId>
<artifactId>libutil</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>jakarta.tck</groupId>
<artifactId>runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>jakarta.tck</groupId>
<artifactId>dbprocedures</artifactId>
<version>3.2.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.15.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<version>10.15.2.0</version>
</dependency>

</dependencies>

Expand Down Expand Up @@ -233,6 +283,73 @@
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<id>04-copy-lib</id>
<goals>
<goal>copy</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>jakarta.tck.arquillian</groupId>
<artifactId>arquillian-protocol-lib</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<destFileName>arquillian-protocol-lib.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>jakarta.tck</groupId>
<artifactId>libutil</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<destFileName>libutil.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>jakarta.tck.arquillian</groupId>
<artifactId>tck-porting-lib</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<destFileName>tck-porting-lib.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>jakarta.tck</groupId>
<artifactId>runtime</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<destFileName>runtime.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>jakarta.tck</groupId>
<artifactId>${tck.artifactId}</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<destFileName>jsonb-platform-tck.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${glassfish.lib.dir}</outputDirectory>
<destFileName>derbyclient.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${glassfish.lib.dir}</outputDirectory>
<destFileName>derbytools.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>jakarta.tck.arquillian</groupId>
<artifactId>arquillian-protocol-lib</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<destFileName>protocol.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>07-copy-protocol-lib</id>
<goals>
Expand Down Expand Up @@ -286,6 +403,7 @@
<harness.log.traceflag>true</harness.log.traceflag>
<cts.harness.debug>true</cts.harness.debug>
<java.io.tmpdir>/tmp</java.io.tmpdir>
<project.basedir>${project.basedir}</project.basedir>
<arquillian.xml>appclient-arquillian.xml</arquillian.xml>
</systemPropertyVariables>
<environmentVariables>
Expand Down Expand Up @@ -325,17 +443,17 @@
</environmentVariables>
</configuration>
</execution>

<execution>
<id>pluggability-tests-appclient</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!-- <additionalClasspathElements>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.directory}/${glassfish.toplevel.dir}/glassfish/modules/yasson.jar</additionalClasspathElement>
</additionalClasspathElements> -->
<additionalClasspathElement>${project.build.directory}/${glassfish.toplevel.dir}/glassfish/modules/parsson.jar</additionalClasspathElement>
</additionalClasspathElements>
<includes>
<include>com/sun/ts/tests/jsonb/pluggability/jsonbprovidertests/*Appclient*.java</include>
<include>com/sun/ts/tests/jsonb/pluggability/jsonbprovidertests/*Ejb*.java</include>
Expand All @@ -350,6 +468,7 @@
<harness.log.traceflag>true</harness.log.traceflag>
<cts.harness.debug>true</cts.harness.debug>
<java.io.tmpdir>/tmp</java.io.tmpdir>
<project.basedir>${project.basedir}</project.basedir>
<arquillian.xml>appclient-arquillian.xml</arquillian.xml>
</systemPropertyVariables>
<environmentVariables>
Expand All @@ -364,14 +483,14 @@
<goal>verify</goal>
</goals>
<configuration>
<!-- <additionalClasspathElements>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.directory}/${glassfish.toplevel.dir}/glassfish/modules/yasson.jar</additionalClasspathElement>
</additionalClasspathElements> -->
<additionalClasspathElement>${project.build.directory}/${glassfish.toplevel.dir}/glassfish/modules/parsson.jar</additionalClasspathElement>
</additionalClasspathElements>
<includes>
<include>com/sun/ts/tests/jsonb/pluggability/jsonbprovidertests/*Servlet*.java</include>
<include>com/sun/ts/tests/jsonb/pluggability/jsonbprovidertests/*Jsp*.java</include>
</includes>
<!-- Select the @Tag("tck-javatest") tests -->
<groups>tck-javatest</groups>
<dependenciesToScan>jakarta.tck:${tck.artifactId}</dependenciesToScan>
<systemPropertyVariables>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024 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
*/

package org.glassfish.jsonb.tck;

import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor;
import org.jboss.arquillian.test.spi.enricher.resource.ResourceProvider;
import org.jboss.arquillian.core.spi.LoadableExtension;

public class GlassfishLoadableExtension implements LoadableExtension {
@Override
public void register(ExtensionBuilder extensionBuilder) {
extensionBuilder.service(ResourceProvider.class, GlassfishTestArchiveProcessor.class);
extensionBuilder.observer(GlassfishTestArchiveProcessor.class);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/*
* Copyright (c) 2024 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
*/

package org.glassfish.jsonb.tck;

import org.jboss.arquillian.config.descriptor.api.ArquillianDescriptor;
import org.jboss.arquillian.config.descriptor.api.ExtensionDef;
import org.jboss.arquillian.core.api.annotation.Observes;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.container.ManifestContainer;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import tck.arquillian.porting.lib.spi.AbstractTestArchiveProcessor;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Logger;

public class GlassfishTestArchiveProcessor extends AbstractTestArchiveProcessor {

static Logger log = Logger.getLogger(GlassfishTestArchiveProcessor.class.getName());
static HashSet<String> sunXmlFiles = new HashSet<String>();
static {
sunXmlFiles.add("META-INF/sun-application-client.xml");
sunXmlFiles.add("META-INF/sun-application.xml");
sunXmlFiles.add("META-INF/sun-ra.xml");
sunXmlFiles.add("WEB-INF/sun-web.xml");
sunXmlFiles.add("META-INF/sun-ejb-jar.xml");
}

private Path descriptorDirRoot;

/**
* Called on completion of the Arquillian configuration.
*/
public void initalize(@Observes ArquillianDescriptor descriptor) {
// Must call to setup the ResourceProvider
super.initalize(descriptor);


// Get the descriptor path
ExtensionDef descriptorsDef = descriptor.extension("glassfish-descriptors");
String descriptorDir = descriptorsDef.getExtensionProperties().get("descriptorDir");
if(descriptorDir == null) {
String msg = "Specify the descriptorDir property in arquillian.xml as extension:\n"+
"<extension qualifier=\"glassfish-descriptors\">\n" +
" <property name=\"descriptorDir\">path-to-descriptors-dir</property>\n" +
"</extension>";
throw new IllegalStateException(msg);
}
this.descriptorDirRoot = Paths.get(descriptorDir);
if(!Files.exists(this.descriptorDirRoot)) {
throw new RuntimeException("Descriptor directory does not exist: " + this.descriptorDirRoot);
}
}

@Override
public void processClientArchive(JavaArchive clientArchive, Class<?> testClass, URL sunXmlURL) {
String name = clientArchive.getName();
// addDescriptors(name, clientArchive, testClass);
}

@Override
public void processWebArchive(WebArchive webArchive, Class<?> testClass, URL sunXmlURL) {
String name = webArchive.getName();
// addDescriptors(name, webArchive, testClass);
}

@Override
public void processRarArchive(JavaArchive warArchive, Class<?> testClass, URL sunXmlURL) {

}

@Override
public void processParArchive(JavaArchive javaArchive, Class<?> aClass, URL url) {

}

@Override
public void processEarArchive(EnterpriseArchive earArchive, Class<?> testClass, URL sunXmlURL) {
String name = earArchive.getName();
// addDescriptors(name, earArchive, testClass);
}

@Override
public void processEjbArchive(JavaArchive ejbArchive, Class<?> testClass, URL sunXmlURL) {
String name = ejbArchive.getName();
// addDescriptors(name, ejbArchive, testClass);
}

protected void addDescriptors(String archiveName, ManifestContainer<?> archive, Class<?> testClass) {
String pkgName = testClass.getPackageName();
Path pkgPath = Paths.get(pkgName.replace(".", "/"));
Path descriptorDir = descriptorDirRoot.resolve(pkgPath);
List<File> files = findGlassfishDescriptors(descriptorDir);
for (File f : files) {
String name = f.getName();
if(!name.startsWith(archiveName)) {
continue;
}
try {
URL url = f.toURL();
// stateful_migration_threetwo_annotated.ear.jboss-deployment-structure.xml -> jboss-deployment-structure.xml
String descriptorName = name.replace(archiveName+".", "");
if(archive instanceof WebArchive webArchive) {
webArchive.addAsWebInfResource(url, descriptorName);
} else {
archive.addAsManifestResource(url, descriptorName);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}

}

protected List<File> findGlassfishDescriptors(Path pkgPath) {
try {
List<File> files = Files.walk(pkgPath, 1)
.map(Path::toFile)
.filter(File::isFile)
.toList();
return files;
} catch (Exception e) {
}
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.glassfish.jsonb.tck.GlassfishLoadableExtension
Loading

0 comments on commit 1d3acfb

Please sign in to comment.