portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Watler <wat...@wispertel.net>
Subject Re: svn commit: r225607 - in /portals/jetspeed-2/trunk/components/cm/src: java/org/apache/jetspeed/components/ java/org/apache/jetspeed/components/factorybeans/ java/org/apache/jetspeed/mocks/ java/org/apache/jetspeed/testhelpers/ test/org/apache/jetspeed/...
Date Wed, 27 Jul 2005 20:44:56 GMT
Scott...

You just wrote over my commits in

testhelpers/AbstractTestHelper.java

and

testhelpers/DatasourceHelper.java


Was this an accident or a -1 vote on my fixes?

FYI, my build.properties is not in ~/build.properties.

Randy

weaver@apache.org wrote:

>Author: weaver
>Date: Wed Jul 27 13:25:36 2005
>New Revision: 225607
>
>URL: http://svn.apache.org/viewcvs?rev=225607&view=rev
>Log:
>ComponentManagement now has a start() method.
>PlutoFactoryFactoryBean can now can take a pre-existing bean instead of a class name.
>SpringComponentManager consolidated configuration.
>AbstractTestHelper needed to support my original approach along with Randy's maven approach
to support running testcases in Eclipse and maven.
>SpringEngineHelper moved down into components/portal.
>Custom Mocks moved out of src/test into src/java.
>
>Added:
>    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/mocks/
>    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/mocks/BaseMockServletContext.java
  (with props)
>    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/mocks/ResourceLocatingServletContext.java
  (with props)
