Author: julien_viet
Date: 2011-09-01 10:42:08 -0400 (Thu, 01 Sep 2011)
New Revision: 7277
Added:
portal/branches/api/component/api-impl/src/test/resources/
portal/branches/api/component/api-impl/src/test/resources/org/
portal/branches/api/component/api-impl/src/test/resources/org/gatein/
portal/branches/api/component/api-impl/src/test/resources/org/gatein/portal/
portal/branches/api/component/api-impl/src/test/resources/org/gatein/portal/api/
portal/branches/api/component/api-impl/src/test/resources/org/gatein/portal/api/impl/
portal/branches/api/component/api-impl/src/test/resources/org/gatein/portal/api/impl/configuration.xml
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/AbstractAPITestCase.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java
Log:
basic unit test for content registry
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-09-01
14:23:07 UTC (rev 7276)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-09-01
14:42:08 UTC (rev 7277)
@@ -34,17 +34,18 @@
import org.gatein.api.content.Portlet;
import org.gatein.api.content.WSRP;
import org.gatein.api.id.Id;
-import org.gatein.api.util.IterableCollection;
import org.gatein.api.util.IterableIdentifiableCollection;
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletInvokerException;
import org.gatein.pc.federation.FederatingPortletInvoker;
import org.gatein.portal.api.impl.GateInImpl;
import org.gatein.portal.api.impl.portal.PortalImpl;
-import org.gatein.portal.api.impl.util.AdaptedIterableCollection;
import org.gatein.portal.api.impl.util.AdaptedIterableIdentifiableCollection;
import org.gatein.portal.api.impl.util.AggregatedIterableIdentifiableCollection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -89,24 +90,18 @@
}
}
- public IterableCollection<String> getCategoryNames()
+ public Set<String> getCategoryNames()
{
try
{
gateIn.begin();
- final List<ApplicationCategory> categories =
gateIn.getRegistryService().getApplicationCategories();
- return new AdaptedIterableCollection<ApplicationCategory,
String>(categories.size(), categories.iterator())
+ List<ApplicationCategory> categories =
gateIn.getRegistryService().getApplicationCategories();
+ HashSet<String> names = new HashSet<String>();
+ for (ApplicationCategory category : categories)
{
- public String adapt(ApplicationCategory old)
- {
- return old.getName();
- }
-
- public boolean contains(String s)
- {
- return doesCategoryExist(s);
- }
- };
+ names.add(category.getName());
+ }
+ return names;
}
catch (Exception e)
{
@@ -118,24 +113,17 @@
}
}
- public IterableIdentifiableCollection<Category> getAllCategories()
+ public Collection<Category> getAllCategories()
{
try
{
gateIn.begin();
- final List<ApplicationCategory> categories =
gateIn.getRegistryService().getApplicationCategories();
- return new AdaptedIterableIdentifiableCollection<ApplicationCategory,
Category>(categories.size(), categories.iterator())
+ List<Category> categories = new ArrayList<Category>();
+ for (ApplicationCategory category :
gateIn.getRegistryService().getApplicationCategories())
{
- public Category adapt(ApplicationCategory old)
- {
- return new CategoryImpl(old, ContentRegistryImpl.this, gateIn);
- }
-
- public boolean contains(Id<Category> t)
- {
- return doesCategoryExist(t.toString());
- }
- };
+ categories.add(new CategoryImpl(category, ContentRegistryImpl.this,
gateIn));
+ }
+ return categories;
}
catch (Exception e)
{
Modified:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/AbstractAPITestCase.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/AbstractAPITestCase.java 2011-09-01
14:23:07 UTC (rev 7276)
+++
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/AbstractAPITestCase.java 2011-09-01
14:42:08 UTC (rev 7277)
@@ -25,7 +25,8 @@
@ConfigurationUnit(scope = ContainerScope.PORTAL, path =
"conf/exo.portal.component.test.jcr-configuration.xml"),
@ConfigurationUnit(scope = ContainerScope.PORTAL, path =
"conf/exo.portal.component.identity-configuration.xml"),
@ConfigurationUnit(scope = ContainerScope.PORTAL, path =
"conf/exo.portal.component.portal-configuration.xml"),
- @ConfigurationUnit(scope = ContainerScope.PORTAL, path =
"conf/exo.portal.component.application-registry-configuration.xml")
+ @ConfigurationUnit(scope = ContainerScope.PORTAL, path =
"conf/exo.portal.component.application-registry-configuration.xml"),
+ @ConfigurationUnit(scope = ContainerScope.PORTAL, path =
"org/gatein/portal/api/impl/configuration.xml")
})
public abstract class AbstractAPITestCase extends AbstractPortalTest
{
Modified:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java 2011-09-01
14:23:07 UTC (rev 7276)
+++
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/content/ContentRegistryTestCase.java 2011-09-01
14:42:08 UTC (rev 7277)
@@ -4,6 +4,9 @@
import org.gatein.api.content.ContentRegistry;
import org.gatein.portal.api.impl.AbstractAPITestCase;
+import java.util.Collections;
+import java.util.Set;
+
/** @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a> */
public class ContentRegistryTestCase extends AbstractAPITestCase
{
@@ -14,10 +17,8 @@
//
ContentRegistry registry = gatein.getDefaultPortal().getContentRegistry();
-
- //
- registry.getCategoryNames();
-
+ Set<String> names = registry.getCategoryNames();
+ assertEquals(Collections.singleton("administration"), names);
}
}
Added:
portal/branches/api/component/api-impl/src/test/resources/org/gatein/portal/api/impl/configuration.xml
===================================================================
---
portal/branches/api/component/api-impl/src/test/resources/org/gatein/portal/api/impl/configuration.xml
(rev 0)
+++
portal/branches/api/component/api-impl/src/test/resources/org/gatein/portal/api/impl/configuration.xml 2011-09-01
14:42:08 UTC (rev 7277)
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+-->
+<configuration
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd
+
http://www.exoplaform.org/xml/ns/kernel_1_2.xsd"
+
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd">
+
+ <external-component-plugins>
+
<target-component>org.exoplatform.application.registry.ApplicationRegistryService</target-component>
+ <component-plugin>
+ <name>new.portal.portlets.registry</name>
+ <set-method>initListener</set-method>
+
<type>org.exoplatform.application.registry.ApplicationCategoriesPlugins</type>
+ <description>this listener init the portlets are registered in
PortletRegister</description>
+ <init-params>
+ <object-param>
+ <name>administration</name>
+ <description>description</description>
+ <object
type="org.exoplatform.application.registry.ApplicationCategory">
+ <field name="name">
+ <string>administration</string>
+ </field>
+ <field name="displayName">
+ <string>administration</string>
+ </field>
+ <field name="description">
+ <string>application for administration</string>
+ </field>
+ <field name="accessPermissions">
+ <collection type="java.util.ArrayList"
item-type="java.lang.String">
+ <value>
+ <string>*:/platform/administrators</string>
+ </value>
+ <value>
+
<string>*:/organization/management/executive-board</string>
+ </value>
+ </collection>
+ </field>
+ <field name="applications">
+ <collection type="java.util.ArrayList">
+ <value>
+ <object
type="org.exoplatform.application.registry.Application">
+ <field name="applicationName">
+ <string>ApplicationRegistryPortlet</string>
+ </field>
+ <field name="categoryName">
+ <string>administration</string>
+ </field>
+ <field name="displayName">
+ <string>Application Registry</string>
+ </field>
+ <field name="description">
+ <string>Application Registry</string>
+ </field>
+ <field name="type">
+ <string>portlet</string>
+ </field>
+ <field name="contentId">
+
<string>exoadmin/ApplicationRegistryPortlet</string>
+ </field>
+ <field name="accessPermissions">
+ <collection type="java.util.ArrayList"
item-type="java.lang.String">
+ <value>
+
<string>*:/platform/administrators</string>
+ </value>
+ <value>
+
<string>*:/organization/management/executive-board</string>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </value>
+ <value>
+ <object
type="org.exoplatform.application.registry.Application">
+ <field name="applicationName">
+ <string>OrganizationPortlet</string>
+ </field>
+ <field name="categoryName">
+ <string>administration</string>
+ </field>
+ <field name="displayName">
+ <string>Organization Management</string>
+ </field>
+ <field name="description">
+ <string>Organization Management</string>
+ </field>
+ <field name="type">
+ <string>portlet</string>
+ </field>
+ <field name="contentId">
+
<string>exoadmin/OrganizationPortlet</string>
+ </field>
+ <field name="accessPermissions">
+ <collection type="java.util.ArrayList"
item-type="java.lang.String">
+ <value>
+
<string>*:/platform/administrators</string>
+ </value>
+ <value>
+
<string>*:/organization/management/executive-board</string>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </value>
+ <value>
+ <object
type="org.exoplatform.application.registry.Application">
+ <field name="applicationName">
+ <string>AccountPortlet</string>
+ </field>
+ <field name="categoryName">
+ <string>administration</string>
+ </field>
+ <field name="displayName">
+ <string>New Account</string>
+ </field>
+ <field name="description">
+ <string>New Account</string>
+ </field>
+ <field name="type">
+ <string>portlet</string>
+ </field>
+ <field name="contentId">
+ <string>exoadmin/AccountPortlet</string>
+ </field>
+ <field name="accessPermissions">
+ <collection type="java.util.ArrayList"
item-type="java.lang.String">
+ <value>
+
<string>*:/platform/administrators</string>
+ </value>
+ <value>
+
<string>*:/organization/management/executive-board</string>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+</configuration>
\ No newline at end of file