public void testLoadPortletApplicationTree() throws Exception
{
System.out.println("Testing loadPortletApplicationTree");
PortletApplicationDescriptor pad = new PortletApplicationDescriptor(new FileReader("./test/testdata/deploy/portlet.xml"), "unit-test");
MutablePortletApplication app = pad.createPortletApplication();
assertNotNull("App is null", app);
assertNotNull("Version is null", app.getVersion());
assertTrue("Version invalid: " + app.getVersion(), app.getVersion().equals("1.0"));
assertNotNull("PA Identifier is null", app.getApplicationIdentifier());
assertTrue(
"PA Identifier invalid: " + app.getApplicationIdentifier(),
app.getApplicationIdentifier().equals("TestRegistry"));
ExtendedPortletMetadata md = new ExtendedPortletMetadata(new FileReader("./test/testdata/deploy/jetspeed-portlet.xml"), app);
md.load();
PortletDefinitionComposite def1 = (PortletDefinitionComposite)app.getPortletDefinitionByName(PORTLET_01);
PortletDefinitionComposite def2 = (PortletDefinitionComposite)app.getPortletDefinitionByName(PORTLET_02);
PortletDefinitionComposite def3 = (PortletDefinitionComposite)app.getPortletDefinitionByName(PORTLET_03);
PortletDefinitionComposite def4 = (PortletDefinitionComposite)app.getPortletDefinitionByName(PORTLET_04);
Collection titles = app.getMetadata().getFields("title");
Collection def1Titles = def1.getMetadata().getFields("title");
Collection def2Subjects = def2.getMetadata().getFields("subject");
Collection def3Creators = def3.getMetadata().getFields("creator");
Collection def4Field1 = def4.getMetadata().getFields("field1");
Collection def4Fiels2 = def4.getMetadata().getFields("field2");
String securityRef = app.getJetspeedSecurityConstraint();
assertEquals(titles.size(), 3);
assertEquals(def1Titles.size(), 4);
assertEquals(def2Subjects.size(), 5);
assertEquals(def3Creators.size(), 4);
assertEquals(def4Field1.size(), 3);
assertEquals(def4Fiels2.size(), 2);
// Security Constraints tests
assertEquals(securityRef, "admin-only");
assertEquals(def1.getJetspeedSecurityConstraint(), "users-1");
assertEquals(def2.getJetspeedSecurityConstraint(), "users-2");
assertEquals(def3.getJetspeedSecurityConstraint(), "users-4");
assertNull(def4.getJetspeedSecurityConstraint());
Collection servicesCollection = app.getJetspeedServices();
assertNotNull("Metadata services is null", servicesCollection);
assertEquals("Expected 2 service definitions", servicesCollection.size(), 2);
Object[] services = servicesCollection.toArray();
JetspeedServiceReference service = (JetspeedServiceReference)services[0];
System.out.println("**** service = " + service.getName());