You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2010/12/26 10:04:37 UTC

svn commit: r1052843 - in /myfaces/extensions/cdi/trunk: ./ test-modules/ test-modules/base-cargo-test-infrastructure-module/ test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/ test-modul...

Author: gpetracek
Date: Sun Dec 26 09:04:36 2010
New Revision: 1052843

URL: http://svn.apache.org/viewvc?rev=1052843&view=rev
Log:
EXTCDI-106 first draft

Added:
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/pom.xml
      - copied, changed from r1052842, myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/pom.xml
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/AbstractCargoTest.java
      - copied unchanged from r1052842, myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/AbstractCargoTest.java
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/ContainerNotStartedException.java
      - copied unchanged from r1052842, myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/ContainerNotStartedException.java
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/SimplePageInteraction.java
      - copied unchanged from r1052842, myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/SimplePageInteraction.java
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/TestConfiguration.java
      - copied unchanged from r1052842, myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/TestConfiguration.java
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/AbstractJsfAwareTest.java
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/AbstractServletAwareTest.java
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/HybridCdiTestOpenWebBeansContainer.java
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/HybridStandaloneLifeCycle.java
Removed:
    myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/pom.xml
    myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/AbstractCargoTest.java
    myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/ContainerNotStartedException.java
    myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/SimplePageInteraction.java
    myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/TestConfiguration.java
Modified:
    myfaces/extensions/cdi/trunk/pom.xml
    myfaces/extensions/cdi/trunk/test-modules/pom.xml

