Skip to content

Commit

Permalink
TCK Tracking: Jakarta EE 10 Core Profile #6799
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
  • Loading branch information
jbescos committed Jun 9, 2023
1 parent 036d073 commit 56ac1ee
Show file tree
Hide file tree
Showing 50 changed files with 1,676 additions and 47 deletions.
27 changes: 25 additions & 2 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<version.lib.jakarta.jaxrs-api>3.1.0</version.lib.jakarta.jaxrs-api>
<version.lib.jakarta.jms-api>3.0.0</version.lib.jakarta.jms-api>
<version.lib.jakarta.jsonb-api>3.0.0</version.lib.jakarta.jsonb-api>
<version.lib.jakarta.jsonp-api>2.1.1</version.lib.jakarta.jsonp-api>
<version.lib.jakarta.jsonp-api>2.1.0</version.lib.jakarta.jsonp-api>
<version.lib.jakarta.persistence-api>3.1.0</version.lib.jakarta.persistence-api>
<version.lib.jakarta.transaction-api>2.0.0</version.lib.jakarta.transaction-api>
<version.lib.jakarta.validation-api>3.0.0</version.lib.jakarta.validation-api>
Expand Down Expand Up @@ -105,6 +105,9 @@
<version.lib.micronaut.sql>4.4.0</version.lib.micronaut.sql>
<!-- FIXME upgrade to 3.1 when it is released in Maven -->
<version.lib.microprofile-config>3.0.1</version.lib.microprofile-config>
<version.lib.microprofile-core-profile>10.0.1</version.lib.microprofile-core-profile>
<version.lib.microprofile-cdi-tck>4.0.9</version.lib.microprofile-cdi-tck>
<version.lib.microprofile-restfull-tck>3.1.3</version.lib.microprofile-restfull-tck>
<!-- FIXME upgrade to 4.1 when it is released in Maven -->
<version.lib.microprofile-fault-tolerance-api>4.0</version.lib.microprofile-fault-tolerance-api>
<version.lib.microprofile-graphql>2.0</version.lib.microprofile-graphql>
Expand Down Expand Up @@ -140,7 +143,7 @@
<version.lib.opentracing.grpc>0.2.1</version.lib.opentracing.grpc>
<version.lib.opentracing.tracerresolver>0.1.8</version.lib.opentracing.tracerresolver>
<version.lib.perfmark-api>0.25.0</version.lib.perfmark-api>
<version.lib.parsson>1.0.2</version.lib.parsson>
<version.lib.parsson>1.1.2</version.lib.parsson>
<version.lib.postgresql>42.4.3</version.lib.postgresql>
<version.lib.prometheus>0.9.0</version.lib.prometheus>
<version.lib.slf4j>2.0.0</version.lib.slf4j>
Expand Down Expand Up @@ -680,6 +683,26 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.ee.tck.coreprofile</groupId>
<artifactId>core-profile-tck-impl</artifactId>
<version>${version.lib.microprofile-core-profile}</version>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>cdi-tck-core-impl</artifactId>
<version>${version.lib.microprofile-cdi-tck}</version>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>cdi-tck-api</artifactId>
<version>${version.lib.microprofile-cdi-tck}</version>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta-restful-ws-tck</artifactId>
<version>${version.lib.microprofile-restfull-tck}</version>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.opentracing</groupId>
<artifactId>microprofile-opentracing-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* is empty)</li>
* <li>replaceConfigSourcesWithMp: (Optional) defaults to false: whether to replace config sources with microprofile if it
* exists</li>
* <li>useWebInfBeans: (Optional) defaults to false: whether WEB-INF/beans.xml should be loaded</li>
* </ul>
*/
public class HelidonContainerConfiguration implements ContainerConfiguration {
Expand All @@ -45,6 +46,7 @@ public class HelidonContainerConfiguration implements ContainerConfiguration {
private boolean deleteTmp = true;
private boolean useRelativePath = false;
private boolean useParentClassloader = true;
private boolean useWebInfBeans = false;
private final List<Consumer<ConfigBuilder>> builderConsumers = new ArrayList<>();

/**
Expand Down Expand Up @@ -104,6 +106,14 @@ public void setUseParentClassloader(boolean useParentClassloader) {
this.useParentClassloader = useParentClassloader;
}

public boolean isUseWebInfBeans() {
return useWebInfBeans;
}

public void setUseWebInfBeans(boolean useWebInfBeans) {
this.useWebInfBeans = useWebInfBeans;
}

@Override
public void validate() throws ConfigurationException {
if ((port <= 0) || (port > Short.MAX_VALUE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
* <li>A temporary directory is created</li>
* <li>The WebArchive contents are written to the temporary directory</li>
* <li>beans.xml is created in WEB-INF/classes if not present</li>
* <li>WEB-INF/beans.xml will be moved to WEB-INF/classes/META-INF if present</li>
* <li>The server is started with WEB-INF/classes and all libraries in WEB-INF/libon the classpath.</li>
* </ol>
*
Expand Down Expand Up @@ -180,14 +181,14 @@ public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {

Path rootDir = context.deployDir.resolve("");
if (isJavaArchive) {
ensureBeansXml(rootDir);
ensureBeansXml(rootDir, null);
classPath.add(rootDir);
} else {
// Prepare the launcher files
Path webInfDir = context.deployDir.resolve("WEB-INF");
Path classesDir = webInfDir.resolve("classes");
Path libDir = webInfDir.resolve("lib");
ensureBeansXml(classesDir);
ensureBeansXml(classesDir, webInfDir);
addServerClasspath(classPath, classesDir, libDir, rootDir);
}

Expand Down Expand Up @@ -376,17 +377,24 @@ void addServerClasspath(List<Path> classpath, Path classesDir, Path libDir, Path
classpath.add(rootDir);
}

private void ensureBeansXml(Path classesDir) throws IOException {
private void ensureBeansXml(Path classesDir, Path webinfDir) throws IOException {
Path beansPath = classesDir.resolve("META-INF/beans.xml");
Path metaInfPath = beansPath.getParent();
if (null != metaInfPath) {
Files.createDirectories(metaInfPath);
}
if (containerConfig.isUseWebInfBeans() && webinfDir != null) {
// In case exists WEB-INF/beans.xml, then move it to classes/META-INF/beans.xml
Path webInfBeansPath = webinfDir.resolve("beans.xml");
if (Files.exists(webInfBeansPath)) {
Files.move(webInfBeansPath, beansPath);
return;
}
}
if (Files.exists(beansPath)) {
return;
}
try (InputStream beanXmlTemplate = HelidonDeployableContainer.class.getResourceAsStream("/templates/beans.xml")) {
Path metaInfPath = beansPath.getParent();
if (null != metaInfPath) {
Files.createDirectories(metaInfPath);
}

if (null == beanXmlTemplate) {
Files.write(beansPath, new byte[0]);
} else {
Expand Down Expand Up @@ -576,8 +584,10 @@ public Enumeration<URL> getResources(String name) throws IOException {
}
}
}

return Collections.enumeration(result);
// Give priority to WebApp resources (for example ServiceLoader provided by WebApp)
List<URL> toRevert = new ArrayList<URL>(result);
Collections.reverse(toRevert);
return Collections.enumeration(toRevert);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018, 2022 Oracle and/or its affiliates.
Copyright (c) 2018, 2023 Oracle and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -19,8 +19,8 @@
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
https://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd"
version="3.0"
https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
version="4.0"
bean-discovery-mode="all">
</beans>

39 changes: 9 additions & 30 deletions microprofile/tests/tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
<module>tck-reactive-operators</module>
<module>tck-lra</module>
<module>tck-telemetry</module>
<!--
Tests are passing, but maven artifact is not published yet
<module>tck-core-profile</module>
-->
<module>tck-cdi</module>
<module>tck-restfull</module>
<module>tck-jsonb</module>
<module>tck-jsonp</module>
<module>tck-inject</module>
</modules>

<properties>
Expand All @@ -53,36 +62,6 @@
</properties>



<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>${version.plugin.surefire}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>

<profiles>
<profile>
<id>tck-ft</id>
Expand Down
67 changes: 67 additions & 0 deletions microprofile/tests/tck/tck-cdi/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2023 Oracle and/or its affiliates.
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.
-->

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>tck-project</artifactId>
<groupId>io.helidon.microprofile.tests</groupId>
<version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>tck-cdi</artifactId>
<name>Helidon Microprofile Tests TCK CDI</name>

<dependencies>
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-arquillian</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>cdi-tck-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>cdi-tck-core-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>tck-suite.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
*
* 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.
*/

package io.helidon.microprofile.cdi.tck;

import org.jboss.arquillian.container.test.impl.enricher.resource.URLResourceProvider;
import org.jboss.arquillian.core.spi.LoadableExtension;
import org.jboss.arquillian.test.spi.enricher.resource.ResourceProvider;

/**
* LoadableExtension tht will load UrlResourceProvider.
*/
public class UrlLoaderExtension implements LoadableExtension {
@Override
public void register(ExtensionBuilder extensionBuilder) {
extensionBuilder.override(ResourceProvider.class, URLResourceProvider.class, UrlResourceProvider.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
*
* 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.
*/
package io.helidon.microprofile.cdi.tck;

import java.lang.annotation.Annotation;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;

import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.arquillian.test.spi.enricher.resource.ResourceProvider;

/**
* TCKs use addition when creating URL for a client. The default Arquillian implementation returns url without the trailing
* /.
*/
public class UrlResourceProvider implements ResourceProvider {
@Override
public Object lookup(ArquillianResource arquillianResource, Annotation... annotations) {
try {
return URI.create("http://localhost:8080/").toURL();
} catch (MalformedURLException e) {
return null;
}
}

@Override
public boolean canProvide(Class<?> type) {
return URL.class.isAssignableFrom(type);
}
}
Loading

0 comments on commit 56ac1ee

Please sign in to comment.