weaver      2004/06/10 13:07:34

  Modified:    
components/registry/src/test/org/apache/jetspeed/components/portletentity
                        TestPortletEntityAccessComponent.java
  Log:
  changed some of the test logic to include testing of the fragment-based logic now
  in place.
  
  Revision  Changes    Path
  1.7       +34 -14    
jakarta-jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityAccessComponent.java
  
  Index: TestPortletEntityAccessComponent.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityAccessComponent.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestPortletEntityAccessComponent.java     5 Jun 2004 05:11:18 -0000       1.6
  +++ TestPortletEntityAccessComponent.java     10 Jun 2004 20:07:34 -0000      1.7
  @@ -27,13 +27,16 @@
   import org.apache.jetspeed.components.portletregistry.PortletRegistryComponentImpl;
   import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
   import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
  +import org.apache.jetspeed.om.page.Fragment;
   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.util.JetspeedObjectID;
   import org.apache.pluto.om.portlet.PortletApplicationDefinition;
  -import org.apache.pluto.om.portlet.PortletDefinition;
   import org.apache.pluto.om.portlet.PortletDefinitionList;
  +import org.jmock.Mock;
  +import org.jmock.core.matcher.InvokeAtLeastOnceMatcher;
  +import org.jmock.core.stub.ReturnStub;
   
   /**
    * Test Portlet Entity Accessor
  @@ -58,10 +61,10 @@
       protected void setUp() throws Exception
       {        
           super.setUp();
  -    
  -            entityAccess = new PortletEntityAccessComponentImpl(persistenceStore);
  -            registry = new PortletRegistryComponentImpl(persistenceStore);
  -        
  +
  +        registry = new PortletRegistryComponentImpl(persistenceStore);
  +        entityAccess = new PortletEntityAccessComponentImpl(persistenceStore, 
registry);
  +
           setupTestData();                   
       }
   
  @@ -102,29 +105,44 @@
           System.out.println("pa = " + pa.getId());
           PortletDefinitionList portlets = pa.getPortletDefinitionList(); 
//.get(JetspeedObjectID.createFromString(TEST_PORTLET));
           Iterator pi = portlets.iterator();
  -        PortletDefinition pd = null;
  +        PortletDefinitionComposite pd = null;
           while (pi.hasNext())
           {
  -            pd = (PortletDefinition)pi.next();
  +            pd = (PortletDefinitionComposite)pi.next();
               assertTrue("Portlet Def not found", 
pd.getName().equals("EntityTestPortlet"));
           }
           assertNotNull("Portlet Def is null", pd);
  -        MutablePortletEntity entity = entityAccess.newPortletEntityInstance(pd);
  -        entity.setId(TEST_ENTITY);
  +        
  +        
  +        
  +        Mock mockf1 = new Mock(Fragment.class);
  +        mockf1.expects(new InvokeAtLeastOnceMatcher()).method("getName").will(new 
ReturnStub(pd.getUniqueName()));
  +        mockf1.expects(new InvokeAtLeastOnceMatcher()).method("getId").will(new 
ReturnStub(TEST_ENTITY));
  +        Fragment f1 =(Fragment) mockf1.proxy();
  +            
  +        MutablePortletEntity entity = entityAccess.generateEntityFromFragment(f1);
  +
           entityAccess.storePortletEntity(entity);
           
  -        MutablePortletEntity entity2 = 
entityAccess.getPortletEntity(JetspeedObjectID.createFromString(TEST_ENTITY));
  +        MutablePortletEntity entity2 = entityAccess.getPortletEntityForFragment(f1);
           assertTrue("entity id ", entity2.getId().toString().equals(TEST_ENTITY));
           assertNotNull("entity's portlet ", entity2.getPortletDefinition());
  +        mockf1.verify();
  +        
  +        
  +        Mock mockf2 = new Mock(Fragment.class);
  +        mockf2.expects(new InvokeAtLeastOnceMatcher()).method("getName").will(new 
ReturnStub(pd.getUniqueName()));
  +        Fragment f2 =(Fragment) mockf2.proxy();
           
           MutablePortletEntity entity5 = entityAccess.newPortletEntityInstance(pd);
  +        
           System.out.println("before storing entity: "  + entity5.getId());
           
  -        //entity.setId(TEST_ENTITY);
           entityAccess.storePortletEntity(entity5);
  -        System.out.println("store done: " + entity5.getId());        
  +        System.out.println("store done: " + entity5.getId());  
  +        mockf2.expects(new InvokeAtLeastOnceMatcher()).method("getId").will(new 
ReturnStub( entity5.getId().toString()));
   
  -        MutablePortletEntity entity6 = 
entityAccess.getPortletEntity(entity5.getId());
  +        MutablePortletEntity entity6 = entityAccess.getPortletEntityForFragment(f2);
           assertNotNull(entity6);
           System.out.println("reget : " + entity6.getId());        
           
  @@ -191,5 +209,7 @@
           store.getTransaction().commit();              
   
       }
  +    
  +    
       
   }
  
  
  

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

Reply via email to