Repository: tomee Updated Branches: refs/heads/develop a1b67450e -> 8ed1027f9
simple EL CDI TCK Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/8ed1027f Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/8ed1027f Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/8ed1027f Branch: refs/heads/develop Commit: 8ed1027f985d5487e382e215da864e7b4c248778 Parents: a1b6745 Author: Romain Manni-Bucau <[email protected]> Authored: Wed Jan 7 22:56:01 2015 +0100 Committer: Romain Manni-Bucau <[email protected]> Committed: Wed Jan 7 22:56:01 2015 +0100 ---------------------------------------------------------------------- .../apache/openejb/cdi/OpenEJBLifecycle.java | 3 + .../openejb/web/LightweightWebAppBuilder.java | 121 ++++++++++++++++++- .../server/httpd/EmbeddedServletContext.java | 5 + .../server/httpd/HttpListenerRegistry.java | 3 + .../openejb/server/httpd/HttpRequestImpl.java | 55 +++++++-- .../openejb/server/httpd/util/HttpUtil.java | 49 ++++++-- tck/cdi-embedded/pom.xml | 22 +++- .../openejb/tck/cdi/embedded/TckTlds.java | 68 +++++++++++ .../META-INF/org.apache.openejb.extension | 1 + tck/cdi-embedded/src/test/resources/failing.xml | 13 +- 10 files changed, 311 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/8ed1027f/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java index d982a8c..b3d7767 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java @@ -370,6 +370,9 @@ public class OpenEJBLifecycle implements ContainerLifecycle { } public void startServletContext(final ServletContext servletContext) { + if (service != null) { + return; + } service = initializeServletContext(servletContext, webBeansContext); } http://git-wip-us.apache.org/repos/asf/tomee/blob/8ed1027f/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java index 8c75347..2b58638 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java @@ -34,13 +34,18 @@ import org.apache.openejb.assembler.classic.ServletInfo; import org.apache.openejb.assembler.classic.WebAppBuilder; import org.apache.openejb.assembler.classic.WebAppInfo; import org.apache.openejb.cdi.CdiBuilder; +import org.apache.openejb.cdi.OpenEJBLifecycle; import org.apache.openejb.core.CoreContainerSystem; import org.apache.openejb.core.WebContext; import org.apache.openejb.loader.SystemInstance; +import org.apache.openejb.observer.Event; import org.apache.openejb.spi.ContainerSystem; import org.apache.openejb.util.ArrayEnumeration; import org.apache.openejb.util.LogCategory; import org.apache.openejb.util.Logger; +import org.apache.openejb.util.OpenEjbVersion; +import org.apache.webbeans.spi.ContainerLifecycle; +import org.apache.webbeans.web.lifecycle.test.MockServletContext; import org.apache.webbeans.web.lifecycle.test.MockServletContextEvent; import javax.naming.Binding; @@ -61,7 +66,10 @@ import javax.servlet.annotation.WebListener; import javax.servlet.annotation.WebServlet; import javax.ws.rs.core.Application; import java.io.File; +import java.io.InputStream; import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -74,6 +82,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.TreeMap; +import java.util.concurrent.ConcurrentHashMap; import static java.util.Arrays.asList; @@ -84,14 +93,16 @@ public class LightweightWebAppBuilder implements WebAppBuilder { private static Method removeServletMethod; private static Method addFilterMethod; private static Method removeFilterMethod; + private static Method addDefaults; static { try { - final Class<?> utilClass = LightweightWebAppBuilder.class.getClassLoader().loadClass("org.apache.openejb.server.httpd.util.HttpUtil"); + final Class<?> utilClass = Class.forName("org.apache.openejb.server.httpd.util.HttpUtil", true/*setFactory()*/, LightweightWebAppBuilder.class.getClassLoader()); addServletMethod = utilClass.getMethod("addServlet", String.class, WebContext.class, String.class); removeServletMethod = utilClass.getMethod("removeServlet", String.class, WebContext.class); addFilterMethod = utilClass.getMethod("addFilter", String.class, WebContext.class, String.class, FilterConfig.class); removeFilterMethod = utilClass.getMethod("removeFilter", String.class, WebContext.class); + addDefaults = utilClass.getMethod("addDefaultsIfAvailable", WebContext.class); } catch (final Exception e) { LOGGER.info("Web features will not be available, add openejb-http if you need them"); } @@ -151,7 +162,13 @@ public class LightweightWebAppBuilder implements WebAppBuilder { webContext.setHost(webAppInfo.host); webContext.getInjections().addAll(injections); webContext.setInitialContext(new EmbeddedInitialContext(webContext.getJndiEnc(), webContext.getBindings())); - webContext.setServletContext(SystemInstance.get().getComponent(ServletContext.class)); + + final ServletContext component = SystemInstance.get().getComponent(ServletContext.class); + final ServletContextEvent sce = component == null ? new MockServletContextEvent() : + new ServletContextEvent(new LightServletContext(component, webContext.getClassLoader())); + servletContextEvents.put(webAppInfo, sce); + webContext.setServletContext(sce.getServletContext()); + SystemInstance.get().fireEvent(new EmbeddedServletContextCreated(sce.getServletContext())); appContext.getWebContexts().add(webContext); cs.addWebContext(webContext); @@ -162,9 +179,6 @@ public class LightweightWebAppBuilder implements WebAppBuilder { assembler.startEjbs(true, beanContexts); } - final ServletContextEvent sce = new MockServletContextEvent(); // TODO: reuse EmbeddableServletContext - servletContextEvents.put(webAppInfo, sce); - // listeners for (final ListenerInfo listener : webAppInfo.listeners) { final Class<?> clazz = webContext.getClassLoader().loadClass(listener.classname); @@ -205,6 +219,10 @@ public class LightweightWebAppBuilder implements WebAppBuilder { deployedWebObjects.webContext = webContext; servletDeploymentInfo.put(webAppInfo, deployedWebObjects); + if (webContext.getWebBeansContext() != null) { + OpenEJBLifecycle.class.cast(webContext.getWebBeansContext().getService(ContainerLifecycle.class)).startServletContext(sce.getServletContext()); + } + if (addServletMethod == null) { // can't manage filter/servlets continue; } @@ -313,9 +331,18 @@ public class LightweightWebAppBuilder implements WebAppBuilder { } } } + + if (addDefaults != null && tryJsp()) { + addDefaults.invoke(null, webContext); + deployedWebObjects.mappings.add("*\\.jsp"); + } } } + private static boolean tryJsp() { + return "true".equalsIgnoreCase(SystemInstance.get().getProperty("openejb.embedded.try-jsp", "true")); + } + public Collection<Object> listenersFor(final String context) { for (final Map.Entry<WebAppInfo, List<Object>> info : listeners.entrySet()) { if (context != null && context.replace("/", "").equals(info.getKey().contextRoot.replace("/", ""))) { @@ -582,4 +609,88 @@ public class LightweightWebAppBuilder implements WebAppBuilder { return new ArrayEnumeration(params.keySet()); } } + + @Event + public static class EmbeddedServletContextCreated { + private final ServletContext context; + + public EmbeddedServletContextCreated(ServletContext context) { + this.context = context; + } + + public ServletContext getContext() { + return context; + } + + @Override + public String toString() { + return "EmbeddedServletContextCreated{" + + "context=" + context + + '}'; + } + } + + public static class LightServletContext extends MockServletContext { + private final Map<String, Object> attributes = new ConcurrentHashMap<>(); + private final ServletContext delegate; // EmbeddedServletContext has some resource handling we want to reuse here, TODO: move it here? + private final ClassLoader loader; + + public LightServletContext(final ServletContext delegate, final ClassLoader loader) { + this.delegate = delegate; + this.loader = loader; + } + + @Override + public ClassLoader getClassLoader() { + return loader; + } + + @Override + public URL getResource(final String path) throws MalformedURLException { + return delegate.getResource(path); + } + + @Override + public InputStream getResourceAsStream(final String path) { + return delegate.getResourceAsStream(path); + } + + @Override + public int getMajorVersion() { + return 3; + } + + @Override + public int getEffectiveMajorVersion() { + return 3; + } + + @Override + public String getVirtualServerName() { + return "openejb-embedded"; + } + + @Override + public void setAttribute(final String name, final Object object) { + attributes.put(name, object); + } + + @Override + public Object getAttribute(final String name) { + final Object o = attributes.get(name); + return o == null ? delegate.getAttribute(name) : o; + } + + @Override + public Enumeration<String> getAttributeNames() { + final Set<String> c = new HashSet<>(attributes.keySet()); + c.addAll(Collections.list(delegate.getAttributeNames())); + return Collections.enumeration(c); + } + + @Override + public String getServerInfo() { + return "EmbeddedOpenEJB/" + OpenEjbVersion.get().getVersion(); + } + } } http://git-wip-us.apache.org/repos/asf/tomee/blob/8ed1027f/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EmbeddedServletContext.java ---------------------------------------------------------------------- diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EmbeddedServletContext.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EmbeddedServletContext.java index a4f2674..d6ecc3c 100644 --- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EmbeddedServletContext.java +++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EmbeddedServletContext.java @@ -43,6 +43,11 @@ public class EmbeddedServletContext extends MockServletContext { } @Override + public ClassLoader getClassLoader() { + return Thread.currentThread().getContextClassLoader(); + } + + @Override public URL getResource(final String path) throws MalformedURLException { if (resourceProviders.isEmpty()) { return super.getResource(path); http://git-wip-us.apache.org/repos/asf/tomee/blob/8ed1027f/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java ---------------------------------------------------------------------- diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java index aff3759..4cb4bfb 100644 --- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java +++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java @@ -148,6 +148,9 @@ public class HttpListenerRegistry implements HttpListener { if (wbc != null) { CdiAppContextsService.class.cast(wbc.getService(ContextsService.class)).checkConversationState(); } + if (pattern.contains("/.*\\.") && HttpRequestImpl.class.isInstance(request)) { // TODO: enhance it, basically servlet *.xxx + HttpRequestImpl.class.cast(request).noPathInfo(); + } entry.getValue().onMessage(request, response); break; } http://git-wip-us.apache.org/repos/asf/tomee/blob/8ed1027f/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java ---------------------------------------------------------------------- diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java index e30e40b..a4a7db2 100644 --- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java +++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpRequestImpl.java @@ -192,6 +192,7 @@ public class HttpRequestImpl implements HttpRequest { private Collection<ServletRequestListener> listeners; private volatile boolean asyncStarted; + private boolean noPathInfo; public HttpRequestImpl(URI socketURI) { this.socketURI = socketURI; @@ -260,11 +261,13 @@ public class HttpRequestImpl implements HttpRequest { return parts.values(); } + public void noPathInfo() { // todo: enhance it + noPathInfo = true; + } + @Override public String getPathInfo() { - // hack for jsf, would need to rething all our getpathInfo() to get rid of it - // Note: if you tackle it ensure to not break CXF integrations - if (path != null && path.contains(".jsf") || servletPath != null && servletPath.endsWith(".jsf")) { + if (noPathInfo) { return null; } if (servletPath != null) { @@ -321,13 +324,10 @@ public class HttpRequestImpl implements HttpRequest { if (servletPath != null) { return servletPath; } - if (path != null && path.endsWith(".jsf")) { // see getPathInfo() - return path; - } if ("/".equals(path) && uri != null) { // not initialized, contextpath = "" so let use it for our router (HttpListenerRegistry) return uri.getPath(); } - return getPathInfo(); + return path; } public void initServletPath(final String servlet) { @@ -1113,7 +1113,7 @@ public class HttpRequestImpl implements HttpRequest { @Override public RequestDispatcher getRequestDispatcher(String s) { - return null; + return new SimpleDispatcher(s); } @Override @@ -1248,4 +1248,43 @@ public class HttpRequestImpl implements HttpRequest { } } } + + private static class SimpleDispatcher implements RequestDispatcher { + private final String path; + + public SimpleDispatcher(final String path) { + this.path = path; + } + + @Override + public void forward(final ServletRequest request, final ServletResponse response) throws ServletException, IOException { + if (!HttpRequestImpl.class.isInstance(request)) { + if (HttpServletResponse.class.isInstance(response)) { + HttpServletResponse.class.cast(response).sendError(HttpServletResponse.SC_NOT_FOUND); + } + return; + } + + final HttpRequestImpl cast = HttpRequestImpl.class.cast(request); + final HttpRequestImpl httpRequest = new HttpRequestImpl(cast.socketURI); + httpRequest.uri = cast.uri; + httpRequest.parameters.putAll(cast.parameters); + httpRequest.initPathFromContext(cast.contextPath); + httpRequest.initServletPath(path); + httpRequest.method = cast.method; + + try { + SystemInstance.get().getComponent(HttpListenerRegistry.class).onMessage( + httpRequest, + HttpResponse.class.isInstance(response)? HttpResponse.class.cast(response) : new ServletResponseAdapter(HttpServletResponse.class.cast(response))); + } catch (final Exception e) { + throw new ServletException(e.getMessage(), e); + } + } + + @Override + public void include(final ServletRequest request, final ServletResponse response) throws ServletException, IOException { + // not yet supported: TODO: fake response write in ByteArrayOutputStream and then call HttpListenerRegistry and write it back + } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/8ed1027f/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java ---------------------------------------------------------------------- diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java index fff57b2..65b8576 100644 --- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java +++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/util/HttpUtil.java @@ -17,6 +17,7 @@ package org.apache.openejb.server.httpd.util; import org.apache.openejb.OpenEJBRuntimeException; +import org.apache.openejb.core.ParentClassLoaderFinder; import org.apache.openejb.core.WebContext; import org.apache.openejb.loader.SystemInstance; import org.apache.openejb.server.httpd.FilterListener; @@ -33,12 +34,15 @@ import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import java.util.Collection; +import java.util.Collections; import java.util.Enumeration; import java.util.List; -import java.util.regex.Pattern; public final class HttpUtil { private static final String WILDCARD = SystemInstance.get().getProperty("openejb.http.wildcard", ".*"); + static { + setJspFactory(); + } private HttpUtil() { // no-op @@ -65,6 +69,17 @@ public final class HttpUtil { return addresses.iterator().next(); } + public static void addDefaultsIfAvailable(final WebContext wc) { + try { + final Class<?> servlet = wc.getClassLoader().loadClass("org.apache.jasper.servlet.JspServlet"); + SystemInstance.get().getComponent(ServletContext.class).setAttribute("org.apache.tomcat.InstanceManager", + wc.getClassLoader().loadClass("org.apache.tomee.catalina.JavaeeInstanceManager").getConstructor(WebContext.class).newInstance(wc)); + addServlet(servlet.getName(), wc, "*.jsp"); + } catch (final Exception e) { + // no-op + } + } + public static boolean addServlet(final String classname, final WebContext wc, final String mapping) { final HttpListenerRegistry registry = SystemInstance.get().getComponent(HttpListenerRegistry.class); if (registry == null || mapping == null) { @@ -73,16 +88,16 @@ public final class HttpUtil { final ServletListener listener; try { - final ServletContext servletContext = SystemInstance.get().getComponent(ServletContext.class); + ServletContext servletContext = wc.getServletContext(); + if (servletContext == null) { + servletContext = SystemInstance.get().getComponent(ServletContext.class); + } if ("javax.faces.webapp.FacesServlet".equals(classname)) { try { // faking it to let the FacesServlet starting // NOTE: needs myfaces-impl + tomcat-jasper (JspFactory) // TODO: handle the whole lifecycle (cleanup mainly) + use myfaces SPI to make scanning really faster (take care should work in tomee were we already have it impl) final Class<?> mfListenerClass = wc.getClassLoader().loadClass("org.apache.myfaces.webapp.StartupServletContextListener"); - final Class<?> jspFactory = wc.getClassLoader().loadClass("org.apache.jasper.runtime.JspFactoryImpl"); - final Class<?> jspFactoryApi = wc.getClassLoader().loadClass("javax.servlet.jsp.JspFactory"); - jspFactoryApi.getMethod("setDefaultFactory", jspFactoryApi).invoke(null, jspFactory.newInstance()); final ServletContextListener servletContextListener = ServletContextListener.class.cast(mfListenerClass.newInstance()); servletContext.setAttribute("javax.enterprise.inject.spi.BeanManager", new InjectableBeanManager(wc.getWebBeansContext().getBeanManagerImpl())); @@ -102,6 +117,7 @@ public final class HttpUtil { final ClassLoader old = setClassLoader(wc, thread); try { listener = new ServletListener((Servlet) wc.newInstance(wc.getClassLoader().loadClass(classname)), wc.getContextRoot()); + final ServletContext sc = servletContext; listener.getDelegate().init(new ServletConfig() { @Override public String getServletName() { @@ -110,18 +126,21 @@ public final class HttpUtil { @Override public ServletContext getServletContext() { - return servletContext; + return sc; } @Override public String getInitParameter(final String s) { - return servletContext.getInitParameter(s); + return sc.getInitParameter(s); } @Override public Enumeration<String> getInitParameterNames() { - return servletContext.getInitParameterNames(); + final Enumeration<String> parameterNames = sc.getInitParameterNames(); + return parameterNames == null ? Collections.<String>emptyEnumeration() : parameterNames; } + + }); } finally { thread.setContextClassLoader(old); @@ -134,6 +153,17 @@ public final class HttpUtil { return true; } + private static void setJspFactory() { + try { + final ClassLoader classLoader = ParentClassLoaderFinder.Helper.get(); + final Class<?> jspFactory = classLoader.loadClass("org.apache.jasper.runtime.JspFactoryImpl"); + final Class<?> jspFactoryApi = classLoader.loadClass("javax.servlet.jsp.JspFactory"); + jspFactoryApi.getMethod("setDefaultFactory", jspFactoryApi).invoke(null, jspFactory.newInstance()); + } catch (final Throwable t) { + // no-op + } + } + private static ClassLoader setClassLoader(final WebContext wc, final Thread thread) { final ClassLoader old = thread.getContextClassLoader(); thread.setContextClassLoader(wc.getClassLoader() == null ? wc.getAppContext().getClassLoader() : wc.getClassLoader()); @@ -149,6 +179,9 @@ public final class HttpUtil { final Servlet servlet = ((ServletListener) registry.removeHttpListener(pattern(wc.getContextRoot(), mapping))).getDelegate(); servlet.destroy(); wc.destroy(servlet); + if (servlet.getClass().equals("org.apache.jasper.servlet.JspServlet")) { + SystemInstance.get().getComponent(ServletContext.class).removeAttribute("org.apache.tomcat.InstanceManager"); + } } public static boolean addFilter(final String classname, final WebContext wc, final String mapping, final FilterConfig config) { http://git-wip-us.apache.org/repos/asf/tomee/blob/8ed1027f/tck/cdi-embedded/pom.xml ---------------------------------------------------------------------- diff --git a/tck/cdi-embedded/pom.xml b/tck/cdi-embedded/pom.xml index d2e230a..0786023 100644 --- a/tck/cdi-embedded/pom.xml +++ b/tck/cdi-embedded/pom.xml @@ -43,25 +43,31 @@ <groupId>org.apache.myfaces.core</groupId> <artifactId>myfaces-impl</artifactId> <version>${myfaces.version}</version> - <scope>provided</scope> + <scope>test</scope> </dependency> <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-jasper</artifactId> <version>${tomcat.version}</version> - <scope>provided</scope> + <scope>test</scope> </dependency> <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-jasper-el</artifactId> <version>${tomcat.version}</version> - <scope>provided</scope> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.tomcat</groupId> + <artifactId>tomcat-catalina</artifactId> + <version>${tomcat.version}</version> + <scope>test</scope> </dependency> <dependency> <groupId>org.apache.openejb.patch</groupId> <artifactId>openejb-jstl</artifactId> <version>1.2</version> - <scope>provided</scope> + <scope>test</scope> </dependency> <dependency> @@ -74,6 +80,7 @@ <groupId>org.apache.openejb</groupId> <artifactId>tck-common</artifactId> <version>${openejb.version}</version> + <scope>test</scope> </dependency> <dependency> @@ -128,6 +135,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.apache.openejb</groupId> + <artifactId>tomee-catalina</artifactId> + <version>${tomee.version}</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.apache.openwebbeans</groupId> <artifactId>openwebbeans-jsf</artifactId> <version>${org.apache.openwebbeans.version}</version> @@ -190,6 +203,7 @@ <openejb.http.mock-request>true</openejb.http.mock-request> <openejb.http.default-content-type>text/plain</openejb.http.default-content-type> + <openejb.embedded.try-jsp>true</openejb.embedded.try-jsp> <openejb.deploymentId.format>{appId}/{ejbJarId}/{ejbName}</openejb.deploymentId.format> <org.apache.openejb.assembler.classic.WebAppBuilder>org.apache.openejb.web.LightweightWebAppBuilder</org.apache.openejb.assembler.classic.WebAppBuilder> </systemPropertyVariables> http://git-wip-us.apache.org/repos/asf/tomee/blob/8ed1027f/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/TckTlds.java ---------------------------------------------------------------------- diff --git a/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/TckTlds.java b/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/TckTlds.java new file mode 100644 index 0000000..e7117e8 --- /dev/null +++ b/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/TckTlds.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.openejb.tck.cdi.embedded; + +import org.apache.jasper.compiler.TldCache; +import org.apache.openejb.observer.Observes; +import org.apache.openejb.util.reflection.Reflections; +import org.apache.openejb.web.LightweightWebAppBuilder; +import org.apache.tomcat.util.descriptor.tld.TaglibXml; +import org.apache.tomcat.util.descriptor.tld.TldResourcePath; +import org.apache.tomee.jasper.TomEETldScanner; +import org.xml.sax.SAXException; + +import javax.servlet.ServletContext; +import java.io.IOException; +import java.util.Map; + +public class TckTlds extends TldCache { + private static final TomEETldScanner SCANNER = new TomEETldScanner(null, false, false, false) { + @Override + protected void scanJspConfig() throws IOException, SAXException { + // no-op + } + + @Override + protected void scanResourcePaths(final String startPath) throws IOException, SAXException { + // no-op + } + + @Override + public void scanJars() { + // no-op + } + }; + static { + try { + SCANNER.scan(); + } catch (final Exception e) { + // no-op + } + } + + public TckTlds(final ServletContext context) { + super(context, + (Map<String, TldResourcePath>) Reflections.get(SCANNER, "uriTldResourcePathMap"), + (Map<TldResourcePath, TaglibXml>) Reflections.get(SCANNER, "tldResourcePathTaglibXmlMap")); + } + + public static class Observer { + public void setup(@Observes final LightweightWebAppBuilder.EmbeddedServletContextCreated created) { + created.getContext().setAttribute(TldCache.class.getName(), new TckTlds(created.getContext())); + } + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/8ed1027f/tck/cdi-embedded/src/test/resources/META-INF/org.apache.openejb.extension ---------------------------------------------------------------------- diff --git a/tck/cdi-embedded/src/test/resources/META-INF/org.apache.openejb.extension b/tck/cdi-embedded/src/test/resources/META-INF/org.apache.openejb.extension new file mode 100644 index 0000000..ff66987 --- /dev/null +++ b/tck/cdi-embedded/src/test/resources/META-INF/org.apache.openejb.extension @@ -0,0 +1 @@ +org.apache.openejb.tck.cdi.embedded.TckTlds$Observer \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/8ed1027f/tck/cdi-embedded/src/test/resources/failing.xml ---------------------------------------------------------------------- diff --git a/tck/cdi-embedded/src/test/resources/failing.xml b/tck/cdi-embedded/src/test/resources/failing.xml index bc6142c..8a76ebe 100644 --- a/tck/cdi-embedded/src/test/resources/failing.xml +++ b/tck/cdi-embedded/src/test/resources/failing.xml @@ -18,15 +18,20 @@ <suite name="CDI TCK" verbose="0"> <test name="CDI TCK"> <!-- runner helping properties + -ea + -Dopenejb.deploymentId.format={appId}/{ejbJarId}/{ejbName} + -Dopenejb.http.default-content-type=text/plain + -Dhttpejbd.print=REQUEST,RESPONSE + -Dopenejb.jul.forceReload=true + -Dlogging.level.org.apache.openejb.server.httpd.HttpResponseImpl=FINEST + -Dopenejb.cdi.filter.classloader=false -Dorg.apache.openejb.assembler.classic.WebAppBuilder=org.apache.openejb.web.LightweightWebAppBuilder -Dopenejb.cdi.debug=true - -Dopenejb.cdi.filter.classloader=false -Dopenejb.http.mock-request=true - -Dopenejb.http.default-content-type=text/plain - -Dopenejb.deploymentId.format={appId}/{ejbJarId}/{ejbName} + -Dopenejb.embedded.try-jsp=true --> <classes> - <class name="org.jboss.cdi.tck.tests.context.request.event.async.RequestScopeEventAsyncTest" /> + <class name="org.jboss.cdi.tck.tests.lookup.el.integration.IntegrationWithUnifiedELTest" /> </classes> </test> </suite>
