[logback-dev] svn commit: r1766 - in logback/trunk/logback-core/src: main/java/ch/qos/logback/core/joran/action main/java/ch/qos/logback/core/joran/spi test/input/joran test/input/joran/skip test/java/ch/qos/logback/core/joran test/java/ch/qos/logback/core/joran/action test/java/ch/qos/logback/core/joran/action/ext test/java/ch/qos/logback/core/joran/implicitAction test/java/ch/qos/logback/core/joran/replay

noreply.ceki at qos.ch noreply.ceki at qos.ch
Tue Aug 19 21:47:23 CEST 2008


Author: ceki
Date: Tue Aug 19 21:47:22 2008
New Revision: 1766

Added:
   logback/trunk/logback-core/src/test/input/joran/skip/
   logback/trunk/logback-core/src/test/input/joran/skip/badBegin1.xml
   logback/trunk/logback-core/src/test/input/joran/skip/badBegin2.xml
   logback/trunk/logback-core/src/test/input/joran/skip/badEnd1.xml
      - copied unchanged from r1761, /logback/trunk/logback-core/src/test/input/joran/badEnd1.xml
   logback/trunk/logback-core/src/test/input/joran/skip/badEnd2.xml
      - copied, changed from r1761, /logback/trunk/logback-core/src/test/input/joran/badEnd2.xml
Removed:
   logback/trunk/logback-core/src/test/input/joran/badEnd1.xml
   logback/trunk/logback-core/src/test/input/joran/badEnd2.xml
   logback/trunk/logback-core/src/test/input/joran/exception1.xml
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/SoccerPlayer.java
Modified:
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderAction.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/MatcherAction.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/StatusListenerAction.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadBeginAction.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadEndAction.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/IncAction.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/FruitContextAction.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShellAction.java

Log:
Related to LBCLASSIC-63

Since we now only support skipping children, removed the SkipCode enumeration from the code.

Added test cases making sure that the bug was corrected.


Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderAction.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/AppenderAction.java	Tue Aug 19 21:47:22 2008
@@ -17,7 +17,6 @@
 import ch.qos.logback.core.Appender;
 import ch.qos.logback.core.joran.spi.ActionException;
 import ch.qos.logback.core.joran.spi.InterpretationContext;
-import ch.qos.logback.core.joran.spi.ActionException.SkipCode;
 import ch.qos.logback.core.spi.LifeCycle;
 import ch.qos.logback.core.util.OptionHelper;
 
@@ -80,7 +79,7 @@
       inError = true;
       addError(
         "Could not create an Appender of type ["+className+"].", oops);
-      throw new ActionException(SkipCode.SKIP_CHILDREN, oops);
+      throw new ActionException(oops);
     }
   }
 

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/MatcherAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/MatcherAction.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/MatcherAction.java	Tue Aug 19 21:47:22 2008
@@ -15,7 +15,6 @@
 import ch.qos.logback.core.boolex.Matcher;
 import ch.qos.logback.core.joran.spi.ActionException;
 import ch.qos.logback.core.joran.spi.InterpretationContext;
-import ch.qos.logback.core.joran.spi.ActionException.SkipCode;
 import ch.qos.logback.core.util.OptionHelper;
 
 
@@ -58,7 +57,7 @@
       inError = true;
       addError("Could not attach matcher to JaninoEventEvaluator",
           oops);
-      throw new ActionException(SkipCode.SKIP_CHILDREN, oops);
+      throw new ActionException(oops);
     }
   }
 

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/StatusListenerAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/StatusListenerAction.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/StatusListenerAction.java	Tue Aug 19 21:47:22 2008
@@ -14,7 +14,6 @@
 
 import ch.qos.logback.core.joran.spi.ActionException;
 import ch.qos.logback.core.joran.spi.InterpretationContext;
-import ch.qos.logback.core.joran.spi.ActionException.SkipCode;
 import ch.qos.logback.core.spi.LifeCycle;
 import ch.qos.logback.core.status.StatusListener;
 import ch.qos.logback.core.util.OptionHelper;