Modified: myfaces/extensions/cdi/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/pom.xml?rev=1052843&r1=1052842&r2=1052843&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/pom.xml Sun Dec 26 09:04:36 2010
@@ -148,6 +148,12 @@
                 <version>${owb.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>org.apache.myfaces.test</groupId>
+                <artifactId>myfaces-test12</artifactId>
+                <version>1.0.0</version>
+                <scope>provided</scope>
+            </dependency>
 
             <!-- the JSF independent core -->
             <dependency>

Copied: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/pom.xml (from r1052842, myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/pom.xml)
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/pom.xml?p2=myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/pom.xml&p1=myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/pom.xml&r1=1052842&r2=1052843&rev=1052843&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/pom.xml Sun Dec 26 09:04:36 2010
@@ -25,7 +25,7 @@
     <packaging>jar</packaging>
 
     <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
-    <artifactId>myfaces-extcdi-cargo-base-test-infrastructure</artifactId>
+    <artifactId>myfaces-extcdi-base-test-infrastructure</artifactId>
     <version>0.9.2-SNAPSHOT</version>
 
     <name>MyFaces Extensions-CDI Base-Test-Infrastructure for Cargo</name>
@@ -39,18 +39,55 @@
     <dependencies>
 
         <dependency>
+            <groupId>org.apache.myfaces.core</groupId>
+            <artifactId>myfaces-api</artifactId>
+            <version>1.2.8</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.myfaces.extensions.cdi.core</groupId>
             <artifactId>myfaces-extcdi-core-api</artifactId>
             <scope>provided</scope>
         </dependency>
 
         <dependency>
+            <groupId>org.apache.myfaces.extensions.cdi.core</groupId>
+            <artifactId>myfaces-extcdi-core-impl</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.myfaces.extensions.cdi.modules</groupId>
             <artifactId>myfaces-extcdi-jsf12-module-impl</artifactId>
             <scope>provided</scope>
         </dependency>
 
         <dependency>
+            <groupId>org.apache.openwebbeans.test</groupId>
+            <artifactId>cditest</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.openwebbeans.test</groupId>
+            <artifactId>cditest-owb</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.myfaces.test</groupId>
+            <artifactId>myfaces-test12</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_2.5_spec</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>provided</scope>

Added: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/AbstractJsfAwareTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/AbstractJsfAwareTest.java?rev=1052843&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/AbstractJsfAwareTest.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/AbstractJsfAwareTest.java Sun Dec 26 09:04:36 2010
@@ -0,0 +1,185 @@
+/*
+ * 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.myfaces.extensions.cdi.test.base.junit4.runner;
+
+import org.apache.myfaces.test.mock.MockHttpServletRequest;
+import org.apache.myfaces.test.mock.MockHttpServletResponse;
+import org.apache.myfaces.test.mock.MockServletConfig;
+import org.apache.myfaces.test.mock.MockHttpSession;
+import org.apache.myfaces.test.mock.MockServletContext;
+import org.apache.myfaces.test.mock.MockExternalContext;
+import org.apache.myfaces.test.mock.MockFacesContext;
+import org.apache.myfaces.test.mock.MockRenderKit;
+import org.apache.myfaces.test.mock.MockApplicationFactory;
+import org.apache.myfaces.test.mock.MockFacesContextFactory;
+import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
+import org.apache.myfaces.test.mock.MockRenderKitFactory;
+import org.junit.After;
+import org.junit.Before;
+
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class AbstractJsfAwareTest extends AbstractServletAwareTest
+{
+    protected Application application = null;
+    protected MockServletConfig config = null;
+    protected ExternalContext externalContext = null;
+    protected FacesContext facesContext = null;
+    protected FacesContextFactory facesContextFactory = null;
+    protected Lifecycle lifecycle = null;
+    protected LifecycleFactory lifecycleFactory = null;
+    protected RenderKit renderKit = null;
+    protected MockHttpServletRequest request = null;
+    protected MockHttpServletResponse response = null;
+    protected MockServletContext servletContext = null;
+    protected MockHttpSession session = null;
+
+    // Thread context class loader saved and restored after each test
+    private ClassLoader threadContextClassLoader = null;
+
+    @Override
+    @Before
+    public final void before() throws Exception
+    {
+        // Set up a new thread context class loader
+        threadContextClassLoader = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread()
+                .setContextClassLoader(new URLClassLoader(new URL[0], this.getClass().getClassLoader()));
+
+        // Set up Servlet API Objects
+        initServletObjects();
+
+        // Set up JSF API Objects
+        FactoryFinder.releaseFactories();
+
+        initFactories();
+
+        initJsfObjects();
+
+        super.before();
+    }
+
+    @Override
+    @After
+    public void after() throws Exception
+    {
+        super.after();
+
+        application = null;
+        config = null;
+        externalContext = null;
+        lifecycle = null;
+        lifecycleFactory = null;
+        renderKit = null;
+        request = null;
+        response = null;
+        servletContext = null;
+        session = null;
+
+        if (facesContext != null)
+        {
+            facesContext.release();
+        }
+        FactoryFinder.releaseFactories();
+
+        Thread.currentThread().setContextClassLoader(threadContextClassLoader);
+        threadContextClassLoader = null;
+        facesContext = null;
+    }
+
+    protected void initJsfObjects() throws Exception
+    {
+        initExternalContext();
+        initLifecycle();
+        initFacesContext();
+        initApplication();
+        initRenderKit();
+    }
+
+    protected void initServletObjects() throws Exception
+    {
+        servletContext = new MockServletContext();
+        config = new MockServletConfig(servletContext);
+        session = new MockHttpSession();
+        session.setServletContext(servletContext);
+        request = new MockHttpServletRequest(session);
+        request.setServletContext(servletContext);
+        response = new MockHttpServletResponse();
+    }
+
+    protected void initFactories() throws Exception
+    {
+        FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName());
+        FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY, MockFacesContextFactory.class.getName());
+        FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY, MockLifecycleFactory.class.getName());
+        FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY, MockRenderKitFactory.class.getName());
+    }
+
+    protected void initExternalContext() throws Exception
+    {
+        externalContext = new MockExternalContext(servletContext, request, response);
+    }
+
+    protected void initLifecycle() throws Exception
+    {
+        lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+        lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+    }
+
+    protected void initFacesContext() throws Exception
+    {
+        facesContextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+        facesContext = facesContextFactory.getFacesContext(servletContext, request, response, lifecycle);
+        if (facesContext.getExternalContext() != null)
+        {
+            externalContext = facesContext.getExternalContext();
+        }
+    }
+
+    protected void initApplication() throws Exception
+    {
+        ApplicationFactory applicationFactory =
+                (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+        application = applicationFactory.getApplication();
+        ((MockFacesContext) facesContext).setApplication(application);
+    }
+
+    protected void initRenderKit() throws Exception
+    {
+        RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder
+                .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+        renderKit = new MockRenderKit();
+        renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT,
+                renderKit);
+    }
+}

Added: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/AbstractServletAwareTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/AbstractServletAwareTest.java?rev=1052843&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/AbstractServletAwareTest.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/AbstractServletAwareTest.java Sun Dec 26 09:04:36 2010
@@ -0,0 +1,72 @@
+/*
+ * 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.myfaces.extensions.cdi.test.base.junit4.runner;
+
+import org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage;
+import org.apache.myfaces.extensions.cdi.core.impl.projectstage.ProjectStageProducer;
+import org.apache.webbeans.cditest.CdiTestContainer;
+import org.apache.webbeans.context.ContextFactory;
+import org.junit.After;
+import org.junit.Before;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+/**
+ * Allows dependency injection in JUnit tests and implementing JUnit tests in web-projects.
+ *
+ * @author Gerhard Petracek
+ */
+public abstract class AbstractServletAwareTest
+{
+    private CdiTestContainer testContainer;
+
+    @Before
+    public void before() throws Exception
+    {
+        ProjectStageProducer.setProjectStage(ProjectStage.UnitTest);
+
+        this.testContainer = new HybridCdiTestOpenWebBeansContainer();
+        this.testContainer.bootContainer();
+
+        this.testContainer.startContexts();
+        ContextFactory.activateContext(SessionScoped.class);
+        ContextFactory.activateContext(RequestScoped.class);
+
+        BeanManager beanManager = this.testContainer.getBeanManager();
+        CreationalContext creationalContext = beanManager.createCreationalContext(null);
+
+        AnnotatedType annotatedType = beanManager.createAnnotatedType(getClass());
+        InjectionTarget injectionTarget = beanManager.createInjectionTarget(annotatedType);
+        injectionTarget.inject(this, creationalContext);
+    }
+
+    @After
+    public void after() throws Exception
+    {
+        ContextFactory.deActivateContext(SessionScoped.class);
+        ContextFactory.deActivateContext(RequestScoped.class);
+        this.testContainer.stopContexts();
+        this.testContainer.shutdownContainer();
+    }
+}

Added: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/HybridCdiTestOpenWebBeansContainer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/HybridCdiTestOpenWebBeansContainer.java?rev=1052843&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/HybridCdiTestOpenWebBeansContainer.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/HybridCdiTestOpenWebBeansContainer.java Sun Dec 26 09:04:36 2010
@@ -0,0 +1,144 @@
+/*
+ * 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.myfaces.extensions.cdi.test.base.junit4.runner;
+
+import org.apache.myfaces.test.mock.MockHttpServletRequest;
+import org.apache.webbeans.cditest.CdiTestContainer;
+import org.apache.webbeans.cditest.owb.MockHttpSession;
+import org.apache.webbeans.cditest.owb.MockServletContext;
+import org.apache.webbeans.context.ContextFactory;
+import org.apache.webbeans.spi.ContainerLifecycle;
+
+import javax.enterprise.inject.ResolutionException;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.servlet.ServletRequestEvent;
+import java.lang.annotation.Annotation;
+
+/**
+ * Allows JUnit tests in a web-app project
+ *
+ * @author Gerhard Petracek
+ */
+class HybridCdiTestOpenWebBeansContainer implements CdiTestContainer
+{
+    private ContainerLifecycle lifecycle = null;
+    private MockServletContext servletContext = null;
+    private MockHttpSession session = null;
+    private MockHttpServletRequest request;
+
+    public void bootContainer() throws Exception
+    {
+        this.servletContext = new MockServletContext();
+        this.session = new MockHttpSession();
+        this.request = new MockHttpServletRequest(this.session);
+        this.lifecycle = new HybridStandaloneLifeCycle(this.servletContext, this.session, this.request);
+        this.lifecycle.startApplication(this.servletContext);
+    }
+
+    public void shutdownContainer() throws Exception
+    {
+        if (this.lifecycle != null)
+        {
+            this.lifecycle.stopApplication(this.servletContext);
+        }
+    }
+
+    public void startContexts() throws Exception
+    {
+        ContextFactory.initSingletonContext(this.servletContext);
+        ContextFactory.initApplicationContext(this.servletContext);
+        ContextFactory.initSessionContext(this.session);
+        ContextFactory.initConversationContext(null);
+        ContextFactory.initRequestContext(new ServletRequestEvent(this.servletContext, this.request));
+    }
+
+    public void startApplicationScope() throws Exception
+    {
+        ContextFactory.initApplicationContext(this.servletContext);
+    }
+
+    public void startConversationScope() throws Exception
+    {
+    }
+
+    public void startCustomScope(Class<? extends Annotation> scopeClass) throws Exception
+    {
+    }
+
+    public void startRequestScope() throws Exception
+    {
+        ContextFactory.initRequestContext(new ServletRequestEvent(this.servletContext, this.request));
+    }
+
+    public void startSessionScope() throws Exception
+    {
+        ContextFactory.initSessionContext(this.session);
+    }
+
+    public void stopContexts() throws Exception
+    {
+        ContextFactory.destroyRequestContext(new ServletRequestEvent(this.servletContext, this.request));
+        ContextFactory.destroyConversationContext();
+        ContextFactory.destroySessionContext(this.session);
+        ContextFactory.destroyApplicationContext(this.servletContext);
+        ContextFactory.destroySingletonContext(this.servletContext);
+
+        ContextFactory.cleanUpContextFactory();
+    }
+
+    public void stopApplicationScope() throws Exception
+    {
+        ContextFactory.destroyApplicationContext(this.servletContext);
+    }
+
+    public void stopConversationScope() throws Exception
+    {
+    }
+
+    public void stopCustomScope(Class<? extends Annotation> scopeClass) throws Exception
+    {
+    }
+
+    public void stopRequestScope() throws Exception
+    {
+        ContextFactory.destroyRequestContext(new ServletRequestEvent(this.servletContext, this.request));
+    }
+
+    public void stopSessionScope() throws Exception
+    {
+        ContextFactory.destroySessionContext(this.session);
+    }
+
+    public BeanManager getBeanManager()
+    {
+        return this.lifecycle.getBeanManager();
+    }
+
+    public <T> T getInstance(Class<T> type, Annotation... qualifiers)
+            throws ResolutionException
+    {
+        return null;
+    }
+
+    public Object getInstance(String name)
+            throws ResolutionException
+    {
+        return null;
+    }
+}

Added: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/HybridStandaloneLifeCycle.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/HybridStandaloneLifeCycle.java?rev=1052843&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/HybridStandaloneLifeCycle.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/junit4/runner/HybridStandaloneLifeCycle.java Sun Dec 26 09:04:36 2010
@@ -0,0 +1,77 @@
+/*
+ * 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.myfaces.extensions.cdi.test.base.junit4.runner;
+
+import org.apache.myfaces.test.mock.MockHttpServletRequest;
+import org.apache.webbeans.cditest.owb.MockHttpSession;
+import org.apache.webbeans.cditest.owb.MockServletContext;
+import org.apache.webbeans.context.ContextFactory;
+import org.apache.webbeans.el.ELContextStore;
+import org.apache.webbeans.lifecycle.StandaloneLifeCycle;
+
+import javax.servlet.ServletRequestEvent;
+
+/**
+ * @author Gerhard Petracek
+ */
+class HybridStandaloneLifeCycle extends StandaloneLifeCycle
+{
+    private MockServletContext servletContext;
+    private MockHttpSession session;
+
+    private MockHttpServletRequest request;
+
+    public HybridStandaloneLifeCycle(MockServletContext servletContext,
+                                      MockHttpSession session,
+                                      MockHttpServletRequest request)
+    {
+        this.servletContext = servletContext;
+        this.session = session;
+        this.request = request;
+    }
+
+    @Override
+    public void beforeStartApplication(Object object)
+    {
+        ContextFactory.initRequestContext(new ServletRequestEvent(this.servletContext, this.request));
+        ContextFactory.initSessionContext(this.session);
+        ContextFactory.initConversationContext(null);
+        ContextFactory.initApplicationContext(this.servletContext);
+        ContextFactory.initSingletonContext(this.servletContext);
+    }
+
+    @Override
+    public void beforeStopApplication(Object endObject)
+    {
+        ContextFactory.destroyRequestContext(new ServletRequestEvent(this.servletContext, this.request));
+        ContextFactory.destroySessionContext(this.session);
+        ContextFactory.destroyConversationContext();
+        ContextFactory.destroyApplicationContext(this.servletContext);
+        ContextFactory.destroySingletonContext(this.servletContext);
+
+        ContextFactory.cleanUpContextFactory();
+
+        // clean up the EL caches after each request
+        ELContextStore elStore = ELContextStore.getInstance(false);
+        if (elStore != null)
+        {
+            elStore.destroyELContextStore();
+        }
+    }
+}

Modified: myfaces/extensions/cdi/trunk/test-modules/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/pom.xml?rev=1052843&r1=1052842&r2=1052843&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/test-modules/pom.xml Sun Dec 26 09:04:36 2010
@@ -37,7 +37,7 @@
     </parent>
 
     <modules>
-        <module>base-cargo-test-infrastructure-module</module>
+        <module>base-test-infrastructure-module</module>
     </modules>
     
     <profiles>