portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/container TestPortletContainer.java
Date Wed, 17 Mar 2004 22:23:06 GMT
taylor      2004/03/17 14:23:06

  Modified:    portal/src/test/org/apache/jetspeed/aggregator
                        TestAggregator.java
               portal/src/test/org/apache/jetspeed/container
                        TestPortletContainer.java
  Added:       portal/src/test/org/apache/jetspeed/containers
                        test-renderer-container.groovy
                        test-aggregator-container.groovy
               portal/src/test/org/apache/jetspeed/aggregator
                        TestRenderer.java
  Log:
  Renderer and Aggregator tests and container tests
  
  PR:
  Obtained from:
  Submitted by:	
  Reviewed by:	
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.1                  jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/containers/test-renderer-container.groovy
  
  Index: test-renderer-container.groovy
  ===================================================================
  /*
   * Copyright 2000-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import org.picocontainer.defaults.DefaultPicoContainer
  import org.picocontainer.defaults.ConstantParameter
  import org.picocontainer.defaults.ComponentParameter
  import org.picocontainer.Parameter
  import org.apache.jetspeed.components.util.NanoQuickAssembler
   
  import org.apache.pluto.PortletContainer
  import org.apache.jetspeed.aggregator.PortletRenderer
  import org.apache.jetspeed.aggregator.impl.PortletRendererImpl
  import org.apache.jetspeed.container.window.PortletWindowAccessor
  import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent
  import org.apache.jetspeed.components.portletregistry.PortletRegistryComponent
  
  // def register(container) 
  
  
  ClassLoader cl = Thread.currentThread().getContextClassLoader()
  container = new DefaultPicoContainer()
  
  // RDBMS Datasource and JNDI registration
  NanoQuickAssembler.assemble(cl, "org/apache/jetspeed/containers/rdbms.container.groovy",
container)
  
  // Persistence Store
  NanoQuickAssembler.assemble(cl, "org/apache/jetspeed/containers/persistence.container.groovy",
container)
  
  // Portlet Registry and Entity Access
  NanoQuickAssembler.assemble(cl, "org/apache/jetspeed/containers/registry.container.groovy",
container)
  
  //WindowAccessor
  // Portlet Window component
  NanoQuickAssembler.assemble(cl, "org/apache/jetspeed/containers/window-accessor-container.groovy",
container)
  
  // Portlet Container 
  NanoQuickAssembler.assemble(cl, "org/apache/jetspeed/containers/portlet-container.groovy",
container)
  
  container.registerComponentImplementation(PortletRenderer, 
                                            PortletRendererImpl,
                                new Parameter[] {new ComponentParameter(PortletContainer),
new ComponentParameter(PortletWindowAccessor)} )
  
  return container
  
  
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/containers/test-aggregator-container.groovy
  
  Index: test-aggregator-container.groovy
  ===================================================================
  /*
   * Copyright 2000-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import org.picocontainer.defaults.DefaultPicoContainer
  import org.picocontainer.defaults.ConstantParameter
  import org.picocontainer.defaults.ComponentParameter
  import org.picocontainer.Parameter
  import org.apache.jetspeed.components.util.NanoQuickAssembler
   
  import org.apache.jetspeed.aggregator.PortletRenderer
  import org.apache.jetspeed.container.window.PortletWindowAccessor
  import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent
  import org.apache.jetspeed.components.portletregistry.PortletRegistryComponent
  import org.apache.jetspeed.aggregator.PageAggregator
  import org.apache.jetspeed.aggregator.impl.PageAggregatorImpl
  import org.apache.jetspeed.aggregator.PortletAggregator
  import org.apache.jetspeed.aggregator.impl.PortletAggregatorImpl
  
  import org.apache.pluto.PortletContainer
  import org.apache.jetspeed.aggregator.impl.PortletRendererImpl
  import org.apache.jetspeed.container.window.PortletWindowAccessor
  
  
  
  ClassLoader cl = Thread.currentThread().getContextClassLoader()
  container = new DefaultPicoContainer()
  
  // RDBMS Datasource and JNDI registration
  NanoQuickAssembler.assemble(cl, "org/apache/jetspeed/containers/rdbms.container.groovy",
container)
  
  // Persistence Store
  NanoQuickAssembler.assemble(cl, "org/apache/jetspeed/containers/persistence.container.groovy",
container)
  
  // Portlet Registry and Entity Access
  NanoQuickAssembler.assemble(cl, "org/apache/jetspeed/containers/registry.container.groovy",
container)
  
  // Portlet Window component
  NanoQuickAssembler.assemble(cl, "org/apache/jetspeed/containers/window-accessor-container.groovy",
container)
  
  // Portlet Container 
  NanoQuickAssembler.assemble(cl, "org/apache/jetspeed/containers/portlet-container.groovy",
container)
  
  container.registerComponentImplementation(PortletRenderer, 
                                            PortletRendererImpl,
                                new Parameter[] {new ComponentParameter(PortletContainer),
new ComponentParameter(PortletWindowAccessor)} )
  
  //
  // Portlet Renderer
  //
  // THIS FAILS: NanoQuickAssembler.assemble(cl, "org/apache/jetspeed/containers/renderer-container.groovy",
container)
  
  // sequential = 0, parallel = 1
  strategy = 0
  
  container.registerComponentImplementation(PageAggregator, 
                                             PageAggregatorImpl,
                                new Parameter[] {new ComponentParameter(PortletRenderer),

                                                 new ConstantParameter(strategy)} )      
                    	    
  
  container.registerComponentImplementation(PortletAggregator, 
                                            PortletAggregatorImpl,
                                new Parameter[] {new ComponentParameter(PortletRenderer)}
)
  
  return container
  
  
  
  
  
  1.7       +34 -17    jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/aggregator/TestAggregator.java
  
  Index: TestAggregator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/aggregator/TestAggregator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestAggregator.java	8 Mar 2004 00:35:57 -0000	1.6
  +++ TestAggregator.java	17 Mar 2004 22:23:06 -0000	1.7
  @@ -18,14 +18,14 @@
   import junit.framework.Test;
   
   import org.apache.jetspeed.Jetspeed;
  -import org.apache.jetspeed.test.JetspeedTest;
  -import org.apache.jetspeed.test.JetspeedTestSuite;
   
   import org.apache.jetspeed.request.RequestContext;
   import org.apache.jetspeed.request.RequestContextFactory;
   import org.apache.jetspeed.profiler.Profiler;
  -import org.apache.jetspeed.cps.CommonPortletServices;
  +import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
  +import org.apache.jetspeed.components.ComponentAwareTestSuite;
   import org.apache.jetspeed.profiler.ProfileLocator;
  +import org.picocontainer.MutablePicoContainer;
   
   /**
    * <P>Test the aggregation service</P>
  @@ -34,8 +34,12 @@
    * @version $Id$
    * 
    */
  -public class TestAggregator extends JetspeedTest
  +public class TestAggregator extends AbstractComponentAwareTestCase
   {
  +    private MutablePicoContainer container;
  +    private PortletAggregator portletAggregator;
  +    private PageAggregator pageAggregator;
  +    
       /**
        * Defines the testcase name for JUnit.
        *
  @@ -46,12 +50,6 @@
           super(name);
       }
   
  -    public static Test suite()
  -    {
  -        // All methods starting with "test" will be executed in the test suite.
  -        return new JetspeedTestSuite(TestAggregator.class);
  -    }
  -
       /**
        * Start the tests.
        *
  @@ -62,14 +60,32 @@
           junit.awtui.TestRunner.main(new String[] { TestAggregator.class.getName()});
       }
   
  +    protected void setUp() throws Exception
  +    {
  +        super.setUp();
  +        container = (MutablePicoContainer) getContainer();
  +        pageAggregator = (PageAggregator) container.getComponentInstance(PageAggregator.class);
  +        portletAggregator = (PortletAggregator) container.getComponentInstance(PortletAggregator.class);
               
  +    }
  +
       /**
  -     * Simple test that verifies ...
  +     * Creates the test suite.
        *
  -     * @throws Exception
  +     * @return a test suite (<code>TestSuite</code>) that includes all methods
  +     *         starting with "test"
        */
  -    public void testAggregator() throws Exception
  +    public static Test suite()
  +    {
  +        ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestAggregator.class);
  +        suite.setScript("org/apache/jetspeed/containers/test-aggregator-container.groovy");
  +        return suite;                                   
  +    }
  +
  +    public void testBasic() throws Exception
       {
  -        Aggregator aggregator = (Aggregator) CommonPortletServices.getPortalService(Aggregator.SERVICE_NAME);
  +        assertNotNull("portlet aggregator is null", portletAggregator);
  +        assertNotNull("page aggregator is null", pageAggregator);
  +        /*
           Profiler profiler = (Profiler)Jetspeed.getComponentManager().getComponent(Profiler.class);
   
           RequestContext request = RequestContextFactory.getInstance(null, null, null);
  @@ -77,7 +93,8 @@
           ProfileLocator locator = profiler.getProfile(request);
           request.setProfileLocator(locator);
   
  -        aggregator.build(request);
  -
  +        pageAggregator.build(request);
  +        */
       }
  +
   }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/aggregator/TestRenderer.java
  
  Index: TestRenderer.java
  ===================================================================
  /*
   * Copyright 2000-2001,2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.jetspeed.aggregator;
  
  import junit.framework.Test;
  
  import org.apache.jetspeed.aggregator.PortletRenderer;
  import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
  import org.apache.jetspeed.components.ComponentAwareTestSuite;
  import org.apache.jetspeed.container.TestPortletContainer;
  import org.picocontainer.MutablePicoContainer;
  
  /**
   * TestPortletRenderer
   *
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: TestRenderer.java,v 1.1 2004/03/17 22:23:06 taylor Exp $
   */
  public class TestRenderer extends AbstractComponentAwareTestCase 
  {
      private MutablePicoContainer container;
      private PortletRenderer renderer;
      
      /**
       * Defines the testcase name for JUnit.
       *
       * @param name the testcase's name.
       */
      public TestRenderer(String name)
      {
          super(name);
      }
  
      /**
       * Start the tests.
       *
       * @param args the arguments. Not used
       */
      public static void main(String args[])
      {
          junit.awtui.TestRunner.main(new String[] { TestRenderer.class.getName()});
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
          container = (MutablePicoContainer) getContainer();
          renderer = (PortletRenderer) container.getComponentInstance(PortletRenderer.class);
       
      }
  
      /**
       * Creates the test suite.
       *
       * @return a test suite (<code>TestSuite</code>) that includes all methods
       *         starting with "test"
       */
      public static Test suite()
      {
          ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestPortletContainer.class);
          suite.setScript("org/apache/jetspeed/containers/test-renderer-container.groovy");
          return suite;                                   
      }
  
      public void testBasic() throws Exception
      {
          assertNotNull("portlet renderer is null", renderer);
      }
      
  }
  
  
  
  1.2       +4 -3      jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/container/TestPortletContainer.java
  
  Index: TestPortletContainer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/container/TestPortletContainer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestPortletContainer.java	17 Mar 2004 01:50:12 -0000	1.1
  +++ TestPortletContainer.java	17 Mar 2004 22:23:06 -0000	1.2
  @@ -23,10 +23,10 @@
   import org.picocontainer.MutablePicoContainer;
   
   /**
  - * @author david
  + * TestPortletContainer
    *
  - * To change the template for this generated type comment go to
  - * Window - Preferences - Java - Code Generation - Code and Comments
  + * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  + * @version $Id$
    */
   public class TestPortletContainer extends AbstractComponentAwareTestCase 
   {
  @@ -76,5 +76,6 @@
       public void testBasic()
       {
           assertNotNull("portlet container is null", portletContainer);
  +        // not much more i can do without setting up a mock servlet or portlet framework
       }
   }
  
  
  

---------------------------------------------------------------------
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