@@ -46,7 +45,7 @@
       inError = true;
       addError(
         "Could not create an StatusListener of type ["+className+"].", e);
-      throw new ActionException(SkipCode.SKIP_CHILDREN, e);
+      throw new ActionException(e);
     }
     
   }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ActionException.java	Tue Aug 19 21:47:22 2008
@@ -12,44 +12,21 @@
 
 /**
  * By throwing an exception an action can signal the Interpreter to skip
- * processing, all the nested elements nested within the element throwing the
- * exception or skip all following sibling elements in the document.
+ * processing of all the nested (child) elements of the element associated with
+ * the action causing the exception.
  *
  * @author Ceki Gulcu
  */
 public class ActionException extends Exception {
 
   
-  public enum SkipCode {
-    /**
-     * SKIP_CHILDREN signals the {@link Interpreter} to skip processing all the
-     * nested elements contained within the element causing this ActionException.
-     * 
-     * <p>It is the only recognized skipping mode in Joran.
-     */
-    SKIP_CHILDREN;
-  }
-  
   private static final long serialVersionUID = 2743349809995319806L;
 
-
-  final Throwable rootCause;
-  final SkipCode skipCode;
-
-  public ActionException(final SkipCode skipCode) {
-    this(skipCode, null);
+  public ActionException() {
   }
 
-  public ActionException(final SkipCode skipCode, final Throwable rootCause) {
-    this.skipCode = skipCode;
-    this.rootCause = rootCause;
+  public ActionException(final Throwable rootCause) {
+    super(rootCause);
   }
 
-  public Throwable getCause() {
-    return rootCause;
-  }
-
-  public SkipCode getSkipCode() {
-    return skipCode;
-  }
 }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java	Tue Aug 19 21:47:22 2008
@@ -60,9 +60,9 @@
  * @author Ceki G&uuml;lcu&uuml;
  * 
  */
-public class Interpreter  {
+public class Interpreter {
   private static List EMPTY_LIST = new Vector(0);
-  
+
   final private RuleStore ruleStore;
   final private InterpretationContext ec;
   final private ArrayList<ImplicitAction> implicitActions;
@@ -71,7 +71,7 @@
   Locator locator;
   EventPlayer player;
 
-   /**
+  /**
    * The <id>actionListStack</id> contains a list of actions that are executing
    * for the given XML element.
    * 
@@ -90,7 +90,7 @@
   public Interpreter(Context context, RuleStore rs) {
     this.cai = new CAI_WithLocatorSupport(this);
     this.cai.setContext(context);
-    ruleStore = rs; 
+    ruleStore = rs;
     ec = new InterpretationContext(context, this);
     implicitActions = new ArrayList<ImplicitAction>(3);
     pattern = new Pattern();
@@ -109,9 +109,9 @@
     setDocumentLocator(se.getLocator());
     startElement(se.namespaceURI, se.localName, se.qName, se.attributes);
   }
-  
-  private void startElement(String namespaceURI, String localName, String qName,
-      Attributes atts) {
+
+  private void startElement(String namespaceURI, String localName,
+      String qName, Attributes atts) {
 
     String tagName = getTagName(localName, qName);
 
@@ -120,7 +120,7 @@
     pattern.push(tagName);
 
     List applicableActionList = getApplicableActionList(pattern, atts);
- 
+
     if (applicableActionList != null) {
       actionListStack.add(applicableActionList);
       callBeginAction(applicableActionList, tagName, atts);
@@ -136,7 +136,7 @@
   public void characters(BodyEvent be) {
 
     setDocumentLocator(be.locator);
-    
+
     String body = be.getText();
     List applicableActionList = (List) actionListStack.peek();
 
@@ -161,7 +161,8 @@
     if (skip != null) {
       if (skip.equals(pattern)) {
         skip = null;
-        callEndAction(applicableActionList, getTagName(localName, qName));
+        // FIXME
+        // callEndAction(applicableActionList, getTagName(localName, qName));
       }
     } else if (applicableActionList != EMPTY_LIST) {
       callEndAction(applicableActionList, getTagName(localName, qName));
@@ -251,17 +252,12 @@
       // exceptions
       try {
         action.begin(ec, tagName, atts);
-      } catch (ActionException ae) {
-        switch (ae.getSkipCode()) {
-        case SKIP_CHILDREN:
-          skip = (Pattern) pattern.clone();
-          break;
-        }
-        // getLogger().info("Skip pattern set to [{}]", skip);
-      } catch (Exception e) {
+      } catch (ActionException e) {
         skip = (Pattern) pattern.clone();
-        // getLogger().info("Skip pattern set to [{}]", skip);
-        cai.addError("Exception in Action for tag [" + tagName + "]", e);
+        cai.addError("ActionException in Action for tag [" + tagName + "]", e);
+      } catch (RuntimeException e) {
+        skip = (Pattern) pattern.clone();
+        cai.addError("RuntimeException in Action for tag [" + tagName + "]", e);
       }
     }
   }
@@ -277,7 +273,9 @@
       try {
         action.body(ec, body);
       } catch (ActionException ae) {
-        cai.addError("Exception in end() methd for action [" + action + "]", ae);
+        cai
+            .addError("Exception in end() methd for action [" + action + "]",
+                ae);
       }
     }
   }
@@ -297,16 +295,12 @@
       try {
         action.end(ec, tagName);
       } catch (ActionException ae) {
-        switch (ae.getSkipCode()) {
-        case SKIP_CHILDREN:
-          // after end() is called there can't be any children
-          break;
-        }
-      } catch (Exception e) {
-        cai.addError("Exception in Action for tag [" + tagName + "]", e);
-        skip = (Pattern) pattern.clone();
-        skip.pop(); // induce the siblings to be skipped
-        // getLogger().info("Skip pattern set to [{}].", skip);
+        // at this point endAction, there is no point in skipping children as
+        // they have been already processed
+        cai.addError("ActionException in Action for tag [" + tagName + "]", ae);
+      } catch (RuntimeException e) {
+        // no point in setting skip
+        cai.addError("RuntimeException in Action for tag [" + tagName + "]", e);
       }
     }
   }
@@ -314,11 +308,11 @@
   public RuleStore getRuleStore() {
     return ruleStore;
   }
-  
+
   public void play(List<SaxEvent> eventList) {
     player.play(eventList);
   }
-  
+
   public void addEvents(List<SaxEvent> eventList) {
     if (player != null) {
       player.addEvents(eventList);
@@ -327,26 +321,27 @@
 }
 
 /**
- * When {@link Interpreter} class is used as the origin of an 
- * {@link ContextAwareImpl} instance, then XML locator information
- * is lost. This class preserves locator information (as a string).
+ * When {@link Interpreter} class is used as the origin of an
+ * {@link ContextAwareImpl} instance, then XML locator information is lost. This
+ * class preserves locator information (as a string).
  * 
  * @author ceki
  */
 class CAI_WithLocatorSupport extends ContextAwareImpl {
-  
+
   CAI_WithLocatorSupport(Interpreter interpreter) {
     super(interpreter);
   }
-  
+
   @Override
   protected Object getOrigin() {
     Interpreter i = (Interpreter) super.getOrigin();
     Locator locator = i.locator;
-    if(locator != null) {
-      return Interpreter.class.getName()+"@"+locator.getLineNumber()+":"+locator.getColumnNumber();
+    if (locator != null) {
+      return Interpreter.class.getName() + "@" + locator.getLineNumber() + ":"
+          + locator.getColumnNumber();
     } else {
-      return Interpreter.class.getName()+"@NA:NA";
+      return Interpreter.class.getName() + "@NA:NA";
     }
   }
 }

Added: logback/trunk/logback-core/src/test/input/joran/skip/badBegin1.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/input/joran/skip/badBegin1.xml	Tue Aug 19 21:47:22 2008
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE test>
+
+<test>
+
+  <!-- this action throws an exception in the Action.begin method -->
+  <badBegin>
+    <touch/>
+    <touch/>
+  </badBegin>  
+
+  <hello name="John Doe"></hello>
+  
+</test>
\ No newline at end of file

Added: logback/trunk/logback-core/src/test/input/joran/skip/badBegin2.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/input/joran/skip/badBegin2.xml	Tue Aug 19 21:47:22 2008
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE test>
+
+<test>
+
+  <!-- this action throws an ActionException in the Action.begin method -->
+  <badBegin type="ActionException">
+    <touch/>
+    <touch/>
+  </badBegin>  
+
+  <hello name="John Doe"></hello>
+  
+</test>
\ No newline at end of file

Copied: logback/trunk/logback-core/src/test/input/joran/skip/badEnd2.xml (from r1761, /logback/trunk/logback-core/src/test/input/joran/badEnd2.xml)
==============================================================================
--- /logback/trunk/logback-core/src/test/input/joran/badEnd2.xml	(original)
+++ logback/trunk/logback-core/src/test/input/joran/skip/badEnd2.xml	Tue Aug 19 21:47:22 2008
@@ -5,7 +5,7 @@
 
   <isolate>
     <!-- badEnd throws an exception in the Action.end method -->
-    <badEnd>
+    <badEnd type="ActionException">
       <touch/>
     </badEnd> 
     <!-- should be skipped -->

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java	Tue Aug 19 21:47:22 2008
@@ -18,7 +18,7 @@
 
   public static Test suite() {
     TestSuite suite = new TestSuite();
-    suite.addTestSuite(SkippingInInterpreterTest.class);
+    suite.addTest(new JUnit4TestAdapter(SkippingInInterpreterTest.class));
     suite.addTest(new JUnit4TestAdapter(TrivialcConfiguratorTest.class));
     suite.addTest(ch.qos.logback.core.joran.action.PackageTest.suite());
     suite.addTest(ch.qos.logback.core.joran.event.PackageTest.suite());

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java	Tue Aug 19 21:47:22 2008
@@ -9,23 +9,26 @@
  */
 package ch.qos.logback.core.joran;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
 import java.util.HashMap;
 
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.ContextBase;
 import ch.qos.logback.core.joran.action.Action;
 import ch.qos.logback.core.joran.action.NOPAction;
 import ch.qos.logback.core.joran.action.ext.BadBeginAction;
-import ch.qos.logback.core.joran.action.ext.BadEndAction;
 import ch.qos.logback.core.joran.action.ext.HelloAction;
 import ch.qos.logback.core.joran.action.ext.TouchAction;
 import ch.qos.logback.core.joran.spi.Pattern;
 import ch.qos.logback.core.util.Constants;
-
+import ch.qos.logback.core.util.StatusPrinter;
 
 /**
  * Test the way Interpreter skips elements in case of exceptions thrown by
@@ -33,97 +36,70 @@
  * 
  * @author Ceki Gulcu
  */
-public class SkippingInInterpreterTest extends TestCase {
+public class SkippingInInterpreterTest {
 
   HashMap<Pattern, Action> rulesMap = new HashMap<Pattern, Action>();
   Context context = new ContextBase();
-  
-  public SkippingInInterpreterTest(String name) {
-    super(name);
-    
-  }
-
-  protected void setUp() throws Exception {
-    super.setUp();
-  }
-
-  /*
-   * @see TestCase#tearDown()
-   */
-  protected void tearDown() throws Exception {
-    super.tearDown();
-  }
 
   SAXParser createParser() throws Exception {
     SAXParserFactory spf = SAXParserFactory.newInstance();
     return spf.newSAXParser();
   }
 
-  /**
-   * Tests that whenever an action throws an exception, processing of child
-   * elements is skipped.
-   * 
-   * @throws Exception
-   */
-  public void testChildrenSkipping() throws Exception {
-    
+  void doTest(String filename) throws Exception {
+
     rulesMap.put(new Pattern("test"), new NOPAction());
     rulesMap.put(new Pattern("test/badBegin"), new BadBeginAction());
     rulesMap.put(new Pattern("test/badBegin/touch"), new TouchAction());
     rulesMap.put(new Pattern("test/hello"), new HelloAction());
-    
+
     TrivialConfigurator tc = new TrivialConfigurator(rulesMap);
     tc.setContext(context);
-    
-    tc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/exception1.xml");
+    tc .doConfigure(Constants.TEST_DIR_PREFIX
+            + "input/joran/skip/"+filename);
 
     String str = context.getProperty("hello");
     assertEquals("Hello John Doe.", str);
 
     Object i = (String) context.getObject(TouchAction.KEY);
     assertNull(i);
+
+    StatusPrinter.print(context);
   }
 
   /**
-   * An exception thrown by the end() method of an action will cause sibling
-   * elements to be skipped.
-   * 
-   * @throws Exception
+   * Tests that whenever an action throws a RuntimeException, processing of
+   * child elements is skipped.
    */
-  public void testSkipSiblings() throws Exception {
-
-    rulesMap.put(new Pattern("test"), new NOPAction());
-    rulesMap.put(new Pattern("test/badEnd"), new BadEndAction());
-    rulesMap.put(new Pattern("test/badEnd/touch"), new TouchAction());
-    rulesMap.put(new Pattern("test/hello"), new HelloAction());
-
-    TrivialConfigurator tc = new TrivialConfigurator(rulesMap);
-    tc.setContext(context);
-    
-    tc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/badEnd1.xml");
-
-    
-    String str = context.getProperty("hello");
-    assertNull(str);
-    Integer i = (Integer) context.getObject(TouchAction.KEY);
-    assertEquals(2, i.intValue());
+  @Test
+  public void testSkippingRuntimeExInBadBegin() throws Exception {
+    doTest("badBegin1.xml");
   }
 
-  public void testSkipSiblings2() throws Exception {
+  /**
+   * Tests that whenever an action throws a RuntimeException, processing of
+   * child elements is skipped.
+   */
+  @Test
+  public void testSkippingActionExInBadBegin() throws Exception {
+    doTest("badBegin2.xml");
+  }
 
-    rulesMap.put(new Pattern("test"), new NOPAction());
-    rulesMap.put(new Pattern("test/isolate/badEnd"), new BadEndAction());
-    rulesMap.put(new Pattern("*/touch"), new TouchAction());
-    rulesMap.put(new Pattern("test/hello"), new HelloAction());
+  /**
+   * A RuntimeException thrown by the end() method of an action will be caught without
+   * further consequences (as there are no children).
+   */
+  @Test
+  public void testSkippingRuntimeExInBadEnd() throws Exception {
+    doTest("badEnd1.xml");
+  }
 
-    TrivialConfigurator tc = new TrivialConfigurator(rulesMap);
-    tc.setContext(context);
-    
-    tc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/badEnd2.xml");
-    
-    String str = context.getProperty("hello");
-    assertEquals("Hello John Doe.", str);
-    Integer i = (Integer) context.getObject(TouchAction.KEY);
-    assertEquals(1, i.intValue());
+  /**
+   * An ActionException thrown by the end() method of an action will be caught without
+   * further consequences (as there are no children).
+   */
+  @Test
+  public void testSkippingActionExInBadEnd() throws Exception {
+    doTest("badEnd2.xml");
   }
 }

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java	Tue Aug 19 21:47:22 2008
@@ -155,6 +155,12 @@
     verifyConfig(3);
   }
 
+  @Test
+  public void errorInDoBegin() {
+    
+  }
+  
+  
   void verifyConfig(int expected) {
     assertEquals(expected, IncAction.beginCount);
     assertEquals(expected, IncAction.endCount);

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadBeginAction.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadBeginAction.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadBeginAction.java	Tue Aug 19 21:47:22 2008
@@ -13,6 +13,7 @@
 import org.xml.sax.Attributes;
 
 import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.ActionException;
 import ch.qos.logback.core.joran.spi.InterpretationContext;
 
 
@@ -20,11 +21,30 @@
 public class BadBeginAction extends Action {
 
 
+  static String EXCEPTION_TYPE = "type";
+  static final int RUNTIME_EDXCEPTION = 0;
+  static final int ACTION_EXCEPTION = 1;
+  
+  int type;
+  
   public BadBeginAction() {
   }
 
-  public void begin(InterpretationContext ec, String name, Attributes attributes) {
-    throw new IllegalStateException("bad begin");
+  public void begin(InterpretationContext ec, String name, Attributes attributes) throws ActionException {
+    
+    String exType = attributes.getValue(EXCEPTION_TYPE);
+    type = RUNTIME_EDXCEPTION;
+    if("ActionException".equals(exType)) {
+      type = ACTION_EXCEPTION;
+    }
+    
+    switch(type) {
+    case ACTION_EXCEPTION: 
+      throw new ActionException();
+    default:
+      throw new IllegalStateException("bad begin");
+    }
+   
   }
 
   public void end(InterpretationContext ec, String name) {

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadEndAction.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadEndAction.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/BadEndAction.java	Tue Aug 19 21:47:22 2008
@@ -14,17 +14,34 @@
 import org.xml.sax.Attributes;
 
 import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.spi.ActionException;
 import ch.qos.logback.core.joran.spi.InterpretationContext;
 
 
 
 public class BadEndAction extends Action {
 
-
+  static String EXCEPTION_TYPE = "type";
+  static final int RUNTIME_EDXCEPTION = 0;
+  static final int ACTION_EXCEPTION = 1;
+  
+  int type;
+  
+  
   public void begin(InterpretationContext ec, String name, Attributes attributes) {
+    String exType = attributes.getValue(EXCEPTION_TYPE);
+    type = RUNTIME_EDXCEPTION;
+    if("ActionException".equals(exType)) {
+      type = ACTION_EXCEPTION;
+    }
   }
 
-  public void end(InterpretationContext ec, String name) {
-    throw new IllegalStateException("bad end");
+  public void end(InterpretationContext ec, String name) throws ActionException {
+    switch(type) {
+    case ACTION_EXCEPTION: 
+      throw new ActionException();
+    default:
+      throw new IllegalStateException("bad end");
+    }
   }
 }

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/IncAction.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/IncAction.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/ext/IncAction.java	Tue Aug 19 21:47:22 2008
@@ -15,7 +15,6 @@
 import ch.qos.logback.core.joran.action.Action;
 import ch.qos.logback.core.joran.spi.ActionException;
 import ch.qos.logback.core.joran.spi.InterpretationContext;
-import ch.qos.logback.core.joran.spi.ActionException.SkipCode;
 
 
 
@@ -40,7 +39,7 @@
     String val = attributes.getValue("increment");
     if(!"1".equals(val)) {
       errorCount++;
-      throw new ActionException(SkipCode.SKIP_CHILDREN);
+      throw new ActionException();
     }
   }
 

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/FruitContextAction.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/FruitContextAction.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/FruitContextAction.java	Tue Aug 19 21:47:22 2008
@@ -15,7 +15,6 @@
 import ch.qos.logback.core.joran.action.Action;
 import ch.qos.logback.core.joran.spi.ActionException;
 import ch.qos.logback.core.joran.spi.InterpretationContext;
-import ch.qos.logback.core.joran.spi.ActionException.SkipCode;
 
 public class FruitContextAction extends Action {
 
@@ -34,7 +33,7 @@
       inError = true;
       addError(
         "Could not push context", oops);
-      throw new ActionException(SkipCode.SKIP_CHILDREN, oops);
+      throw new ActionException(oops);
     }
   }
 

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShellAction.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShellAction.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitShellAction.java	Tue Aug 19 21:47:22 2008
@@ -15,7 +15,6 @@
 import ch.qos.logback.core.joran.action.Action;
 import ch.qos.logback.core.joran.spi.ActionException;
 import ch.qos.logback.core.joran.spi.InterpretationContext;
-import ch.qos.logback.core.joran.spi.ActionException.SkipCode;
 import ch.qos.logback.core.util.OptionHelper;
 
 /** 
@@ -55,7 +54,7 @@
       inError = true;
       addError(
         "Could not create an FruitShell", oops);
-      throw new ActionException(SkipCode.SKIP_CHILDREN, oops);
+      throw new ActionException(oops);
     }
   }
 


More information about the logback-dev mailing list