cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r468501 - /cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/container/ContainerTestCase.java
Date Fri, 27 Oct 2006 19:05:18 GMT
Author: cziegeler
Date: Fri Oct 27 12:05:18 2006
New Revision: 468501

URL: http://svn.apache.org/viewvc?view=rev&rev=468501
Log:
Fix compilation of jcr test cases 

Modified:
    cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/container/ContainerTestCase.java

Modified: cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/container/ContainerTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/container/ContainerTestCase.java?view=diff&rev=468501&r1=468500&r2=468501
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/container/ContainerTestCase.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/container/ContainerTestCase.java
Fri Oct 27 12:05:18 2006
@@ -32,6 +32,7 @@
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.context.DefaultContext;
 import org.apache.avalon.framework.logger.ConsoleLogger;
 import org.apache.avalon.framework.logger.Logger;
@@ -287,13 +288,24 @@
             }
         }
         defaultContext.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, new MockContext());
-        this.addContext( defaultContext );
+        final MapBasedDefaultContext avalonConfig = new MapBasedDefaultContext(defaultContext);
+        this.addContext( avalonConfig );
+        this.addContext(defaultContext);
         return defaultContext ;
     }
 
     /**
      * This method may be overwritten by subclasses to put additional objects
      * into the context programmatically.
+     * @deprecated Use {@link #addContext(Map)} instead.
+     */
+    protected void addContext( DefaultContext defaultContext ) {
+        // nothing to add here
+    }
+
+    /**
+     * This method may be overwritten by subclasses to put additional objects
+     * into the context programmatically.
      */
     protected void addContext( Map defaultContext ) {
         // nothing to add here
@@ -457,5 +469,39 @@
         public boolean isSingleton() {
             return true;
         }
+    }
+
+    protected final static class MapBasedDefaultContext extends DefaultContext {
+
+        private final Map map;
+
+        public MapBasedDefaultContext(Map aMap) {
+            this.map = aMap;
+        }
+
+        /**
+         * @see org.apache.avalon.framework.context.DefaultContext#put(java.lang.Object,
java.lang.Object)
+         */
+        public void put(Object arg0, Object arg1) throws IllegalStateException {
+            super.put(arg0, arg1);
+            this.map.put(arg0, arg1);
+        }
+
+        /**
+         * @see org.apache.avalon.framework.context.DefaultContext#get(java.lang.Object)
+         */
+        public Object get(Object arg0) throws ContextException {
+            Object result;
+            try {
+                result = super.get(arg0);                
+            } catch (ContextException e) {
+                result = this.map.get(arg0);
+                if ( result == null ) {
+                    throw e;
+                }
+            }
+            return result;
+        }
+
     }
 }



Mime
View raw message