Author: nbubna
Date: Fri Mar 13 22:17:31 2009
New Revision: 753450

URL: http://svn.apache.org/viewvc?rev=753450&view=rev
Log:
#set( $foo = $null ) will heretofore always be allowed

Removed:
    
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/NullSetEventHandler.java
Modified:
    velocity/engine/branches/2.0_Exp/src/changes/changes.xml
    
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventCartridge.java
    
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerUtil.java
    
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeConstants.java
    
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java
    
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties
    
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
    
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java
    
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EventHandlingTestCase.java
    
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ExceptionTestCase.java
    
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/FilteredEventHandlingTestCase.java
    
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ScopeTestCase.java
    
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/SetTestCase.java
    
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler1.java
    
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler2.java
    
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/ExceptionGeneratingEventHandler.java
    velocity/engine/branches/2.0_Exp/test/set/compare/set1.cmp
    velocity/engine/branches/2.0_Exp/xdocs/docs/developer-guide.xml
    velocity/engine/branches/2.0_Exp/xdocs/docs/vtl-reference-guide.xml

Modified: velocity/engine/branches/2.0_Exp/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/changes/changes.xml?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/changes/changes.xml (original)
+++ velocity/engine/branches/2.0_Exp/src/changes/changes.xml Fri Mar 13 
22:17:31 2009
@@ -27,6 +27,12 @@
   <body>
     <release version="2.0" date="In Subversion">
 
