weaver      2004/06/10 13:20:36

  Modified:    portal/src/test/org/apache/jetspeed/deployment
                        TestSimpleDeployment.java
  Log:
  added tests for loading portlets from other classloaders
  
  Revision  Changes    Path
  1.8       +39 -14    
jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/deployment/TestSimpleDeployment.java
  
  Index: TestSimpleDeployment.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/deployment/TestSimpleDeployment.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestSimpleDeployment.java 9 Jun 2004 16:39:05 -0000       1.7
  +++ TestSimpleDeployment.java 10 Jun 2004 20:20:36 -0000      1.8
  @@ -8,6 +8,9 @@
   
   import java.io.File;
   import java.util.HashMap;
  +import java.util.Iterator;
  +
  +import javax.portlet.Portlet;
   
   import junit.framework.AssertionFailedError;
   import junit.framework.Test;
  @@ -20,11 +23,14 @@
   import org.apache.jetspeed.deployment.impl.DeployPortletAppEventListener;
   import org.apache.jetspeed.deployment.simpleregistry.SimpleRegistry;
   import org.apache.jetspeed.deployment.simpleregistry.impl.InMemoryRegistryImpl;
  +import org.apache.jetspeed.factory.JetspeedPortletFactory;
  +import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
   import org.apache.jetspeed.test.JetspeedTest;
   import org.apache.jetspeed.test.JetspeedTestSuite;
   import org.apache.jetspeed.tools.pamanager.FileSystemPAM;
   import org.apache.jetspeed.tools.pamanager.PortletApplicationException;
   import org.apache.jetspeed.util.DirectoryUtils;
  +import org.apache.pluto.om.portlet.PortletDefinition;
   
   /**
    * <p>
  @@ -117,9 +123,27 @@
                PortletRegistryComponent portletRegistry = (PortletRegistryComponent) 
Jetspeed.getComponentManager().getComponent(PortletRegistryComponent.class);
           assertNotNull(TEST_PORTLET_APP_NAME+" was not registered into the portlet 
registery.", portletRegistry.getPortletApplicationByIdentifier(TEST_PORTLET_APP_NAME));
           assertTrue(TEST_PORTLET_APP_NAME+" directory was not created, app not 
deployed.", new File(webAppsDir+"/"+TEST_PORTLET_APP_NAME).exists());
  -        assertNotNull("jetspeed was not registered into the portlet registery.", 
portletRegistry.getPortletApplicationByIdentifier("jetspeed"));
  +        MutablePortletApplication jetspeedApp = 
portletRegistry.getPortletApplicationByIdentifier("jetspeed");
  +        assertNotNull("jetspeed was not registered into the portlet registery.", 
jetspeedApp);
           assertFalse("local app, jetspeed, got deployed when it should have only 
been registered.", new File(webAppsDir+"/jetspeed").exists());
           
  +        //make sure we can load registered app's classed
  +        Iterator portletDefItr =  jetspeedApp.getPortletDefinitions().iterator();
  +        while(portletDefItr.hasNext())
  +        {
  +            PortletDefinition def = (PortletDefinition) portletDefItr.next();
  +            try
  +            {
  +                Portlet portlet = 
JetspeedPortletFactory.loadPortletClass(def.getClassName());
  +                assertNotNull(portlet);
  +            }
  +            catch (Exception e)
  +            {
  +                assertNull("Unable to load registered portlet class, 
"+def.getClassName(), e);
  +            }
  +           
  +        }
  +        
   
       }
   
  @@ -138,13 +162,23 @@
               delpoySrc = new File("./test/deployment/deploy").getCanonicalPath();
               deployRootFile = new File("./test/deployment/templates/decorator");
               deployRoot = deployRootFile.getCanonicalPath();
  -            webAppsDir = new File("./test/deployment/webapps").getCanonicalPath();
  +            File webAppsDirFile = new File("./target/webapps");
  +            
  +            if(!webAppsDirFile.exists())
  +            { 
  +               webAppsDirFile.mkdirs();
  +            }
  +            webAppsDir = webAppsDirFile.getCanonicalPath();
               testDb = new File("./test/db/hsql/Registry").getCanonicalPath();
               // remove any prior left overs
               
                        FileSystemPAM pam = new FileSystemPAM();
                        
  -                     pam.undeploy(webAppsDir, TEST_PORTLET_APP_NAME);        
  +
  +                 pam.undeploy(webAppsDir, TEST_PORTLET_APP_NAME);
  +            pam.unregister(webAppsDir, "jetspeed");
  +            pam.undeploy(webAppsDir, "struts-demo");
  +             
           }
           catch (Exception e)
           {
  @@ -161,16 +195,7 @@
       {
           
           super.tearDown();
  -             FileSystemPAM pam = new FileSystemPAM();
  -             try
  -        {
  -            pam.undeploy(webAppsDir, TEST_PORTLET_APP_NAME);
  -            pam.unregister(webAppsDir, "jetspeed");
  -        }
  -        catch (PortletApplicationException e)
  -        {            
  -            e.printStackTrace();
  -        }
  +             
                
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to