assertNotNull(fragment);
Vector portlets = fragment.getPortlets();
// test abstract
PortletEntry rss = (PortletEntry) portlets.elementAt(1);
assertNotNull(rss);
assertTrue(rss.getName().equals("RSS"));
assertTrue(!rss.isHidden());
assertTrue(rss.getType().equals("abstract"));
assertNull(rss.getParent());
assertTrue(!rss.isApplication());
assertTrue(rss.getClassname().equals("org.apache.jetspeed.portal.portlets.NewRSSPortlet"));
// params
Iterator it = rss.getParameterNames();
HashMap mapParams = new HashMap();
while (it.hasNext())
{
String name = (String) it.next();
Parameter p = rss.getParameter(name);
assertNotNull(p);
//System.out.println("PARAM:" + p.getName() + " = " + p.getValue());
mapParams.put(p.getName(), p);
}
assertTrue(mapParams.containsKey("showtitle"));
assertTrue(mapParams.containsKey("stylesheet"));
assertTrue(mapParams.containsKey("itemdisplayed"));
// test ref
PortletEntry hack = (PortletEntry) portlets.elementAt(2);
assertNotNull(hack);
assertTrue(hack.getName().equals("XMLHack"));
assertTrue(hack.isHidden());
assertTrue(hack.getType().equals("ref"));
assertTrue(hack.getParent().equals("RSS"));
assertTrue(!hack.isApplication());
assertTrue(hack.getTitle().equals("XMLHack Title"));
assertTrue(hack.getDescription().equals("XMLHack Description"));
assertTrue(hack.getMetaInfo().getTitle().equals("XMLHack Title"));
assertTrue(hack.getMetaInfo().getDescription().equals("XMLHack Description"));
assertTrue(hack.getClassname().equals("org.apache.jetspeed.portal.portlets.NewRSSPortlet"));
mapParams.clear();
it = hack.getParameterNames();
while (it.hasNext())
{
String name = (String) it.next();
Parameter p = hack.getParameter(name);
assertNotNull(p);
//System.out.println("HACK PARAM:" + p.getName() + " = " + p.getValue());
mapParams.put(p.getName(), p);
}
assertTrue(mapParams.containsKey("showtitle"));
assertTrue(mapParams.containsKey("stylesheet"));
assertTrue(mapParams.containsKey("itemdisplayed"));
assertTrue(mapParams.containsKey("HACK"));
Parameter p = (Parameter) mapParams.get("HACK");
assertTrue(p.getValue().equals("hacker"));
Parameter p2 = (Parameter) mapParams.get("showtitle");
MetaInfo p2m = p2.getMetaInfo();
assertTrue(p2m.getTitle().equals("Show title description ?"));
assertTrue(p2.getTitle().equals("Show title description ?"));
Map pMap = hack.getParameterMap();
String v15 = (String) pMap.get("itemdisplayed");
assertTrue(v15.equals("15"));
// test falling back on meta info
PortletEntry mp = (PortletEntry) portlets.elementAt(5);
assertNotNull(mp);
assertTrue(mp.getName().equals("MetaTest"));
assertTrue(mp.getType().equals("ref"));
assertTrue(mp.getParent().equals("AdminScreen"));
assertTrue(mp.getClassname().equals("org.apache.jetspeed.portal.portlets.TurbineScreenPortlet"));
String title = mp.getTitle();
assertNotNull(title);
assertTrue(title.equals("Turbine Screen in a portlet"));
assertTrue(mp.getDescription().equals("We put the Admin Screen in a portlet."));
MetaInfo meta = mp.getMetaInfo();
assertNotNull(meta);
assertTrue(mp.getMetaInfo().getTitle().equals("Turbine Screen in a portlet"));
assertTrue(meta.getDescription().equals("We put the Admin Screen in a portlet."));
// media type
Iterator mpi = mp.listMediaTypes();
assertNotNull(mpi);
HashMap mpMap = new HashMap();
while (mpi.hasNext())
{
String s = (String) mpi.next();
mpMap.put(s, s);
}
assertTrue(mpMap.containsKey("html"));
assertTrue(mpMap.containsKey("wml"));
assertTrue(mpMap.containsKey("xml"));
assertTrue(mp.hasMediaType("wml"));
PortletEntry mt = (PortletEntry) portlets.elementAt(6);
assertNotNull(mt);
assertTrue(mt.getName().equals("NoMediaType"));
assertTrue(mt.getType().equals("ref"));
Iterator mti = mt.listMediaTypes();
assertNotNull(mti);
assertTrue(mti.hasNext());
String s = (String) mti.next();
assertTrue(s.equals("html"));
assertTrue(hack.getURL().equals("http://www.xmlhack.com/rss.php"));
assertTrue(hack.isCachedOnURL());
PortletEntry keytest = (PortletEntry) portlets.elementAt(7);
assertNotNull(keytest);
assertTrue(keytest.getName().equals("KeyTest"));
assertTrue(keytest.getType().equals("ref"));
it = keytest.getParameterNames();
mpMap.clear();
while (it.hasNext())
{
String name = (String) it.next();
CachedParameter cp = keytest.getCachedParameter(name);
mpMap.put(cp.getName(), cp);
//System.out.println("param = " + cp.getName() + "," + cp.getValue());
//System.out.println("keys = " + cp.isCachedOnName() + "," + cp.isCachedOnValue());
}
assertTrue(keytest.isCachedOnURL() == false);
CachedParameter cp = (CachedParameter) mpMap.get("newsid");
assertNotNull(cp);
assertTrue(cp.isCachedOnName() == false);
assertTrue(cp.isCachedOnValue() == true);
cp = (CachedParameter) mpMap.get("sportsid");
assertNotNull(cp);
assertTrue(cp.isCachedOnName() == true);
assertTrue(cp.isCachedOnValue() == false);
cp = (CachedParameter) mpMap.get("contact2");
assertNotNull(cp);
assertTrue(cp.isCachedOnName() == true);
assertTrue(cp.isCachedOnValue() == true);
cp = (CachedParameter) mpMap.get("showtitle");
assertNotNull(cp);
assertTrue(cp.isCachedOnName() == true);
assertTrue(cp.isCachedOnValue() == true);
// categories
PortletEntry feeder = (PortletEntry) portlets.elementAt(3);
assertNotNull(feeder);
assertTrue(feeder.getName().equals("Feeder"));
assertTrue(feeder.getType().equals("ref"));
Iterator fi = feeder.listCategories();
Category cat = (Category) fi.next();
assertTrue(cat.getName().equals("news.world.politics"));
assertTrue(cat.getGroup().equals("news"));
assertTrue(feeder.hasCategory("news.world.politics", "news"));
feeder.addCategory("news.us.economy");
assertTrue(feeder.hasCategory("news.us.economy"));
feeder.removeCategory("news.us.economy");
assertTrue(!feeder.hasCategory("news.us.economy"));
/*
Iterator fi = feeder.listCategories();
Category cat = (Category)fi.next();
System.out.println("cat = " + cat.getName());
System.out.println("cat.group = " + cat.getGroup());