diff --git a/.github/workflows/tck-webprofile.yml b/.github/workflows/tck-webprofile.yml index 528c754c6f..ba6f149689 100644 --- a/.github/workflows/tck-webprofile.yml +++ b/.github/workflows/tck-webprofile.yml @@ -41,6 +41,31 @@ jobs: with: paths: "external/webprofile-tck/atinject/target/tck/example/target/surefire-reports/TEST-*.xml" if: always() + cdi: + runs-on: ${{ matrix.os }} + strategy: + matrix: + java: [ '21' ] + os: [ubuntu-latest] + steps: + - name: Checkout Sources + uses: actions/checkout@v4 + - name: Set up Java ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: ${{ matrix.java }} + - name: Setup for TCK + run: mvn -B -DskipTests=true -ntp install + - name: Run TCK + run: | + cd external/webprofile-tck/cdi + mvn -B -fae -ntp verify + - name: Test Summary + uses: test-summary/action@v2 + with: + paths: "external/webprofile-tck/cdi/runner/core/target/surefire-reports/junitreports/TEST-*.xml" + if: always() jsonb: runs-on: ${{ matrix.os }} strategy: diff --git a/external/webprofile-tck/cdi/installer/pom.xml b/external/webprofile-tck/cdi/installer/pom.xml new file mode 100644 index 0000000000..f1fe858d47 --- /dev/null +++ b/external/webprofile-tck/cdi/installer/pom.xml @@ -0,0 +1,76 @@ + + + + 4.0.0 + + + cloud.piranha.external.webprofiletck.cditck + project + 24.10.0-SNAPSHOT + + + installer + pom + + Piranha Web Profile - CDI TCK - Installer + + + + + cloud.piranha + bom + ${project.version} + pom + import + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + pre-integration-test + pre-integration-test + + run + + + + + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-clean-plugin + + + + ${basedir}/runner/target + + + + + + + diff --git a/external/webprofile-tck/cdi/pom.xml b/external/webprofile-tck/cdi/pom.xml new file mode 100644 index 0000000000..77f98211f0 --- /dev/null +++ b/external/webprofile-tck/cdi/pom.xml @@ -0,0 +1,22 @@ + + + + 4.0.0 + + + cloud.piranha.external.webprofiletck + project + 24.10.0-SNAPSHOT + + + cloud.piranha.external.webprofiletck.cditck + project + pom + + Piranha Web Profile - CDI TCK - Project + + + installer + runner + + diff --git a/external/webprofile-tck/cdi/runner/core/pom.xml b/external/webprofile-tck/cdi/runner/core/pom.xml new file mode 100644 index 0000000000..778d1f657a --- /dev/null +++ b/external/webprofile-tck/cdi/runner/core/pom.xml @@ -0,0 +1,341 @@ + + + 4.0.0 + + cloud.piranha.external.webprofiletck.cditck.runner + project + 24.10.0-SNAPSHOT + + core + + Piranha Web Profile - CDI TCK - Runner - Core + + + ${project.version} + + + + + + org.jboss.arquillian + arquillian-bom + ${arquillian.version} + pom + import + + + + + + + + jakarta.enterprise + jakarta.enterprise.cdi-api + provided + + + + jakarta.servlet + jakarta.servlet-api + test + + + + + + + + org.jboss.weld + weld-core-impl + ${weld.version} + + + org.testng + testng + + + jakarta.el + jakarta.el-api + + + + + + org.jboss.weld + weld-lite-extension-translator + ${weld.version} + + + + org.jboss.weld.module + weld-jsf + ${weld.version} + + + org.testng + testng + + + + + + org.jboss.weld.module + weld-ejb + ${weld.version} + + + org.jboss.weld.module + weld-web + ${weld.version} + + + + + + + jakarta.enterprise + cdi-tck-api + 4.0.13 + test + + + * + * + + + + + + + jakarta.enterprise + cdi-tck-core-impl + 4.0.13 + test + + + * + * + + + + + + + jakarta.enterprise + cdi-tck-core-impl + 4.0.13 + xml + suite + test + + + * + * + + + + + + + + + org.glassfish.expressly + expressly + provided + + + * + * + + + + + + commons-lang + commons-lang + 2.6 + test + + + org.testng + testng + 7.4.0 + test + + + org.jboss.arquillian.testng + arquillian-testng-container + test + + + org.jboss.shrinkwrap.descriptors + shrinkwrap-descriptors-impl-javaee + test + + + + + + + cloud.piranha.arquillian + piranha-arquillian-managed + ${piranha.version} + test + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 21 + -Xlint:unchecked + + + + + maven-dependency-plugin + + + + copy-test-suites + generate-test-sources + + copy + + + + + + jakarta.enterprise + cdi-tck-core-impl + 4.0.13 + xml + suite + false + tck-core-suite.xml + + + target/suites + false + true + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + process-test-classes + + test-jar + + + + ${project.build.directory}/dependency/lib + + + false + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + test + + + + + + + + target/suites/tck-core-suite.xml + + se + + jakarta.enterprise:cdi-tck-core-impl + + + 1 + + + + surefire.testng.verbose + 1 + + + false + + -ea + + ${project.build.directory}/dependency/lib + + true + + + + + org.apache.maven.plugins + maven-surefire-report-plugin + + + generate-test-report + test + + report-only + + + + + target/surefire-reports + test-report + + + + + + diff --git a/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/PiranhaDeploymentExceptionTransformer.java b/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/PiranhaDeploymentExceptionTransformer.java new file mode 100644 index 0000000000..dbb57e654c --- /dev/null +++ b/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/PiranhaDeploymentExceptionTransformer.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2024 Manorrock.com. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package org.jboss.weld.tck.piranha; + +import jakarta.enterprise.inject.spi.DefinitionException; +import jakarta.enterprise.inject.spi.DeploymentException; + +import java.util.List; + +import org.apache.commons.lang.exception.ExceptionUtils; +import org.jboss.arquillian.container.spi.client.container.DeploymentExceptionTransformer; + +/** + * + * See AS7-1197 for more details. + * + * @see org.jboss.weld.tck.glassfish.GlassFishExtension + * @author J J Snyder (j.j.snyder@oracle.com) + * @author Arjan Tijms + */ +public class PiranhaDeploymentExceptionTransformer implements DeploymentExceptionTransformer { + + private static final String[] DEPLOYMENT_EXCEPTION_FRAGMENTS = new String[] { + "Only normal scopes can be passivating", + "org.jboss.weld.exceptions.DeploymentException", + "org.jboss.weld.exceptions.UnserializableDependencyException", + "org.jboss.weld.exceptions.InconsistentSpecializationException", + "CDI deployment failure:", + "org.jboss.weld.exceptions.NullableDependencyException" }; + + private static final String[] DEFINITION_EXCEPTION_FRAGMENTS = new String[] + { "CDI definition failure:", + "org.jboss.weld.exceptions.DefinitionException" }; + + @Override + public Throwable transform(Throwable throwable) { + List throwableList = ExceptionUtils.getThrowableList(throwable); + if (throwableList.size() < 1) + return throwable; + + Throwable root = null; + + if (throwableList.size() == 1) { + root = throwable; + } else { + root = ExceptionUtils.getRootCause(throwable); + } + + if (root instanceof DeploymentException || root instanceof DefinitionException) { + return root; + } + if (isFragmentFound(DEPLOYMENT_EXCEPTION_FRAGMENTS, root)) { + return new DeploymentException(root.getMessage()); + } + if (isFragmentFound(DEFINITION_EXCEPTION_FRAGMENTS, root)) { + return new DefinitionException(root.getMessage()); + } + return throwable; + } + + private boolean isFragmentFound(String[] fragments, Throwable rootException) { + for (String fragment : fragments) { + if (rootException.getMessage().contains(fragment)) { + return true; + } + } + return false; + } + +} diff --git a/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/PiranhaExtension.java b/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/PiranhaExtension.java new file mode 100644 index 0000000000..1c9a897a01 --- /dev/null +++ b/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/PiranhaExtension.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2002-2024 Manorrock.com. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package org.jboss.weld.tck.piranha; + +import org.jboss.arquillian.container.spi.client.container.DeploymentExceptionTransformer; +import org.jboss.arquillian.core.spi.LoadableExtension; + +/** + * Registers the exception transformer to properly identify deployment failures. + * + */ +public class PiranhaExtension implements LoadableExtension { + + @Override + public void register(ExtensionBuilder builder) { + builder.service(DeploymentExceptionTransformer.class, PiranhaDeploymentExceptionTransformer.class); + } + +} diff --git a/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/WeldBeansImpl.java b/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/WeldBeansImpl.java new file mode 100644 index 0000000000..fff057443b --- /dev/null +++ b/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/WeldBeansImpl.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 Manorrock.com. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package org.jboss.weld.tck.piranha; + +import java.io.IOException; +import java.util.Arrays; + +import org.jboss.cdi.tck.spi.Beans; + +/** + * CDI TCK tests use this class as an adapter between the test application and server container. + * + * Then its implementation can simplify the behavior, ie. explicit passivation, while + * in a real application the decision to passivate/activate some object is on the container + * and cannot be requested by the application. + *

+ * Until GlassFish provides standalone utility to do that, we have to fake + * the passivation/activation. + * + * @author David Matejcek + */ +public class WeldBeansImpl implements Beans { + + private Object fakeSerialized; + + @Override + public boolean isProxy(Object instance) { + return instance.getClass().getName().indexOf("_$$_Weld") > 0; + } + + @Override + public byte[] passivate(Object instance) throws IOException { + fakeSerialized = instance; + return instance.toString().getBytes(); + } + + + @Override + public Object activate(byte[] bytes) throws IOException, ClassNotFoundException { + if (Arrays.equals(fakeSerialized.toString().getBytes(), bytes)) { + Object result = fakeSerialized; + fakeSerialized = null; + return result; + } + + return null; + } +} diff --git a/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/WeldContextImpl.java b/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/WeldContextImpl.java new file mode 100644 index 0000000000..65b6fc1278 --- /dev/null +++ b/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/WeldContextImpl.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2024 Manorrock.com. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package org.jboss.weld.tck.piranha; + +import jakarta.enterprise.context.spi.Context; +import jakarta.enterprise.inject.spi.CDI; +import jakarta.servlet.ServletContext; + +import org.jboss.cdi.tck.spi.Contexts; +import org.jboss.weld.Container; +import org.jboss.weld.context.ApplicationContext; +import org.jboss.weld.context.DependentContext; +import org.jboss.weld.context.ManagedContext; +import org.jboss.weld.context.RequestContext; +import org.jboss.weld.context.http.HttpRequestContext; +import org.jboss.weld.util.ForwardingContext; + +public class WeldContextImpl implements Contexts { + + @Override + public void setActive(Context context) { + context = ForwardingContext.unwrap(context); + if (context instanceof ManagedContext managedContext) { + managedContext.activate(); + } else if (context instanceof ApplicationContext) { + // No-op, always active + } else { + throw new UnsupportedOperationException(); + } + } + + @Override + public void setInactive(Context context) { + context = ForwardingContext.unwrap(context); + if (context instanceof ManagedContext managedContext) { + managedContext.deactivate(); + } else { + throw new UnsupportedOperationException(); + } + } + + @Override + public RequestContext getRequestContext() { + return + Container.instance(getContextId()) + .deploymentManager() + .instance() + .select(HttpRequestContext.class) + .get(); + } + + @Override + public DependentContext getDependentContext() { + return + Container.instance(getContextId()) + .deploymentManager().instance() + .select(DependentContext.class) + .get(); + } + + @Override + public void destroyContext(Context context) { + context = ForwardingContext.unwrap(context); + if (context instanceof ManagedContext managedContext) { + managedContext.invalidate(); + managedContext.deactivate(); + managedContext.activate(); + } else if (context instanceof ApplicationContext applicationContext) { + applicationContext.invalidate(); + } else { + throw new UnsupportedOperationException(); + } + } + + private String getContextId() { + ServletContext servletContext = CDI.current().select(ServletContext.class).get(); + + return servletContext.getInitParameter("WELD_CONTEXT_ID_KEY"); + } +} diff --git a/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/WeldELImpl.java b/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/WeldELImpl.java new file mode 100644 index 0000000000..3eb86c119d --- /dev/null +++ b/external/webprofile-tck/cdi/runner/core/src/test/java/org/jboss/weld/tck/piranha/WeldELImpl.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2024 Manorrock.com. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package org.jboss.weld.tck.piranha; + +import jakarta.el.ArrayELResolver; +import jakarta.el.BeanELResolver; +import jakarta.el.CompositeELResolver; +import jakarta.el.ELContext; +import jakarta.el.ELContextEvent; +import jakarta.el.ELContextListener; +import jakarta.el.ELResolver; +import jakarta.el.ExpressionFactory; +import jakarta.el.FunctionMapper; +import jakarta.el.ListELResolver; +import jakarta.el.MapELResolver; +import jakarta.el.ResourceBundleELResolver; +import jakarta.el.VariableMapper; +import jakarta.enterprise.inject.spi.BeanManager; + +import org.jboss.cdi.tck.spi.EL; +import org.jboss.weld.bean.builtin.BeanManagerProxy; +import org.jboss.weld.manager.BeanManagerImpl; +import org.jboss.weld.module.web.el.WeldELContextListener; +import org.jboss.weld.module.web.el.WeldExpressionFactory; + +public class WeldELImpl implements EL { + + private static final ExpressionFactory EXPRESSION_FACTORY = new WeldExpressionFactory(ExpressionFactory.newInstance()); + + private static final ELContextListener[] EL_CONTEXT_LISTENERS = { new WeldELContextListener() }; + + @Override + @SuppressWarnings("unchecked") + public T evaluateValueExpression(BeanManager beanManager, String expression, Class expectedType) { + ELContext elContext = createELContext(beanManager); + return (T) EXPRESSION_FACTORY.createValueExpression(elContext, expression, expectedType).getValue(elContext); + } + + @Override + @SuppressWarnings("unchecked") + public T evaluateMethodExpression(BeanManager beanManager, String expression, Class expectedType, + Class[] expectedParamTypes, Object[] expectedParams) { + ELContext elContext = createELContext(beanManager); + return (T) EXPRESSION_FACTORY.createMethodExpression(elContext, expression, expectedType, expectedParamTypes).invoke( + elContext, expectedParams); + } + + @Override + public ELContext createELContext(BeanManager beanManager) { + if (beanManager instanceof BeanManagerProxy) { + BeanManagerProxy proxy = (BeanManagerProxy) beanManager; + beanManager = proxy.delegate(); + } + if (beanManager instanceof BeanManagerImpl) { + return createELContext((BeanManagerImpl) beanManager); + } + throw new IllegalStateException("Wrong manager"); + } + + private ELContext createELContext(BeanManagerImpl beanManagerImpl) { + + final ELResolver resolver = createELResolver(beanManagerImpl); + + ELContext context = new ELContext() { + + @Override + public ELResolver getELResolver() { + return resolver; + } + + @Override + public FunctionMapper getFunctionMapper() { + return null; + } + + @Override + public VariableMapper getVariableMapper() { + return null; + } + + }; + callELContextListeners(context); + return context; + } + + private ELResolver createELResolver(BeanManagerImpl beanManagerImpl) { + CompositeELResolver resolver = new CompositeELResolver(); + resolver.add(beanManagerImpl.getELResolver()); + resolver.add(new MapELResolver()); + resolver.add(new ListELResolver()); + resolver.add(new ArrayELResolver()); + resolver.add(new ResourceBundleELResolver()); + resolver.add(new BeanELResolver()); + return resolver; + } + + private void callELContextListeners(ELContext context) { + ELContextEvent event = new ELContextEvent(context); + for (ELContextListener listener : EL_CONTEXT_LISTENERS) { + listener.contextCreated(event); + } + } +} diff --git a/external/webprofile-tck/cdi/runner/core/src/test/resources/META-INF/cdi-tck.properties b/external/webprofile-tck/cdi/runner/core/src/test/resources/META-INF/cdi-tck.properties new file mode 100644 index 0000000000..4833d3f258 --- /dev/null +++ b/external/webprofile-tck/cdi/runner/core/src/test/resources/META-INF/cdi-tck.properties @@ -0,0 +1,4 @@ +org.jboss.cdi.tck.cdiLiteMode=false +org.jboss.cdi.tck.spi.Beans=org.jboss.weld.tck.piranha.WeldBeansImpl +org.jboss.cdi.tck.spi.Contexts=org.jboss.weld.tck.piranha.WeldContextImpl +org.jboss.cdi.tck.spi.EL=org.jboss.weld.tck.piranha.WeldELImpl diff --git a/external/webprofile-tck/cdi/runner/core/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/external/webprofile-tck/cdi/runner/core/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension new file mode 100644 index 0000000000..a1b1c306c5 --- /dev/null +++ b/external/webprofile-tck/cdi/runner/core/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension @@ -0,0 +1 @@ +org.jboss.weld.tck.piranha.PiranhaExtension \ No newline at end of file diff --git a/external/webprofile-tck/cdi/runner/core/src/test/resources/arquillian.xml b/external/webprofile-tck/cdi/runner/core/src/test/resources/arquillian.xml new file mode 100644 index 0000000000..16507cd026 --- /dev/null +++ b/external/webprofile-tck/cdi/runner/core/src/test/resources/arquillian.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/external/webprofile-tck/cdi/runner/pom.xml b/external/webprofile-tck/cdi/runner/pom.xml new file mode 100644 index 0000000000..0472f78d53 --- /dev/null +++ b/external/webprofile-tck/cdi/runner/pom.xml @@ -0,0 +1,22 @@ + + + + 4.0.0 + + + cloud.piranha.external.webprofiletck.cditck + project + 24.10.0-SNAPSHOT + + + cloud.piranha.external.webprofiletck.cditck.runner + project + pom + + Piranha Web Profile - CDI TCK - Runner - Project + + + core + signature + + diff --git a/external/webprofile-tck/cdi/runner/signature/pom.xml b/external/webprofile-tck/cdi/runner/signature/pom.xml new file mode 100644 index 0000000000..ad754535ea --- /dev/null +++ b/external/webprofile-tck/cdi/runner/signature/pom.xml @@ -0,0 +1,111 @@ + + + + 4.0.0 + + + cloud.piranha.external.webprofiletck.cditck.runner + project + 24.10.0-SNAPSHOT + + + signature + + Piranha Web Profile - CDI TCK - Runner - Signature + Aggregates dependencies and runs the CDI Signature TCK on Piranha + + + ${project.version} + ${project.build.directory}/piranha + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-cdi-sigtest + process-resources + + copy + + + + + + jakarta.enterprise + cdi-tck-core-impl + 4.0.13 + sig + sigtest-jdk11 + ${project.build.directory}/sigtest + + + true + true + + + + + unpack-piranha + process-test-resources + + unpack + + + ${piranha.root}/dependency-maven-plugin-markers + + + cloud.piranha.dist + piranha-dist-webprofile + ${piranha.version} + jar + false + target/cdi-sigtest-classes + + + + + + + + + jakarta.tck + sigtest-maven-plugin + + + sigtest + verify + + check + + + + + target/sigtest/cdi-tck-core-impl-sigtest-jdk11.sig + jakarta.decorator,jakarta.enterprise.**,jakarta.interceptor + target/cdi-sigtest-classes + target/cdi-sig-report.txt + + + + + diff --git a/external/webprofile-tck/pom.xml b/external/webprofile-tck/pom.xml index 70bdbd0820..760a5f9501 100644 --- a/external/webprofile-tck/pom.xml +++ b/external/webprofile-tck/pom.xml @@ -17,9 +17,11 @@ Piranha - External - Web Profile TCK - Project 2.0.2 + 4.0.13 atinject + cdi jsonb jsonp