+      <action type="add" dev="nbubna">
+    Remove directive.set.null.allowed and instead always allow null to be
+    #set to references.  This also means removing all NullSetEventHandler
+    code, since it was only in play when nulls were not allowed to be #set.
+      </action>
+
       <action type="add" dev="nbubna" issue="VELOCITY-704">
     Remove features deprecated in 1.7 ($velocityCount, $velocityHasNext,
     velocimacro.context.localscope, directive.evaluate.context.class and

Modified: 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventCartridge.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventCartridge.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventCartridge.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventCartridge.java
 Fri Mar 13 22:17:31 2009
@@ -54,7 +54,6 @@
 public class EventCartridge
   {
     private List referenceHandlers = new ArrayList();
-    private List nullSetHandlers = new ArrayList();
     private List methodExceptionHandlers = new ArrayList();
     private List includeHandlers = new ArrayList();
     private List invalidReferenceHandlers = new ArrayList();
@@ -87,12 +86,6 @@
             found = true;
         }
 
-        if ( ev instanceof NullSetEventHandler )
-        {
-            addNullSetEventHandler( (NullSetEventHandler) ev );
-            found = true;
-        }
-
         if ( ev instanceof MethodExceptionEventHandler )
         {
             addMethodExceptionHandler( (MethodExceptionEventHandler) ev );
@@ -126,17 +119,6 @@
      }
 
     /**
-      *  Add a null set event handler to the Cartridge.
-      *
-      *  @param ev NullSetEventHandler
-      * @since 1.5
-      */
-     public void addNullSetEventHandler( NullSetEventHandler ev )
-     {
-         nullSetHandlers.add( ev );
-     }
-
-    /**
      *  Add a method exception event handler to the Cartridge.
      *
      *  @param ev MethodExceptionEventHandler
@@ -191,9 +173,6 @@
         if ( ev instanceof ReferenceInsertionEventHandler )
             return referenceHandlers.remove( ev );
 
-        if ( ev instanceof NullSetEventHandler )
-            return nullSetHandlers.remove( ev );
-
         if ( ev instanceof MethodExceptionEventHandler )
             return methodExceptionHandlers.remove(ev );
 
@@ -218,17 +197,6 @@
     }
 
     /**
-     * Iterate through all the stored NullSetEventHandler objects
-     * 
-     * @return iterator of handler objects
-     * @since 1.5
-     */
-    public Iterator getNullSetEventHandlers()
-    {
-        return nullSetHandlers.iterator();
-    }
-
-    /**
      * Iterate through all the stored MethodExceptionEventHandler objects
      * 
      * @return iterator of handler objects
@@ -314,17 +282,6 @@
             }
         }
 
-        for ( Iterator i = nullSetHandlers.iterator(); i.hasNext(); )
-        {
-            EventHandler eh = ( EventHandler ) i.next();
-            if ( (eh instanceof RuntimeServicesAware) &&
-                    !initializedHandlers.contains(eh) )
-            {
-                ((RuntimeServicesAware) eh).setRuntimeServices ( rs );
-                initializedHandlers.add( eh );
-            }
-        }
-
         for ( Iterator i = methodExceptionHandlers.iterator(); i.hasNext(); )
         {
             EventHandler eh = ( EventHandler ) i.next();

Modified: 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerUtil.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerUtil.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerUtil.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerUtil.java
 Fri Mar 13 22:17:31 2009
@@ -109,51 +109,6 @@
             throw ExceptionUtils.createRuntimeException("Exception in event 
handler.",e);
         }
     }
-
-    /**
-     * Called when a null is evaluated during a #set. All event handlers are
-     * called in sequence until a false is returned. The default implementation
-     * always returns true.
-     *
-     * @param lhs Left hand side of the expression.
-     * @param rhs Right hand side of the expression.
-     * @param rsvc current instance of RuntimeServices
-     * @param context The internal context adapter.
-     * @return true if to be logged, false otherwise
-     */
-    public static boolean shouldLogOnNullSet(RuntimeServices rsvc,
-            InternalContextAdapter context, String lhs, String rhs)
-    {
-        // app level cartridges have already been initialized
-        EventCartridge ev1 = rsvc.getApplicationEventCartridge();
-        Iterator applicationEventHandlerIterator = 
-            (ev1 == null) ? null: ev1.getNullSetEventHandlers();              
-        
-        EventCartridge ev2 = context.getEventCartridge();
-        initializeEventCartridge(rsvc, ev2);
-        Iterator contextEventHandlerIterator = 
-            (ev2 == null) ? null: ev2.getNullSetEventHandlers();              
-                
-        try 
-        {
-            EventHandlerMethodExecutor methodExecutor = 
-                new NullSetEventHandler.ShouldLogOnNullSetExecutor(context, 
lhs, rhs);
-
-            callEventHandlers(
-                    applicationEventHandlerIterator, 
-                    contextEventHandlerIterator, methodExecutor);
-            
-            return ((Boolean) methodExecutor.getReturnValue()).booleanValue(); 
   
-        }
-        catch (RuntimeException e)
-        {
-            throw e;
-        }
-        catch (Exception e)
-        {
-            throw ExceptionUtils.createRuntimeException("Exception in event 
handler.",e);
-        }
-    }
     
     /**
      * Called when a method exception is generated during Velocity merge. Only

Modified: 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeConstants.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeConstants.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeConstants.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeConstants.java
 Fri Mar 13 22:17:31 2009
@@ -85,9 +85,6 @@
      */
     String SKIP_INVALID_ITERATOR = "directive.foreach.skip.invalid";
 
-    /** if set to true then allows #set to accept null values in the right 
hand side. */
-    String SET_NULL_ALLOWED = "directive.set.null.allowed";
-
     /**
      * Starting tag for error messages triggered by passing a parameter not 
allowed in the #include directive. Only string literals,
      * and references are allowed.
@@ -107,12 +104,6 @@
     String DEFINE_DIRECTIVE_MAXDEPTH = "directive.define.max.depth";
 
     /**
-     * class to use for local context with #evaluate()
-     * @since 1.6
-     */
-    String EVALUATE_CONTEXT_CLASS = "directive.evaluate.context.class";
-
-    /**
      * Used to suppress various scope control objects.
      * @since 1.7
      */
@@ -171,12 +162,6 @@
     String EVENTHANDLER_REFERENCEINSERTION = 
"eventhandler.referenceinsertion.class";
 
     /**
-     * The <code>eventhandler.nullset.class</code> property specifies a list 
of the
-     * {...@link org.apache.velocity.app.event.NullSetEventHandler} 
implementations to use.
-     */
-    String EVENTHANDLER_NULLSET = "eventhandler.nullset.class";
-
-    /**
      * The <code>eventhandler.methodexception.class</code> property specifies 
a list of the
      * {...@link org.apache.velocity.app.event.MethodExceptionEventHandler} 
implementations to use.
      */

Modified: 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java
 Fri Mar 13 22:17:31 2009
@@ -40,7 +40,6 @@
 import org.apache.velocity.app.event.IncludeEventHandler;
 import org.apache.velocity.app.event.InvalidReferenceEventHandler;
 import org.apache.velocity.app.event.MethodExceptionEventHandler;
-import org.apache.velocity.app.event.NullSetEventHandler;
 import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
 import org.apache.velocity.context.Context;
 import org.apache.velocity.context.InternalContextAdapterImpl;
@@ -762,17 +761,6 @@
             }
         }
 
