portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletregistry AbstractRegistryTest.java TestPortletRegistryDAO.java
Date Fri, 29 Oct 2004 14:06:04 GMT
weaver      2004/10/29 07:06:04

  Modified:    components/registry/src/test/org/apache/jetspeed/components/portletregistry
                        AbstractRegistryTest.java
                        TestPortletRegistryDAO.java
  Log:
  see: http://nagoya.apache.org/jira/browse/JS2-144
  - refactor of registry and entity DAO
  
  Revision  Changes    Path
  1.5       +42 -60    jakarta-jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletregistry/AbstractRegistryTest.java
  
  Index: AbstractRegistryTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletregistry/AbstractRegistryTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractRegistryTest.java	30 Sep 2004 19:42:15 -0000	1.4
  +++ AbstractRegistryTest.java	29 Oct 2004 14:06:04 -0000	1.5
  @@ -1,8 +1,17 @@
   /*
  - * Created on Jun 16, 2004
  - *
  - * TODO To change the template for this generated file go to
  - * Window - Preferences - Java - Code Generation - Code and Comments
  + * 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.components.portletregistry;
   
  @@ -10,18 +19,15 @@
   import java.util.Iterator;
   import java.util.Locale;
   
  -import org.apache.jetspeed.components.persistence.store.Filter;
  -import org.apache.jetspeed.components.persistence.store.LockFailedException;
  -import org.apache.jetspeed.components.persistence.store.util.PersistenceSupportedTestCase;
  +import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
   import org.apache.jetspeed.om.common.DublinCore;
   import org.apache.jetspeed.om.common.GenericMetadata;
  +import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
   import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
   import org.apache.jetspeed.om.impl.DublinCoreImpl;
   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.prefs.impl.PreferencesProviderImpl;
  -import org.apache.jetspeed.prefs.impl.PropertyManagerImpl;
   
   /**
    * @author scott
  @@ -29,7 +35,7 @@
    * TODO To change the template for this generated type comment go to Window -
    * Preferences - Java - Code Generation - Code and Comments
    */
  -public abstract class AbstractRegistryTest extends PersistenceSupportedTestCase 
  +public abstract class AbstractRegistryTest extends DatasourceEnabledSpringTestCase 
   {
       
       protected static final String PORTLET_0_CLASS = "com.portlet.MyClass0";
  @@ -43,27 +49,11 @@
       protected static final String MODE_EDIT = "EDIT";
       public static final String APP_1_NAME = "RegistryTestPortlet";
   
  -    protected PortletRegistryComponentImpl registry;
  +    protected PortletRegistry registry;
       private static int testPasses = 0;
       
   
       /**
  -     *  
  -     */
  -    public AbstractRegistryTest()
  -    {
  -        super();
  -    }
  -
  -    /**
  -     * @param arg0
  -     */
  -    public AbstractRegistryTest( String arg0 )
  -    {
  -        super(arg0);
  -    }
  -
  -    /**
        * <p>
        * setUp
        * </p>
  @@ -74,12 +64,8 @@
       protected void setUp() throws Exception
       {
           super.setUp();
  -        registry = new PortletRegistryComponentImpl(persistenceStore);
  -
  -        PropertyManagerImpl pms = new PropertyManagerImpl(persistenceStore);
  -        PreferencesProviderImpl provider = new PreferencesProviderImpl(persistenceStore,
  -                "org.apache.jetspeed.prefs.impl.PreferencesFactoryImpl", false);
  -        provider.start();
  +        registry = (PortletRegistry) ctx.getBean("portletRegistry");
  +       
           testPasses++;
       }
   
  @@ -116,26 +102,24 @@
           assertEquals(dc.getTypes().size(), 1);
       }
   
  -    protected void invalidate( Object[] objs ) throws LockFailedException
  -    {
  -        persistenceStore.getTransaction().begin();
  -        for (int i = 0; i < objs.length; i++)
  -        {
  -            persistenceStore.invalidate(objs[i]);
  -        }
  -        persistenceStore.getTransaction().commit();
  -    }
  +//    protected void invalidate( Object[] objs ) throws LockFailedException
  +//    {
  +//        persistenceStore.getTransaction().begin();
  +//        for (int i = 0; i < objs.length; i++)
  +//        {
  +//            persistenceStore.invalidate(objs[i]);
  +//        }
  +//        persistenceStore.getTransaction().commit();
  +//    }
   
       protected void verifyData(boolean afterUpdates) throws Exception
       {
  -        PortletApplicationDefinitionImpl app;
  +        MutablePortletApplication app;
           WebApplicationDefinitionImpl webApp;
           PortletDefinitionComposite portlet;
   
  -        // Now makes sure everthing got persisted
  -        persistenceStore.getTransaction().begin();
           app = null;
  -        Filter filter = persistenceStore.newFilter();
  +        
           app = (PortletApplicationDefinitionImpl) registry.getPortletApplication("App_1");
   
           webApp = (WebApplicationDefinitionImpl) app.getWebApplicationDefinition();
  @@ -190,31 +174,29 @@
           assertEquals("\"preference 1\" did not have 2 values.", 2, valueCount);
   
           // Pull out our Web app and add a Description to it
  -        persistenceStore.getTransaction().begin();
  +        
           webApp = null;
  -        filter = persistenceStore.newFilter();
  -        filter.addEqualTo("name", "App_1");
  -        app = (PortletApplicationDefinitionImpl) persistenceStore.getObjectByQuery(persistenceStore.newQuery(
  -                PortletApplicationDefinitionImpl.class, filter));
  -        persistenceStore.lockForWrite(app);
  +        
  +        app = registry.getPortletApplication("App_1");
  +        
           webApp = (WebApplicationDefinitionImpl) app.getWebApplicationDefinition();
           assertNotNull("Web app was not located by query.", webApp);
           webApp.addDescription(Locale.getDefault(), "Web app description");
   
  -        persistenceStore.getTransaction().commit();
   
  -        persistenceStore.getTransaction().begin();
           webApp = null;
  -        filter = persistenceStore.newFilter();
  -        filter.addEqualTo("name", "App_1");
  -        app = (PortletApplicationDefinitionImpl) persistenceStore.getObjectByQuery(persistenceStore.newQuery(
  -                PortletApplicationDefinitionImpl.class, filter));
  -        webApp = (WebApplicationDefinitionImpl) app.getWebApplicationDefinition();
   
  -        persistenceStore.getTransaction().commit();
  +        app = registry.getPortletApplication("App_1");
  +        webApp = (WebApplicationDefinitionImpl) app.getWebApplicationDefinition();
  +        
           assertNotNull("Web app was not located by query.", webApp);
           assertNotNull("Web app did NOT persist its description", webApp.getDescription(Locale.getDefault()));
   
  +    }
  +
  +    protected String[] getConfigurations()
  +    {
  +        return new String[] {"/META-INF/transaction.xml", "/META-INF/registry-dao.xml"};
       }
   
      
  
  
  
  1.2       +21 -9     jakarta-jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletregistry/TestPortletRegistryDAO.java
  
  Index: TestPortletRegistryDAO.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletregistry/TestPortletRegistryDAO.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestPortletRegistryDAO.java	12 Oct 2004 20:12:32 -0000	1.1
  +++ TestPortletRegistryDAO.java	29 Oct 2004 14:06:04 -0000	1.2
  @@ -1,8 +1,17 @@
   /*
  - * Created on Oct 8, 2004
  - *
  - * TODO To change the template for this generated file go to
  - * Window - Preferences - Java - Code Generation - Code and Comments
  + * 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.components.portletregistry;
   
  @@ -14,7 +23,7 @@
   import javax.portlet.PortletMode;
   
   import org.apache.jetspeed.components.persistence.store.LockFailedException;
  -import org.apache.jetspeed.components.util.DatasourceTestCase;
  +import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
   import org.apache.jetspeed.om.common.DublinCore;
   import org.apache.jetspeed.om.common.GenericMetadata;
   import org.apache.jetspeed.om.common.JetspeedServiceReference;
  @@ -35,7 +44,6 @@
   import org.apache.jetspeed.util.JetspeedLocale;
   import org.apache.pluto.om.common.PreferenceSetCtrl;
   import org.apache.pluto.om.portlet.PortletApplicationDefinition;
  -import org.springframework.context.support.ClassPathXmlApplicationContext;
   
   /**
    * <p>
  @@ -48,7 +56,7 @@
    * @version $Id$
    *
    */
  -public class TestPortletRegistryDAO extends  DatasourceTestCase
  +public class TestPortletRegistryDAO extends  DatasourceEnabledSpringTestCase
   {
       public static final String APP_1_NAME = "RegistryTestPortlet";
       protected static final String MODE_EDIT = "EDIT";
  @@ -69,7 +77,7 @@
       protected void setUp() throws Exception
       {
           super.setUp();
  -        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/META-INF/registry-dao.xml");
  +        
   		this.portletRegistry = (PortletRegistry) ctx.getBean("portletRegistry");
   		buildTestData();
   		
  @@ -301,4 +309,8 @@
   
   
   
  +    protected String[] getConfigurations()
  +    {
  +        return new String[] {"/META-INF/transaction.xml", "/META-INF/registry-dao.xml"};
  +    }
   }
  
  
  

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