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 2011/03/16 16:36:55 UTC
svn commit: r1082168 [1/2] - in /myfaces/extensions/cdi/trunk: ./
examples/jsf-examples/hello_myfaces-codi_jsf20/ test-modules/
test-modules/base-test-infrastructure-module/
test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/...
Author: gpetracek
Date: Wed Mar 16 15:36:53 2011
New Revision: 1082168
URL: http://svn.apache.org/viewvc?rev=1082168&view=rev
Log:
EXTCDI-157 refactored test modules
Added:
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/TestContainerResolver.java
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/CdiTestContainer.java
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/TestContainer.java
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/WebAppAwareCdiTestContainer.java
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/WebAppTestContainer.java
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/pom.xml
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/java/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/java/org/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/java/org/apache/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/java/org/apache/myfaces/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/java/org/apache/myfaces/extensions/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/java/org/apache/myfaces/extensions/cdi/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/jsf/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/jsf/MyFacesCore12WebAppTestContainer.java
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/LICENSE.txt
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/META-INF/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/META-INF/services/
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.test.spi.WebAppTestContainer
myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/NOTICE.txt
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/pom.xml
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/AbstractOpenWebBeans10TestContainer.java
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/HybridCdiTestOpenWebBeansContainer.java
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/HybridStandaloneLifeCycle.java
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/ServletOpenWebBeans10TestContainer.java
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/StandaloneOpenWebBeans10TestContainer.java
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/resources/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/resources/LICENSE.txt
- copied unchanged from r1079049, myfaces/extensions/cdi/trunk/core/impl/src/main/resources/META-INF/LICENSE.txt
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/resources/META-INF/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/resources/META-INF/services/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.test.spi.CdiTestContainer
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/resources/NOTICE.txt
- copied unchanged from r1079049, myfaces/extensions/cdi/trunk/core/impl/src/main/resources/META-INF/NOTICE.txt
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/test/
- copied from r1079049, myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/test/
Removed:
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/HybridCdiTestOpenWebBeansContainer.java
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/HybridStandaloneLifeCycle.java
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/test/
myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/test/java/org/apache/myfaces/extensions/cdi/test/base/
Modified:
myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/pom.xml
myfaces/extensions/cdi/trunk/pom.xml
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/pom.xml
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/ContainerNotStartedException.java
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/runner/JUnit4WithCargo.java
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/AbstractCdiAwareTest.java
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/AbstractJsfAwareTest.java
myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/AbstractServletAwareTest.java
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml
myfaces/extensions/cdi/trunk/test-modules/pom.xml
Modified: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/pom.xml?rev=1082168&r1=1082167&r2=1082168&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/pom.xml Wed Mar 16 15:36:53 2011
@@ -91,7 +91,18 @@
<dependency>
<groupId>org.apache.myfaces.extensions.cdi.test</groupId>
<artifactId>myfaces-extcdi-base-test-infrastructure</artifactId>
- <version>0.9.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-owb10-support-module</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-jsf-support-module</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
@@ -593,6 +604,18 @@
</dependency>
<dependency>
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-owb10-support-module</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-jsf-support-module</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.openwebbeans.test</groupId>
<artifactId>cditest</artifactId>
<scope>test</scope>
Modified: myfaces/extensions/cdi/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/pom.xml?rev=1082168&r1=1082167&r2=1082168&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/pom.xml Wed Mar 16 15:36:53 2011
@@ -267,6 +267,18 @@
<version>0.9.4-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-owb10-support-module</artifactId>
+ <version>0.9.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-jsf-support-module</artifactId>
+ <version>0.9.4-SNAPSHOT</version>
+ </dependency>
+
<!--
We currently need this for the CDI test container to emulate the @SessionScoped.
TODO: Finally this should not be necessary anymore.
Modified: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/pom.xml?rev=1082168&r1=1082167&r2=1082168&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/pom.xml Wed Mar 16 15:36:53 2011
@@ -37,25 +37,6 @@
<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.geronimo.specs</groupId>
- <artifactId>geronimo-el_2.2_spec</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-validation_1.0_spec</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
<groupId>org.apache.myfaces.extensions.cdi.core</groupId>
<artifactId>myfaces-extcdi-core-api</artifactId>
<scope>provided</scope>
@@ -74,24 +55,6 @@
</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>
Added: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/TestContainerResolver.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/TestContainerResolver.java?rev=1082168&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/TestContainerResolver.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/TestContainerResolver.java Wed Mar 16 15:36:53 2011
@@ -0,0 +1,119 @@
+/*
+ * 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;
+
+import org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueDescriptor;
+import org.apache.myfaces.extensions.cdi.core.impl.config.ServiceLoaderResolver;
+import org.apache.myfaces.extensions.cdi.test.spi.WebAppAwareCdiTestContainer;
+import org.apache.myfaces.extensions.cdi.test.spi.CdiTestContainer;
+import org.apache.myfaces.extensions.cdi.test.spi.WebAppTestContainer;
+
+import java.util.List;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class TestContainerResolver
+{
+ public static WebAppTestContainer getNewJsfTestContainer()
+ {
+ List<WebAppTestContainer> testContainers =
+ new ServiceLoaderResolver()
+ .resolveInstances(new ConfiguredValueDescriptor<String, WebAppTestContainer>()
+ {
+ public String getKey()
+ {
+ return WebAppTestContainer.class.getSimpleName();
+ }
+
+ public Class<WebAppTestContainer> getTargetType()
+ {
+ return WebAppTestContainer.class;
+ }
+ });
+
+ if(testContainers.size() != 1)
+ {
+ if(testContainers.size() == 0)
+ {
+ throw new IllegalStateException("no implementation of " + WebAppTestContainer.class.getName()
+ + " detected.");
+ }
+ StringBuilder foundImplementations = new StringBuilder();
+
+ for(WebAppTestContainer webAppTestContainer : testContainers)
+ {
+ foundImplementations.append("\n");
+ foundImplementations.append(webAppTestContainer.getClass().getName());
+ }
+ throw new IllegalStateException("only one implementation of " + WebAppTestContainer.class.getName()
+ + " is allowed. Found implementations: " + foundImplementations.toString());
+ }
+
+ return testContainers.iterator().next();
+ }
+
+ public static CdiTestContainer getNewCdiTestContainer(boolean createServletContext /*TODO*/)
+ {
+ List<CdiTestContainer> testContainers =
+ new ServiceLoaderResolver().resolveInstances(new ConfiguredValueDescriptor<String, CdiTestContainer>()
+ {
+ public String getKey()
+ {
+ return CdiTestContainer.class.getSimpleName();
+ }
+
+ public Class<CdiTestContainer> getTargetType()
+ {
+ return CdiTestContainer.class;
+ }
+ });
+
+ CdiTestContainer standaloneTestContainer = null;
+ for(CdiTestContainer testContainer : testContainers)
+ {
+ if(createServletContext && isServletContextAwareContainer(testContainer))
+ {
+ return testContainer;
+ }
+ else if(!isServletContextAwareContainer(testContainer))
+ {
+ standaloneTestContainer = testContainer;
+ }
+ }
+
+ if(standaloneTestContainer != null)
+ {
+ return standaloneTestContainer;
+ }
+ if(createServletContext)
+ {
+ throw new IllegalStateException("no embedded test-cdi-container found");
+ }
+ else
+ {
+ throw new IllegalStateException("no stand-alone test-cdi-container found");
+ }
+ }
+
+ private static boolean isServletContextAwareContainer(CdiTestContainer testContainer)
+ {
+ return WebAppAwareCdiTestContainer.class.isAssignableFrom(testContainer.getClass());
+ }
+}
Modified: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/ContainerNotStartedException.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/cargo/ContainerNotStartedException.java?rev=1082168&r1=1082167&r2=1082168&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/ContainerNotStartedException.java (original)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/ContainerNotStartedException.java Wed Mar 16 15:36:53 2011
@@ -23,6 +23,7 @@ import java.io.IOException;
/**
* @author Gerhard Petracek
*/
+@Deprecated
public class ContainerNotStartedException extends RuntimeException
{
private static final long serialVersionUID = -2362433864481560645L;
Modified: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/runner/JUnit4WithCargo.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/cargo/runner/JUnit4WithCargo.java?rev=1082168&r1=1082167&r2=1082168&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/runner/JUnit4WithCargo.java (original)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/runner/JUnit4WithCargo.java Wed Mar 16 15:36:53 2011
@@ -33,6 +33,7 @@ import java.util.logging.Logger;
/**
* @author Gerhard Petracek
*/
+@Deprecated
public class JUnit4WithCargo extends BlockJUnit4ClassRunner
{
private static final Logger LOGGER = Logger.getLogger(JUnit4WithCargo.class.getName());
Modified: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/AbstractCdiAwareTest.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/junit4/AbstractCdiAwareTest.java?rev=1082168&r1=1082167&r2=1082168&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/AbstractCdiAwareTest.java (original)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/AbstractCdiAwareTest.java Wed Mar 16 15:36:53 2011
@@ -18,18 +18,11 @@
*/
package org.apache.myfaces.extensions.cdi.test.junit4;
-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.cditest.CdiTestContainerLoader;
+import org.apache.myfaces.extensions.cdi.test.TestContainerResolver;
+import org.apache.myfaces.extensions.cdi.test.spi.CdiTestContainer;
import org.junit.After;
import org.junit.Before;
-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 (standalone) JUnit tests.
*
@@ -42,28 +35,18 @@ public abstract class AbstractCdiAwareTe
@Before
public void before() throws Exception
{
- ProjectStageProducer.setProjectStage(ProjectStage.UnitTest);
-
- this.testContainer = CdiTestContainerLoader.getCdiContainer();
- this.testContainer.bootContainer();
+ this.testContainer = TestContainerResolver.getNewCdiTestContainer(false);
+ this.testContainer.initEnvironment();
+ this.testContainer.startContainer();
this.testContainer.startContexts();
- injectFields();
- }
-
- protected void injectFields()
- {
- BeanManager beanManager = this.testContainer.getBeanManager();
- CreationalContext creationalContext = beanManager.createCreationalContext(null);
-
- AnnotatedType annotatedType = beanManager.createAnnotatedType(getClass());
- InjectionTarget injectionTarget = beanManager.createInjectionTarget(annotatedType);
- injectionTarget.inject(this, creationalContext);
+ this.testContainer.injectFields(this);
}
@After
public void after() throws Exception
{
this.testContainer.stopContexts();
+ this.testContainer.startContainer();
}
}
Modified: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/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/junit4/AbstractJsfAwareTest.java?rev=1082168&r1=1082167&r2=1082168&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/AbstractJsfAwareTest.java (original)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/AbstractJsfAwareTest.java Wed Mar 16 15:36:53 2011
@@ -18,77 +18,26 @@
*/
package org.apache.myfaces.extensions.cdi.test.junit4;
-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.apache.myfaces.extensions.cdi.test.TestContainerResolver;
+import org.apache.myfaces.extensions.cdi.test.spi.WebAppTestContainer;
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.component.UIViewRoot;
-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;
-import java.util.Locale;
-
/**
* @author Gerhard Petracek
*/
public abstract 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;
+ protected WebAppTestContainer webAppTestContainer;
@Override
@Before
public 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();
+ this.webAppTestContainer = TestContainerResolver.getNewJsfTestContainer();
- initJsfObjects();
-
- initDefaultView();
+ this.webAppTestContainer.initEnvironment();
+ this.webAppTestContainer.startContainer();
super.before();
}
@@ -98,105 +47,6 @@ public abstract class AbstractJsfAwareTe
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 initDefaultView()
- {
- UIViewRoot root = new UIViewRoot();
- root.setViewId("/viewId");
- root.setLocale(getLocale());
- root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
- facesContext.setViewRoot(root);
- }
-
- protected Locale getLocale()
- {
- return Locale.getDefault();
- }
-
- 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);
+ this.webAppTestContainer.stopContainer();
}
}
Modified: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/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/junit4/AbstractServletAwareTest.java?rev=1082168&r1=1082167&r2=1082168&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/AbstractServletAwareTest.java (original)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/junit4/AbstractServletAwareTest.java Wed Mar 16 15:36:53 2011
@@ -18,44 +18,41 @@
*/
package org.apache.myfaces.extensions.cdi.test.junit4;
-import org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage;
-import org.apache.myfaces.extensions.cdi.core.impl.projectstage.ProjectStageProducer;
-import org.apache.webbeans.context.ContextFactory;
+import org.apache.myfaces.extensions.cdi.test.TestContainerResolver;
+import org.apache.myfaces.extensions.cdi.test.spi.WebAppAwareCdiTestContainer;
+import org.apache.myfaces.extensions.cdi.test.spi.CdiTestContainer;
import org.junit.After;
import org.junit.Before;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.context.SessionScoped;
-
/**
* Allows dependency injection in JUnit tests and implementing JUnit tests in web-projects.
*
* @author Gerhard Petracek
*/
-public abstract class AbstractServletAwareTest extends AbstractCdiAwareTest
+public abstract class AbstractServletAwareTest
{
- @Override
+ protected CdiTestContainer testContainer;
+
@Before
public void before() throws Exception
{
- ProjectStageProducer.setProjectStage(ProjectStage.UnitTest);
-
- this.testContainer = new HybridCdiTestOpenWebBeansContainer();
- this.testContainer.bootContainer();
+ this.testContainer = TestContainerResolver.getNewCdiTestContainer(true);
+ this.testContainer.initEnvironment();
+ this.testContainer.startContainer();
this.testContainer.startContexts();
- ContextFactory.activateContext(SessionScoped.class);
- ContextFactory.activateContext(RequestScoped.class);
+ ((WebAppAwareCdiTestContainer)this.testContainer).beginSession();
+ ((WebAppAwareCdiTestContainer)this.testContainer).beginRequest();
- injectFields();
+ this.testContainer.injectFields(this);
}
@After
public void after() throws Exception
{
- ContextFactory.deActivateContext(SessionScoped.class);
- ContextFactory.deActivateContext(RequestScoped.class);
+ ((WebAppAwareCdiTestContainer)this.testContainer).endRequest();
+ ((WebAppAwareCdiTestContainer)this.testContainer).endSession();
this.testContainer.stopContexts();
- this.testContainer.shutdownContainer();
+ this.testContainer.stopContainer();
}
}
Added: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/CdiTestContainer.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/spi/CdiTestContainer.java?rev=1082168&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/CdiTestContainer.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/CdiTestContainer.java Wed Mar 16 15:36:53 2011
@@ -0,0 +1,35 @@
+/*
+ * 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.spi;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+/**
+ * @author Gerhard Petracek
+ */
+public interface CdiTestContainer extends TestContainer
+{
+ void startContexts();
+
+ void stopContexts();
+
+ BeanManager getBeanManager();
+
+ <T> T injectFields(T instance);
+}
Added: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/TestContainer.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/spi/TestContainer.java?rev=1082168&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/TestContainer.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/TestContainer.java Wed Mar 16 15:36:53 2011
@@ -0,0 +1,31 @@
+/*
+ * 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.spi;
+
+/**
+ * @author Gerhard Petracek
+ */
+public interface TestContainer
+{
+ void initEnvironment();
+
+ void startContainer();
+
+ void stopContainer();
+}
Added: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/WebAppAwareCdiTestContainer.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/spi/WebAppAwareCdiTestContainer.java?rev=1082168&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/WebAppAwareCdiTestContainer.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/WebAppAwareCdiTestContainer.java Wed Mar 16 15:36:53 2011
@@ -0,0 +1,33 @@
+/*
+ * 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.spi;
+
+/**
+ * @author Gerhard Petracek
+ */
+public interface WebAppAwareCdiTestContainer extends CdiTestContainer
+{
+ void beginSession();
+
+ void beginRequest();
+
+ void endRequest();
+
+ void endSession();
+}
Added: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/WebAppTestContainer.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/spi/WebAppTestContainer.java?rev=1082168&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/WebAppTestContainer.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/spi/WebAppTestContainer.java Wed Mar 16 15:36:53 2011
@@ -0,0 +1,26 @@
+/*
+ * 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.spi;
+
+/**
+ * @author Gerhard Petracek
+ */
+public interface WebAppTestContainer extends TestContainer
+{
+}
Modified: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml?rev=1082168&r1=1082167&r2=1082168&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml Wed Mar 16 15:36:53 2011
@@ -151,14 +151,30 @@
</dependency>
<dependency>
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-owb10-support-module</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-jsf-support-module</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.openwebbeans.test</groupId>
<artifactId>cditest</artifactId>
+ <!-- owb 1.1+ isn't compatible with the used owb-support module -> explicit version required -->
+ <version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans.test</groupId>
<artifactId>cditest-owb</artifactId>
+ <!-- owb 1.1+ isn't compatible with the used owb-support module -> explicit version required -->
+ <version>1.0.0</version>
<scope>test</scope>
</dependency>
@@ -259,35 +275,40 @@
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-impl</artifactId>
- <version>${owb.version}</version>
+ <!-- owb 1.1+ isn't compatible with the used owb-support module -> explicit version required -->
+ <version>1.0.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-spi</artifactId>
- <version>${owb.version}</version>
+ <!-- owb 1.1+ isn't compatible with the used owb-support module -> explicit version required -->
+ <version>1.0.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-jsf</artifactId>
- <version>${owb.version}</version>
+ <!-- owb 1.1+ isn't compatible with the used owb-support module -> explicit version required -->
+ <version>1.0.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-resource</artifactId>
- <version>${owb.version}</version>
+ <!-- owb 1.1+ isn't compatible with the used owb-support module -> explicit version required -->
+ <version>1.0.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-web</artifactId>
- <version>${owb.version}</version>
+ <!-- owb 1.1+ isn't compatible with the used owb-support module -> explicit version required -->
+ <version>1.0.0</version>
<scope>runtime</scope>
</dependency>
Added: myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/pom.xml?rev=1082168&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/pom.xml (added)
+++ myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/pom.xml Wed Mar 16 15:36:53 2011
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <packaging>jar</packaging>
+
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-jsf-support-module</artifactId>
+ <version>0.9.4-SNAPSHOT</version>
+
+ <name>MyFaces Extensions-CDI JSF 1.2 Test-Support Module</name>
+
+ <parent>
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-test-project</artifactId>
+ <version>0.9.4-SNAPSHOT</version>
+ </parent>
+
+ <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.geronimo.specs</groupId>
+ <artifactId>geronimo-el_2.2_spec</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-base-test-infrastructure</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>
+ </dependency>
+ </dependencies>
+
+</project>
Added: myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/jsf/MyFacesCore12WebAppTestContainer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/jsf/MyFacesCore12WebAppTestContainer.java?rev=1082168&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/jsf/MyFacesCore12WebAppTestContainer.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/jsf/MyFacesCore12WebAppTestContainer.java Wed Mar 16 15:36:53 2011
@@ -0,0 +1,211 @@
+/*
+ * 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.jsf;
+
+import org.apache.myfaces.extensions.cdi.test.spi.WebAppTestContainer;
+
+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 javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+import javax.faces.component.UIViewRoot;
+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;
+import java.util.Locale;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class MyFacesCore12WebAppTestContainer implements WebAppTestContainer
+{
+ 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;
+
+ public void initEnvironment()
+ {
+ //nothing to do
+ }
+
+ public void startContainer()
+ {
+ // Set up a new thread context class loader
+ threadContextClassLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread()
+ .setContextClassLoader(new URLClassLoader(new URL[0], this.getClass().getClassLoader()));
+
+ try
+ {
+ // Set up Servlet API Objects
+ initServletObjects();
+
+ // Set up JSF API Objects
+ FactoryFinder.releaseFactories();
+
+ initFactories();
+
+ initJsfObjects();
+
+ initDefaultView();
+
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void stopContainer()
+ {
+ 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 initDefaultView()
+ {
+ UIViewRoot root = new UIViewRoot();
+ root.setViewId("/viewId");
+ root.setLocale(getLocale());
+ root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+ facesContext.setViewRoot(root);
+ }
+
+ protected Locale getLocale()
+ {
+ return Locale.getDefault();
+ }
+
+ 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/jsf12-support-module/src/main/resources/LICENSE.txt
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/LICENSE.txt?rev=1082168&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/LICENSE.txt (added)
+++ myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/LICENSE.txt Wed Mar 16 15:36:53 2011
@@ -0,0 +1,174 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
Added: myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.test.spi.WebAppTestContainer
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.test.spi.WebAppTestContainer?rev=1082168&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.test.spi.WebAppTestContainer (added)
+++ myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.test.spi.WebAppTestContainer Wed Mar 16 15:36:53 2011
@@ -0,0 +1 @@
+org.apache.myfaces.extensions.cdi.test.jsf.MyFacesCore12WebAppTestContainer
\ No newline at end of file
Added: myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/NOTICE.txt
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/NOTICE.txt?rev=1082168&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/NOTICE.txt (added)
+++ myfaces/extensions/cdi/trunk/test-modules/jsf12-support-module/src/main/resources/NOTICE.txt Wed Mar 16 15:36:53 2011
@@ -0,0 +1,9 @@
+Apache MyFaces Extensions CDI (aka MyFaces CODI)
+Copyright 2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+------------------------------------------------------------------------
+See the file LICENSE.txt
+------------------------------------------------------------------------
\ No newline at end of file
Added: myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/pom.xml?rev=1082168&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/pom.xml (added)
+++ myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/pom.xml Wed Mar 16 15:36:53 2011
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <packaging>jar</packaging>
+
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-owb10-support-module</artifactId>
+ <version>0.9.4-SNAPSHOT</version>
+
+ <name>MyFaces Extensions-CDI OpenWebBeans 1.0.0 Test-Support Module</name>
+
+ <parent>
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-test-project</artifactId>
+ <version>0.9.4-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <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.test</groupId>
+ <artifactId>myfaces-extcdi-base-test-infrastructure</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-impl</artifactId>
+ <!-- owb 1.1+ isn't compatible with the used owb-support module -> explicit version required -->
+ <version>1.0.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openwebbeans.test</groupId>
+ <artifactId>cditest</artifactId>
+ <!-- owb 1.1+ isn't compatible with the used owb-support module -> explicit version required -->
+ <version>1.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openwebbeans.test</groupId>
+ <artifactId>cditest-owb</artifactId>
+ <!-- owb 1.1+ isn't compatible with the used owb-support module -> explicit version required -->
+ <version>1.0.0</version>
+ <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>
+ </dependency>
+
+ <!-- TODO -->
+ <dependency>
+ <groupId>org.apache.myfaces.test</groupId>
+ <artifactId>myfaces-test12</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Added: myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/AbstractOpenWebBeans10TestContainer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/AbstractOpenWebBeans10TestContainer.java?rev=1082168&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/AbstractOpenWebBeans10TestContainer.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/AbstractOpenWebBeans10TestContainer.java Wed Mar 16 15:36:53 2011
@@ -0,0 +1,109 @@
+/*
+ * 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.owb;
+
+import org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage;
+import org.apache.myfaces.extensions.cdi.core.impl.projectstage.ProjectStageProducer;
+import org.apache.myfaces.extensions.cdi.test.spi.CdiTestContainer;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+/**
+ * @author Gerhard Petracek
+ */
+public abstract class AbstractOpenWebBeans10TestContainer implements CdiTestContainer
+{
+ protected org.apache.webbeans.cditest.CdiTestContainer testContainer;
+
+ public void initEnvironment()
+ {
+ ProjectStageProducer.setProjectStage(ProjectStage.UnitTest);
+ }
+
+ public void startContainer()
+ {
+ try
+ {
+ this.testContainer.bootContainer();
+ }
+ catch (Exception e)
+ {
+ //TODO
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void stopContainer()
+ {
+ try
+ {
+ this.testContainer.shutdownContainer();
+ }
+ catch (Exception e)
+ {
+ //TODO
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void startContexts()
+ {
+ try
+ {
+ this.testContainer.startContexts();
+ }
+ catch (Exception e)
+ {
+ //TODO
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void stopContexts()
+ {
+ try
+ {
+ this.testContainer.stopContexts();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public BeanManager getBeanManager()
+ {
+ this.testContainer.getBeanManager();
+ throw new IllegalStateException("not implemented");
+ }
+
+ public <T> T injectFields(T instance)
+ {
+ BeanManager beanManager = getBeanManager();
+ CreationalContext creationalContext = beanManager.createCreationalContext(null);
+
+ AnnotatedType annotatedType = beanManager.createAnnotatedType(getClass());
+ InjectionTarget injectionTarget = beanManager.createInjectionTarget(annotatedType);
+ injectionTarget.inject(instance, creationalContext);
+ return instance;
+ }
+}
Added: myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/HybridCdiTestOpenWebBeansContainer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/HybridCdiTestOpenWebBeansContainer.java?rev=1082168&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/HybridCdiTestOpenWebBeansContainer.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/owb10-support-module/src/main/java/org/apache/myfaces/extensions/cdi/test/owb/HybridCdiTestOpenWebBeansContainer.java Wed Mar 16 15:36:53 2011
@@ -0,0 +1,145 @@
+/*
+ * 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.owb;
+
+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;
+ //TODO
+ 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;
+ }
+}