-        String[] nullset = 
configuration.getStringArray(RuntimeConstants.EVENTHANDLER_NULLSET);
-        if ( nullset != null )
-        {
-            for ( int i=0; i < nullset.length; i++ )
-            {
-                EventHandler ev = 
initializeSpecificEventHandler(nullset[i],RuntimeConstants.EVENTHANDLER_NULLSET,NullSetEventHandler.class);
-                if (ev != null)
-                    
eventCartridge.addNullSetEventHandler((NullSetEventHandler) ev);
-            }
-        }
-
         String[] methodexception = 
configuration.getStringArray(RuntimeConstants.EVENTHANDLER_METHODEXCEPTION);
         if ( methodexception != null )
         {

Modified: 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties
 Fri Mar 13 22:17:31 2009
@@ -54,16 +54,6 @@
 directive.foreach.maxloops = -1
 
 # ----------------------------------------------------------------------------
-# S E T  P R O P E R T I E S
-# ----------------------------------------------------------------------------
-# These properties control the behavior of #set.
-# For compatibility, the default behavior is to disallow setting a reference
-# to null.  This default may be changed in a future version.
-# ----------------------------------------------------------------------------
-
-directive.set.null.allowed = false
-
-# ----------------------------------------------------------------------------
 # I N C L U D E  P R O P E R T I E S
 # ----------------------------------------------------------------------------
 # These are the properties that governed the way #include'd content

Modified: 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
 Fri Mar 13 22:17:31 2009
@@ -43,8 +43,6 @@
     private String leftReference = "";
     private Node right = null;
     private ASTReference left = null;
-    boolean logOnNull = false;
-    private boolean allowNull = false;
     private boolean isInitialized;
 
     /**
@@ -108,10 +106,7 @@
             right = getRightHandSide();
             left = getLeftHandSide();
     
-            logOnNull = 
rsvc.getBoolean(RuntimeConstants.RUNTIME_LOG_REFERENCE_LOG_INVALID, true);
-            allowNull = rsvc.getBoolean(RuntimeConstants.SET_NULL_ALLOWED, 
false);
             strictRef = 
rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);
-            if (strictRef) allowNull = true;  // strictRef implies allowNull
             
             /*
              *  grab this now.  No need to redo each time
@@ -141,40 +136,6 @@
 
         Object value = right.value(context);
 
-        /*
-         * it's an error if we don't have a value of some sort AND
-         * it is not allowed by configuration
-         */
-
-        if( !allowNull )
-        {
-            if ( value == null )
-            {                
-                /*
-                 *  first, are we supposed to say anything anyway?
-                 */
-                if(logOnNull)
-                {
-                    boolean doit = EventHandlerUtil.shouldLogOnNullSet( rsvc, 
context, left.literal(), right.literal() );
-
-                    if (doit && rsvc.getLog().isDebugEnabled())
-                    {
-                        rsvc.getLog().debug("RHS of #set statement is null. 
Context will not be modified. "
-                                      + Log.formatFileString(this));
-                    }
-                }
-                
-                String rightReference = null;
-                if (right instanceof ASTExpression)
-                {
-                    rightReference = ((ASTExpression) 
right).getLastToken().image;
-                }
-                EventHandlerUtil.invalidSetMethod(rsvc, context, 
leftReference, rightReference, uberInfo);
-                
-                return false;
-            }
-        }
-
         if ( value == null && !strictRef)
         {
             String rightReference = null;

Modified: 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BaseTestCase.java
 Fri Mar 13 22:17:31 2009
@@ -453,7 +453,7 @@
     {
         if (DEBUG)
         {
-            info("Result: "+resultsDir+baseFileName+resultExt);
+            info("Result: "+resultsDir+'/'+baseFileName+'.'+resultExt);
         }
         String result = getFileContents(resultsDir, baseFileName, resultExt);
         return isMatch(result,compareDir,baseFileName,compareExt);
@@ -487,7 +487,7 @@
         compare = normalizeNewlines(compare);
         if (DEBUG)
         {
-            info("Expection: "+compareDir+baseFileName+compareExt);
+            info("Expection: "+compareDir+'/'+baseFileName+'.'+compareExt);
         }
         return result.equals(compare);
     }

Modified: 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EventHandlingTestCase.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EventHandlingTestCase.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EventHandlingTestCase.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EventHandlingTestCase.java
 Fri Mar 13 22:17:31 2009
@@ -25,7 +25,6 @@
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.app.event.EventCartridge;
 import org.apache.velocity.app.event.MethodExceptionEventHandler;
-import org.apache.velocity.app.event.NullSetEventHandler;
 import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
 import org.apache.velocity.context.Context;
 import org.apache.velocity.exception.MethodInvocationException;
@@ -52,12 +51,6 @@
         super(name);
     }
 
-    public void setUp() throws Exception
-    {
-        super.setUp();
-        engine.setProperty(RuntimeConstants.SET_NULL_ALLOWED, false);
-    }
-
     public void testManualEventHandlers()
             throws Exception
     {
@@ -79,8 +72,6 @@
          */
         doTestReferenceInsertionEventHandler1();
         doTestReferenceInsertionEventHandler2();
-        doTestNullValueEventHandler();
-        doTestSetNullValueEventHandler();
         doTestMethodExceptionEventHandler1();
         doTestMethodExceptionEventHandler2();
     }
@@ -92,13 +83,10 @@
             throws Exception
     {
         engine.setProperty(RuntimeConstants.EVENTHANDLER_METHODEXCEPTION, 
TestEventCartridge.class.getName());
-        engine.setProperty(RuntimeConstants.EVENTHANDLER_NULLSET, 
TestEventCartridge.class.getName());
         engine.setProperty(RuntimeConstants.EVENTHANDLER_REFERENCEINSERTION, 
TestEventCartridge.class.getName());
 
         doTestReferenceInsertionEventHandler1();
         doTestReferenceInsertionEventHandler2();
-        doTestNullValueEventHandler();
-        doTestSetNullValueEventHandler();
         doTestMethodExceptionEventHandler1();
         doTestMethodExceptionEventHandler2();
     }
@@ -138,68 +126,6 @@
         context = outer;
     }
 
