portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletregistry TestRegistry.java
Date Fri, 27 Feb 2004 20:08:47 GMT
weaver      2004/02/27 12:08:46

  Modified:    components/registry/src/java/org/apache/jetspeed/containers
                        registry.container.groovy
               components/registry/src/test/org/apache/jetspeed/components/portletregistry
                        TestRegistry.java
  Log:
  now using the BoundDatasourceComponent so manual binding is unneeded
  outside of the script file
  
  Revision  Changes    Path
  1.4       +8 -18     jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/containers/registry.container.groovy
  
  Index: registry.container.groovy
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/containers/registry.container.groovy,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- registry.container.groovy	27 Feb 2004 18:30:00 -0000	1.3
  +++ registry.container.groovy	27 Feb 2004 20:08:46 -0000	1.4
  @@ -8,7 +8,7 @@
   import org.hsqldb.jdbcDriver
   import org.apache.jetspeed.components.jndi.JNDIComponent
   import org.apache.jetspeed.components.jndi.TyrexJNDIComponent
  -import org.apache.jetspeed.components.datasource.DBCPDatasourceComponent
  +import org.apache.jetspeed.components.datasource.BoundDBCPDatasourceComponent
   import org.apache.jetspeed.components.datasource.DatasourceComponent
   import org.apache.commons.pool.impl.GenericObjectPool
   import org.apache.jetspeed.components.persistence.store.ojb.OJBTypeIntializer
  @@ -37,11 +37,10 @@
   
   
   // This JNDI component helps us publish the datasource
  -Class jndiClass = Class.forName("org.apache.jetspeed.components.jndi.JNDIComponent")
  -Class tyrexJndiClass = Class.forName("org.apache.jetspeed.components.jndi.TyrexJNDIComponent")
  -container.registerComponentImplementation(jndiClass, tyrexJndiClass)
  +Class jndiClass = JNDIComponent
  +JNDIComponent jndiImpl = new TyrexJNDIComponent()
  +container.registerComponentInstance(jndiClass, jndiImpl)
   
  -Class dsClass = Class.forName("org.apache.jetspeed.components.datasource.DatasourceComponent")
   String url = System.getProperty("org.apache.jetspeed.database.url")
   String driver = System.getProperty("org.apache.jetspeed.database.driver")
   String user = System.getProperty("org.apache.jetspeed.database.user")
  @@ -49,31 +48,22 @@
   
   if(url != null)
   {
  -	container.registerComponentInstance(dsClass, new DBCPDatasourceComponent(user, password,
driver, url, 20, 5000, GenericObjectPool.WHEN_EXHAUSTED_GROW, true))
  +	container.registerComponentInstance(DatasourceComponent, new BoundDBCPDatasourceComponent(user,
password, driver, url, 20, 5000, GenericObjectPool.WHEN_EXHAUSTED_GROW, true, "jetspeed",
jndiImpl))
   }
   
   //
   // Persistence
   PersistenceContainer pContainer = new DefaultPersistenceStoreContainer(300000, 10000)
  -Class pContainerClass = Class.forName("org.apache.jetspeed.components.persistence.store.PersistenceStoreContainer")
   
  -// Parameter[] storeParams = new Parameter[] {new ConstantParameter("jetspeed")}
  -
  -
  -Class OTMStoreClass = Class.forName("org.apache.jetspeed.components.persistence.store.ojb.otm.OTMStoreImpl")
  -ComponentAdapter ca = new ConstructorComponentAdapter("jetspeed", OTMStoreClass, new Parameter[]
{new ConstantParameter("jetspeed")})
  +ComponentAdapter ca = new ConstructorComponentAdapter("jetspeed", OTMStoreImpl, new Parameter[]
{new ConstantParameter("jetspeed")})
   
   pContainer.registerComponent(ca)
   
  -container.registerComponentInstance(pContainerClass, pContainer);
  +container.registerComponentInstance(PersistenceStoreContainer, pContainer);
   
   //
   // Portlet Registry
   //
  -
  -Class registryClass = Class.forName("org.apache.jetspeed.components.portletregsitry.PortletRegistryComponent")
  -Class registryImplClass = Class.forName("org.apache.jetspeed.components.portletregsitry.PortletRegistryComponentImpl")
  -// Parameter[] regParams = new Parameter[] {new ComponentParameter(pContainerClass), new
