myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r928768 - in /myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src: main/java/org/apache/myfaces/scripting/api/ main/java/org/apache/myfaces/scripting/core/util/ test/java/org/apache/myfaces/scripting/core/lifecycle/ te...
Date Mon, 29 Mar 2010 13:30:50 GMT
Author: werpu
Date: Mon Mar 29 13:30:50 2010
New Revision: 928768

URL: http://svn.apache.org/viewvc?rev=928768&view=rev
Log:
http://issues.apache.org/jira/browse/EXTSCRIPT-109

Added:
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/support/TestcaseLoggingHandler.java
      - copied, changed from r928422, myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/lifecycle/FailedStartupTestcase.java
Modified:
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/api/ScriptingConst.java
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContextInitializer.java
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/lifecycle/FailedStartupTestcase.java

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/api/ScriptingConst.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/api/ScriptingConst.java?rev=928768&r1=928767&r2=928768&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/api/ScriptingConst.java
(original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/api/ScriptingConst.java
Mon Mar 29 13:30:50 2010
@@ -99,4 +99,17 @@ public class ScriptingConst {
     public static final String SCOPE_REQUEST = "request";
     public static final String GROOVY_SOURCE_ROOT = "/WEB-INF/groovy/";
     public static final String JAVA_SOURCE_ROOT = "/WEB-INF/java/";
+    public static final String ERR_SERVLET_FILTER = "[EXT-SCRIPTING] The servlet filter has
not been set, please check your web.xml for following entries:" +
+            "\n    <filter>\n" +
+            "        <filter-name>scriptingFilter</filter-name>\n" +
+            "        <filter-class>org.apache.myfaces.scripting.servlet.ScriptingServletFilter</filter-class>\n"
+
+            "    </filter>\n" +
+            "    <filter-mapping>\n" +
+            "        <filter-name>scriptingFilter</filter-name>\n" +
+            "        <url-pattern>/*</url-pattern>\n" +
+            "        <dispatcher>REQUEST</dispatcher>\n" +
+            "        <dispatcher>FORWARD</dispatcher>\n" +
+            "        <dispatcher>INCLUDE</dispatcher>\n" +
+            "        <dispatcher>ERROR</dispatcher>\n" +
+            "    </filter-mapping>";
 }

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContextInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContextInitializer.java?rev=928768&r1=928767&r2=928768&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContextInitializer.java
(original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/core/util/WeavingContextInitializer.java
Mon Mar 29 13:30:50 2010
@@ -136,19 +136,7 @@ public class WeavingContextInitializer {
         }
 
         if (!WeavingContext.isScriptingEnabled()) {
-            String warnMsg = "[EXT-SCRIPTING] The servlet filter has not been set, please
check your web.xml for following entries:" +
-                    "\n    <filter>\n" +
-                    "        <filter-name>scriptingFilter</filter-name>\n" +
-                    "        <filter-class>org.apache.myfaces.scripting.servlet.ScriptingServletFilter</filter-class>\n"
+
-                    "    </filter>\n" +
-                    "    <filter-mapping>\n" +
-                    "        <filter-name>scriptingFilter</filter-name>\n" +
-                    "        <url-pattern>/*</url-pattern>\n" +
-                    "        <dispatcher>REQUEST</dispatcher>\n" +
-                    "        <dispatcher>FORWARD</dispatcher>\n" +
-                    "        <dispatcher>INCLUDE</dispatcher>\n" +
-                    "        <dispatcher>ERROR</dispatcher>\n" +
-                    "    </filter-mapping>";
+            String warnMsg = ScriptingConst.ERR_SERVLET_FILTER;
             _logger.severe(warnMsg);
         }
     }

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/lifecycle/FailedStartupTestcase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/lifecycle/FailedStartupTestcase.java?rev=928768&r1=928767&r2=928768&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/lifecycle/FailedStartupTestcase.java
(original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/lifecycle/FailedStartupTestcase.java
Mon Mar 29 13:30:50 2010
@@ -19,7 +19,9 @@
 
 package org.apache.myfaces.scripting.core.lifecycle;
 
+import org.apache.myfaces.scripting.api.ScriptingConst;
 import org.apache.myfaces.scripting.core.support.MockServletContext;
+import org.apache.myfaces.scripting.core.support.TestcaseLoggingHandler;
 import org.apache.myfaces.scripting.core.util.WeavingContext;
 import org.apache.myfaces.scripting.core.util.WeavingContextInitializer;
 import org.junit.Before;
@@ -27,6 +29,9 @@ import org.junit.Test;
 
 import javax.servlet.ServletContext;
 
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
 import static org.junit.Assert.*;
 
 /**
@@ -39,16 +44,35 @@ import static org.junit.Assert.*;
 
 public class FailedStartupTestCase {
     ServletContext context;
+    TestcaseLoggingHandler handler;
+    Logger logger;
 
     @Before
     public void init() {
-        context = new MockServletContext("../../src/test/resources/brokenwebapp");
-
+        logger = Logger.getLogger(WeavingContextInitializer.class.getName());
+        handler = new TestcaseLoggingHandler();
+       /*
+        * we suppress the original handlers because we do not
+        * want unwanted messages in our console
+        */
+        logger.setUseParentHandlers(false);
+        logger.addHandler(handler);
+        logger.setLevel(Level.INFO);
     }
 
     @Test
     public void testStartup() {
+        context = new MockServletContext("../../src/test/resources/brokenwebapp");
+        WeavingContextInitializer.initWeavingContext(context);
+        assertFalse("Scripting must be disabled", WeavingContext.isScriptingEnabled());
+        assertTrue(handler.getOutput().toString().contains(ScriptingConst.ERR_SERVLET_FILTER));
+    }
+
+    @Test
+    public void testWebxmlMissing() {
+        context = new MockServletContext("../../src/test/resources/brokenwebapp2");
         WeavingContextInitializer.initWeavingContext(context);
         assertFalse("Scripting must be disabled", WeavingContext.isScriptingEnabled());
+        assertTrue(handler.getOutput().toString().contains(ScriptingConst.ERR_SERVLET_FILTER));
     }
 }

