portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pau...@apache.org
Subject cvs commit: jakarta-jetspeed/webapp/WEB-INF/psml/test testcaseMarshall.psml
Date Wed, 24 Jul 2002 03:00:42 GMT
paulsp      2002/07/23 20:00:42

  Modified:    src/java/org/apache/jetspeed/services/psmlmanager
                        TestMarshalPsml.java
               webapp/WEB-INF/psml/test testcaseMarshall.psml
  Log:
  Add tests for PSML MetaInfo
  
  Revision  Changes    Path
  1.10      +95 -5     jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/TestMarshalPsml.java
  
  Index: TestMarshalPsml.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/TestMarshalPsml.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestMarshalPsml.java	23 Jul 2002 04:54:36 -0000	1.9
  +++ TestMarshalPsml.java	24 Jul 2002 03:00:42 -0000	1.10
  @@ -54,12 +54,12 @@
   
   package org.apache.jetspeed.services.psmlmanager;
   
  +// Java imports
   import java.io.File;
   import java.io.FileReader;
   import java.io.Writer;
   import java.io.FileWriter;
   import java.io.IOException;
  -
   import java.util.Iterator;
   import java.util.Vector;
   
  @@ -76,16 +76,28 @@
   import org.exolab.castor.mapping.Mapping;
   import org.exolab.castor.mapping.MappingException;
   import org.xml.sax.InputSource;
  +
   // serialization support
   import org.apache.xml.serialize.Serializer;
   import org.apache.xml.serialize.XMLSerializer;
   import org.apache.xml.serialize.OutputFormat;
   
  +// Jetspeed imports
   import org.apache.jetspeed.om.SecurityReference;
  -import org.apache.jetspeed.om.profile.*;
  +import org.apache.jetspeed.om.profile.ConfigElement;
  +import org.apache.jetspeed.om.profile.Control;
  +import org.apache.jetspeed.om.profile.Controller;
  +import org.apache.jetspeed.om.profile.Entry;
  +import org.apache.jetspeed.om.profile.Layout;
  +import org.apache.jetspeed.om.profile.MetaInfo;
  +import org.apache.jetspeed.om.profile.Parameter;
  +import org.apache.jetspeed.om.profile.Portlets;
  +import org.apache.jetspeed.om.profile.Reference;
  +import org.apache.jetspeed.om.profile.Skin;
  +import org.apache.jetspeed.om.profile.Security;
   
  +// Turbine imports
   import org.apache.turbine.services.TurbineServices;
  -import org.apache.jetspeed.services.idgenerator.*;
   import org.apache.stratum.configuration.Configuration;
   import org.apache.stratum.configuration.PropertiesConfiguration;
   import org.apache.turbine.util.TurbineConfig;
  @@ -354,7 +366,7 @@
                   assertTrue(ref.getId().equals("300"));
                   Portlets epr = ref.getPortletsReference();
                   assertNotNull(epr);
  -                assertTrue(ref.getPath().equals("group/apache/page/news/media-type/html"));
  +                assertEquals("group/apache/page/news/media-type/html", ref.getPath());
                   assertTrue(epr.getMetaInfo().getTitle().equals("Default Apache News page"));
                   // DST: - TODO: only use 'test' psml for unit tests -
                   // otherwise the tests are against moving targets;
  @@ -577,4 +589,82 @@
           }  
       }
   
  +    public void testMetaInfo() throws Exception 
  +    {
  +        boolean foundEntry07 = false;
  +        boolean foundPortlet02 = false;
  +        
  +        System.out.println("Testing marshalling of PSML on base *** IdentityElement ***");
  +
  +        String psmlFile = "../webapp/WEB-INF/psml/test/testcaseMarshall.psml";
  +
  +        Mapping mapping = null;
  +        String mapFile = getMappingFileName();
  +        File map = new File(mapFile);
  +        if (map.exists() && map.isFile() && map.canRead())
  +        {
  +            try
  +            {
  +                FileReader reader = new FileReader(psmlFile);
  +                mapping = new Mapping();
  +                InputSource is = new InputSource( new FileReader(map) );
  +                is.setSystemId( mapFile );
  +                mapping.loadMapping( is );
  +                System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++");
  +                Unmarshaller unmarshaller = new Unmarshaller(mapping);
  +                Portlets rootset = (Portlets)unmarshaller.unmarshal(reader);
  +                System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++");
  +
  +                assertTrue(rootset.getName().equals("theRootSet"));
  +                assertTrue(rootset.getId().equals("01"));
  +
  +                Iterator itt = rootset.getPortletsIterator();
  +                while (itt.hasNext())
  +                {
  +                    Portlets pp = (Portlets)itt.next();
  +                    System.out.println(" PORTLETS %%% " + pp.getId());
  +                    if ( pp.getId().equals("02"))
  +                    {
  +                        foundPortlet02 = true;
  +                        MetaInfo pp02MetaInfo = pp.getMetaInfo();
  +                        assertNotNull( "Portlet ID 02 has metaInfo", pp02MetaInfo);
  +                        assertEquals( "Portlet ID 02 Title", "Portlet Title", pp02MetaInfo.getTitle());
  +                        assertEquals( "Portlet ID 02 Title", "Portlet Description", pp02MetaInfo.getDescription());
  +                        assertEquals( "Portlet ID 02 Title", "Portlet Image", pp02MetaInfo.getImage());
  +                        Iterator pp02itt = pp.getEntriesIterator();
  +                        while (pp02itt.hasNext())
  +                        {
  +                            Entry pp02Entry = (Entry) pp02itt.next();
  +                            assertNotNull( "Portlet Id 02 has entry", pp02Entry);
  +                            if (pp02Entry.getId().equals("07"))
  +                            {
  +                                foundEntry07 = true;
  +                                MetaInfo entry07MetaInfo = pp02Entry.getMetaInfo();
  +                                assertNotNull( "Entry ID 07 has metaInfo", entry07MetaInfo);
  +                                assertEquals( "Entry ID 07 Title", "Entry Title", entry07MetaInfo.getTitle());
  +                                assertEquals( "Entry ID 07 Title", "Entry Description",
entry07MetaInfo.getDescription());
  +                                assertEquals( "Entry ID 07 Title", "Entry Image", entry07MetaInfo.getImage());
  +                            }
  +                        }
  +                    }
  +                }
  +                assertTrue( "Tested Portlet 02", foundPortlet02);
  +                assertTrue( "Tested Entry 07", foundEntry07);
  +
  +            }
  +            catch (Exception e)
  +            {
  +                String errmsg = "Error in psml mapping creation: " + e.toString();
  +                e.printStackTrace();
  +                System.err.println(errmsg);
  +                assertNotNull(errmsg, null);
  +            }
  +        }
  +        else
  +        {
  +            String errmsg = "PSML Mapping not found or not a file or unreadable: ";
  +            System.err.println(errmsg);
  +            assertNotNull(errmsg, null);
  +        }  
  +    }
   }
  
  
  
  1.2       +12 -4     jakarta-jetspeed/webapp/WEB-INF/psml/test/testcaseMarshall.psml
  
  Index: testcaseMarshall.psml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/psml/test/testcaseMarshall.psml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- testcaseMarshall.psml	6 Apr 2002 01:49:48 -0000	1.1
  +++ testcaseMarshall.psml	24 Jul 2002 03:00:42 -0000	1.2
  @@ -1,16 +1,24 @@
   <?xml version="1.0" encoding="UTF-8"?>
   <portlets id="01" name="theRootSet">
       <portlets id='02' name='test'>
  +        <metainfo>
  +          <title>Portlet Title</title>
  +          <description>Portlet Description</description>
  +          <image>Portlet Image</image>
  +        </metainfo>
           <entry id="07" parent="http://www.xmlhack.com/rsscat.php">
  -            <metainfo/>
  -            <skin/>
  +            <metainfo>
  +                <title>Entry Title</title>
  +                <description>Entry Description</description>
  +                <image>Entry Image</image>
  +            </metainfo>
  +            <skin name="gray"/>
               <layout position="-1" size="-1">
                   <property name="column" value="0"/>
                   <property name="row" value="2"/>
               </layout>
  -            <control/>
           </entry>
       </portlets>       
  -    <reference id='300' name='ReferenceTest' path='group/apache/page/news'/>
  +    <reference id='300' name='ReferenceTest' path='group/apache/page/news/'/>
   
   </portlets>
  
  
  

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


Mime
View raw message