You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2016/08/26 01:45:52 UTC
svn commit: r1757774 - in /myfaces/core/branches/2.3.x: impl/
impl/src/test/java/org/apache/myfaces/mc/test/core/
impl/src/test/java/org/apache/myfaces/mc/test/core/runner/
impl/src/test/resources/META-INF/openwebbeans/ parent/
Author: lu4242
Date: Fri Aug 26 01:45:52 2016
New Revision: 1757774
URL: http://svn.apache.org/viewvc?rev=1757774&view=rev
Log:
update OWB version to 1.6.3 for CDI tests and fix annotation dependency to match CDI 2.0
Added:
myfaces/core/branches/2.3.x/impl/src/test/resources/META-INF/openwebbeans/
myfaces/core/branches/2.3.x/impl/src/test/resources/META-INF/openwebbeans/openwebbeans.properties
Modified:
myfaces/core/branches/2.3.x/impl/pom.xml
myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/mc/test/core/AbstractMyFacesTestCase.java
myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/mc/test/core/runner/AbstractJsfTestContainer.java
myfaces/core/branches/2.3.x/parent/pom.xml
Modified: myfaces/core/branches/2.3.x/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/pom.xml?rev=1757774&r1=1757773&r2=1757774&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/pom.xml (original)
+++ myfaces/core/branches/2.3.x/impl/pom.xml Fri Aug 26 01:45:52 2016
@@ -41,7 +41,7 @@
</scm>
<properties>
- <openwebbeans.version>1.2.8</openwebbeans.version>
+ <openwebbeans.version>1.6.3</openwebbeans.version>
</properties>
<build>
@@ -1169,10 +1169,10 @@
<optional>true</optional> <!-- optional does not completely work in dependencyManagement (MNG-1630) -->
</dependency>
- <!-- annotations 1.0 (javax.annotation.*) -->
+ <!-- annotations 1.2 (javax.annotation.*) -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-annotation_1.0_spec</artifactId>
+ <artifactId>geronimo-annotation_1.2_spec</artifactId>
</dependency>
<!-- jpa 3.0 - needed in AllAnnotationLifecycleProvider -->
@@ -1289,7 +1289,7 @@
<!-- Openwebbeans for CDI Test -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+ <artifactId>geronimo-interceptor_1.2_spec</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
@@ -1323,12 +1323,13 @@
<version>${openwebbeans.version}</version>
<scope>test</scope>
</dependency>
+ <!--
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-clustering</artifactId>
<version>${openwebbeans.version}</version>
<scope>test</scope>
- </dependency>
+ </dependency>-->
<dependency>
<groupId>org.apache.bval</groupId>
Modified: myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/mc/test/core/AbstractMyFacesTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/mc/test/core/AbstractMyFacesTestCase.java?rev=1757774&r1=1757773&r2=1757774&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/mc/test/core/AbstractMyFacesTestCase.java (original)
+++ myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/mc/test/core/AbstractMyFacesTestCase.java Fri Aug 26 01:45:52 2016
@@ -346,7 +346,7 @@ public abstract class AbstractMyFacesTes
protected AbstractFacesInitializer createFacesInitializer()
{
- return new JUnitFacesInitializer(this);
+ return new JUnitNoCDIFacesInitializer(this);
}
protected void setUpMyFaces() throws Exception
@@ -1474,6 +1474,22 @@ public abstract class AbstractMyFacesTes
}
+ protected class JUnitNoCDIFacesInitializer extends JUnitFacesInitializer
+ {
+
+ public JUnitNoCDIFacesInitializer(AbstractMyFacesTestCase testCase)
+ {
+ super(testCase);
+ }
+
+ @Override
+ protected void initCDIIntegration(ServletContext servletContext, ExternalContext externalContext)
+ {
+ //super.initCDIIntegration(servletContext, externalContext);
+ }
+
+ }
+
protected static class SharedFacesConfiguration
{
private List<FacesConfig> classloaderFacesConfig;
Modified: myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/mc/test/core/runner/AbstractJsfTestContainer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/mc/test/core/runner/AbstractJsfTestContainer.java?rev=1757774&r1=1757773&r2=1757774&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/mc/test/core/runner/AbstractJsfTestContainer.java (original)
+++ myfaces/core/branches/2.3.x/impl/src/test/java/org/apache/myfaces/mc/test/core/runner/AbstractJsfTestContainer.java Fri Aug 26 01:45:52 2016
@@ -91,6 +91,7 @@ import org.apache.myfaces.test.mock.Mock
import org.apache.myfaces.test.mock.MockWebContainer;
import org.apache.myfaces.util.ExternalSpecifications;
import org.apache.myfaces.webapp.AbstractFacesInitializer;
+import static org.apache.myfaces.webapp.AbstractFacesInitializer.CDI_BEAN_MANAGER_INSTANCE;
import org.apache.myfaces.webapp.FacesInitializer;
import org.apache.myfaces.webapp.StartupServletContextListener;
import org.junit.runners.model.FrameworkMethod;
@@ -1601,7 +1602,96 @@ public class AbstractJsfTestContainer
{
return testCase;
}
+
+ private static final String CDI_SERVLET_CONTEXT_BEAN_MANAGER_ATTRIBUTE =
+ "javax.enterprise.inject.spi.BeanManager";
+
+ protected void initCDIIntegration(
+ ServletContext servletContext, ExternalContext externalContext)
+ {
+ // Lookup bean manager and put it into an application scope attribute to
+ // access it later. Remember the trick here is do not call any CDI api
+ // directly, so if no CDI api is on the classpath no exception will be thrown.
+
+ // Try with servlet context
+ Object beanManager = servletContext.getAttribute(
+ CDI_SERVLET_CONTEXT_BEAN_MANAGER_ATTRIBUTE);
+ if (beanManager == null)
+ {
+ beanManager = lookupBeanManagerFromJndi();
+ }
+ if (beanManager != null)
+ {
+ externalContext.getApplicationMap().put(CDI_BEAN_MANAGER_INSTANCE,
+ beanManager);
+ }
+ }
+ /**
+ * Try to lookup the CDI BeanManager from JNDI.
+ * We do all this via reflection to not blow up if CDI is not available.
+ */
+ private Object lookupBeanManagerFromJndi()
+ {
+ Object beanManager = null;
+ // Use reflection to avoid restricted API in GAE
+ Class icclazz = null;
+ Method lookupMethod = null;
+ try
+ {
+ icclazz = ClassUtils.simpleClassForName("javax.naming.InitialContext");
+ if (icclazz != null)
+ {
+ lookupMethod = icclazz.getMethod("doLookup", String.class);
+ }
+ }
+ catch (Throwable t)
+ {
+ //
+ }
+ if (lookupMethod != null)
+ {
+ // Try with JNDI
+ try
+ {
+ // in an application server
+ //beanManager = InitialContext.doLookup("java:comp/BeanManager");
+ beanManager = lookupMethod.invoke(icclazz, "java:comp/BeanManager");
+ }
+ catch (Exception e)
+ {
+ // silently ignore
+ }
+ catch (NoClassDefFoundError e)
+ {
+ //On Google App Engine, javax.naming.Context is a restricted class.
+ //In that case, NoClassDefFoundError is thrown. stageName needs to be configured
+ //below by context parameter.
+ }
+
+ if (beanManager == null)
+ {
+ try
+ {
+ // in a servlet container
+ //beanManager = InitialContext.doLookup("java:comp/env/BeanManager");
+ beanManager = lookupMethod.invoke(icclazz, "java:comp/env/BeanManager");
+ }
+ catch (Exception e)
+ {
+ // silently ignore
+ }
+ catch (NoClassDefFoundError e)
+ {
+ //On Google App Engine, javax.naming.Context is a restricted class.
+ //In that case, NoClassDefFoundError is thrown. stageName needs to be configured
+ //below by context parameter.
+ }
+ }
+ }
+
+ return beanManager;
+ }
}
protected static class SharedFacesConfiguration
Added: myfaces/core/branches/2.3.x/impl/src/test/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/test/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1757774&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/test/resources/META-INF/openwebbeans/openwebbeans.properties (added)
+++ myfaces/core/branches/2.3.x/impl/src/test/resources/META-INF/openwebbeans/openwebbeans.properties Fri Aug 26 01:45:52 2016
@@ -0,0 +1 @@
+org.apache.webbeans.scanBeansXmlOnly=true
\ No newline at end of file
Modified: myfaces/core/branches/2.3.x/parent/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/parent/pom.xml?rev=1757774&r1=1757773&r2=1757774&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/parent/pom.xml (original)
+++ myfaces/core/branches/2.3.x/parent/pom.xml Fri Aug 26 01:45:52 2016
@@ -397,11 +397,11 @@
</exclusions>
</dependency>
- <!-- annotations 1.0 (javax.annotation.*) -->
+ <!-- annotations 1.2 (javax.annotation.*) -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-annotation_1.0_spec</artifactId>
- <version>1.1.1</version>
+ <artifactId>geronimo-annotation_1.2_spec</artifactId>
+ <version>1.0</version>
<scope>provided</scope>
</dependency>