Skip to content

Commit

Permalink
Enable disabled TCKs
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 Oct 12, 2023
1 parent 25ce702 commit a6101d9
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Handler;
Expand All @@ -46,6 +45,8 @@
import jakarta.enterprise.context.BeforeDestroyed;
import jakarta.enterprise.context.Destroyed;
import jakarta.enterprise.context.Initialized;
import jakarta.enterprise.event.Startup;
import jakarta.enterprise.inject.Any;
import jakarta.enterprise.inject.se.SeContainer;
import jakarta.enterprise.inject.spi.BeanManager;
import jakarta.enterprise.inject.spi.CDI;
Expand Down Expand Up @@ -96,6 +97,8 @@ final class HelidonContainerImpl extends Weld implements HelidonContainer {
private static final Context ROOT_CONTEXT;
// whether the current shutdown was invoked by the shutdown hook
private static final AtomicBoolean FROM_SHUTDOWN_HOOK = new AtomicBoolean();
// Default Weld container id. TCKs assumes this value.
private static final String STATIC_INSTANCE = "STATIC_INSTANCE";

static {
HelidonFeatures.flavor(HelidonFlavor.MP);
Expand All @@ -119,7 +122,7 @@ final class HelidonContainerImpl extends Weld implements HelidonContainer {

HelidonContainerImpl() {
this.bootstrap = new WeldBootstrap();
id = UUID.randomUUID().toString();
this.id = STATIC_INSTANCE;
}

/**
Expand Down Expand Up @@ -205,6 +208,7 @@ public Collection<URL> getResources(String name) {
}
deployment.getServices().add(ExternalConfiguration.class, configurationBuilder.build());

// CDI TCK tests expects SE to be excluded, which means Helidon may require to do things that Weld is supposed to do.
bootstrap.startContainer(id, Environments.SE, deployment);

bootstrap.startInitialization();
Expand Down Expand Up @@ -315,6 +319,7 @@ private HelidonContainerImpl doStart() {
keepLoggingActive(shutdownHook);

bm.getEvent().select(Initialized.Literal.APPLICATION).fire(new ContainerInitialized(id));
bm.getEvent().select(Any.Literal.INSTANCE).fire(new Startup());

now = System.currentTimeMillis() - now;
LOGGER.fine("Container started in " + now + " millis (this excludes the initialization time)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import jakarta.enterprise.context.Dependent;
import jakarta.enterprise.context.spi.CreationalContext;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.Vetoed;
import jakarta.enterprise.inject.spi.AfterBeanDiscovery;
import jakarta.enterprise.inject.spi.AfterDeploymentValidation;
import jakarta.enterprise.inject.spi.Annotated;
Expand Down Expand Up @@ -136,7 +137,7 @@ private void processAnnotatedType(@Observes @WithAnnotations(ConfigProperties.cl
private <X> void harvestConfigPropertyInjectionPointsFromEnabledObserverMethod(@Observes ProcessObserverMethod<?, X> event,
BeanManager beanManager) {
AnnotatedMethod<X> annotatedMethod = event.getAnnotatedMethod();
if (annotatedMethod != null) {
if (annotatedMethod != null && !annotatedMethod.getDeclaringType().isAnnotationPresent(Vetoed.class)) {
List<AnnotatedParameter<X>> annotatedParameters = annotatedMethod.getParameters();
if (annotatedParameters != null) {
for (AnnotatedParameter<?> annotatedParameter : annotatedParameters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
* is empty)</li>
* <li>replaceConfigSourcesWithMp: (Optional) defaults to false: whether to replace config sources with microprofile if it
* exists</li>
* <li>inWebContainer: defaults to false: sets web app context root, load WEB-INF/beans.xml and find any jakarta.ws.rs.core.Application in the webapp classes</li>
* <li>inWebContainer: (Optional) defaults to false: sets web app context root, load WEB-INF/beans.xml and find any
* jakarta.ws.rs.core.Application in the webapp classes</li>
* <li>useBeanXmlTemplate: (Optional) defaults to true: will create the default templates/beans.xml when beans.xml is missing</li>
* </ul>
*/
public class HelidonContainerConfiguration implements ContainerConfiguration {
Expand All @@ -47,6 +49,7 @@ public class HelidonContainerConfiguration implements ContainerConfiguration {
private boolean useRelativePath = false;
private boolean useParentClassloader = true;
private boolean inWebContainer = false;
private boolean useBeanXmlTemplate = true;
private final List<Consumer<ConfigBuilder>> builderConsumers = new ArrayList<>();

/**
Expand Down Expand Up @@ -114,6 +117,14 @@ public void setInWebContainer(boolean inWebContainer) {
this.inWebContainer = inWebContainer;
}

public boolean isUseBeanXmlTemplate() {
return useBeanXmlTemplate;
}

public void setUseBeanXmlTemplate(boolean useBeanXmlTemplate) {
this.useBeanXmlTemplate = useBeanXmlTemplate;
}

@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 @@ -32,7 +32,6 @@
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
Expand Down Expand Up @@ -72,7 +71,6 @@
import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePath;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Node;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.descriptor.api.Descriptor;
Expand All @@ -90,7 +88,7 @@
* <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>
* <li>The server is started with WEB-INF/classes and all libraries in WEB-INF/lib on the classpath.</li>
* </ol>
*
* Control is then returned to the test harness (in this case, generally testng) to run tests over HTTP.
Expand Down Expand Up @@ -226,10 +224,7 @@ public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
addServerClasspath(classPath, classesDir, libDir, rootDir);
if (containerConfig.isInWebContainer()) {
context.rootContext = archive.getName().split("\\.")[0];
if (!loadApplicationFromWebXml(context, webInfDir)) {
// Search Application in classes
loadApplicationFromClasses(context, archive);
}
loadApplicationFromWebXml(context, webInfDir);
}
}

Expand Down Expand Up @@ -263,36 +258,6 @@ public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
return new ProtocolMetaData();
}

private boolean loadApplicationFromClasses(RunContext context, Archive<?> archive)
throws ClassNotFoundException, ReflectiveOperationException {
ArchivePath classes = ArchivePaths.create("WEB-INF", "classes");
org.jboss.shrinkwrap.api.Node root = archive.getContent().get(classes);
Collection<Class<Application>> applications = new HashSet<>();
if (root != null) {
deepApplicationFind(root, applications);
context.applications.addAll(applications);
}
return !context.applications.isEmpty();
}

private void deepApplicationFind(org.jboss.shrinkwrap.api.Node parent,
Collection<Class<Application>> applications) throws ClassNotFoundException {
for (org.jboss.shrinkwrap.api.Node child : parent.getChildren()) {
if (child.getChildren().isEmpty()) {
String name = child.toString();
if (name.endsWith(".class")) {
name = name.replaceFirst("\\.class", "").replaceFirst("/WEB-INF/classes/", "").replaceAll("/", ".");
Class<?> clazz = Class.forName(name);
if (Application.class.isAssignableFrom(clazz)) {
applications.add((Class<Application>) clazz);
}
}
} else {
deepApplicationFind(child, applications);
}
}
}

private boolean loadApplicationFromWebXml(RunContext context, Path webInfDir) throws IOException,
ParserConfigurationException, SAXException, ReflectiveOperationException {
Path webXml = webInfDir.resolve("web.xml");
Expand Down Expand Up @@ -341,10 +306,12 @@ static Optional<Exception> lookForSupressedDeploymentException(Throwable t) {
}
if (jakarta.enterprise.inject.spi.DeploymentException.class.isAssignableFrom(t.getClass())) {
return Optional.of((jakarta.enterprise.inject.spi.DeploymentException) t);
}
if (IllegalStateException.class.isAssignableFrom(t.getClass())) {
} else if (IllegalStateException.class.isAssignableFrom(t.getClass())) {
return Optional.of((IllegalStateException) t);
} else if (java.lang.Error.class.isAssignableFrom(t.getClass())) {
return Optional.of((new jakarta.enterprise.inject.spi.DeploymentException(t)));
}

var deploymentException = lookForSupressedDeploymentException(t.getCause());
for (Throwable suppressed : t.getSuppressed()) {
var candicate = lookForSupressedDeploymentException(suppressed);
Expand Down Expand Up @@ -519,12 +486,13 @@ private void ensureBeansXml(Path classesDir, Path webinfDir) throws IOException
if (Files.exists(beansPath)) {
return;
}
try (InputStream beanXmlTemplate = HelidonDeployableContainer.class.getResourceAsStream("/templates/beans.xml")) {
if (null == beanXmlTemplate) {
Files.write(beansPath, new byte[0]);
} else {

Files.copy(beanXmlTemplate, beansPath);
if (containerConfig.isUseBeanXmlTemplate()) {
try (InputStream beanXmlTemplate = HelidonDeployableContainer.class.getResourceAsStream("/templates/beans.xml")) {
if (null == beanXmlTemplate) {
Files.write(beansPath, new byte[0]);
} else {
Files.copy(beanXmlTemplate, beansPath);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import io.helidon.microprofile.arquillian.HelidonContainerExtension.HelidonCDIInjectionEnricher;

import jakarta.enterprise.context.ContextNotActiveException;
import jakarta.enterprise.context.control.RequestContextController;
import org.jboss.arquillian.container.test.spi.ContainerMethodExecutor;
import org.jboss.arquillian.test.api.ArquillianResource;
Expand Down Expand Up @@ -83,7 +84,11 @@ public TestResult invoke(TestMethodExecutor testMethodExecutor) {
} catch (Throwable t) {
return TestResult.failed(t);
} finally {
controller.deactivate();
try {
controller.deactivate();
} catch (ContextNotActiveException e) {
LOGGER.log(Level.WARNING, "Controller " + controller + " was already deactivated");
}
}
return TestResult.passed();
}
Expand Down
30 changes: 6 additions & 24 deletions microprofile/tests/tck/tck-cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,37 +73,19 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<org.jboss.weld.construction.relaxed>false</org.jboss.weld.construction.relaxed>
</systemPropertyVariables>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<excludedGroups>cdi-full,se</excludedGroups>
<!-- https://jakartaee.github.io/cdi-tck/#_using_the_cdi_tck_with_the_jakarta_ee_core_profile -->
<excludedGroups>cdi-full,integration,javaee-full,se</excludedGroups>
<dependenciesToScan>
<dependency>jakarta.enterprise:cdi-tck-core-impl</dependency>
</dependenciesToScan>
<includes>
<include>org/jboss/cdi/tck/tests/**/*Test.java</include>
<include>org/jboss/cdi/tck/interceptors/DependentContextTesttests/**/*Test.java</include>
<include>org/jboss/cdi/tck/**/*Test.java</include>
</includes>
<excludes>
<exclude>org/jboss/cdi/tck/tests/fulSyntheticBeanWithLookupTestl/extensions/lifecycle/bbd/broken/passivatingScope/AddingPassivatingScopeTest.java</exclude>
<!-- FIXME: Next tests must be enabled -->
<exclude>org/jboss/cdi/tck/tests/build/compatible/extensions/changeObserverQualifier/ChangeObserverQualifierTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/build/compatible/extensions/customStereotype/CustomStereotypeTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/build/compatible/extensions/syntheticBeanWithLookup/SyntheticBeanWithLookupTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/context/dependent/DependentContextTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/definition/bean/types/ManagedBeanTypesTest.java</exclude>
<exclude>org/jboss/cdi.tck/tests/event/EventTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/event/lifecycle/StartupShutdownTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/event/observer/broken/validation/unsatisfied/ObserverMethodParameterInjectionValidationTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/event/observer/broken/validation/ambiguous/ObserverMethodParameterInjectionValidationTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/event/observer/runtimeException/ObserverExceptionRethrownTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/event/observer/conditional/ConditionalObserverTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/event/observer/ObserverNotificationTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/event/observer/async/executor/FireAsyncWithCustomExecutorTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/inheritance/generics/MemberLevelInheritanceTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/lookup/clientProxy/unproxyable/privateConstructor/PrivateConstructorTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/lookup/clientProxy/unproxyable/beanConstructor/BeanConstructorWithParametersTest.java</exclude>
<exclude>org/jboss/cdi/tck/tests/implementation/simple/lifecycle/unproxyable/UnproxyableManagedBeanTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<container qualifier="helidon-embedded" default="true">
<configuration>
<property name="inWebContainer">true</property>
<property name="useBeanXmlTemplate">false</property>
</configuration>
</container>
</arquillian>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<dependencies>
<dependency>
<groupId>io.helidon.microprofile.bundles</groupId>
<artifactId>helidon-microprofile-core</artifactId>
<artifactId>helidon-microprofile</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -77,12 +77,6 @@
<includes>
<include>*IT.java</include>
</includes>
<!-- FIXME: Enable when this https://github.com/jakartaee/platform-tck/pull/1178 is integrated -->
<excludes>
<exclude>ee/jakarta/tck/core/jsonb/JsonbApplicationIT.java</exclude>
<exclude>ee/jakarta/tck/core/json/ApplicationJsonpIT.java</exclude>
<exclude>ee/jakarta/tck/core/rest/jsonb/cdi/CustomJsonbSerializationIT.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</engine>
<container qualifier="helidon-embedded" default="true">
<configuration>
<property name="useWebInfBeans">true</property>
<property name="inWebContainer">true</property>
</configuration>
</container>
</arquillian>
2 changes: 1 addition & 1 deletion microprofile/tests/tck/tck-restful/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<configuration>
<target>
<!-- If you use proxy you need to set it as a system properties -->
<get skipexisting="true" src="https://download.eclipse.org/jakartaee/restful-ws/3.1/jakarta-restful-ws-tck-${version.lib.microprofile-restful-tck}.zip" dest="jakarta-restful-ws-tck-${version.lib.microprofile-restful-tck}.zip"/>
<get skipexisting="true" src="https://www.eclipse.org/downloads/download.php?file=/ee4j/jakartaee-tck/jakartaee10/staged/eftl/jakarta-restful-ws-tck-${version.lib.microprofile-restful-tck}.zip" dest="jakarta-restful-ws-tck-${version.lib.microprofile-restful-tck}.zip"/>
<unzip src="jakarta-restful-ws-tck-${version.lib.microprofile-restful-tck}.zip" dest="./target"/>
<chmod file="artifact-install.sh" perm="+x"/>
<exec executable="sh">
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
<version.lib.checkstyle>9.1</version.lib.checkstyle>
<version.lib.commons-io>2.11.0</version.lib.commons-io>
<version.lib.groovy-all>2.4.14</version.lib.groovy-all>
<version.lib.microprofile-core-profile>10.0.1</version.lib.microprofile-core-profile>
<version.lib.microprofile-cdi-tck>4.0.10</version.lib.microprofile-cdi-tck>
<version.lib.microprofile-restful-tck>3.1.3</version.lib.microprofile-restful-tck>
<version.lib.microprofile-core-profile>10.0.2</version.lib.microprofile-core-profile>
<version.lib.microprofile-cdi-tck>4.0.12</version.lib.microprofile-cdi-tck>
<version.lib.microprofile-restful-tck>3.1.4</version.lib.microprofile-restful-tck>
<!-- Silence javadoc error org.jboss.logging.annotations.Message$Format not found -->
<version.lib.jboss-logging-annotations>2.2.1.Final</version.lib.jboss-logging-annotations>
<version.lib.jsoup>1.15.3</version.lib.jsoup>
Expand Down

0 comments on commit a6101d9

Please sign in to comment.