-    private void doTestNullValueEventHandler()
-            throws Exception
-    {
-        VelocityContext outer = context;
-        context = new VelocityContext(context);
-        context.put("log", log);
-
-        /*
-         *  now lets test setting a null value - this test
-         *  should result in *no* log output.
-         */
-        boolean debug = DEBUG;
-        DEBUG = false;
-        log.startCapture();
-        log.setEnabledLevel(TestLogChute.DEBUG_ID);
-        evaluate("#set($settest = $NotAReference)");
-        log.setEnabledLevel(TestLogChute.INFO_ID);
-        log.stopCapture();
-        DEBUG = debug;
-
-        String output = log.getLog();
-        info("Logged: \""+output+"\"");
-        if (!(output == null || output.length() == 0))
-        {
-            info("Log should have been empty!");
-            fail( "NullSetEventHandler test 1");
-        }
-
-        context = outer;
-    }
-
-    private void doTestSetNullValueEventHandler()
-            throws Exception
-    {
-        VelocityContext outer = context;
-        context = new VelocityContext(context);
-        context.put("log", log);
-
-        /*
-         *  now lets test setting a null value - this test
-         *  should result in log output.
-         */
-        boolean debug = DEBUG;
-        DEBUG = false;
-        log.startCapture();
-        log.setEnabledLevel(TestLogChute.DEBUG_ID);
-        evaluate("#set($logthis = $NotAReference)");
-        log.setEnabledLevel(TestLogChute.INFO_ID);
-        log.stopCapture();
-        DEBUG = debug;
-
-        String output = log.getLog();
-        info("Logged: \""+output+"\"");
-        if (output == null || output.length() == 0)
-        {
-            info("Log should not have been empty!");
-            fail( "NullSetEventHandler test 2");
-        }
-
-        context = outer;
-    }
-
     private void doTestMethodExceptionEventHandler1()
             throws Exception
     {
@@ -255,7 +181,7 @@
 
     public static class TestEventCartridge
             implements ReferenceInsertionEventHandler,
-                       NullSetEventHandler, MethodExceptionEventHandler,
+                       MethodExceptionEventHandler,
                        RuntimeServicesAware,ContextAware
     {
         private RuntimeServices rs;
@@ -308,24 +234,6 @@
         }
 
         /**
-         *  Event handler for when the right hand side of
-         *  a #set() directive is null, which results in
-         *  a log message.  This method gives the application
-         *  a chance to 'vote' on msg generation
-         */
-        public boolean shouldLogOnNullSet( String lhs, String rhs )
-        {
-            // as a test, make sure this EventHandler is initialized
-            if (rs == null)
-                fail ("Event handler not initialized!");
-
-            if (lhs.equals("$settest"))
-                return false;
-
-            return true;
-        }
-
-        /**
          *  Handles exceptions thrown during in-template method access
          */
         public Object methodException( Class claz, String method, Exception e )

Modified: 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ExceptionTestCase.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ExceptionTestCase.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ExceptionTestCase.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ExceptionTestCase.java
 Fri Mar 13 22:17:31 2009
@@ -84,15 +84,6 @@
         assertMethodInvocationException(ve,context,"$test.throw");
     }
 
