You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by we...@apache.org on 2004/05/27 21:57:24 UTC

cvs commit: jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/tools/pamanager TestPortletDescriptorSecurityRoles.java TestPortletDescriptor.java TestJetspeedPortletDescriptor.java

weaver      2004/05/27 12:57:24

  Modified:    portal/src/test/org/apache/jetspeed/tools/pamanager
                        TestPortletDescriptorSecurityRoles.java
                        TestPortletDescriptor.java
                        TestJetspeedPortletDescriptor.java
  Log:
  JS2-59 <http://nagoya.apache.org/jira/browse/JS2-59>
  
  Revision  Changes    Path
  1.4       +17 -66    jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptorSecurityRoles.java
  
  Index: TestPortletDescriptorSecurityRoles.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptorSecurityRoles.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestPortletDescriptorSecurityRoles.java	18 May 2004 00:45:24 -0000	1.3
  +++ TestPortletDescriptorSecurityRoles.java	27 May 2004 19:57:24 -0000	1.4
  @@ -15,29 +15,20 @@
    */
   package org.apache.jetspeed.tools.pamanager;
   
  -import java.io.FileInputStream;
  -import java.util.Properties;
  -
   import junit.framework.Test;
  +import junit.framework.TestSuite;
   import junit.textui.TestRunner;
   
  -import org.apache.commons.logging.LogFactory;
  -import org.apache.commons.logging.impl.Log4jFactory;
   import org.apache.jetspeed.Jetspeed;
  -import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
  -import org.apache.jetspeed.components.ComponentAwareTestSuite;
  -import org.apache.jetspeed.components.persistence.store.PersistenceStore;
  -import org.apache.jetspeed.components.portletregistry.PortletRegistryComponent;
  +import org.apache.jetspeed.components.util.RegistrySupportedTestCase;
   import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
   import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
   import org.apache.jetspeed.om.servlet.impl.SecurityRoleImpl;
  -import org.apache.log4j.PropertyConfigurator;
   import org.apache.pluto.om.common.SecurityRole;
   import org.apache.pluto.om.common.SecurityRoleRef;
   import org.apache.pluto.om.common.SecurityRoleRefSet;
   import org.apache.pluto.om.common.SecurityRoleSet;
   import org.apache.pluto.om.portlet.PortletDefinition;
  -import org.picocontainer.MutablePicoContainer;
   
   /**
    * TestPortletDescriptorSecurityRoles - test and validate security roles and
  @@ -47,15 +38,9 @@
    * 
    * @version $Id$
    */
  -public class TestPortletDescriptorSecurityRoles extends AbstractComponentAwareTestCase
  +public class TestPortletDescriptorSecurityRoles extends RegistrySupportedTestCase
   {
   
  -    private PortletRegistryComponent registry;
  -
  -    private MutablePicoContainer container;
  -
  -    private PersistenceStore store;
  -
       /**
        * Defines the testcase name for JUnit.
        * 
  @@ -78,39 +63,6 @@
           TestRunner.main(new String[] { TestPortletDescriptorSecurityRoles.class.getName()});
       }
   
  -    public static final String LOG4J_CONFIG_FILE = "log4j.file";
  -
  -    // TODO: make this relative, move it into script
  -    public static final String LOG4J_CONFIG_FILE_DEFAULT = "src/webapp/WEB-INF/conf/Log4j.properties";
  -
  -    protected void setUp() throws Exception
  -    {
  -        // super.setUp();
  -
  -        // TODO: this is REALLY strange. If I don't setup LOG4J here Digester
  -        // crashes with a NPE
  -        // if I setup Log4J in my super class, Digester crashes ... mysterious
  -        // TODO: need a Logging Component
  -
  -        String log4jFile = LOG4J_CONFIG_FILE_DEFAULT;
  -        Properties p = new Properties();
  -        try
  -        {
  -            p.load(new FileInputStream(log4jFile));
  -        }
  -        catch (Exception e)
  -        {
  -            e.printStackTrace();
  -        }
  -        PropertyConfigurator.configure(p);
  -
  -        System.getProperties().setProperty(LogFactory.class.getName(), Log4jFactory.class.getName());
  -
  -        container = (MutablePicoContainer) getContainer();
  -        registry = (PortletRegistryComponent) container.getComponentInstance(PortletRegistryComponent.class);
  -        store = registry.getPersistenceStore();
  -    }
  -
       /**
        * Creates the test suite.
        * 
  @@ -119,11 +71,10 @@
        */
       public static Test suite()
       {
  -        ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestPortletDescriptorSecurityRoles.class);
  -        suite.setScript("org/apache/jetspeed/tools/pamanager/containers/pa-container.groovy");
  -        return suite;
  +        // All methods starting with "test" will be executed in the test suite.
  +        return new TestSuite(TestPortletDescriptorSecurityRoles.class);
       }
  -
  +    
       public void testSecurityRoles() throws Exception
       {
           System.out.println("Testing securityRoles");
  @@ -170,22 +121,22 @@
           // persist the app
           try
           {
  -            store.getTransaction().begin();
  -            registry.registerPortletApplication(app);
  -            store.getTransaction().commit();
  +            persistenceStore.getTransaction().begin();
  +            portletRegistry.registerPortletApplication(app);
  +            persistenceStore.getTransaction().commit();
           }
           catch (Exception e)
           {
               String msg =
                   "Unable to register portlet application, " + app.getName() + ", through the portlet registry: " + e.toString();
  -            store.getTransaction().rollback();
  +            persistenceStore.getTransaction().rollback();
               throw new Exception(msg, e);
           }
           // clear cache
  -        store.invalidateAll();
  +        persistenceStore.invalidateAll();
   
           // read back in
  -        app = registry.getPortletApplication("unit-test");
  +        app = portletRegistry.getPortletApplication("unit-test");
           validateFailed = true;
           try
           {
  @@ -200,14 +151,14 @@
           // remove the app
           try
           {
  -            store.getTransaction().begin();
  -            registry.removeApplication(app);
  -            store.getTransaction().commit();
  +            persistenceStore.getTransaction().begin();
  +            portletRegistry.removeApplication(app);
  +            persistenceStore.getTransaction().commit();
           }
           catch (Exception e)
           {
               String msg =
  -                "Unable to remove portlet application, " + app.getName() + ", through the portlet registry: " + e.toString();
  +                "Unable to remove portlet application, " + app.getName() + ", through the portlet portletRegistry: " + e.toString();
               throw new Exception(msg, e);
           }
   
  
  
  
  1.19      +16 -63    jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptor.java
  
  Index: TestPortletDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/tools/pamanager/TestPortletDescriptor.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- TestPortletDescriptor.java	7 May 2004 13:45:25 -0000	1.18
  +++ TestPortletDescriptor.java	27 May 2004 19:57:24 -0000	1.19
  @@ -15,23 +15,18 @@
    */
   package org.apache.jetspeed.tools.pamanager;
   
  -import java.io.FileInputStream;
   import java.util.Collection;
   import java.util.Iterator;
   import java.util.Locale;
  -import java.util.Properties;
   
   import javax.portlet.PortletMode;
   
   import junit.framework.Test;
  +import junit.framework.TestSuite;
   import junit.textui.TestRunner;
   
  -import org.apache.commons.logging.LogFactory;
  -import org.apache.commons.logging.impl.Log4jFactory;
  -import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
  -import org.apache.jetspeed.components.ComponentAwareTestSuite;
   import org.apache.jetspeed.components.persistence.store.PersistenceStore;
  -import org.apache.jetspeed.components.portletregistry.PortletRegistryComponent;
  +import org.apache.jetspeed.components.util.RegistrySupportedTestCase;
   import org.apache.jetspeed.om.common.MutableLanguage;
   import org.apache.jetspeed.om.common.ParameterComposite;
   import org.apache.jetspeed.om.common.UserAttribute;
  @@ -39,7 +34,6 @@
   import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
   import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
   import org.apache.jetspeed.om.common.preference.PreferenceComposite;
  -import org.apache.log4j.PropertyConfigurator;
   import org.apache.pluto.om.common.DisplayName;
   import org.apache.pluto.om.common.LanguageSet;
   import org.apache.pluto.om.common.ParameterSet;
  @@ -48,7 +42,6 @@
   import org.apache.pluto.om.portlet.ContentTypeSet;
   import org.apache.pluto.om.portlet.PortletDefinition;
   import org.apache.pluto.om.portlet.PortletDefinitionList;
  -import org.picocontainer.MutablePicoContainer;
   
   /**
    * TestPortletDescriptor - tests loading the portlet.xml deployment descriptor
  @@ -58,11 +51,8 @@
    * 
    * @version $Id$
    */
  -public class TestPortletDescriptor extends AbstractComponentAwareTestCase
  +public class TestPortletDescriptor extends RegistrySupportedTestCase
   {
  -    private PortletRegistryComponent registry;
  -    private MutablePicoContainer container;
  -
       /**
        * Defines the testcase name for JUnit.
        *
  @@ -83,49 +73,12 @@
           TestRunner.main(new String[] { TestPortletDescriptor.class.getName()});
       }
   
  -    public static final String LOG4J_CONFIG_FILE = "log4j.file";
  -    // TODO: make this relative, move it into script
  -    public static final String LOG4J_CONFIG_FILE_DEFAULT = "src/webapp/WEB-INF/conf/Log4j.properties";
  -
  -    protected void setUp() throws Exception
  -    {
  -        // super.setUp();
  -
  -        // TODO: this is REALLY strange. If I don't setup LOG4J here Digester crashes with a NPE
  -        // if I setup Log4J in my super class, Digester crashes ... mysterious
  -        // TODO: need a Logging Component
  -
  -        String log4jFile = LOG4J_CONFIG_FILE_DEFAULT;
  -        Properties p = new Properties();
  -        try
  -        {
  -            p.load(new FileInputStream(log4jFile));
  -        }
  -        catch (Exception e)
  -        {
  -            e.printStackTrace();
  -        }
  -        PropertyConfigurator.configure(p);
  -
  -        System.getProperties().setProperty(LogFactory.class.getName(), Log4jFactory.class.getName());
  -
  -        container = (MutablePicoContainer) getContainer();
  -        registry = (PortletRegistryComponent) container.getComponentInstance(PortletRegistryComponent.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(TestPortletDescriptor.class);
  -        suite.setScript("org/apache/jetspeed/tools/pamanager/containers/pa-container.groovy");
  -        return suite;
  +    public static Test suite()
  +    {
  +        // All methods starting with "test" will be executed in the test suite.
  +        return new TestSuite(TestPortletDescriptor.class);
       }
  -
  +    
       /*
        * Overrides the database properties
        */
  @@ -338,12 +291,12 @@
   
       public void testWritingToDB() throws Exception
       {
  -        PersistenceStore store = registry.getPersistenceStore();
  +        PersistenceStore store = portletRegistry.getPersistenceStore();
           store.getTransaction().begin();
  -        MutablePortletApplication app = registry.getPortletApplication("HW_App");
  +        MutablePortletApplication app = portletRegistry.getPortletApplication("HW_App");
           if (app != null)
           {
  -            registry.removeApplication(app);
  +            portletRegistry.removeApplication(app);
               store.getTransaction().commit();
               store.getTransaction().begin();
           }
  @@ -352,12 +305,12 @@
           app.setName("HW_App");
   
           store.getTransaction().begin();
  -        registry.registerPortletApplication(app);
  +        portletRegistry.registerPortletApplication(app);
           store.getTransaction().commit();
           // store.invalidateAll();
   
           store.getTransaction().begin();
  -        PortletDefinition pd = registry.getPortletDefinitionByUniqueName("HW_App::PreferencePortlet");
  +        PortletDefinition pd = portletRegistry.getPortletDefinitionByUniqueName("HW_App::PreferencePortlet");
           store.getTransaction().commit();
           assertNotNull(pd);
   
  @@ -378,12 +331,12 @@
           assertTrue(count > 0);
   
           store.getTransaction().begin();
  -        pd = registry.getPortletDefinitionByUniqueName("HW_App::PickANumberPortlet");
  +        pd = portletRegistry.getPortletDefinitionByUniqueName("HW_App::PickANumberPortlet");
           store.getTransaction().commit();
           assertNotNull(pd);
   
           store.getTransaction().begin();
  -        registry.removeApplication(app);
  +        portletRegistry.removeApplication(app);
           store.getTransaction().commit();
   
       }
  
  
  
  1.3       +7 -24     jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/tools/pamanager/TestJetspeedPortletDescriptor.java
  
  Index: TestJetspeedPortletDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/tools/pamanager/TestJetspeedPortletDescriptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestJetspeedPortletDescriptor.java	11 Mar 2004 23:19:26 -0000	1.2
  +++ TestJetspeedPortletDescriptor.java	27 May 2004 19:57:24 -0000	1.3
  @@ -9,14 +9,12 @@
   import java.util.Collection;
   
   import junit.framework.Test;
  +import junit.framework.TestSuite;
   import junit.textui.TestRunner;
   
  -import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
  -import org.apache.jetspeed.components.ComponentAwareTestSuite;
  -import org.apache.jetspeed.components.portletregistry.PortletRegistryComponent;
  +import org.apache.jetspeed.components.util.RegistrySupportedTestCase;
   import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
   import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
  -import org.picocontainer.MutablePicoContainer;
   
   /**
    * @author jford
  @@ -25,10 +23,7 @@
    * Window - Preferences - Java - Code Generation - Code and Comments
    */
   public class TestJetspeedPortletDescriptor
  -    extends AbstractComponentAwareTestCase {
  -    
  -    private PortletRegistryComponent registry;
  -    private MutablePicoContainer container;
  +    extends RegistrySupportedTestCase {
       
       private static final String PORTLET_01 = "HelloWorld Portlet";
       private static final String PORTLET_02 = "Display the Portlet Request Information";
  @@ -50,7 +45,7 @@
        * @param log4jFile
        */
       public TestJetspeedPortletDescriptor(String arg0, String log4jFile) {
  -        super(arg0, log4jFile);
  +        super(arg0);
       }
       
       /**
  @@ -63,18 +58,7 @@
           TestRunner.main(new String[] { TestPortletDescriptor.class.getName()});
       }
   
  -    public static final String LOG4J_CONFIG_FILE = "log4j.file";
  -    // TODO: make this relative, move it into script
  -    public static final String LOG4J_CONFIG_FILE_DEFAULT = "src/webapp/WEB-INF/conf/test/Log4j.properties";
  -    
  -    protected void setUp() throws Exception
  -    {
  -        super.setUp();
  -        
  -        container = (MutablePicoContainer) getContainer();
  -        registry = (PortletRegistryComponent) container.getComponentInstance(PortletRegistryComponent.class);
  -    }
  -    
  +   
       /**
        * Creates the test suite.
        *
  @@ -83,9 +67,8 @@
        */
       public static Test suite()
       {
  -        ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestJetspeedPortletDescriptor.class);
  -        suite.setScript("org/apache/jetspeed/tools/pamanager/containers/pa-container.groovy");
  -        return suite;
  +        // All methods starting with "test" will be executed in the test suite.
  +        return new TestSuite(TestJetspeedPortletDescriptor.class);
       }
       
       public void testLoadPortletApplicationTree() throws Exception
  
  
  

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