diff --git a/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-install/pom.xml b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-install/pom.xml new file mode 100644 index 0000000000..13baaa33f2 --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-install/pom.xml @@ -0,0 +1,87 @@ + + + + 4.0.0 + + + org.eclipse.ee4j + project + 1.0.9 + + + + cdi-extra-tck-install + 4.0.0-SNAPSHOT + pom + TCK: Install Jakarta cdi Platform Extra TCK + + + jakarta-cdi-extra-tck-${tck.test.cdi-extra.version}.zip + https://download.eclipse.org/ee4j/jakartaee-tck/jakartaee11/staged/eftl/${tck.test.cdi-extra.file} + 4.1.0-M1 + + + + + + com.googlecode.maven-download-plugin + download-maven-plugin + 1.13.0 + + ${tck.test.cdi-extra.url} + true + ${project.build.directory} + + + + download-cdi-extra-tck + + wget + + generate-resources + + + + + + maven-install-plugin + 3.1.3 + + + install-cdi-extra-tck-pom + + install-file + + process-resources + + ${project.build.directory}/cdi-tck-ee-impl-${tck.test.cdi-extra.version}.jar + ${project.build.directory}/cdi-tck-ee-impl-${tck.test.cdi-extra.version}-sources.jar + jakarta.tck + cdi-tck-ee-impl + ${tck.test.cdi-extra.version} + jar + + + + + + + + + diff --git a/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/pom.xml b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/pom.xml new file mode 100644 index 0000000000..80d8e41e5b --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/pom.xml @@ -0,0 +1,484 @@ + + + + 4.0.0 + + + org.eclipse.ee4j + project + 1.0.9 + + + + org.glassfish + glassfish.cdi-platform-extra-tck + 4.1.0-SNAPSHOT + + Jakarta CDI TCK Runner for Glassfish + Aggregates dependencies and runs the CDI TCK (both standalone and on GlassFish) + + + 4.1.0 + 4.1.0-M1 + + ${project.build.directory} + + + 8.0.0-M9 + + + 2.50.0 + + false + + + 6.0.0.Final + 6.0.Final + + + + + + jakarta.enterprise + jakarta.enterprise.cdi-api + 4.1.0 + + + org.jboss.arquillian + arquillian-bom + 1.9.3.Final + pom + import + + + org.jboss.shrinkwrap.descriptors + shrinkwrap-descriptors-impl-javaee + 2.0.0 + + + + + + + + + jakarta.enterprise + jakarta.enterprise.cdi-api + provided + + + jakarta.enterprise + jakarta.enterprise.cdi-el-api + 4.1.0 + provided + + + jakarta.el + jakarta.el-api + 6.0.0 + provided + + + + jakarta.faces + jakarta.faces-api + 4.1.0 + test + + + jakarta.servlet + jakarta.servlet-api + 6.1.0 + test + + + jakarta.jms + jakarta.jms-api + 3.1.0 + test + + + jakarta.transaction + jakarta.transaction-api + 2.0.1 + test + + + jakarta.resource + jakarta.resource-api + 2.1.0 + test + + + jakarta.servlet.jsp + jakarta.servlet.jsp-api + 4.0.0 + test + + + jakarta.ws.rs + jakarta.ws.rs-api + 4.0.0 + test + + + + + org.jboss.weld + weld-api + ${weld.version2} + provided + + + * + * + + + + + org.jboss.weld + weld-spi + ${weld.version2} + provided + + + * + * + + + + + org.jboss.weld + weld-core-impl + ${weld.version} + provided + + + * + * + + + + + org.jboss.weld.module + weld-web + ${weld.version} + provided + + + * + * + + + + + + + jakarta.enterprise + cdi-tck-api + ${cdi.tck-4-1.version} + test + + + * + * + + + + + + + jakarta.tck + cdi-tck-ee-impl + ${tck.version} + test + + + + org.glassfish.expressly + expressly + 6.0.0-M1 + provided + + + * + * + + + + + + commons-lang + commons-lang + 2.6 + test + + + net.sourceforge.htmlunit + htmlunit + ${htmlunit.version} + test + + + + org.jboss.weld + weld-lite-extension-translator + ${weld.version} + + + + org.testng + testng + 7.9.0 + test + + + org.jboss.arquillian.testng + arquillian-testng-container + test + + + org.jboss.shrinkwrap.descriptors + shrinkwrap-descriptors-impl-javaee + test + + + + org.omnifaces.arquillian + arquillian-glassfish-server-managed + 1.7 + test + + + + + + + maven-compiler-plugin + 3.13.0 + + + -proc:none + + + + maven-jar-plugin + + + + test-jar + + + ${project.build.directory}/dependency/lib + + + false + + + + + + + + maven-dependency-plugin + + + + copy-test-suites + + unpack + + pre-integration-test + + + + jakarta.tck + cdi-tck-ee-impl + ${tck.version} + false + + + tck-tests.xml + target/suites + false + true + + + + + + install-cdi-tck-ext-lib + + copy + + pre-integration-test + + + + jakarta.enterprise + cdi-tck-ext-lib + ${cdi.tck-4-1.version} + jar + true + ${glassfish.root}/glassfish8/glassfish/domains/domain1/lib/applibs + cdi-tck-ext-lib.jar + + + + + + + unpack-glassfish + + unpack + + pre-integration-test + + ${glassfish.root}/dependency-maven-plugin-markers + + + org.glassfish.main.distributions + ${glassfish-artifact-id} + ${glassfish.version} + zip + false + ${glassfish.root} + + + + + + + + + maven-failsafe-plugin + 3.5.2 + + + org.apache.maven.surefire + surefire-testng + 3.5.2 + + + + + run ee tck + + integration-test + + integration-test + + ${skip.ee.cdi.tck} + -Xmx768m + + + + target/suites/tck-tests.xml + + ${excluded.groups} + + jakarta.tck:cdi-tck-ee-impl + + + + + surefire.testng.verbose + 1 + + + 1 + true + + + + ${glassfish.root}/glassfish8 + true + 2048m + :org.jboss.cdi.tck... + + cdiTckExcludeDummy=true + glassfish.servlet.loadAllOnStartup=true + + + create-jms-resource --restype jakarta.jms.Queue --property Name=queue_test queue_test + create-jms-resource --restype jakarta.jms.Topic --property Name=topic_test topic_test + set configs.config.server-config.cdi-service.enable-implicit-cdi=true + create-file-user --groups student --passwordfile ${project.build.directory}/test-classes/password.txt student + create-file-user --groups printer --passwordfile ${project.build.directory}/test-classes/password.txt printer + create-file-user --groups student:alarm --passwordfile ${project.build.directory}/test-classes/password.txt alarm + + + ${project.build.outputDirectory} + ${project.build.directory}/dependency/lib + true + + + + + + + + maven-surefire-report-plugin + 3.5.2 + + ${project.build.directory}/failsafe-reports/junitreports + ${project.build.directory}/surefire-reports + test-report + + + + generate-test-report + + report-only + + verify + + + + + + + + + + full + + true + + + se + glassfish + + + + web + + javaee-full,se + web + + + + + diff --git a/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishBeansImpl.java b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishBeansImpl.java new file mode 100644 index 0000000000..bf419df51f --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishBeansImpl.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022 Eclipse Foundation 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.jboss.weld.tck.glassfish; + +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 it's 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 GlassFishBeansImpl 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/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishContextImpl.java b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishContextImpl.java new file mode 100644 index 0000000000..a225eb1c8e --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishContextImpl.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2022 Eclipse Foundation 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.jboss.weld.tck.glassfish; + +import jakarta.enterprise.context.spi.Context; + +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 GlassFishContextImpl implements Contexts { + @Override + public RequestContext getRequestContext() { + return Container.instance().deploymentManager().instance().select(HttpRequestContext.class).get(); + } + + @Override + public void setActive(Context context) { + context = ForwardingContext.unwrap(context); + if (context instanceof ManagedContext) { + ((ManagedContext) context).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) context).deactivate(); + } else { + throw new UnsupportedOperationException(); + } + } + + @Override + public DependentContext getDependentContext() { + return Container.instance().deploymentManager().instance().select(DependentContext.class).get(); + } + + @Override + public void destroyContext(Context context) { + context = ForwardingContext.unwrap(context); + if (context instanceof ManagedContext) { + ManagedContext managedContext = (ManagedContext) context; + managedContext.invalidate(); + managedContext.deactivate(); + managedContext.activate(); + } else if (context instanceof ApplicationContext) { + ((ApplicationContext) context).invalidate(); + } else { + throw new UnsupportedOperationException(); + } + } +} diff --git a/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishContextualsImpl.java b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishContextualsImpl.java new file mode 100644 index 0000000000..0c1ea19ae8 --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishContextualsImpl.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 Eclipse Foundation and/or its affiliates. + * + * 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.jboss.weld.tck.glassfish; + +import jakarta.enterprise.context.spi.Context; +import jakarta.enterprise.context.spi.CreationalContext; +import org.jboss.cdi.tck.spi.Contextuals; + +public class GlassFishContextualsImpl implements Contextuals { + + @Override + public Inspectable create(T instance, Context context) { + return new InspectableContextual<>(instance); + } + + static class InspectableContextual implements Inspectable { + + private T instancePassedToConstructor; + private T instancePassedToDestroy; + + private CreationalContext creationalContextPassedToCreate; + private CreationalContext creationalContextPassedToDestroy; + + InspectableContextual(T instance) { + this.instancePassedToConstructor = instance; + } + + @Override + public T create(CreationalContext creationalContext) { + this.creationalContextPassedToCreate = creationalContext; + return instancePassedToConstructor; + } + + @Override + public void destroy(T instance, CreationalContext creationalContext) { + instancePassedToDestroy = instance; + creationalContextPassedToDestroy = creationalContext; + } + + @Override + public CreationalContext getCreationalContextPassedToCreate() { + return creationalContextPassedToCreate; + } + + @Override + public T getInstancePassedToDestroy() { + return instancePassedToDestroy; + } + + @Override + public CreationalContext getCreationalContextPassedToDestroy() { + return creationalContextPassedToDestroy; + } + } + +} diff --git a/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishCreationalContextsImpl.java b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishCreationalContextsImpl.java new file mode 100644 index 0000000000..05f52b3c2e --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishCreationalContextsImpl.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation. + * + * 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.jboss.weld.tck.glassfish; + +import jakarta.enterprise.context.spi.Contextual; +import org.jboss.cdi.tck.spi.CreationalContexts; +import org.jboss.weld.contexts.CreationalContextImpl; + +/** + * This returns the Weld (and thus GlassFish) specific CreationalContextImpl with added methods + * for inspection. + */ +public class GlassFishCreationalContextsImpl implements CreationalContexts { + + @Override + public Inspectable create(Contextual contextual) { + return new InspectableCreationalContext<>(contextual); + } + + static class InspectableCreationalContext extends CreationalContextImpl implements Inspectable { + + private T lastBeanPushed; + private boolean pushCalled; + private boolean releaseCalled; + + public InspectableCreationalContext(Contextual contextual) { + super(contextual); + } + + @Override + public void push(T incompleteInstance) { + lastBeanPushed = incompleteInstance; + + pushCalled = true; + super.push(incompleteInstance); + } + + @Override + public Object getLastBeanPushed() { + return lastBeanPushed; + } + + @Override + public boolean isPushCalled() { + return pushCalled; + } + + @Override + public boolean isReleaseCalled() { + return releaseCalled; + } + + @Override + public void release(Contextual contextual, T instance) { + releaseCalled = true; + super.release(contextual, instance); + } + + @Override + public void release() { + releaseCalled = true; + super.release(); + } + + } + +} diff --git a/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishDeploymentExceptionTransformer.java b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishDeploymentExceptionTransformer.java new file mode 100644 index 0000000000..d098234239 --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishDeploymentExceptionTransformer.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation. + * Copyright (c) 2013, 2020 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.jboss.weld.tck.glassfish; + +import java.util.List; + +import org.apache.commons.lang.exception.ExceptionUtils; +import org.jboss.arquillian.container.spi.client.container.DeploymentExceptionTransformer; + +import jakarta.enterprise.inject.spi.DefinitionException; +import jakarta.enterprise.inject.spi.DeploymentException; + +/** + * + * See AS7-1197 for more details. + * + * @see org.jboss.weld.tck.glassfish.GlassFishExtension + * @author J J Snyder (j.j.snyder@oracle.com) + */ +public class GlassFishDeploymentExceptionTransformer 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) { + + // Arquillian sometimes returns InvocationException with nested AS7 + // exception and sometimes AS7 exception itself + @SuppressWarnings("unchecked") + 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/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishELImpl.java b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishELImpl.java new file mode 100644 index 0000000000..187421b57f --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishELImpl.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2022 Eclipse Foundation 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.jboss.weld.tck.glassfish; + +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 GlassFishELImpl 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/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishExtension.java b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishExtension.java new file mode 100644 index 0000000000..d0a16a2835 --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/java/org/jboss/weld/tck/glassfish/GlassFishExtension.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013, 2018 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.jboss.weld.tck.glassfish; + +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. + * + * @author J J Snyder (j.j.snyder@oracle.com) + */ +public class GlassFishExtension implements LoadableExtension { + + private static final String GLASSFISH_CLIENTUTILS_CLASS = "org.omnifaces.arquillian.container.glassfish.clientutils.GlassFishClientUtil"; + + @Override + public void register(ExtensionBuilder builder) { + if (Validate.classExists(GLASSFISH_CLIENTUTILS_CLASS)) { + builder.service(DeploymentExceptionTransformer.class, GlassFishDeploymentExceptionTransformer.class); + } + } + +} diff --git a/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/resources/META-INF/cdi-tck.properties b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/resources/META-INF/cdi-tck.properties new file mode 100644 index 0000000000..d04503bf95 --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/resources/META-INF/cdi-tck.properties @@ -0,0 +1,9 @@ +org.jboss.cdi.tck.spi.Beans=org.jboss.weld.tck.glassfish.GlassFishBeansImpl +org.jboss.cdi.tck.spi.CreationalContexts=org.jboss.weld.tck.glassfish.GlassFishCreationalContextsImpl +org.jboss.cdi.tck.spi.Contexts=org.jboss.weld.tck.glassfish.GlassFishContextImpl +org.jboss.cdi.tck.spi.Contextuals=org.jboss.weld.tck.glassfish.GlassFishContextualsImpl +org.jboss.cdi.tck.spi.EL=org.jboss.weld.tck.glassfish.GlassFishELImpl +org.jboss.cdi.tck.testDataSource=jdbc/__default +org.jboss.cdi.tck.testJmsConnectionFactory=java:comp/DefaultJMSConnectionFactory +org.jboss.cdi.tck.testJmsQueue=queue_test +org.jboss.cdi.tck.testJmsTopic=topic_test diff --git a/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension new file mode 100644 index 0000000000..8682cd7ed2 --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension @@ -0,0 +1 @@ +org.jboss.weld.tck.glassfish.GlassFishExtension \ No newline at end of file diff --git a/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/resources/log4j.xml b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/resources/log4j.xml new file mode 100644 index 0000000000..61e40a067f --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/resources/log4j.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/resources/password.txt b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/resources/password.txt new file mode 100644 index 0000000000..10da04386d --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/cdi-platform-extra-tck-run/src/test/resources/password.txt @@ -0,0 +1,3 @@ +AS_ADMIN_MASTERPASSWORD= +AS_ADMIN_PASSWORD= +AS_ADMIN_USERPASSWORD= diff --git a/glassfish-runner/cdi-platform-extra-tck/pom.xml b/glassfish-runner/cdi-platform-extra-tck/pom.xml new file mode 100644 index 0000000000..f64897ac37 --- /dev/null +++ b/glassfish-runner/cdi-platform-extra-tck/pom.xml @@ -0,0 +1,37 @@ + + + + + 4.0.0 + + + org.eclipse.ee4j + project + 1.0.9 + + + + cdi-platform-extra-tck + 4.1.0-SNAPSHOT + pom + + + cdi-platform-extra-tck-install + cdi-platform-extra-tck-run + + diff --git a/glassfish-runner/cdi-tck/cdi-tck-install/pom.xml b/glassfish-runner/cdi-tck/cdi-tck-install/pom.xml index f88de6f46e..840a954f2f 100644 --- a/glassfish-runner/cdi-tck/cdi-tck-install/pom.xml +++ b/glassfish-runner/cdi-tck/cdi-tck-install/pom.xml @@ -94,7 +94,6 @@ ${project.build.directory}/cdi-tck-4.1.0/artifacts/cdi-tck-api-4.1.0.jar ${project.build.directory}/cdi-tck-4.1.0/artifacts/cdi-tck-api-4.1.0-javadoc.jar ${project.build.directory}/cdi-tck-4.1.0/artifacts/cdi-tck-api-4.1.0-sources.jar - true @@ -110,7 +109,6 @@ 4.1.0 jar ${project.build.directory}/cdi-tck-4.1.0/artifacts/cdi-tck-ext-lib-4.1.0.jar - true @@ -126,7 +124,6 @@ 4.1.0 jar ${project.build.directory}/cdi-tck-4.1.0/artifacts/cdi-tck-core-impl-4.1.0.jar - true