-    public void testNullSetEventHandlerException()
-    throws Exception
-    {
-        ve = new VelocityEngine();
-        
ve.setProperty(RuntimeConstants.EVENTHANDLER_NULLSET,ExceptionGeneratingEventHandler.class.getName());
-        ve.init();
-        assertException(ve,"#set($test = $abc)");
-    }
-
     public void testIncludeEventHandlerException()
     throws Exception
     {

Modified: 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/FilteredEventHandlingTestCase.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/FilteredEventHandlingTestCase.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/FilteredEventHandlingTestCase.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/FilteredEventHandlingTestCase.java
 Fri Mar 13 22:17:31 2009
@@ -118,7 +118,6 @@
         VelocityEngine ve = new VelocityEngine();
         ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, this);
         ve.setProperty(RuntimeConstants.EVENTHANDLER_METHODEXCEPTION, 
sequence1);
-        ve.setProperty(RuntimeConstants.EVENTHANDLER_NULLSET, sequence1);
         ve.setProperty(RuntimeConstants.EVENTHANDLER_REFERENCEINSERTION, 
sequence1);
         ve.setProperty(RuntimeConstants.EVENTHANDLER_INCLUDE, sequence1);
         ve.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, 
FILE_RESOURCE_LOADER_PATH);
@@ -127,7 +126,6 @@
         VelocityEngine ve2 = new VelocityEngine();
         ve2.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, this);
         ve2.setProperty(RuntimeConstants.EVENTHANDLER_METHODEXCEPTION, 
sequence2);
-        ve2.setProperty(RuntimeConstants.EVENTHANDLER_NULLSET, sequence2);
         ve2.setProperty(RuntimeConstants.EVENTHANDLER_REFERENCEINSERTION, 
sequence2);
         ve2.setProperty(RuntimeConstants.EVENTHANDLER_INCLUDE, sequence2);
         ve2.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, 
FILE_RESOURCE_LOADER_PATH);

Modified: 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ScopeTestCase.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ScopeTestCase.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ScopeTestCase.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ScopeTestCase.java
 Fri Mar 13 22:17:31 2009
@@ -34,13 +34,6 @@
        super(name);
     }
 
-    @Override
-    public void setUp() throws Exception
-    {
-        super.setUp();
-        engine.setProperty(RuntimeConstants.SET_NULL_ALLOWED, true);
-    }
-
     public void testRootTemplateMergeScope()
     {
         addTemplate("foo", "foo#break($template)bar");

Modified: 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/SetTestCase.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/SetTestCase.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/SetTestCase.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/SetTestCase.java
 Fri Mar 13 22:17:31 2009
@@ -23,14 +23,7 @@
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.context.Context;
 import org.apache.velocity.runtime.RuntimeConstants;
 
 /**
@@ -80,17 +73,13 @@
         super(name);
     }
 
-    public void setUp()
-            throws Exception
+    public void setUp() throws Exception
     {
+        super.setUp();
+        engine.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, 
FILE_RESOURCE_LOADER_PATH);
         assureResultsDirectoryExists(RESULTS_DIR);
     }
 
-    public static Test suite ()
-    {
-        return new TestSuite(SetTestCase.class);
-    }
-
     /**
      * Runs the test.
      */
@@ -98,52 +87,29 @@
             throws Exception
     {
         /**
-         * Check that #set does not accept nulls
+         * Check that #set does accept nulls
          */
-
-        VelocityEngine ve = new VelocityEngine();
-        ve.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, 
FILE_RESOURCE_LOADER_PATH);
-        ve.init();
-
-        checkTemplate(ve,"set1");
-
-        /**
-         * Check that setting the property is the same as the default
-         */
-        ve = new VelocityEngine();
-        ve.addProperty(RuntimeConstants.SET_NULL_ALLOWED, "false");
-        ve.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, 
FILE_RESOURCE_LOADER_PATH);
-        ve.init();
-
-        checkTemplate(ve,"set1");
+        checkTemplate("set1");
 
         /**
          * Check that #set can accept nulls, and has the correct behaviour for 
complex LHS
          */