Copied: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/support/TestcaseLoggingHandler.java
(from r928422, myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/lifecycle/FailedStartupTestcase.java)
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/support/TestcaseLoggingHandler.java?p2=myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/support/TestcaseLoggingHandler.java&p1=myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/lifecycle/FailedStartupTestcase.java&r1=928422&r2=928768&rev=928768&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/lifecycle/FailedStartupTestcase.java
(original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/support/TestcaseLoggingHandler.java
Mon Mar 29 13:30:50 2010
@@ -17,38 +17,41 @@
  * under the License.
  */
 
-package org.apache.myfaces.scripting.core.lifecycle;
+package org.apache.myfaces.scripting.core.support;
 
-import org.apache.myfaces.scripting.core.support.MockServletContext;
-import org.apache.myfaces.scripting.core.util.WeavingContext;
-import org.apache.myfaces.scripting.core.util.WeavingContextInitializer;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.servlet.ServletContext;
-
-import static org.junit.Assert.*;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
 
 /**
- * A Testcase simulating failed startup conditions
- * (first a missing servlet filter)
+ * A logging handler which can capture our internal logging output
  *
  * @author Werner Punz (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
 
-public class FailedStartupTestCase {
-    ServletContext context;
+public class TestcaseLoggingHandler extends Handler {
+    StringBuilder _output = new StringBuilder();
 
-    @Before
-    public void init() {
-        context = new MockServletContext("../../src/test/resources/brokenwebapp");
+    @Override
+    public void publish(LogRecord record) {
+        _output.append(record.getMessage());
+    }
+
+    public StringBuilder getOutput() {
+        return _output;
+    }
 
+    public void setOutput(StringBuilder output) {
+        _output = output;
     }
 
-    @Test
-    public void testStartup() {
-        WeavingContextInitializer.initWeavingContext(context);
-        assertFalse("Scripting must be disabled", WeavingContext.isScriptingEnabled());
+    @Override
+    public void flush() {
+
+    }
+
+    @Override
+    public void close() throws SecurityException {
+
     }
 }



Mime
View raw message