[weld-commits] Weld SVN: r5833 - in core/trunk/tests: src/test/java/org/jboss/weld/tests and 1 other directories.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Fri Feb 12 00:07:37 EST 2010
Author: dan.j.allen
Date: 2010-02-12 00:07:37 -0500 (Fri, 12 Feb 2010)
New Revision: 5833
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/jsf/
core/trunk/tests/src/test/java/org/jboss/weld/tests/jsf/JsfApiAbstractionTest.java
Modified:
core/trunk/tests/pom.xml
Log:
WELD-434
Also added tests for JsfApiAbstraction, both in the case of JSF 1.2 and 2.0
Modified: core/trunk/tests/pom.xml
===================================================================
--- core/trunk/tests/pom.xml 2010-02-09 12:24:56 UTC (rev 5832)
+++ core/trunk/tests/pom.xml 2010-02-12 05:07:37 UTC (rev 5833)
@@ -116,6 +116,8 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
+ <!-- override for testing compatibility w/ JSF 2.0 -->
+ <version>2.0.2-FCS</version>
</dependency>
<dependency>
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/jsf/JsfApiAbstractionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/jsf/JsfApiAbstractionTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/jsf/JsfApiAbstractionTest.java 2010-02-12 05:07:37 UTC (rev 5833)
@@ -0,0 +1,64 @@
+package org.jboss.weld.tests.jsf;
+
+import javax.faces.component.behavior.Behavior;
+import javax.faces.context.FacesContext;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.weld.jsf.JsfApiAbstraction;
+import org.jboss.weld.resources.DefaultResourceLoader;
+import org.jboss.weld.resources.spi.ResourceLoader;
+import org.jboss.weld.resources.spi.ResourceLoadingException;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.util.ApiAbstraction.Dummy;
+import org.testng.annotations.Test;
+
+/**
+ * @author Dan Allen
+ */
+ at Artifact
+public class JsfApiAbstractionTest extends AbstractWeldTest {
+ @Test
+ public void testDetectsJsf12Version() {
+ JsfApiAbstraction abstraction = new JsfApiAbstraction(getResourceLoaderHidingJsf20Classes());
+ assert abstraction.MINIMUM_API_VERSION == 1.2;
+ assert abstraction.isApiVersionCompatibleWith(2.0) == false;
+ }
+
+ @Test
+ public void testLoadsJsf12Classes() {
+ JsfApiAbstraction abstraction = new JsfApiAbstraction(getResourceLoaderHidingJsf20Classes());
+ assert FacesContext.class.equals(abstraction.FACES_CONTEXT);
+ assert Dummy.class.equals(abstraction.BEHAVIOR_CLASS);
+ }
+
+ @Test
+ public void testDetectsJsf20Version() {
+ JsfApiAbstraction abstraction = new JsfApiAbstraction(getResourceLoader());
+ assert abstraction.MINIMUM_API_VERSION == 2.0;
+ assert abstraction.isApiVersionCompatibleWith(2.0);
+ }
+
+ @Test
+ public void testLoadsJsf20Classes() {
+ JsfApiAbstraction abstraction = new JsfApiAbstraction(getResourceLoader());
+ assert FacesContext.class.equals(abstraction.FACES_CONTEXT);
+ assert Behavior.class.equals(abstraction.BEHAVIOR_CLASS);
+ }
+
+ private ResourceLoader getResourceLoader() {
+ return new DefaultResourceLoader();
+ }
+
+ private ResourceLoader getResourceLoaderHidingJsf20Classes() {
+ return new DefaultResourceLoader() {
+
+ @Override
+ public Class<?> classForName(String name) {
+ if ("javax.faces.component.behavior.Behavior".equals(name)) {
+ throw new ResourceLoadingException("Hidden class");
+ }
+ return super.classForName(name);
+ }
+
+ };
+ }
+}
More information about the weld-commits
mailing list