From 449a4519120e79c752125e15ffd830d5538be88a Mon Sep 17 00:00:00 2001 From: "Donald J. Brown" Date: Sun, 21 May 2006 06:24:37 +0000 Subject: [PATCH] Fixing jsf setup interceptor to not complain so loudly if jsf isn't present, fixed freemarker test to properly extend StrutsTestCase git-svn-id: https://svn.apache.org/repos/asf/struts/action2/trunk@408140 13f79535-47bb-0310-9956-ffa450edef68 --- .../struts/action2/jsf/FacesSetupInterceptor.java | 11 ++++++++++- .../views/freemarker/FreemarkerManagerTest.java | 5 ++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/apache/struts/action2/jsf/FacesSetupInterceptor.java b/core/src/main/java/org/apache/struts/action2/jsf/FacesSetupInterceptor.java index f5771191b..c6bc72ecc 100644 --- a/core/src/main/java/org/apache/struts/action2/jsf/FacesSetupInterceptor.java +++ b/core/src/main/java/org/apache/struts/action2/jsf/FacesSetupInterceptor.java @@ -57,8 +57,17 @@ public class FacesSetupInterceptor extends FacesSupport implements Interceptor { * Initializes the lifecycle and factories */ public void init() { - facesContextFactory = (FacesContextFactory) FactoryFinder + try { + facesContextFactory = (FacesContextFactory) FactoryFinder .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); + } catch (Exception ex) { + log.debug("Unable to initialize faces", ex); + } + + if (facesContextFactory == null) { + log.info("Unable to initialize jsf interceptors probably due missing JSF framework initialization"); + return; + } // Javadoc says: Lifecycle instance is shared across multiple // simultaneous requests, it must be implemented in a thread-safe // manner. diff --git a/core/src/test/java/org/apache/struts/action2/views/freemarker/FreemarkerManagerTest.java b/core/src/test/java/org/apache/struts/action2/views/freemarker/FreemarkerManagerTest.java index fe714b178..6860455c1 100644 --- a/core/src/test/java/org/apache/struts/action2/views/freemarker/FreemarkerManagerTest.java +++ b/core/src/test/java/org/apache/struts/action2/views/freemarker/FreemarkerManagerTest.java @@ -18,16 +18,15 @@ package org.apache.struts.action2.views.freemarker; import org.apache.struts.action2.StrutsConstants; +import org.apache.struts.action2.StrutsTestCase; import org.apache.struts.action2.config.Configuration; import org.apache.struts.action2.views.jsp.StrutsMockServletContext; -import junit.framework.TestCase; - /** * Test case for FreemarkerManager * */ -public class FreemarkerManagerTest extends TestCase { +public class FreemarkerManagerTest extends StrutsTestCase { public void testIfStrutsEncodingIsSetProperty() throws Exception { Configuration.set(StrutsConstants.STRUTS_I18N_ENCODING, "UTF-8");