-        ve = new VelocityEngine();
-        ve.addProperty(RuntimeConstants.SET_NULL_ALLOWED, "true");
-        ve.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, 
FILE_RESOURCE_LOADER_PATH);
-        ve.init();
-
-        checkTemplate(ve,"set2");
+        checkTemplate("set2");
     }
 
-    public void checkTemplate(VelocityEngine ve, String templateName)
-    throws Exception
+    public void checkTemplate(String templateName) throws Exception
     {
         Template template;
         FileOutputStream fos;
         Writer fwriter;
-        Context context;
 
-        template = ve.getTemplate( getFileName(null, templateName, 
TMPL_FILE_EXT) );
+        template = engine.getTemplate(getFileName(null, templateName, 
TMPL_FILE_EXT));
 
         fos = new FileOutputStream (
                 getFileName(RESULTS_DIR, templateName, RESULT_FILE_EXT));
 
         fwriter = new BufferedWriter( new OutputStreamWriter(fos) );
 
-        context = new VelocityContext();
         template.merge(context, fwriter);
         fwriter.flush();
         fwriter.close();

Modified: 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler1.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler1.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler1.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler1.java
 Fri Mar 13 22:17:31 2009
@@ -21,7 +21,6 @@
 
 import org.apache.velocity.app.event.IncludeEventHandler;
 import org.apache.velocity.app.event.MethodExceptionEventHandler;
-import org.apache.velocity.app.event.NullSetEventHandler;
 import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
 
 /**
@@ -31,15 +30,7 @@
  * @version $Id$
  */
 public class Handler1
-    implements NullSetEventHandler, ReferenceInsertionEventHandler, 
MethodExceptionEventHandler, IncludeEventHandler {
-
-        /**
-         * never log
-         */
-        public boolean shouldLogOnNullSet(String lhs, String rhs)
-        {
-            return false;
-        }
+    implements ReferenceInsertionEventHandler, MethodExceptionEventHandler, 
IncludeEventHandler {
 
         /**
          * display output twice, once uppercase and once lowercase

Modified: 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler2.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler2.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler2.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler2.java
 Fri Mar 13 22:17:31 2009
@@ -21,7 +21,6 @@
 
 import org.apache.velocity.app.event.IncludeEventHandler;
 import org.apache.velocity.app.event.MethodExceptionEventHandler;
-import org.apache.velocity.app.event.NullSetEventHandler;
 import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
 
 /**
@@ -31,15 +30,7 @@
  * @version $Id$
  */
 public class Handler2
-    implements NullSetEventHandler, ReferenceInsertionEventHandler, 
MethodExceptionEventHandler, IncludeEventHandler {
-
-    /**
-     * always log
-     */
-    public boolean shouldLogOnNullSet(String lhs, String rhs)
-    {
-        return true;
-    }
+    implements ReferenceInsertionEventHandler, MethodExceptionEventHandler, 
IncludeEventHandler {
 
     /**
      * convert output to upper case

Modified: 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/ExceptionGeneratingEventHandler.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/ExceptionGeneratingEventHandler.java?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/ExceptionGeneratingEventHandler.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/ExceptionGeneratingEventHandler.java
 Fri Mar 13 22:17:31 2009
@@ -21,7 +21,6 @@
 
 import org.apache.velocity.app.event.IncludeEventHandler;
 import org.apache.velocity.app.event.MethodExceptionEventHandler;
-import org.apache.velocity.app.event.NullSetEventHandler;
 import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
 
 /**
@@ -32,7 +31,7 @@
  * @version $Id$
  */
 public class ExceptionGeneratingEventHandler implements IncludeEventHandler,
-        MethodExceptionEventHandler, NullSetEventHandler, 
ReferenceInsertionEventHandler
+        MethodExceptionEventHandler, ReferenceInsertionEventHandler
 {
 
     public String includeEvent(String includeResourcePath, String 
currentResourcePath,
@@ -46,11 +45,6 @@
         throw new RuntimeException("exception");
     }
 
-    public boolean shouldLogOnNullSet(String lhs, String rhs)
-    {
-        throw new RuntimeException("exception");
-    }
-
     public Object referenceInsert(String reference, Object value)
     {
         throw new RuntimeException("exception");

Modified: velocity/engine/branches/2.0_Exp/test/set/compare/set1.cmp
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/test/set/compare/set1.cmp?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/test/set/compare/set1.cmp (original)
+++ velocity/engine/branches/2.0_Exp/test/set/compare/set1.cmp Fri Mar 13 
22:17:31 2009
@@ -1,9 +1,9 @@
 set1
 
 123
-123
+$abc
 
 foo
 bar
 foo
-bar
+$map.bar

Modified: velocity/engine/branches/2.0_Exp/xdocs/docs/developer-guide.xml
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/xdocs/docs/developer-guide.xml?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/xdocs/docs/developer-guide.xml (original)
+++ velocity/engine/branches/2.0_Exp/xdocs/docs/developer-guide.xml Fri Mar 13 
22:17:31 2009
@@ -542,8 +542,8 @@
 ]]></source>
 
 <p>
-Please note that like a Hashtable, the value must be derived from
-java.lang.Object, and must not be null. Fundamental types like int or float 
must
+Please note that the value must be derived from
+java.lang.Object. Fundamental types like int or float must
 be wrapped in the appropriate wrapper classes.
 </p>
 <p>
@@ -1387,29 +1387,6 @@
 </dl>
 </blockquote>
 
-<i><code>org.apache.velocity.app.event.NullSetEventHandler</code></i>
-
-<blockquote>
-When a #set() rejects an assignment due to the right hand side being an invalid
-or null reference, this is normally
-logged.  The <code>NullSetEventHandler</code> allows you to 'veto' the
-logging of this condition.  Multiple <code>NullSetEventHandler</code>'s can
-be chained; each event handler is called in sequence until a false is returned.
-<br/>
-<pre>
-public interface NullSetEventHandler extends EventHandler
-{
-    public boolean shouldLogOnNullSet( String lhs, 
-                                       String rhs );
-}
-</pre>
-<br/>
-Available implementations include:
-<dl>
-<li><i>none provided</i></li>
-</dl>
-</blockquote>
-
 
<i><code>org.apache.velocity.app.event.ReferenceInsertionEventHandler</code></i>
 <blockquote>
 A <code>ReferenceInsertionEventHandler</code> allows the
@@ -1654,17 +1631,6 @@
 </p>
 
 <p>
-<strong>#set() Directive</strong>
-</p>
-
-<p>
-<code>directive.set.null.allowed = false</code><br/>
-If true, having a right hand side of a #set() statement with
-an invalid reference or null value will set the left hand side to null.
-If false, the left hand side will stay the same.
-</p>
-
-<p>
 <strong>#include() and #parse() Directive</strong>
 </p>
 
@@ -1888,10 +1854,9 @@
 defined in the context, or have not been defined with a #set
 directive.  This setting will also throw an exception if an attempt is
 made to call a non-existing property on an object or if the object is
-null.  When this property is true then property
-'directive.set.null.allowed' is also set to true. Also,
-'directive.foreach.skip.invalid' defaults to true when this property
-is true, but explicitly setting 'directive.foreach.skip.invalid' will
+null.  When this property is true then 
+'directive.foreach.skip.invalid' defaults to true,
+but explicitly setting 'directive.foreach.skip.invalid' will
 override this default. For a complete discussion see <a
 href="user-guide.html#strictreferences">Strict References Setting</a>.
 </p>

Modified: velocity/engine/branches/2.0_Exp/xdocs/docs/vtl-reference-guide.xml
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/xdocs/docs/vtl-reference-guide.xml?rev=753450&r1=753449&r2=753450&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/xdocs/docs/vtl-reference-guide.xml 
(original)
+++ velocity/engine/branches/2.0_Exp/xdocs/docs/vtl-reference-guide.xml Fri Mar 
13 22:17:31 2009
@@ -144,8 +144,7 @@
     reference or a property reference.</li>
     <li><em>arg</em> - The RHS of the assignment, <em>arg</em> is parsed
     if enclosed in double quotes, and not parsed if enclosed in single
-    quotes.  If the RHS evaluates to <em>null</em>, it is <b>not</b>
-    assigned to the LHS.</li>
+    quotes.</li>
     </ul>
 
     <p>


Reply via email to