ConstantParameter("jetspeed")}
  -container.registerComponentImplementation(registryClass, registryImplClass, new Parameter[]
{new ComponentParameter(pContainerClass), new ConstantParameter("jetspeed")} );
  +container.registerComponentImplementation(PortletRegistryComponent, PortletRegistryComponentImpl,
new Parameter[] {new ComponentParameter(PersistenceStoreContainer), new ConstantParameter("jetspeed")}
);
   
   return container
  
  
  
  1.4       +12 -24    jakarta-jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletregistry/TestRegistry.java
  
  Index: TestRegistry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletregistry/TestRegistry.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestRegistry.java	26 Feb 2004 19:16:39 -0000	1.3
  +++ TestRegistry.java	27 Feb 2004 20:08:46 -0000	1.4
  @@ -56,13 +56,13 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Locale;
  -import javax.naming.NameAlreadyBoundException;
  +
   import javax.portlet.PortletMode;
  +
   import junit.framework.Test;
  +
   import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
   import org.apache.jetspeed.components.ComponentAwareTestSuite;
  -import org.apache.jetspeed.components.datasource.DatasourceComponent;
  -import org.apache.jetspeed.components.jndi.JNDIComponent;
   import org.apache.jetspeed.components.persistence.store.Filter;
   import org.apache.jetspeed.components.persistence.store.PersistenceStore;
   import org.apache.jetspeed.components.persistence.store.PersistenceStoreContainer;
  @@ -103,6 +103,7 @@
    */
   public class TestRegistry extends AbstractComponentAwareTestCase
   {
  +
       private MutablePicoContainer container;
       private static final String PORTLET_0_CLASS = "com.portlet.MyClass0";
       private static final String PORTLET_0_NAME = "Portlet 0";
  @@ -133,27 +134,18 @@
           super.setUp();
           container = (MutablePicoContainer) getContainer();
           registry = (PortletRegistryComponent) container.getComponentInstance(PortletRegistryComponent.class);
  -        try
  -        {
  -            DatasourceComponent ds = (DatasourceComponent) container.getComponentInstance(DatasourceComponent.class);
  -            JNDIComponent jndi = (JNDIComponent) container.getComponentInstance(JNDIComponent.class);
  -            jndi.bindObject("comp/env/jdbc/jetspeed", ds.getDatasource());
  -        }
  -        catch (NameAlreadyBoundException e)
  -        {
  -            // ignore
  -        }
           PersistenceStoreContainer pContainer = (PersistenceStoreContainer) container
           .getComponentInstanceOfType(PersistenceStoreContainer.class);
           try
           {
               store = pContainer.getStoreForThread("jetspeed");
  -        } catch (Throwable e1)
  +        }
  +        catch (Throwable e1)
           {
  -            
  +
               // TODO Auto-generated catch block
               e1.printStackTrace();
  -            throw (Exception)e1;
  +            throw (Exception) e1;
           }
           clean();
           buildTestPortletApp();
  @@ -247,7 +239,6 @@
               dc.addTitle(JetspeedLocale.getDefaultLocale(), "Test title 1");
               dc.addTitle(JetspeedLocale.getDefaultLocale(), "Test title 2");
               dc.addTitle(JetspeedLocale.getDefaultLocale(), "Test title 3");
  -            
               dc.addContributor(JetspeedLocale.getDefaultLocale(), "Contrib 1");
               dc.addCoverage(JetspeedLocale.getDefaultLocale(), "Coverage 1");
               dc.addCoverage(JetspeedLocale.getDefaultLocale(), "Coverage 2");
  @@ -262,7 +253,6 @@
               dc.addSource(JetspeedLocale.getDefaultLocale(), "Source 1");
               dc.addSubject(JetspeedLocale.getDefaultLocale(), "Subject 1");
               dc.addType(JetspeedLocale.getDefaultLocale(), "Type 1");
  -            
               wac.setContextRoot("/root");
               wac.addDescription(JetspeedLocale.getDefaultLocale(), "This is an english desrcitpion");
               wac.addDisplayName(JetspeedLocale.getDefaultLocale(), "This is an english display
name");
  @@ -276,7 +266,7 @@
               pac.addPortletDefinition(portlet0);
               registry.registerPortletApplication(pac);
               store.getTransaction().commit();
  -            
  +
               // invalidate(new Object[] {wac, portlet0, pac});
           }
           catch (Exception e)
  @@ -333,7 +323,6 @@
           assertNotNull(appExists);
           DublinCore dc = new DublinCoreImpl(appExists.getMetadata());
           assertEquals(dc.getTitles().size(), 3);
  -        
           assertEquals(dc.getContributors().size(), 1);
           assertEquals(dc.getCoverages().size(), 2);
           assertEquals(dc.getCreators().size(), 1);
  @@ -347,7 +336,6 @@
           assertEquals(dc.getSources().size(), 1);
           assertEquals(dc.getSubjects().size(), 1);
           assertEquals(dc.getTypes().size(), 1);
  -        
       }
   
       public void testAddingPortlet() throws Throwable
  @@ -620,11 +608,11 @@
           store.deleteAll(store.newQuery(clazz, filter));
           store.getTransaction().commit();
       }
  -    
  +
       protected void invalidate(Object[] objs) throws LockFailedException
       {
           store.getTransaction().begin();
  -        for(int i=0; i<objs.length; i++)
  +        for (int i = 0; i < objs.length; i++)
           {
               store.invalidate(objs[i]);
           }
  
  
  

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


Mime
View raw message