>Modified:
>    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/ComponentManagement.java
>    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/ContainerManagement.java
>    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/SpringComponentManager.java
>    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/factorybeans/PlutoFactoryFactoryBean.java
>    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/AbstractTestHelper.java
>    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/DatasourceHelper.java
>    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/OJBHelper.java
>    portals/jetspeed-2/trunk/components/cm/src/test/org/apache/jetspeed/testhelpers/TestOJBHelper.java
>
>Modified: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/ComponentManagement.java
>URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/ComponentManagement.java?rev=225607&r1=225606&r2=225607&view=diff
>==============================================================================
>--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/ComponentManagement.java
(original)
>+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/ComponentManagement.java
Wed Jul 27 13:25:36 2005
>@@ -27,4 +27,5 @@
>     
>     Object getComponent(Object containerName, Object componentName);
>     
>+    void addComponent(String name, Object bean);    
> }
>
>Modified: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/ContainerManagement.java
>URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/ContainerManagement.java?rev=225607&r1=225606&r2=225607&view=diff
>==============================================================================
>--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/ContainerManagement.java
(original)
>+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/ContainerManagement.java
Wed Jul 27 13:25:36 2005
>@@ -24,8 +24,7 @@
>  * @version $Id$
>  */
> public interface ContainerManagement
>-{
>-    
>+{    
>     Object getContainer(String containerName);
>     
>     Object getRootContainer();
>@@ -34,8 +33,5 @@
>     
>     void stop();
>     
>-    // void addContainer(String containerName, MutablePicoContainer container);
>-    
>-    // void removeContainer(String containerName);
>-    
>+    void start();   
> }
>
>Modified: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/SpringComponentManager.java
>URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/SpringComponentManager.java?rev=225607&r1=225606&r2=225607&view=diff
>==============================================================================
>--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/SpringComponentManager.java
(original)
>+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/SpringComponentManager.java
Wed Jul 27 13:25:36 2005
>@@ -15,56 +15,95 @@
>  */
> package org.apache.jetspeed.components;
> 
>+import java.io.File;
> import java.util.ArrayList;
> import java.util.Collection;
>+import java.util.HashMap;
>+import java.util.Iterator;
>+import java.util.Map;
> 
>+import javax.servlet.ServletContext;
>+
>+import org.apache.jetspeed.engine.JetspeedEngineConstants;
> import org.springframework.context.ApplicationContext;
> import org.springframework.context.ConfigurableApplicationContext;
>-import org.springframework.context.support.FileSystemXmlApplicationContext;
>+import org.springframework.context.support.GenericApplicationContext;
>+import org.springframework.web.context.WebApplicationContext;
>+import org.springframework.web.context.support.XmlWebApplicationContext;
> 
> /**
>  * <p>
>  * SpringComponentManager
>  * </p>
>  * <p>
>- *
>+ * 
>  * </p>
>+ * 
>  * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
>  * @version $Id$
>- *
>+ * 
>  */
> public class SpringComponentManager implements ComponentManager
> {
>     protected ConfigurableApplicationContext appContext;
>-    
>+
>+    private ConfigurableApplicationContext bootCtx;
>+
>     protected ArrayList factories;
>-    
>-    public SpringComponentManager(ConfigurableApplicationContext appContext)
>+
>+    private Map preconfiguredBeans;
>+
>+    private boolean started = false;
>+
>+    public SpringComponentManager(String[] bootConfigs, String[] appConfigs, ServletContext
servletContext,
>+            String appRoot)
>     {
>-        this.appContext = appContext;
>-        factories = new ArrayList();        
>-        factories.add(appContext);        
>-     }
>+        File appRootDir = new File(appRoot);
>+        System.setProperty(JetspeedEngineConstants.APPLICATION_ROOT_KEY, appRootDir.getAbsolutePath());
>+
>+        if (bootConfigs != null && bootConfigs.length > 0)
>+        {
>+            bootCtx = new XmlWebApplicationContext();
>+            ((XmlWebApplicationContext) bootCtx).setServletContext(servletContext);
>+            ((XmlWebApplicationContext) bootCtx).setConfigLocations(bootConfigs);
>+        }
>+        else
>+        {
>+            bootCtx = new GenericApplicationContext();
>+        }
>+
>+        appContext = new XmlWebApplicationContext();
>+        ((XmlWebApplicationContext) appContext).setParent(bootCtx);
>+        ((XmlWebApplicationContext) appContext).setServletContext(servletContext);
>+        ((XmlWebApplicationContext) appContext).setConfigLocations(appConfigs);
>+
>+        factories = new ArrayList();
>+        factories.add(appContext);
>+
>+        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
this);
>+    }
> 
>-    public SpringComponentManager(String[] springConfigs, ApplicationContext parentAppContext)
>+    public SpringComponentManager(String[] bootConfigs, String[] appConfigs, ServletContext
servletContext,
>+            String appRoot, Map preconfiguredBeans)
>     {
>-       this(new FileSystemXmlApplicationContext(springConfigs, parentAppContext )); 
  
>+        this(bootConfigs, appConfigs, servletContext, appRoot);
>+        this.preconfiguredBeans = preconfiguredBeans;
>     }
>-    
>+
>     /**
>      * <p>
>      * getComponent
>      * </p>
>-     *
>+     * 
>      * @see org.apache.jetspeed.components.ComponentManagement#getComponent(java.lang.Object)
>      * @param componentName
>      * @return
>      */
>-    public Object getComponent( Object componentName )
>-    {        
>-        if(componentName instanceof Class)
>+    public Object getComponent(Object componentName)
>+    {
>+        if (componentName instanceof Class)
>         {
>-            return appContext.getBean(((Class)componentName).getName());
>+            return appContext.getBean(((Class) componentName).getName());
>         }
>         else
>         {
>@@ -76,13 +115,14 @@
>      * <p>
>      * getComponent
>      * </p>
>-     *
>-     * @see org.apache.jetspeed.components.ComponentManagement#getComponent(java.lang.Object,
java.lang.Object)
>+     * 
>+     * @see org.apache.jetspeed.components.ComponentManagement#getComponent(java.lang.Object,
>+     *      java.lang.Object)
>      * @param containerName
>      * @param componentName
>      * @return
>      */
>-    public Object getComponent( Object containerName, Object componentName )
>+    public Object getComponent(Object containerName, Object componentName)
>     {
>         return getComponent(componentName);
>     }
>@@ -91,12 +131,12 @@
>      * <p>
>      * getContainer
>      * </p>
>-     *
>+     * 
>      * @see org.apache.jetspeed.components.ContainerManagement#getContainer(java.lang.String)
>      * @param containerName
>      * @return
>      */
>-    public Object getContainer( String containerName )
>+    public Object getContainer(String containerName)
>     {
>         return appContext;
>     }
>@@ -105,7 +145,7 @@
>      * <p>
>      * getRootContainer
>      * </p>
>-     *
>+     * 
>      * @see org.apache.jetspeed.components.ContainerManagement#getRootContainer()
>      * @return
>      */
>@@ -118,12 +158,12 @@
>      * <p>
>      * getContainers
>      * </p>
>-     *
>+     * 
>      * @see org.apache.jetspeed.components.ContainerManagement#getContainers()
>      * @return
>      */
>     public Collection getContainers()
>-    {        
>+    {
>         return factories;
>     }
> 
>@@ -131,18 +171,51 @@
>      * <p>
>      * stop
>      * </p>
>-     *
>+     * 
>      * @see org.apache.jetspeed.components.ContainerManagement#stop()
>      * 
>      */
>     public void stop()
>     {
>         appContext.close();
>+        bootCtx.close();
>+        started = false;
>     }
>-    
>+
>     public ApplicationContext getApplicationContext()
>     {
>         return appContext;
>+    }
>+
>+    public void addComponent(String name, Object bean)
>+    {
>+        if (preconfiguredBeans == null)
>+        {
>+            preconfiguredBeans = new HashMap();
>+        }
>+        preconfiguredBeans.put(name, bean);
>+
>+        if (started)
>+        {
>+            bootCtx.getBeanFactory().registerSingleton(name, bean);
>+        }
>+    }
>+
>+    public void start()
>+    {
>+        bootCtx.refresh();
>+        if (preconfiguredBeans != null)
>+        {
>+            Iterator itr = preconfiguredBeans.entrySet().iterator();
>+            while (itr.hasNext())
>+            {
>+                Map.Entry entry = (Map.Entry) itr.next();
>+                bootCtx.getBeanFactory().registerSingleton(entry.getKey().toString(),
entry.getValue());
>+            }
>+        }
>+
>+        appContext.refresh();
>+        started = true;
>     }
> 
> }
>
>Modified: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/factorybeans/PlutoFactoryFactoryBean.java
>URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/factorybeans/PlutoFactoryFactoryBean.java?rev=225607&r1=225606&r2=225607&view=diff
>==============================================================================
>--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/factorybeans/PlutoFactoryFactoryBean.java
(original)
>+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/components/factorybeans/PlutoFactoryFactoryBean.java
Wed Jul 27 13:25:36 2005
>@@ -21,6 +21,7 @@
> import javax.servlet.ServletConfig;
> 
> import org.apache.pluto.factory.Factory;
>+import org.springframework.beans.factory.BeanCreationException;
> import org.springframework.beans.factory.config.AbstractFactoryBean;
> 
> /**
>@@ -40,6 +41,7 @@
>     private String className;
>     private Map props;
>     private ServletConfig servletConfig;
>+    private Object bean;
>     
>     /**
>      * <p>
>@@ -51,15 +53,29 @@
>      * @throws java.lang.Exception
>      */
>     protected Object createInstance() throws Exception
>-    {        
>-        Factory factory = (Factory)Thread.currentThread()
>-            .getContextClassLoader().loadClass(className).newInstance();
>+    {
>+        Factory factory;
>+        if(bean == null && className != null)            
>+        {
>+            factory = (Factory)Thread.currentThread()
>+                .getContextClassLoader().loadClass(className).newInstance();
>+        }
>+        else if(bean != null)
>+        {
>+            factory = (Factory)bean;
>+        }
>+        else
>+        {
>+            throw new BeanCreationException("PlutoFactoryFactoryBean requires either
a 'className' or a 'bean' reference to be set.");
>+        }
>+        
>         if(props == null)
>         {
>             props = new HashMap();
>         }
>+        
>         factory.init(servletConfig, props);
>-        return factory;
>+        return factory;  
>     }
> 
>     /**
>@@ -120,4 +136,16 @@
>     {
>         this.className = className;
>     }
>+
>+    public Object getBean()
>+    {
>+        return bean;
>+    }
>+    
>+
>+    public void setBean(Object bean)
>+    {
>+        this.bean = bean;
>+    }
>+    
> }
>
>Added: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/mocks/BaseMockServletContext.java
>URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/mocks/BaseMockServletContext.java?rev=225607&view=auto
>==============================================================================
>--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/mocks/BaseMockServletContext.java
(added)
>+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/mocks/BaseMockServletContext.java
Wed Jul 27 13:25:36 2005
>@@ -0,0 +1,166 @@
>+package org.apache.jetspeed.mocks;
>+
>+import java.io.InputStream;
>+import java.net.MalformedURLException;
>+import java.net.URL;
>+import java.util.Enumeration;
>+import java.util.HashMap;
>+import java.util.Map;
>+import java.util.Set;
>+
>+import javax.servlet.RequestDispatcher;
>+import javax.servlet.Servlet;
>+import javax.servlet.ServletContext;
>+import javax.servlet.ServletException;
>+
>+public abstract class BaseMockServletContext implements ServletContext
>+{
>+    private final Map attributes = new HashMap();
>+
>+    public Object getAttribute(String arg0)
>+    {
>+        return attributes.get(arg0);
>+    }
>+
>+    public Enumeration getAttributeNames()
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public ServletContext getContext(String arg0)
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public String getInitParameter(String arg0)
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public Enumeration getInitParameterNames()
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public int getMajorVersion()
>+    {
>+        return 2;
>+    }
>+
>+    public String getMimeType(String arg0)
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public int getMinorVersion()
>+    {
>+        return 3;
>+    }
>+
>+    public RequestDispatcher getNamedDispatcher(String arg0)
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public String getRealPath(String arg0)
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public RequestDispatcher getRequestDispatcher(String arg0)
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public URL getResource(String arg0) throws MalformedURLException
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public InputStream getResourceAsStream(String arg0)
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public Set getResourcePaths(String arg0)
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public String getServerInfo()
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public Servlet getServlet(String arg0) throws ServletException
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public String getServletContextName()
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public Enumeration getServletNames()
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public Enumeration getServlets()
>+    {
>+        unsupported();
>+        return null;
>+    }
>+
>+    public void log(Exception arg0, String arg1)
>+    {
>+        unsupported();
>+        
>+    }
>+
>+    public void log(String arg0, Throwable arg1)
>+    {
>+        unsupported();
>+        
>+    }
>+
>+    public void log(String arg0)
>+    {
>+        unsupported();
>+        
>+    }
>+
>+    public void removeAttribute(String arg0)
>+    {
>+        attributes.remove(arg0);
>+        
>+    }
>+
>+    public void setAttribute(String arg0, Object arg1)
>+    {
>+        attributes.put(arg0, arg1);
>+        
>+    }
>+    
>+    protected final void unsupported() throws UnsupportedOperationException
>+    {
>+        throw new UnsupportedOperationException("The method called has not been implemented.");
>+    }
>+
>+}
>
>Propchange: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/mocks/BaseMockServletContext.java
>------------------------------------------------------------------------------
>    svn:eol-style = native
>
>Added: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/mocks/ResourceLocatingServletContext.java
>URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/mocks/ResourceLocatingServletContext.java?rev=225607&view=auto
>==============================================================================
>--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/mocks/ResourceLocatingServletContext.java
(added)
>+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/mocks/ResourceLocatingServletContext.java
Wed Jul 27 13:25:36 2005
>@@ -0,0 +1,97 @@
>+package org.apache.jetspeed.mocks;
>+
>+import java.io.File;
>+import java.io.IOException;
>+import java.io.InputStream;
>+import java.net.MalformedURLException;
>+import java.net.URL;
>+import java.util.HashMap;
>+import java.util.HashSet;
>+import java.util.Iterator;
>+import java.util.Map;
>+import java.util.Set;
>+
>+public class ResourceLocatingServletContext extends BaseMockServletContext
>+{
>+    private final File rootPath;
>+    private final Map pathOverrides;
>+    
>+    public ResourceLocatingServletContext(File rootPath)
>+    {   
>+        this.rootPath = rootPath;
>+        this.pathOverrides = new HashMap();
>+    }
>+    
>+    public final void addPathOverride(String path, File file)
>+    {
>+        pathOverrides.put(path, file);
>+    }
>+
>+    public URL getResource(String path) throws MalformedURLException
>+    {
>+       if(pathOverrides.containsKey(path))
>+       {
>+           return ((File)pathOverrides.get(path)).toURL();
>+       }
>+       else
>+       {
>+           return new File(rootPath, path).toURL();
>+       }
>+    }
>+
>+    public String getRealPath(String path)
>+    {
>+        if(pathOverrides.containsKey(path))
>+        {
>+            return ((File)pathOverrides.get(path)).getAbsolutePath();
>+        }
>+        else
>+        {
>+            return new File(rootPath, path).getAbsolutePath();
>+        }
>+    }
>+
>+    public InputStream getResourceAsStream(String path)
>+    {
>+        try
>+        {
>+            return getResource(path).openStream();
>+        }
>+        catch (IOException e)
>+        {
>+            // TODO Auto-generated catch block
>+            e.printStackTrace();
>+            return null;
>+        }
>+    }
>+
>+    public Set getResourcePaths(String path)
>+    {
>+        File start = new File(rootPath, path);        
>+        File[] children = start.listFiles();
>+        HashSet pathes = new HashSet();
>+        for(int i=0; i < children.length; i++)
>+        {
>+            File child = children[i];
>+            String relativePath = child.getPath().substring(rootPath.getPath().length()).replace('\\','/');
>+            
>+            if(child.isDirectory())
>+            {                
>+                pathes.add(relativePath+"/");
>+            }
>+            else
>+            {
>+                pathes.add(relativePath);
>+            }
>+        }
>+        
>+        Iterator itr = pathOverrides.keySet().iterator();
>+        while(itr.hasNext())
>+        {
>+            pathes.add(itr.next());
>+        }
>+        
>+        return pathes;
>+    }
>+
>+}
>
>Propchange: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/mocks/ResourceLocatingServletContext.java
>------------------------------------------------------------------------------
>    svn:eol-style = native
>
>Modified: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/AbstractTestHelper.java
>URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/AbstractTestHelper.java?rev=225607&r1=225606&r2=225607&view=diff
>==============================================================================
>--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/AbstractTestHelper.java
(original)
>+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/AbstractTestHelper.java
Wed Jul 27 13:25:36 2005
>@@ -3,14 +3,30 @@
> import java.io.File;
> import java.util.Map;
> 
>+import org.apache.commons.configuration.ConfigurationException;
>+import org.apache.commons.configuration.PropertiesConfiguration;
> import org.springframework.beans.factory.config.ConfigurableBeanFactory;
> import org.springframework.beans.factory.support.DefaultListableBeanFactory;
> 
> public abstract class AbstractTestHelper implements TestHelper
> {
>-    public static final String BEAN_FACTORY = "bean.factory";
>+    public static final String APP_CONTEXT = "AppContext";
>     private final Map context;
> 
>+    private static final PropertiesConfiguration USER_PROPERTIES;
>+    static
>+    {
>+        try
>+        {
>+            USER_PROPERTIES= new PropertiesConfiguration(new File(System.getProperty("user.home"),
"build.properties"));
>+        }
>+        catch (ConfigurationException e)
>+        {
>+            
>+           throw new IllegalStateException("Unable to load ${USER_HOME}/build.properties");
>+        }
>+    }   
>+
>     public AbstractTestHelper(Map context)
>     {
>         this.context = context;
>@@ -26,20 +42,29 @@
>         // use system properties passed to test via the
>         // maven.junit.sysproperties configuration from
>         // maven build.properties and/or project.properties
>-        return System.getProperty(key).toString();
>+        
>+        String prop = System.getProperty(key);
>+        if(prop == null)
>+        {
>+            return (String) USER_PROPERTIES.getProperty(key);
>+        }
>+        else
>+        {
>+            return prop;
>+        }
>     }
>     
>     protected final void addBeanFactory(ConfigurableBeanFactory bf)
>     {
>-        ConfigurableBeanFactory currentBf = (ConfigurableBeanFactory) context.get(BEAN_FACTORY);
>+        ConfigurableBeanFactory currentBf = (ConfigurableBeanFactory) context.get(APP_CONTEXT);
>         if(currentBf != null)
>         {
>             bf.setParentBeanFactory(currentBf);
>-            context.put(BEAN_FACTORY, new DefaultListableBeanFactory(bf));
>+            context.put(APP_CONTEXT, new DefaultListableBeanFactory(bf));
>         }
>         else
>         {
>-            context.put(BEAN_FACTORY, bf);
>+            context.put(APP_CONTEXT, bf);
>         }
>     }
> 
>
>Modified: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/DatasourceHelper.java
>URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/DatasourceHelper.java?rev=225607&r1=225606&r2=225607&view=diff
>==============================================================================
>--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/DatasourceHelper.java
(original)
>+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/DatasourceHelper.java
Wed Jul 27 13:25:36 2005
>@@ -17,10 +17,10 @@
> {
> 
>     public static final String DATASOURCE_KEY = "datasource";
>-    private static final String ORG_APACHE_JETSPEED_DATABASE_PASSWORD = "org.apache.jetspeed.database.password";
>-    private static final String ORG_APACHE_JETSPEED_DATABASE_USER = "org.apache.jetspeed.database.user";
>-    private static final String ORG_APACHE_JETSPEED_DATABASE_URL = "org.apache.jetspeed.database.url";
>-    private static final String ORG_APACHE_JETSPEED_DATABASE_DRIVER = "org.apache.jetspeed.database.driver";
>+    private static final String ORG_APACHE_JETSPEED_TEST_DATABASE_PASSWORD = "org.apache.jetspeed.test.database.password";
>+    private static final String ORG_APACHE_JETSPEED_TEST_DATABASE_USER = "org.apache.jetspeed.test.database.user";
>+    private static final String ORG_APACHE_JETSPEED_TEST_DATABASE_URL = "org.apache.jetspeed.test.database.url";
>+    private static final String ORG_APACHE_JETSPEED_TEST_DATABASE_DRIVER = "org.apache.jetspeed.test.database.driver";
>     protected BasicDataSource datasource;
>     
>     public DatasourceHelper(Map context)
>@@ -32,10 +32,10 @@
>     public void setUp() throws Exception
>     {
>         datasource = new BasicDataSource();
>-        datasource.setDriverClassName(getUserProperty(ORG_APACHE_JETSPEED_DATABASE_DRIVER));
>-        datasource.setUrl(getUserProperty(ORG_APACHE_JETSPEED_DATABASE_URL));
>-        datasource.setUsername(getUserProperty(ORG_APACHE_JETSPEED_DATABASE_USER));
>-        datasource.setPassword(getUserProperty(ORG_APACHE_JETSPEED_DATABASE_PASSWORD));
>+        datasource.setDriverClassName(getUserProperty(ORG_APACHE_JETSPEED_TEST_DATABASE_DRIVER));
>+        datasource.setUrl(getUserProperty(ORG_APACHE_JETSPEED_TEST_DATABASE_URL));
>+        datasource.setUsername(getUserProperty(ORG_APACHE_JETSPEED_TEST_DATABASE_USER));
>+        datasource.setPassword(getUserProperty(ORG_APACHE_JETSPEED_TEST_DATABASE_PASSWORD));
>         getContext().put(DATASOURCE_KEY, datasource);
>     }
> 
>
>Modified: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/OJBHelper.java
>URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/OJBHelper.java?rev=225607&r1=225606&r2=225607&view=diff
>==============================================================================
>--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/OJBHelper.java
(original)
>+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/testhelpers/OJBHelper.java
Wed Jul 27 13:25:36 2005
>@@ -4,6 +4,7 @@
> import java.util.Properties;
> 
> import org.springframework.beans.factory.support.DefaultListableBeanFactory;
>+import org.springframework.context.support.GenericApplicationContext;
> import org.springframework.orm.ojb.PersistenceBrokerTransactionManager;
> import org.springframework.orm.ojb.support.LocalOjbConfigurer;
> import org.springframework.transaction.interceptor.TransactionProxyFactoryBean;
>@@ -12,6 +13,7 @@
> {
> 
>     public static final String DATASOURCE_BEAN = "JetspeedDS";
>+    private GenericApplicationContext appCtx;
>     private DefaultListableBeanFactory bf;
> 
>     public OJBHelper(Map context)
>@@ -20,14 +22,16 @@
>     }
> 
>     public void setUp() throws Exception
>-    {
>-        super.setUp();
>-        bf = new DefaultListableBeanFactory();
>+    {        
>+        super.setUp();        
>+        bf = new DefaultListableBeanFactory();        
>         bf.registerSingleton(DATASOURCE_BEAN, datasource);
>         LocalOjbConfigurer ojbConfigurer = new LocalOjbConfigurer();
>-        ojbConfigurer.setBeanFactory(bf);
>+        ojbConfigurer.setBeanFactory(bf);        
>         addBeanFactory(bf);        
>+        appCtx = new GenericApplicationContext(bf);
>         bf.preInstantiateSingletons();
>+        getContext().put(APP_CONTEXT, appCtx);
>     }
> 
>     public void tearDown() throws Exception
>
>Modified: portals/jetspeed-2/trunk/components/cm/src/test/org/apache/jetspeed/testhelpers/TestOJBHelper.java
>URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/cm/src/test/org/apache/jetspeed/testhelpers/TestOJBHelper.java?rev=225607&r1=225606&r2=225607&view=diff
>==============================================================================
>--- portals/jetspeed-2/trunk/components/cm/src/test/org/apache/jetspeed/testhelpers/TestOJBHelper.java
(original)
>+++ portals/jetspeed-2/trunk/components/cm/src/test/org/apache/jetspeed/testhelpers/TestOJBHelper.java
Wed Jul 27 13:25:36 2005
>@@ -4,6 +4,7 @@
> import java.util.Map;
> 
> import org.springframework.beans.factory.config.ConfigurableBeanFactory;
>+import org.springframework.context.ApplicationContext;
> 
> import junit.framework.TestCase;
> 
>@@ -14,9 +15,9 @@
>         Map context = new HashMap();
>         OJBHelper helper = new OJBHelper(context);
>         helper.setUp();
>-        ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) context.get(AbstractTestHelper.BEAN_FACTORY);
>-        assertNotNull(beanFactory);
>-        assertNotNull(beanFactory.getBean(OJBHelper.DATASOURCE_BEAN));
>+        ApplicationContext appCtx = (ApplicationContext) context.get(AbstractTestHelper.APP_CONTEXT);
>+        assertNotNull(appCtx);
>+        assertNotNull(appCtx.getBean(OJBHelper.DATASOURCE_BEAN));
>         helper.tearDown();
>     }
> 
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
>For additional commands, e-mail: jetspeed-dev-help@portals.apache.org
>
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message