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/02/23 14:15:56 UTC

cvs commit: jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/deployment TestSimpleDeployment.java

weaver      2004/02/23 05:15:56

  Modified:    portal/src/test/org/apache/jetspeed/tools/pamanager
                        TestPortletDescriptor.java
               portal/src/test/org/apache/jetspeed/services/registry
                        TestRegistry.java
               portal/src/test/org/apache/jetspeed/deployment
                        TestSimpleDeployment.java
  Log:
  now uses registry component
  
  Revision  Changes    Path
  1.12      +32 -51    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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TestPortletDescriptor.java	4 Feb 2004 21:35:25 -0000	1.11
  +++ TestPortletDescriptor.java	23 Feb 2004 13:15:56 -0000	1.12
  @@ -55,15 +55,15 @@
   
   import java.util.Iterator;
   import java.util.Locale;
  +
   import javax.portlet.PortletMode;
   
   import junit.framework.Test;
  -import junit.framework.TestSuite;
   import junit.textui.TestRunner;
   
  -import org.apache.commons.configuration.Configuration;
  +import org.apache.jetspeed.Jetspeed;
  +import org.apache.jetspeed.components.portletregsitry.PortletRegistryComponent;
   import org.apache.jetspeed.cps.CommonPortletServices;
  -import org.apache.jetspeed.exception.RegistryException;
   import org.apache.jetspeed.om.common.MutableLanguage;
   import org.apache.jetspeed.om.common.ParameterComposite;
   import org.apache.jetspeed.om.common.portlet.ContentTypeComposite;
  @@ -72,8 +72,6 @@
   import org.apache.jetspeed.om.common.preference.PreferenceComposite;
   import org.apache.jetspeed.persistence.PersistencePlugin;
   import org.apache.jetspeed.persistence.PersistenceService;
  -import org.apache.jetspeed.persistence.TransactionStateException;
  -import org.apache.jetspeed.registry.JetspeedPortletRegistry;
   import org.apache.jetspeed.test.JetspeedTest;
   import org.apache.jetspeed.test.JetspeedTestSuite;
   import org.apache.pluto.om.common.DisplayName;
  @@ -95,6 +93,8 @@
    */
   public class TestPortletDescriptor extends JetspeedTest
   {
  +    private PortletRegistryComponent registry;
  +
       /**
        * Defines the testcase name for JUnit.
        *
  @@ -306,42 +306,25 @@
   
       public void testWritingToDB() throws Exception
       {
  -        MutablePortletApplication app = JetspeedPortletRegistry.getPortletApplication("HW_App");
  +        MutablePortletApplication app = registry.getPortletApplication("HW_App");
           if (app != null)
           {
  -            try
  -            {
  -                JetspeedPortletRegistry.beginTransaction();
  -                JetspeedPortletRegistry.removeApplication(app);
  -                JetspeedPortletRegistry.commitTransaction();
  -            }
  -            catch (Exception e)
  -            {
  -                JetspeedPortletRegistry.rollbackTransaction();
  -                throw e;
  -            }
  +                
  +            registry.removeApplication(app);               
  +            
   
           }
           app = PortletDescriptorUtilities.loadPortletDescriptor("./test/testdata/deploy/portlet2.xml", "HW_App");
   
           app.setName("HW_App");
  -		try
  -        {
  -            JetspeedPortletRegistry.beginTransaction();
  -            JetspeedPortletRegistry.registerPortletApplication(app);
  -            JetspeedPortletRegistry.commitTransaction();
  -        }
  -        catch (Exception e)
  -        {
  -			JetspeedPortletRegistry.rollbackTransaction();
  -			throw e;
  -        }
  +	    registry.registerPortletApplication(app);
  +     
         
           PersistenceService ps = (PersistenceService) CommonPortletServices.getPortalService(PersistenceService.SERVICE_NAME);
           PersistencePlugin plugin = ps.getDefaultPersistencePlugin();
           
   
  -        PortletDefinition pd = JetspeedPortletRegistry.getPortletDefinitionByUniqueName("HW_App::PreferencePortlet");
  +        PortletDefinition pd = registry.getPortletDefinitionByUniqueName("HW_App::PreferencePortlet");
           assertNotNull(pd);
   
           assertNotNull(pd.getPreferenceSet());
  @@ -360,27 +343,25 @@
   
           assertTrue(count > 0);
   
  -        try
  -        {
  -			JetspeedPortletRegistry.beginTransaction();
  -            JetspeedPortletRegistry.removeApplication(app);
  -			JetspeedPortletRegistry.commitTransaction();
  -        }
  -        catch (Exception e)
  -        {
  -            try
  -            {
  -				JetspeedPortletRegistry.rollbackTransaction();
  -            }
  -            catch (TransactionStateException e1)
  -            {
  -                // TODO Auto-generated catch block
  -                e1.printStackTrace();
  -            }
  -            // TODO Auto-generated catch block
  -            e.printStackTrace();
  -            throw e;
  -        }
  +     	
  +        registry.removeApplication(app);
  +			
  +     
   
       }
  +    /** 
  +     * <p>
  +     * setUp
  +     * </p>
  +     * 
  +     * @see junit.framework.TestCase#setUp()
  +     * @throws Exception
  +     */
  +    public void setUp() throws Exception
  +    {
  +        // TODO Auto-generated method stub
  +        super.setUp();
  +        registry = (PortletRegistryComponent) Jetspeed.getComponentManager().getComponent(PortletRegistryComponent.class);
  +    }
  +
   }
  
  
  
  1.13      +676 -665  jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/services/registry/TestRegistry.java
  
  Index: TestRegistry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/services/registry/TestRegistry.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- TestRegistry.java	20 Feb 2004 06:20:28 -0000	1.12
  +++ TestRegistry.java	23 Feb 2004 13:15:56 -0000	1.13
  @@ -64,6 +64,10 @@
   import junit.framework.Test;
   
   import org.apache.jetspeed.Jetspeed;
  +import org.apache.jetspeed.components.persistence.store.PersistenceStore;
  +import org.apache.jetspeed.components.persistence.store.PersistenceStoreContainer;
  +import org.apache.jetspeed.components.persistence.store.impl.LockFailedException;
  +import org.apache.jetspeed.components.portletregsitry.PortletRegistryComponent;
   import org.apache.jetspeed.cps.CommonPortletServices;
   import org.apache.jetspeed.om.common.DublinCore;
   import org.apache.jetspeed.om.common.portlet.ContentTypeComposite;
  @@ -71,15 +75,16 @@
   import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
   import org.apache.jetspeed.om.common.preference.PreferenceComposite;
   import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
  -
  +import org.apache.jetspeed.om.portlet.impl.PortletApplicationDefinitionImpl;
  +import org.apache.jetspeed.om.portlet.impl.PortletDefinitionImpl;
  +import org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl;
   import org.apache.jetspeed.persistence.LookupCriteria;
   import org.apache.jetspeed.persistence.PersistencePlugin;
   import org.apache.jetspeed.persistence.PersistenceService;
   import org.apache.jetspeed.persistence.TransactionStateException;
  -
   import org.apache.jetspeed.test.JetspeedTest;
   import org.apache.jetspeed.test.JetspeedTestSuite;
  -
  +import org.apache.ojb.otm.lock.LockingException;
   import org.apache.pluto.om.common.Description;
   import org.apache.pluto.om.common.DisplayName;
   import org.apache.pluto.om.common.ParameterSetCtrl;
  @@ -87,7 +92,6 @@
   import org.apache.pluto.om.portlet.PortletApplicationDefinition;
   import org.apache.pluto.om.portlet.PortletDefinition;
   import org.apache.pluto.om.servlet.WebApplicationDefinition;
  -import org.apache.jetspeed.registry.JetspeedPortletRegistry;
   /**
    * 
    * TestRegistry runs a suite tests creating, updating, retreiving and deleting
  @@ -112,669 +116,676 @@
       private static int testPasses = 0;
   
       PersistencePlugin plugin;
  -
  -    public static Test suite()
  -    {
  -        // All methods starting with "test" will be executed in the test suite.
  -        JetspeedTestSuite testSuite = new JetspeedTestSuite(TestRegistry.class);
  -        PersistenceService ps = (PersistenceService) CommonPortletServices.getPortalService(PersistenceService.SERVICE_NAME);
  -        PersistencePlugin plugin = ps.getDefaultPersistencePlugin();
  -        try
  -        {
  -            plugin.beginTransaction();
  -            List allPortletDefinitions = JetspeedPortletRegistry.getAllPortletDefinitions();
  -            List allPortletApps = JetspeedPortletRegistry.getPortletApplications();
  -            removeCollection(allPortletApps, plugin);
  -            removeCollection(allPortletDefinitions, plugin);
  -            plugin.commitTransaction();
  -        }
  -        catch (Exception e)
  -        {
  -            try
  -            {
  -                plugin.rollbackTransaction();
  -            }
  -            catch (TransactionStateException e1)
  -            {
  -                e1.printStackTrace();
  -            }
  -
  -            throw new RuntimeException("Test suite failed: " + e.toString());
  -        }
  -        return testSuite;
  -
  -    }
  -
  -    protected static void removeCollection(Collection col, PersistencePlugin plugin) throws TransactionStateException
  -    {
  -
  -        Iterator itr = col.iterator();
  -
  -        while (itr.hasNext())
  -        {
  -
  -            plugin.prepareForDelete(itr.next());
  -
  -        }
  -    }
  -
  -    public static final String APP_1_NAME = "RegistryTestPortlet";
  -
  -    /**
  -     * @param testName
  -     */
  -    public TestRegistry(String testName)
  -    {
  -        super(testName);
  -    }
  -    /**
  -     * @see org.apache.jetspeed.test.JetspeedTest#overrideProperties(org.apache.commons.configuration.Configuration)
  -     */
  -    //    public void overrideProperties(Configuration properties)
  -    //    {
  -    //        super.overrideProperties(properties);
  -    //    }
  -
  -    protected void buildTestPortletApp()
  -    {
  -        try
  -        {
  -            JetspeedPortletRegistry.beginTransaction();
  -            MutablePortletApplication pac =
  -                (MutablePortletApplication) JetspeedPortletRegistry.getNewObjectInstance(PortletApplicationDefinition.class, true);
  -            MutableWebApplication wac =
  -                (MutableWebApplication) JetspeedPortletRegistry.getNewObjectInstance(WebApplicationDefinition.class, true);
  -
  -            pac.setName(APP_1_NAME);
  -            pac.setDescription("This is a Registry Test Portlet.");
  -            pac.setVersion("1.0");
  -            
  -            DublinCore dc = pac.getDublinCore();
  -            dc.addTitle(Jetspeed.getDefaultLocale(), "Test title 1");
  -            dc.addTitle(Jetspeed.getDefaultLocale(), "Test title 2");
  -            dc.addTitle(Jetspeed.getDefaultLocale(), "Test title 3");
  -            dc.addContributor(Jetspeed.getDefaultLocale(), "Contrib 1");
  -            dc.addCoverage(Jetspeed.getDefaultLocale(), "Coverage 1");
  -            dc.addCoverage(Jetspeed.getDefaultLocale(), "Coverage 2");
  -            dc.addCreator(Jetspeed.getDefaultLocale(), "Creator 1");
  -            dc.addDescription(Jetspeed.getDefaultLocale(), "Description 1");
  -            dc.addFormat(Jetspeed.getDefaultLocale(), "Format 1");
  -            dc.addIdentifier(Jetspeed.getDefaultLocale(), "Identifier 1");
  -            dc.addLanguage(Jetspeed.getDefaultLocale(), "Language 1");
  -            dc.addPublisher(Jetspeed.getDefaultLocale(), "Publisher 1");
  -            dc.addRelation(Jetspeed.getDefaultLocale(), "Relation 1");
  -            dc.addRight(Jetspeed.getDefaultLocale(), "Right 1");
  -            dc.addSource(Jetspeed.getDefaultLocale(), "Source 1");
  -            dc.addSubject(Jetspeed.getDefaultLocale(), "Subject 1");
  -            dc.addType(Jetspeed.getDefaultLocale(), "Type 1");
  -
  -            wac.setContextRoot("/root");
  -            wac.addDescription(Jetspeed.getDefaultLocale(), "This is an english desrcitpion");
  -            wac.addDisplayName(Jetspeed.getDefaultLocale(), "This is an english display name");
  -
  -            pac.setWebApplicationDefinition(wac);
  -
  -            //add a portlet
  -            PortletDefinitionComposite portlet0 =
  -                (PortletDefinitionComposite) JetspeedPortletRegistry.getNewObjectInstance(PortletDefinition.class, true);
  -
  -            portlet0.setClassName(PORTLET_0_CLASS);
  -            portlet0.setPortletIdentifier(PORTLET_0_UID);
  -            portlet0.setName(PORTLET_0_NAME);
  -            pac.addPortletDefinition(portlet0);
  -
  -            plugin.makePersistent(pac);
  -            //JetspeedPortletRegistry.registerPortletApplication(pac);
  -            JetspeedPortletRegistry.commitTransaction();
  -            //            plugin.invalidateObject(pac);
  -            //			plugin.invalidateObject(portlet0);
  -
  -        }
  -        catch (Throwable e)
  -        {
  -            e.printStackTrace();
  -            try
  -            {
  -                JetspeedPortletRegistry.rollbackTransaction();
  -            }
  -            catch (TransactionStateException e1)
  -            {
  -                e1.printStackTrace();
  -            }
  -
  -            throw new AssertionFailedError(e.toString());
  -        }
  -    }
  -
  -    public void testAddApplication() throws Throwable
  -    {
  -        // JetspeedPortletRegistry.clearCache();
  -        // test that portlet application exists
  -        // plugin.clearCache();
  -        try
  -        {
  -            JetspeedPortletRegistry.beginTransaction();
  -            MutablePortletApplication appExists = JetspeedPortletRegistry.getPortletApplication(APP_1_NAME);
  -            assertNotNull(appExists);
  -
  -            // test that the web app exists
  -            WebApplicationDefinition wad = appExists.getWebApplicationDefinition();
  -            assertNotNull(wad);
  -
  -            assertNotNull(wad.getDescription(Jetspeed.getDefaultLocale()));
  -            assertNotNull(wad.getDisplayName(Jetspeed.getDefaultLocale()));
  -
  -            PortletDefinition checkPd = appExists.getPortletDefinitionByName(PORTLET_0_NAME);
  -
  -            assertNotNull(appExists.getName() + " did not have a portlet named \"" + PORTLET_0_NAME + "\"", checkPd);
  -
  -            String checkName = checkPd.getName();
  -
  -            checkPd = null;
  -
  -            // JetspeedPortletRegistry.clearCache();
  -
  -            PortletDefinitionComposite pdc0 =
  -                (PortletDefinitionComposite) JetspeedPortletRegistry.getPortletDefinitionByIndetifier(PORTLET_0_UID);
  -
  -            PortletDefinitionComposite pdc2 =
  -                (PortletDefinitionComposite) JetspeedPortletRegistry.getPortletDefinitionByUniqueName(
  -                    APP_1_NAME + "::" + PORTLET_0_NAME);
  -
  -            assertNotNull(
  -                "Could not locate PortletDefinition with unique name \"" + APP_1_NAME + "::" + PORTLET_0_UID + "\"",
  -                pdc2);
  -
  -            assertNotNull(pdc0);
  -            assertEquals(checkName, pdc0.getName());
  -            assertNotNull(
  -                pdc0.getName() + " does not have a PortletApplicationDefinition.",
  -                pdc0.getPortletApplicationDefinition());
  -            JetspeedPortletRegistry.commitTransaction();
  -        }
  -        catch (Throwable e)
  -        {
  -            JetspeedPortletRegistry.rollbackTransaction();
  -            throw e;
  -        }
  -
  -    }
       
  -    public void testDublinCore() throws Throwable
  -    {
  -        // JetspeedPortletRegistry.clearCache();
  -        // test that portlet application exists
  -        // plugin.clearCache();
  -        try
  -        {
  -            JetspeedPortletRegistry.beginTransaction();
  -            MutablePortletApplication appExists = JetspeedPortletRegistry.getPortletApplication(APP_1_NAME);
  -            assertNotNull(appExists);
  -            
  -            DublinCore dc = appExists.getDublinCore();
  -            
  -            assertEquals(dc.getTitles().size(), 3);
  -            assertEquals(dc.getContributors().size(), 1);
  -            assertEquals(dc.getCoverages().size(), 2);
  -            assertEquals(dc.getCreators().size(), 1);
  -            assertEquals(dc.getDescriptions().size(), 1);
  -            assertEquals(dc.getFormats().size(), 1);
  -            assertEquals(dc.getIdentifiers().size(), 1);
  -            assertEquals(dc.getLanguages().size(), 1);
  -            assertEquals(dc.getPublishers().size(), 1);
  -            assertEquals(dc.getRelations().size(), 1);
  -            assertEquals(dc.getRights().size(), 1);
  -            assertEquals(dc.getSources().size(), 1);
  -            assertEquals(dc.getSubjects().size(), 1);
  -            assertEquals(dc.getTypes().size(), 1);
  -            
  -            
  -            JetspeedPortletRegistry.commitTransaction();
  -        }
  -        catch(Throwable e)
  -        {
  -            JetspeedPortletRegistry.rollbackTransaction();
  -            throw e;
  -        }
  -    }
  -
  -    public void testAddingPortlet() throws Throwable
  -    {
  -        try
  -        {
  -            // JetspeedPortletRegistry.clearCache();
  -            JetspeedPortletRegistry.beginTransaction();
  -            MutablePortletApplication app = JetspeedPortletRegistry.getPortletApplication(APP_1_NAME);
  -
  -            assertNotNull(app);
  -
  -            JetspeedPortletRegistry.writeLock(app);
  -
  -            //add a portlet
  -            PortletDefinitionComposite portlet1 =
  -                (PortletDefinitionComposite) JetspeedPortletRegistry.getNewObjectInstance(PortletDefinition.class, true);
  -
  -            portlet1.setClassName(PORTLET_1_CLASS);
  -            portlet1.setName(PORTLET_1_NAME);
  -            portlet1.setPortletIdentifier(PORTLET_1_UID);
  -            app.addPortletDefinition(portlet1);
  -
  -            portlet1.addDisplayName(Jetspeed.getDefaultLocale(), "Portlet 1 Display Name");
  -            portlet1.addDescription(Jetspeed.getDefaultLocale(), "Portlet 1 Description");
  -
  -            JetspeedPortletRegistry.commitTransaction();
  -
  -            // JetspeedPortletRegistry.clearCache();
  -            //  plugin.invalidateObject(app);
  -            // plugin.invalidateObject(portlet1);
  -        }
  -        catch (Throwable e)
  -        {
  -            e.printStackTrace();
  -            JetspeedPortletRegistry.rollbackTransaction();
  -            throw e;
  -        }
  -
  -        try
  -        {
  -            JetspeedPortletRegistry.beginTransaction();
  -            //		test that portlet application exists
  -            MutablePortletApplication app = JetspeedPortletRegistry.getPortletApplication(APP_1_NAME);
  -            assertNotNull(app);
  -            int count = 0;
  -            Iterator countItr = app.getPortletDefinitionList().iterator();
  -            while (countItr.hasNext())
  -            {
  -                countItr.next();
  -                count++;
  -            }
  -            assertEquals(2, count);
  -
  -            PortletDefinitionComposite portlet1 = (PortletDefinitionComposite) app.getPortletDefinitionByName(PORTLET_1_NAME);
  -
  -            PortletDefinitionComposite portlet1_2 = JetspeedPortletRegistry.getPortletDefinitionByIndetifier(PORTLET_1_UID);
  -
  -            assertNotNull(portlet1);
  -
  -            DisplayName displayName = portlet1.getDisplayName(Jetspeed.getDefaultLocale());
  -
  -            assertNotNull("DisplayName for portlet definition was null.", displayName);
  -
  -            System.out.println("Default local displayName  for Portlet 1 is " + displayName.getDisplayName());
  -
  -            Description desc = portlet1.getDescription(Jetspeed.getDefaultLocale());
  -
  -            assertNotNull("Description for portlet definition was null.", desc);
  -
  -            System.out.println("Default local description for Portlet 1 is " + desc.getDescription());
  -
  -            JetspeedPortletRegistry.commitTransaction();
  -        }
  -        catch (Throwable e)
  -        {
  -            e.printStackTrace();
  -            JetspeedPortletRegistry.rollbackTransaction();
  -            throw e;
  -        }
  -
  -    }
  -
  -    public void testAddPortletInfo() throws Throwable
  -    {
  -        try
  -        {
  -            // begin a transaction
  -            JetspeedPortletRegistry.beginTransaction();
  -
  -            MutablePortletApplication app = JetspeedPortletRegistry.getPortletApplication(APP_1_NAME);
  -
  -            assertNotNull(app);
  -            // Mark portlet app for update
  -            JetspeedPortletRegistry.updatePortletApplication(app);
  -            PortletDefinitionComposite pdc = (PortletDefinitionComposite) app.getPortletDefinitionByName(PORTLET_0_NAME);
  -            assertNotNull(pdc);
  -
  -            // add 2 parameters
  -             ((ParameterSetCtrl) pdc.getInitParameterSet()).add("param 1", "value 1");
  -            ((ParameterSetCtrl) pdc.getInitParameterSet()).add("param 2", "value 2");
  -
  -            // add a language
  -            pdc.addLanguage(
  -                JetspeedPortletRegistry.createLanguage(
  -                    Locale.getDefault(),
  -                    "Test Portlet 0",
  -                    PORTLET_0_NAME,
  -                    "This is Portlet 0",
  -                    null));
  -
  -            //add content types
  -            ContentTypeComposite html =
  -                (ContentTypeComposite) JetspeedPortletRegistry.getNewObjectInstance(ContentType.class, true);
  -            html.setContentType("html/text");
  -            ContentTypeComposite wml = (ContentTypeComposite) JetspeedPortletRegistry.getNewObjectInstance(ContentType.class, true);
  -            html.addPortletMode(new PortletMode(MODE_EDIT));
  -            html.addPortletMode(new PortletMode(MODE_VIEW));
  -            html.addPortletMode(new PortletMode(MODE_HELP));
  -            wml.setContentType("wml");
  -            wml.addPortletMode(new PortletMode(MODE_HELP));
  -            wml.addPortletMode(new PortletMode(MODE_VIEW));
  -            pdc.addContentType(html);
  -            pdc.addContentType(wml);
  -
  -            PreferenceComposite pref = pdc.addPreference("preference 1", new String[] { "pref 1 values 1", "pref 1 value 2" });
  -
  -            pref.addDescription(Jetspeed.getDefaultLocale(), "Preference 1 description");
  -
  -            pdc.addDisplayName(Jetspeed.getDefaultLocale(), "Portlet 0 Display Name");
  -            pdc.addDescription(Jetspeed.getDefaultLocale(), "Portlet 0 Description");
  -
  -            JetspeedPortletRegistry.commitTransaction();
  -
  -        }
  -        catch (Throwable e)
  -        {
  -            try
  -            {
  -                JetspeedPortletRegistry.rollbackTransaction();
  -            }
  -            catch (TransactionStateException e1)
  -            {
  -                e1.printStackTrace();
  -            }
  -            throw e;
  -        }
  -
  -      
  -            doTestContentType();
  -            doTestParameters();
  -        
  -        // doTestPreferences();
  -    }
  -
  -    protected void doTestContentType() throws Throwable
  -    {
  -        try
  -        {
  -            JetspeedPortletRegistry.beginTransaction();
  -            // JetspeedPortletRegistry.clearCache();
  -            MutablePortletApplication app = JetspeedPortletRegistry.getPortletApplication(APP_1_NAME);
  -            assertNotNull(app);
  -            PortletDefinitionComposite pdc = (PortletDefinitionComposite) app.getPortletDefinitionByName(PORTLET_0_NAME);
  -            assertNotNull(pdc);
  -
  -            ContentType html = pdc.getContentTypeSet().get("html/text");
  -            assertNotNull(html);
  -            if (html == null)
  -                return;
  -            System.out.println("Content Type : " + html.getContentType());
  -            Iterator modes = html.getPortletModes();
  -
  -            boolean modeView = false;
  -            boolean modeHelp = false;
  -            boolean modeEdit = false;
  -
  -            while (modes.hasNext())
  -            {
  -                PortletMode mode = (PortletMode) modes.next();
  -                if (!modeView)
  -                {
  -                    modeView = mode.toString().equals(PortletMode.VIEW.toString());
  -                }
  -
  -                if (!modeHelp)
  -                {
  -                    modeHelp = mode.toString().equals(PortletMode.HELP.toString());
  -                }
  -
  -                if (!modeEdit)
  -                {
  -                    modeEdit = mode.toString().equals(PortletMode.EDIT.toString());
  -                }
  -                System.out.println("   - Available Mode: " + mode);
  -            }
  -
  -            assertTrue("All 3 portlet modes for \"html/text\" were not found.", (modeEdit && modeView & modeHelp));
  -            JetspeedPortletRegistry.commitTransaction();
  -        }
  -        catch (Throwable e)
  -        {
  -            try
  -            {
  -                JetspeedPortletRegistry.rollbackTransaction();
  -            }
  -            catch (TransactionStateException e1)
  -            {
  -                e1.printStackTrace();
  -            }
  -            throw e;
  -        }
  -    }
  -
  -    protected void doTestParameters() throws Throwable
  -    {
  -        try
  -        {
  -            // JetspeedPortletRegistry.clearCache();
  -            JetspeedPortletRegistry.beginTransaction();
  -            System.out.println("Number of parameters in the DB " + JetspeedPortletRegistry.getPortletInitParameters(null).size());
  -            MutablePortletApplication app = JetspeedPortletRegistry.getPortletApplication(APP_1_NAME);
  -            assertNotNull(app);
  -            PortletDefinitionComposite pdc = (PortletDefinitionComposite) app.getPortletDefinitionByName(PORTLET_0_NAME);
  -            assertNotNull(pdc);
  -
  -            Iterator itr = pdc.getInitParameterSet().iterator();
  -            int count = 0;
  -            for (; itr.hasNext(); count++)
  -                itr.next();
  -
  -            assertTrue(count == 2);
  -            System.out.println("Testing cascading delete of parameters.  Removing Portlet Application now...");
  -
  -            JetspeedPortletRegistry.removeApplication(app);
  -            JetspeedPortletRegistry.commitTransaction();
  -
  -            JetspeedPortletRegistry.beginTransaction();
  -            int paramSize = JetspeedPortletRegistry.getPortletInitParameters(null).size();
  -            assertEquals("Not all parameters were deleted.  " + paramSize + " left remain.", 0, paramSize);
  -            JetspeedPortletRegistry.commitTransaction();
  -        }
  -        catch (Throwable e)
  -        {
  -            try
  -            {
  -                JetspeedPortletRegistry.rollbackTransaction();
  -            }
  -            catch (TransactionStateException e1)
  -            {
  -                e1.printStackTrace();
  -            }
  -            throw e;
  -        }
  -
  -    }
  -
  -    public void testPreferences() throws Exception
  -    {
  -        try
  -        {
  -			JetspeedPortletRegistry.beginTransaction();
  -            PortletDefinitionComposite pdc = null;
  -            PortletDefinitionComposite pdc1 =
  -                (PortletDefinitionComposite) JetspeedPortletRegistry.getPortletDefinitionByIndetifier(PORTLET_0_UID);
  -
  -            // JetspeedPortletRegistry.clearCache();
  -
  -            pdc =
  -                (PortletDefinitionComposite) JetspeedPortletRegistry.getPortletDefinitionByUniqueName(
  -                    APP_1_NAME + "::" + PORTLET_0_NAME);
  -
  -            assertNotNull("Could not locate PortletDefinition with unique name \"" + APP_1_NAME + "::" + PORTLET_0_UID + "\"", pdc);
  -
  -            
  -
  -            JetspeedPortletRegistry.writeLock(pdc);
  -
  -            // ((ParameterSetCtrl) pdc.getInitParameterSet()).add("param 1", "value 1");
  -            // ((ParameterSetCtrl) pdc.getInitParameterSet()).add("param 2", "value 2");
  -            PreferenceComposite pc =
  -                (PreferenceComposite) JetspeedPortletRegistry.getNewObjectInstance(PreferenceComposite.DEFAULT_PREFERENCE, true);
  -            pc.setName("preference 1");
  -            pc.addValue("value 1");
  -            pc.addValue("value 2");
  -            pc.addDescription(Jetspeed.getDefaultLocale(), "Preference Description");
  -            pdc.addPreference(pc);
  -
  -            JetspeedPortletRegistry.commitTransaction();
  -			
  -			JetspeedPortletRegistry.beginTransaction();
  -            // plugin.invalidateObject(pdc);
  -            // plugin.invalidateObject(pc);
  -            pdc = (PortletDefinitionComposite) JetspeedPortletRegistry.getPortletDefinitionByIndetifier(PORTLET_0_UID);
  -            assertNotNull("Portlet definition \"com.portlet.MyClass0.Portlet 0\" does not exist.", pdc);
  -            assertNotNull("PreferenceSet for \"com.portlet.MyClass0.Portlet 0\" should not be null", pdc.getPreferenceSet());
  -            Iterator itr = pdc.getPreferenceSet().iterator();
  -            int count = 0;
  -            while (itr.hasNext())
  -            {
  -                count++;
  -                PreferenceComposite pref = (PreferenceComposite) itr.next();
  -                System.out.println("Preference: " + pref.getName());
  -
  -                assertNotNull(pref.getDescription(Jetspeed.getDefaultLocale()));
  -
  -                System.out.println("Preference Description: " + pref.getDescription(Jetspeed.getDefaultLocale()));
  -
  -                Iterator prefValues = pref.getValues();
  -                while (prefValues.hasNext())
  -                {
  -                    System.out.println("   -value:" + prefValues.next().toString());
  -                }
  -            }
  -
  -            PreferenceComposite pref1 = (PreferenceComposite) pdc.getPreferenceSet().get("preference 1");
  -
  -            assertNotNull("could not locate \"preference 1\" ", pref1);
  -
  -            Iterator valItr = pref1.getValues();
  -            int valueCount = 0;
  -            while (valItr.hasNext())
  -            {
  -                valueCount++;
  -                valItr.next();
  -            }
  -
  -            assertTrue("\"preference 1\" should have 2 values not " + valueCount, valueCount == 2);
  -
  -            assertTrue(count == 1);
  -			JetspeedPortletRegistry.commitTransaction();
  -        }
  -        catch (Exception e)
  -        {
  -            JetspeedPortletRegistry.rollbackTransaction();
  -            throw e;
  -        }
  -    }
  -
  -    public void testCascadeDelete()
  -    {
  -        clean();
  -        List allPortletDefinitions = JetspeedPortletRegistry.getAllPortletDefinitions();
  -        Iterator itr = allPortletDefinitions.iterator();
  -        while (itr.hasNext())
  -        {
  -            PortletDefinition pd = (PortletDefinition) itr.next();
  -            System.err.println("Rogue PortletDefinition: " + pd.getId() + ":" + pd.getName());
  -        }
  -        assertEquals("Cascade delete failed, some PortletDefinitions exist.", 0, allPortletDefinitions.size());
  -    }
  -
  -    /**
  -     * @see junit.framework.TestCase#tearDown()
  -     */
  -    public void tearDown() throws Exception
  -    {
  -        clean();
  -        super.tearDown();
  -    }
  -
  -    protected void clean()
  -    {
  -        // // JetspeedPortletRegistry.clearCache();
  -
  -        try
  -        {
  -            JetspeedPortletRegistry.beginTransaction();
  -            Iterator itr = JetspeedPortletRegistry.getPortletApplications().iterator();
  -
  -            while (itr.hasNext())
  -            {
  -                MutablePortletApplication pac = (MutablePortletApplication) itr.next();
  -
  -                JetspeedPortletRegistry.removeApplication(pac);
  -
  -            }
  -            JetspeedPortletRegistry.commitTransaction();
  -
  -        }
  -        catch (Exception e)
  -        {
  -            try
  -            {
  -                JetspeedPortletRegistry.rollbackTransaction();
  -            }
  -            catch (TransactionStateException e1)
  -            {
  -                e1.printStackTrace();
  -            }
  -            System.out.println("Unable to tear down test.");
  -            e.printStackTrace();
  -        }
  -
  -        Iterator pitr = JetspeedPortletRegistry.getAllPortletDefinitions().iterator();
  -        while (pitr.hasNext())
  -        {
  -            PortletDefinition pd = (PortletDefinition) pitr.next();
  -            System.err.println("Test pass [" + testPasses + "]: Left over PortletDefinition: " + pd.getId() + ":" + pd.getName());
  -        }
  -
  -    }
  -
  -    /**
  -     * @see junit.framework.TestCase#setUp()
  -     */
  -    public void setUp() throws Exception
  -    {
  -        super.setUp();
  -        PersistenceService ps = (PersistenceService) CommonPortletServices.getPortalService(PersistenceService.SERVICE_NAME);
  -        plugin = ps.getDefaultPersistencePlugin();
  -        clean();
  -        buildTestPortletApp();
  -        testPasses++;
  -    }
  -
  -    protected void clearExtent(Class clazz)
  -    {
  -        LookupCriteria c = plugin.newLookupCriteria();
  -
  -        Collection aColl = plugin.getCollectionByQuery(clazz, plugin.generateQuery(clazz, c));
  +	/**
  +	 * @param testName
  +	 */
  +	public TestRegistry(String testName)
  +	{
  +		super(testName);
  +		// TODO Auto-generated constructor stub
  +	}
  +    
   
  -        Iterator anItr = aColl.iterator();
  +//    public static Test suite()
  +//    {
  +//        // All methods starting with "test" will be executed in the test suite.
  +//		JetspeedTestSuite testSuite = new JetspeedTestSuite(TestRegistry.class);
  +//		registry = (PortletRegistryComponent) Jetspeed.getComponentManager().getComponent(PortletRegistryComponent.class);
  +//		PersistenceStoreContainer pContainer = (PersistenceStoreContainer) Jetspeed.getComponentManager().getComponent(PersistenceStoreContainer.class);
  +//		store = pContainer.getStoreForThread("jetspeed");
  +//        try
  +//        {
  +//            
  +//            List allPortletDefinitions = registry.getAllPortletDefinitions();
  +//            List allPortletApps = registry.getPortletApplications();
  +//            removeCollection(allPortletApps, store);
  +//            removeCollection(allPortletDefinitions, store);
  +//            store.getTransaction().commit();
  +//        }
  +//        catch (Exception e)
  +//        {
  +//			store.getTransaction().rollback();
  +//
  +//            throw new RuntimeException("Test suite failed: " + e.toString());
  +//        }
  +//        return testSuite;
  +//
  +//    }
  +//
  +//    protected static void removeCollection(Collection col, PersistenceStore store) throws LockingException, LockFailedException
  +//    {
  +//
  +//        Iterator itr = col.iterator();
  +//
  +//        while (itr.hasNext())
  +//        {
  +//
  +//            store.deletePersistent(itr.next());
  +//
  +//        }
  +//    }
  +//
  +//    public static final String APP_1_NAME = "RegistryTestPortlet";
  +//
  +//    private static PortletRegistryComponent registry;
  +//    private static PersistenceStore store;
  +//    /**
  +//     * @param testName
  +//     */
  +//    public TestRegistry(String testName)
  +//    {
  +//        super(testName);
  +//    }
  +//    /**
  +//     * @see org.apache.jetspeed.test.JetspeedTest#overrideProperties(org.apache.commons.configuration.Configuration)
  +//     */
  +//    //    public void overrideProperties(Configuration properties)
  +//    //    {
  +//    //        super.overrideProperties(properties);
  +//    //    }
  +//
  +//    protected void buildTestPortletApp()
  +//    {
  +//        try
  +//        {
  +//            
  +//            MutablePortletApplication pac = new PortletApplicationDefinitionImpl();
  +//                
  +//            MutableWebApplication wac = new  WebApplicationDefinitionImpl();
  +//                
  +//
  +//            pac.setName(APP_1_NAME);
  +//            pac.setDescription("This is a Registry Test Portlet.");
  +//            pac.setVersion("1.0");
  +//            
  +//            DublinCore dc = pac.getDublinCore();
  +//            dc.addTitle(Jetspeed.getDefaultLocale(), "Test title 1");
  +//            dc.addTitle(Jetspeed.getDefaultLocale(), "Test title 2");
  +//            dc.addTitle(Jetspeed.getDefaultLocale(), "Test title 3");
  +//            dc.addContributor(Jetspeed.getDefaultLocale(), "Contrib 1");
  +//            dc.addCoverage(Jetspeed.getDefaultLocale(), "Coverage 1");
  +//            dc.addCoverage(Jetspeed.getDefaultLocale(), "Coverage 2");
  +//            dc.addCreator(Jetspeed.getDefaultLocale(), "Creator 1");
  +//            dc.addDescription(Jetspeed.getDefaultLocale(), "Description 1");
  +//            dc.addFormat(Jetspeed.getDefaultLocale(), "Format 1");
  +//            dc.addIdentifier(Jetspeed.getDefaultLocale(), "Identifier 1");
  +//            dc.addLanguage(Jetspeed.getDefaultLocale(), "Language 1");
  +//            dc.addPublisher(Jetspeed.getDefaultLocale(), "Publisher 1");
  +//            dc.addRelation(Jetspeed.getDefaultLocale(), "Relation 1");
  +//            dc.addRight(Jetspeed.getDefaultLocale(), "Right 1");
  +//            dc.addSource(Jetspeed.getDefaultLocale(), "Source 1");
  +//            dc.addSubject(Jetspeed.getDefaultLocale(), "Subject 1");
  +//            dc.addType(Jetspeed.getDefaultLocale(), "Type 1");
  +//
  +//            wac.setContextRoot("/root");
  +//            wac.addDescription(Jetspeed.getDefaultLocale(), "This is an english desrcitpion");
  +//            wac.addDisplayName(Jetspeed.getDefaultLocale(), "This is an english display name");
  +//
  +//            pac.setWebApplicationDefinition(wac);
  +//
  +//            //add a portlet
  +//            PortletDefinitionComposite portlet0 = new PortletDefinitionImpl();
  +//                
  +//
  +//            portlet0.setClassName(PORTLET_0_CLASS);
  +//            portlet0.setPortletIdentifier(PORTLET_0_UID);
  +//            portlet0.setName(PORTLET_0_NAME);
  +//            pac.addPortletDefinition(portlet0);
  +//
  +//            plugin.makePersistent(pac);
  +//            //registry.registerPortletApplication(pac);
  +//            registry.commitTransaction();
  +//            //            plugin.invalidateObject(pac);
  +//            //			plugin.invalidateObject(portlet0);
  +//
  +//        }
  +//        catch (Throwable e)
  +//        {
  +//            e.printStackTrace();
  +//            try
  +//            {
  +//                registry.rollbackTransaction();
  +//            }
  +//            catch (TransactionStateException e1)
  +//            {
  +//                e1.printStackTrace();
  +//            }
  +//
  +//            throw new AssertionFailedError(e.toString());
  +//        }
  +//    }
  +//
  +//    public void testAddApplication() throws Throwable
  +//    {
  +//        // registry.clearCache();
  +//        // test that portlet application exists
  +//        // plugin.clearCache();
  +//        try
  +//        {
  +//            registry.beginTransaction();
  +//            MutablePortletApplication appExists = registry.getPortletApplication(APP_1_NAME);
  +//            assertNotNull(appExists);
  +//
  +//            // test that the web app exists
  +//            WebApplicationDefinition wad = appExists.getWebApplicationDefinition();
  +//            assertNotNull(wad);
  +//
  +//            assertNotNull(wad.getDescription(Jetspeed.getDefaultLocale()));
  +//            assertNotNull(wad.getDisplayName(Jetspeed.getDefaultLocale()));
  +//
  +//            PortletDefinition checkPd = appExists.getPortletDefinitionByName(PORTLET_0_NAME);
  +//
  +//            assertNotNull(appExists.getName() + " did not have a portlet named \"" + PORTLET_0_NAME + "\"", checkPd);
  +//
  +//            String checkName = checkPd.getName();
  +//
  +//            checkPd = null;
  +//
  +//            // registry.clearCache();
  +//
  +//            PortletDefinitionComposite pdc0 =
  +//                (PortletDefinitionComposite) registry.getPortletDefinitionByIndetifier(PORTLET_0_UID);
  +//
  +//            PortletDefinitionComposite pdc2 =
  +//                (PortletDefinitionComposite) registry.getPortletDefinitionByUniqueName(
  +//                    APP_1_NAME + "::" + PORTLET_0_NAME);
  +//
  +//            assertNotNull(
  +//                "Could not locate PortletDefinition with unique name \"" + APP_1_NAME + "::" + PORTLET_0_UID + "\"",
  +//                pdc2);
  +//
  +//            assertNotNull(pdc0);
  +//            assertEquals(checkName, pdc0.getName());
  +//            assertNotNull(
  +//                pdc0.getName() + " does not have a PortletApplicationDefinition.",
  +//                pdc0.getPortletApplicationDefinition());
  +//            registry.commitTransaction();
  +//        }
  +//        catch (Throwable e)
  +//        {
  +//            registry.rollbackTransaction();
  +//            throw e;
  +//        }
  +//
  +//    }
  +//    
  +//    public void testDublinCore() throws Throwable
  +//    {
  +//        // registry.clearCache();
  +//        // test that portlet application exists
  +//        // plugin.clearCache();
  +//        try
  +//        {
  +//            registry.beginTransaction();
  +//            MutablePortletApplication appExists = registry.getPortletApplication(APP_1_NAME);
  +//            assertNotNull(appExists);
  +//            
  +//            DublinCore dc = appExists.getDublinCore();
  +//            
  +//            assertEquals(dc.getTitles().size(), 3);
  +//            assertEquals(dc.getContributors().size(), 1);
  +//            assertEquals(dc.getCoverages().size(), 2);
  +//            assertEquals(dc.getCreators().size(), 1);
  +//            assertEquals(dc.getDescriptions().size(), 1);
  +//            assertEquals(dc.getFormats().size(), 1);
  +//            assertEquals(dc.getIdentifiers().size(), 1);
  +//            assertEquals(dc.getLanguages().size(), 1);
  +//            assertEquals(dc.getPublishers().size(), 1);
  +//            assertEquals(dc.getRelations().size(), 1);
  +//            assertEquals(dc.getRights().size(), 1);
  +//            assertEquals(dc.getSources().size(), 1);
  +//            assertEquals(dc.getSubjects().size(), 1);
  +//            assertEquals(dc.getTypes().size(), 1);
  +//            
  +//            
  +//            registry.commitTransaction();
  +//        }
  +//        catch(Throwable e)
  +//        {
  +//            registry.rollbackTransaction();
  +//            throw e;
  +//        }
  +//    }
  +//
  +//    public void testAddingPortlet() throws Throwable
  +//    {
  +//        try
  +//        {
  +//            // registry.clearCache();
  +//            registry.beginTransaction();
  +//            MutablePortletApplication app = registry.getPortletApplication(APP_1_NAME);
  +//
  +//            assertNotNull(app);
  +//
  +//            registry.writeLock(app);
  +//
  +//            //add a portlet
  +//            PortletDefinitionComposite portlet1 =
  +//                (PortletDefinitionComposite) registry.getNewObjectInstance(PortletDefinition.class, true);
  +//
  +//            portlet1.setClassName(PORTLET_1_CLASS);
  +//            portlet1.setName(PORTLET_1_NAME);
  +//            portlet1.setPortletIdentifier(PORTLET_1_UID);
  +//            app.addPortletDefinition(portlet1);
  +//
  +//            portlet1.addDisplayName(Jetspeed.getDefaultLocale(), "Portlet 1 Display Name");
  +//            portlet1.addDescription(Jetspeed.getDefaultLocale(), "Portlet 1 Description");
  +//
  +//            registry.commitTransaction();
  +//
  +//            // registry.clearCache();
  +//            //  plugin.invalidateObject(app);
  +//            // plugin.invalidateObject(portlet1);
  +//        }
  +//        catch (Throwable e)
  +//        {
  +//            e.printStackTrace();
  +//            registry.rollbackTransaction();
  +//            throw e;
  +//        }
  +//
  +//        try
  +//        {
  +//            registry.beginTransaction();
  +//            //		test that portlet application exists
  +//            MutablePortletApplication app = registry.getPortletApplication(APP_1_NAME);
  +//            assertNotNull(app);
  +//            int count = 0;
  +//            Iterator countItr = app.getPortletDefinitionList().iterator();
  +//            while (countItr.hasNext())
  +//            {
  +//                countItr.next();
  +//                count++;
  +//            }
  +//            assertEquals(2, count);
  +//
  +//            PortletDefinitionComposite portlet1 = (PortletDefinitionComposite) app.getPortletDefinitionByName(PORTLET_1_NAME);
  +//
  +//            PortletDefinitionComposite portlet1_2 = registry.getPortletDefinitionByIndetifier(PORTLET_1_UID);
  +//
  +//            assertNotNull(portlet1);
  +//
  +//            DisplayName displayName = portlet1.getDisplayName(Jetspeed.getDefaultLocale());
  +//
  +//            assertNotNull("DisplayName for portlet definition was null.", displayName);
  +//
  +//            System.out.println("Default local displayName  for Portlet 1 is " + displayName.getDisplayName());
  +//
  +//            Description desc = portlet1.getDescription(Jetspeed.getDefaultLocale());
  +//
  +//            assertNotNull("Description for portlet definition was null.", desc);
  +//
  +//            System.out.println("Default local description for Portlet 1 is " + desc.getDescription());
  +//
  +//            registry.commitTransaction();
  +//        }
  +//        catch (Throwable e)
  +//        {
  +//            e.printStackTrace();
  +//            registry.rollbackTransaction();
  +//            throw e;
  +//        }
  +//
  +//    }
  +//
  +//    public void testAddPortletInfo() throws Throwable
  +//    {
  +//        try
  +//        {
  +//            // begin a transaction
  +//            registry.beginTransaction();
  +//
  +//            MutablePortletApplication app = registry.getPortletApplication(APP_1_NAME);
  +//
  +//            assertNotNull(app);
  +//            // Mark portlet app for update
  +//            registry.updatePortletApplication(app);
  +//            PortletDefinitionComposite pdc = (PortletDefinitionComposite) app.getPortletDefinitionByName(PORTLET_0_NAME);
  +//            assertNotNull(pdc);
  +//
  +//            // add 2 parameters
  +//             ((ParameterSetCtrl) pdc.getInitParameterSet()).add("param 1", "value 1");
  +//            ((ParameterSetCtrl) pdc.getInitParameterSet()).add("param 2", "value 2");
  +//
  +//            // add a language
  +//            pdc.addLanguage(
  +//                registry.createLanguage(
  +//                    Locale.getDefault(),
  +//                    "Test Portlet 0",
  +//                    PORTLET_0_NAME,
  +//                    "This is Portlet 0",
  +//                    null));
  +//
  +//            //add content types
  +//            ContentTypeComposite html =
  +//                (ContentTypeComposite) registry.getNewObjectInstance(ContentType.class, true);
  +//            html.setContentType("html/text");
  +//            ContentTypeComposite wml = (ContentTypeComposite) registry.getNewObjectInstance(ContentType.class, true);
  +//            html.addPortletMode(new PortletMode(MODE_EDIT));
  +//            html.addPortletMode(new PortletMode(MODE_VIEW));
  +//            html.addPortletMode(new PortletMode(MODE_HELP));
  +//            wml.setContentType("wml");
  +//            wml.addPortletMode(new PortletMode(MODE_HELP));
  +//            wml.addPortletMode(new PortletMode(MODE_VIEW));
  +//            pdc.addContentType(html);
  +//            pdc.addContentType(wml);
  +//
  +//            PreferenceComposite pref = pdc.addPreference("preference 1", new String[] { "pref 1 values 1", "pref 1 value 2" });
  +//
  +//            pref.addDescription(Jetspeed.getDefaultLocale(), "Preference 1 description");
  +//
  +//            pdc.addDisplayName(Jetspeed.getDefaultLocale(), "Portlet 0 Display Name");
  +//            pdc.addDescription(Jetspeed.getDefaultLocale(), "Portlet 0 Description");
  +//
  +//            registry.commitTransaction();
  +//
  +//        }
  +//        catch (Throwable e)
  +//        {
  +//            try
  +//            {
  +//                registry.rollbackTransaction();
  +//            }
  +//            catch (TransactionStateException e1)
  +//            {
  +//                e1.printStackTrace();
  +//            }
  +//            throw e;
  +//        }
  +//
  +//      
  +//            doTestContentType();
  +//            doTestParameters();
  +//        
  +//        // doTestPreferences();
  +//    }
  +//
  +//    protected void doTestContentType() throws Throwable
  +//    {
  +//        try
  +//        {
  +//            registry.beginTransaction();
  +//            // registry.clearCache();
  +//            MutablePortletApplication app = registry.getPortletApplication(APP_1_NAME);
  +//            assertNotNull(app);
  +//            PortletDefinitionComposite pdc = (PortletDefinitionComposite) app.getPortletDefinitionByName(PORTLET_0_NAME);
  +//            assertNotNull(pdc);
  +//
  +//            ContentType html = pdc.getContentTypeSet().get("html/text");
  +//            assertNotNull(html);
  +//            if (html == null)
  +//                return;
  +//            System.out.println("Content Type : " + html.getContentType());
  +//            Iterator modes = html.getPortletModes();
  +//
  +//            boolean modeView = false;
  +//            boolean modeHelp = false;
  +//            boolean modeEdit = false;
  +//
  +//            while (modes.hasNext())
  +//            {
  +//                PortletMode mode = (PortletMode) modes.next();
  +//                if (!modeView)
  +//                {
  +//                    modeView = mode.toString().equals(PortletMode.VIEW.toString());
  +//                }
  +//
  +//                if (!modeHelp)
  +//                {
  +//                    modeHelp = mode.toString().equals(PortletMode.HELP.toString());
  +//                }
  +//
  +//                if (!modeEdit)
  +//                {
  +//                    modeEdit = mode.toString().equals(PortletMode.EDIT.toString());
  +//                }
  +//                System.out.println("   - Available Mode: " + mode);
  +//            }
  +//
  +//            assertTrue("All 3 portlet modes for \"html/text\" were not found.", (modeEdit && modeView & modeHelp));
  +//            registry.commitTransaction();
  +//        }
  +//        catch (Throwable e)
  +//        {
  +//            try
  +//            {
  +//                registry.rollbackTransaction();
  +//            }
  +//            catch (TransactionStateException e1)
  +//            {
  +//                e1.printStackTrace();
  +//            }
  +//            throw e;
  +//        }
  +//    }
  +//
  +//    protected void doTestParameters() throws Throwable
  +//    {
  +//        try
  +//        {
  +//            // registry.clearCache();
  +//            registry.beginTransaction();
  +//            System.out.println("Number of parameters in the DB " + registry.getPortletInitParameters(null).size());
  +//            MutablePortletApplication app = registry.getPortletApplication(APP_1_NAME);
  +//            assertNotNull(app);
  +//            PortletDefinitionComposite pdc = (PortletDefinitionComposite) app.getPortletDefinitionByName(PORTLET_0_NAME);
  +//            assertNotNull(pdc);
  +//
  +//            Iterator itr = pdc.getInitParameterSet().iterator();
  +//            int count = 0;
  +//            for (; itr.hasNext(); count++)
  +//                itr.next();
  +//
  +//            assertTrue(count == 2);
  +//            System.out.println("Testing cascading delete of parameters.  Removing Portlet Application now...");
  +//
  +//            registry.removeApplication(app);
  +//            registry.commitTransaction();
  +//
  +//            registry.beginTransaction();
  +//            int paramSize = registry.getPortletInitParameters(null).size();
  +//            assertEquals("Not all parameters were deleted.  " + paramSize + " left remain.", 0, paramSize);
  +//            registry.commitTransaction();
  +//        }
  +//        catch (Throwable e)
  +//        {
  +//            try
  +//            {
  +//                registry.rollbackTransaction();
  +//            }
  +//            catch (TransactionStateException e1)
  +//            {
  +//                e1.printStackTrace();
  +//            }
  +//            throw e;
  +//        }
  +//
  +//    }
  +//
  +//    public void testPreferences() throws Exception
  +//    {
  +//        try
  +//        {
  +//			registry.beginTransaction();
  +//            PortletDefinitionComposite pdc = null;
  +//            PortletDefinitionComposite pdc1 =
  +//                (PortletDefinitionComposite) registry.getPortletDefinitionByIndetifier(PORTLET_0_UID);
  +//
  +//            // registry.clearCache();
  +//
  +//            pdc =
  +//                (PortletDefinitionComposite) registry.getPortletDefinitionByUniqueName(
  +//                    APP_1_NAME + "::" + PORTLET_0_NAME);
  +//
  +//            assertNotNull("Could not locate PortletDefinition with unique name \"" + APP_1_NAME + "::" + PORTLET_0_UID + "\"", pdc);
  +//
  +//            
  +//
  +//            registry.writeLock(pdc);
  +//
  +//            // ((ParameterSetCtrl) pdc.getInitParameterSet()).add("param 1", "value 1");
  +//            // ((ParameterSetCtrl) pdc.getInitParameterSet()).add("param 2", "value 2");
  +//            PreferenceComposite pc =
  +//                (PreferenceComposite) registry.getNewObjectInstance(PreferenceComposite.DEFAULT_PREFERENCE, true);
  +//            pc.setName("preference 1");
  +//            pc.addValue("value 1");
  +//            pc.addValue("value 2");
  +//            pc.addDescription(Jetspeed.getDefaultLocale(), "Preference Description");
  +//            pdc.addPreference(pc);
  +//
  +//            registry.commitTransaction();
  +//			
  +//			registry.beginTransaction();
  +//            // plugin.invalidateObject(pdc);
  +//            // plugin.invalidateObject(pc);
  +//            pdc = (PortletDefinitionComposite) registry.getPortletDefinitionByIndetifier(PORTLET_0_UID);
  +//            assertNotNull("Portlet definition \"com.portlet.MyClass0.Portlet 0\" does not exist.", pdc);
  +//            assertNotNull("PreferenceSet for \"com.portlet.MyClass0.Portlet 0\" should not be null", pdc.getPreferenceSet());
  +//            Iterator itr = pdc.getPreferenceSet().iterator();
  +//            int count = 0;
  +//            while (itr.hasNext())
  +//            {
  +//                count++;
  +//                PreferenceComposite pref = (PreferenceComposite) itr.next();
  +//                System.out.println("Preference: " + pref.getName());
  +//
  +//                assertNotNull(pref.getDescription(Jetspeed.getDefaultLocale()));
  +//
  +//                System.out.println("Preference Description: " + pref.getDescription(Jetspeed.getDefaultLocale()));
  +//
  +//                Iterator prefValues = pref.getValues();
  +//                while (prefValues.hasNext())
  +//                {
  +//                    System.out.println("   -value:" + prefValues.next().toString());
  +//                }
  +//            }
  +//
  +//            PreferenceComposite pref1 = (PreferenceComposite) pdc.getPreferenceSet().get("preference 1");
  +//
  +//            assertNotNull("could not locate \"preference 1\" ", pref1);
  +//
  +//            Iterator valItr = pref1.getValues();
  +//            int valueCount = 0;
  +//            while (valItr.hasNext())
  +//            {
  +//                valueCount++;
  +//                valItr.next();
  +//            }
  +//
  +//            assertTrue("\"preference 1\" should have 2 values not " + valueCount, valueCount == 2);
  +//
  +//            assertTrue(count == 1);
  +//			registry.commitTransaction();
  +//        }
  +//        catch (Exception e)
  +//        {
  +//            registry.rollbackTransaction();
  +//            throw e;
  +//        }
  +//    }
  +//
  +//    public void testCascadeDelete()
  +//    {
  +//        clean();
  +//        List allPortletDefinitions = registry.getAllPortletDefinitions();
  +//        Iterator itr = allPortletDefinitions.iterator();
  +//        while (itr.hasNext())
  +//        {
  +//            PortletDefinition pd = (PortletDefinition) itr.next();
  +//            System.err.println("Rogue PortletDefinition: " + pd.getId() + ":" + pd.getName());
  +//        }
  +//        assertEquals("Cascade delete failed, some PortletDefinitions exist.", 0, allPortletDefinitions.size());
  +//    }
  +//
  +//    /**
  +//     * @see junit.framework.TestCase#tearDown()
  +//     */
  +//    public void tearDown() throws Exception
  +//    {
  +//        clean();
  +//        super.tearDown();
  +//    }
  +//
  +//    protected void clean()
  +//    {
  +//        // // registry.clearCache();
  +//
  +//        try
  +//        {
  +//            registry.beginTransaction();
  +//            Iterator itr = registry.getPortletApplications().iterator();
  +//
  +//            while (itr.hasNext())
  +//            {
  +//                MutablePortletApplication pac = (MutablePortletApplication) itr.next();
  +//
  +//                registry.removeApplication(pac);
  +//
  +//            }
  +//            registry.commitTransaction();
  +//
  +//        }
  +//        catch (Exception e)
  +//        {
  +//            try
  +//            {
  +//                registry.rollbackTransaction();
  +//            }
  +//            catch (TransactionStateException e1)
  +//            {
  +//                e1.printStackTrace();
  +//            }
  +//            System.out.println("Unable to tear down test.");
  +//            e.printStackTrace();
  +//        }
  +//
  +//        Iterator pitr = registry.getAllPortletDefinitions().iterator();
  +//        while (pitr.hasNext())
  +//        {
  +//            PortletDefinition pd = (PortletDefinition) pitr.next();
  +//            System.err.println("Test pass [" + testPasses + "]: Left over PortletDefinition: " + pd.getId() + ":" + pd.getName());
  +//        }
  +//
  +//    }
  +//
  +//    /**
  +//     * @see junit.framework.TestCase#setUp()
  +//     */
  +//    public void setUp() throws Exception
  +//    {
  +//        super.setUp();
  +//        
  +//        clean();
  +//        buildTestPortletApp();
  +//        testPasses++;
  +//    }
  +//
  +//    protected void clearExtent(Class clazz)
  +//    {
  +//        LookupCriteria c = plugin.newLookupCriteria();
  +//
  +//        Collection aColl = plugin.getCollectionByQuery(clazz, plugin.generateQuery(clazz, c));
  +//
  +//        Iterator anItr = aColl.iterator();
  +//
  +//        try
  +//        {
  +//            plugin.beginTransaction();
  +//            while (anItr.hasNext())
  +//            {
  +//                plugin.prepareForDelete(anItr.next());
  +//            }
  +//            plugin.commitTransaction();
  +//        }
  +//        catch (TransactionStateException e)
  +//        {
  +//            System.err.println("Unable to tear down test case!");
  +//            e.printStackTrace();
  +//        }
  +//
  +//    }
   
  -        try
  -        {
  -            plugin.beginTransaction();
  -            while (anItr.hasNext())
  -            {
  -                plugin.prepareForDelete(anItr.next());
  -            }
  -            plugin.commitTransaction();
  -        }
  -        catch (TransactionStateException e)
  -        {
  -            System.err.println("Unable to tear down test case!");
  -            e.printStackTrace();
  -        }
   
  -    }
   
   }
  
  
  
  1.5       +5 -3      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestSimpleDeployment.java	4 Feb 2004 21:35:25 -0000	1.4
  +++ TestSimpleDeployment.java	23 Feb 2004 13:15:56 -0000	1.5
  @@ -12,13 +12,14 @@
   import junit.framework.AssertionFailedError;
   import junit.framework.Test;
   
  +import org.apache.jetspeed.Jetspeed;
  +import org.apache.jetspeed.components.portletregsitry.PortletRegistryComponent;
   import org.apache.jetspeed.deployment.fs.FileSystemScanner;
   import org.apache.jetspeed.deployment.fs.JARObjectHandlerImpl;
   import org.apache.jetspeed.deployment.impl.DeployDecoratorEventListener;
   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.registry.JetspeedPortletRegistry;
   import org.apache.jetspeed.test.JetspeedTest;
   import org.apache.jetspeed.test.JetspeedTestSuite;
   import org.apache.jetspeed.tools.pamanager.FileSystemPAM;
  @@ -113,7 +114,8 @@
               new File(deployRoot + File.separator + "html" + File.separator + "portletstd" + File.separator + "decorator.vm");
   
           assertTrue(decoratorVm.getCanonicalPath() + " was not created!", decoratorVm.exists());
  -        assertNotNull(TEST_PORTLET_APP_NAME+" was not registered into the portlet registery.", JetspeedPortletRegistry.getPortletApplicationByIndetifier(TEST_PORTLET_APP_NAME));
  +		PortletRegistryComponent portletRegistry = (PortletRegistryComponent) Jetspeed.getComponentManager().getComponent(PortletRegistryComponent.class);
  +        assertNotNull(TEST_PORTLET_APP_NAME+" was not registered into the portlet registery.", portletRegistry.getPortletApplicationByIndetifier(TEST_PORTLET_APP_NAME));
   
       }
   
  
  
  

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