JBoss Portal SVN: r11279 - docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: mmcallis
Date: 2008-07-02 20:12:36 -0400 (Wed, 02 Jul 2008)
New Revision: 11279
Modified:
docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/portalapi.xml
Log:
removing unnecessary trademark for "Java"
Modified: docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/portalapi.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/portalapi.xml 2008-07-02 23:29:40 UTC (rev 11278)
+++ docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/portalapi.xml 2008-07-03 00:12:36 UTC (rev 11279)
@@ -414,7 +414,7 @@
On this method we simply filter down to UserAuthenticationEvent then depending on the type of authentication event we update the
counters. <emphasis>counter</emphasis> keeps track of the registered and logged-in users, while counterEver only counts the number of
times people logged-in the portal.</para>
- <para>Now that the <trademark class="trade">Java</trademark> class has been written we need to register it so that it can be called when the events are triggered. To do
+ <para>Now that the Java class has been written we need to register it so that it can be called when the events are triggered. To do
so we need to register it as an MBean. It can be done by editing the sar descriptor file:
<emphasis>YourService.sar/META-INF/jboss-service.xml</emphasis> so that it looks like the following:
<programlisting><![CDATA[
16 years
JBoss Portal SVN: r11278 - docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: mmcallis
Date: 2008-07-02 19:29:40 -0400 (Wed, 02 Jul 2008)
New Revision: 11278
Modified:
docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/supported.xml
Log:
Chapter 1. System Requirements
- content revision
Modified: docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/supported.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/supported.xml 2008-07-02 23:29:12 UTC (rev 11277)
+++ docs/branches/JBoss_Portal_Branch_2_7/referenceGuide/en/modules/supported.xml 2008-07-02 23:29:40 UTC (rev 11278)
@@ -12,7 +12,7 @@
</chapterinfo>
<title>System Requirements</title>
<para>
- The following section details tested, or reported as working by users, hardware and software versions that are compatible with JBoss Portal. Before reporting a problem, make sure you are using compatible hardware and software.
+ The following section details hardware and software versions that are compatible with JBoss Portal. The hardware and software listed has been tested, or reported as working by users. Before reporting a problem, make sure you are using compatible hardware and software.
</para>
<para>
If you successfully installed JBoss Portal on versions not listed here, please let us know so it can be added to this section.
16 years
JBoss Portal SVN: r11277 - in docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en: modules and 1 other directory.
by portal-commits@lists.jboss.org
Author: mmcallis
Date: 2008-07-02 19:29:12 -0400 (Wed, 02 Jul 2008)
New Revision: 11277
Modified:
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/master.xml
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/sso.xml
Log:
- backporting trademark or "JBoss"
- heading for single sign on section (from 2.7)
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/master.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/master.xml 2008-07-02 23:20:49 UTC (rev 11276)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/master.xml 2008-07-02 23:29:12 UTC (rev 11277)
@@ -38,7 +38,7 @@
]>
<book lang="en">
<bookinfo>
- <title>JBoss Portal 2.6.6</title>
+ <title><trademark class="registered">JBoss</trademark> Portal 2.6.6</title>
<subtitle>Reference Guide</subtitle>
<releaseinfo>Release 2.6.6</releaseinfo>
<releaseinfo>July 2008</releaseinfo>
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/sso.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/sso.xml 2008-07-02 23:20:49 UTC (rev 11276)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/sso.xml 2008-07-02 23:29:12 UTC (rev 11277)
@@ -11,7 +11,7 @@
<email>sshah(a)redhat.com</email>
</author>
</chapterinfo>
- <title>Single Sign ON</title>
+ <title>Single Sign On</title>
<para>This chapter describes how to setup SSO in JBoss Portal</para>
<sect1>
<title>Overview of SSO in portal</title>
@@ -270,7 +270,7 @@
</sect2>
</sect1>
<sect1>
- <title>JOSSO - Java Open Single SignOn</title>
+ <title><trademark class="trade">Java</trademark> Open Single Sign-On (JOSSO)</title>
<para>JBoss Portal enables seamless integration with JOSSO server. More details on JOSSO can be found
<ulink url="http://www.josso.org/">here</ulink></para>
<note>The steps below assume that JOSS server and JBoss Portal will be deployed on the same JBoss Application Server instance.
16 years
JBoss Portal SVN: r11276 - in docs/branches/JBoss_Portal_Branch_2_6: referenceGuide/en/modules and 1 other directory.
by portal-commits@lists.jboss.org
Author: mmcallis
Date: 2008-07-02 19:20:49 -0400 (Wed, 02 Jul 2008)
New Revision: 11276
Modified:
docs/branches/JBoss_Portal_Branch_2_6/common/en/modules/acknowledgements.xml
docs/branches/JBoss_Portal_Branch_2_6/common/en/modules/featurelist.xml
docs/branches/JBoss_Portal_Branch_2_6/common/en/modules/overview.xml
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/supported.xml
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/xmldescriptors.xml
Log:
backporting changes from 2.7 to 2.6:
- feature list
- overview
- target audience
- acknowledgments
Modified: docs/branches/JBoss_Portal_Branch_2_6/common/en/modules/acknowledgements.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/common/en/modules/acknowledgements.xml 2008-07-02 23:14:56 UTC (rev 11275)
+++ docs/branches/JBoss_Portal_Branch_2_6/common/en/modules/acknowledgements.xml 2008-07-02 23:20:49 UTC (rev 11276)
@@ -1,45 +1,43 @@
<preface id="acknowledgements">
- <title>Acknowledgements</title>
- <para>We would like to thank the developers that participate in the JBoss Portal project effort.</para>
- <para>Specifically,</para>
- <para>
- <itemizedlist>
- <listitem>
- Luca Stancapiano and Luc Boudreau for their localization contributions.
- </listitem>
- <listitem>
- Antoine Herzog for his feedback, for writing Wikis and helping in the forums.
- </listitem>
- <listitem>
- Mark Fernandes and Paul Tamaro from Novell, for their hard work in supplying the
- portal project with usable and attractive themes and layouts in the 2.4 version of JBoss Portal.
- </listitem>
- <listitem>
- Martin Holzner from Novell, for his work on themes in the 2.4 version of JBoss Portal.
- </listitem>
- <listitem>
- Kev "kevs3d" Roast for supplying us with two working portlets that integrate existing
- frameworks in to the portal: Sun JSF-RI and Spring MVC Portlet.
- </listitem>
- <listitem>
- Swarn "sdhaliwal" Dhaliwal for supplying us with the Struts-Bridge, that will allow
- for existing struts applications to work with the Portal.
- </listitem>
- <listitem>
- A few Red Hat employees, Remy Maucherat for Apache Tomcat configuration, Magesh Kumar Bojan and Martin Putz always there to help our customers,
- Prabhat Jha for making sure that JBoss Portal runs great everywhere. Noel Rocher for his early feedback on JBoss Portal 2.6
- and contributions. James Cobb for the Renaissance theme.
- </listitem>
- <listitem>
- The JBoss Labs (http://www.JBoss.org) team for building a great infrastructure on top of JBoss Portal 2.6, providing very useful feedback and
- giving us the initial Drag and Drop implementation.
- </listitem>
- <listitem>
- Everyone participating in the forums and Wiki in general.
- </listitem>
- </itemizedlist>
- </para>
- <para>Contributions of any kind are always welcome, you can contribute by providing ideas,
- filling bug reports, producing some code, designing a theme, writing some documentation,
- etc... If you think your name is missing from this page, please let us know.</para>
+ <title>Acknowledgments</title>
+ <para>We would like to thank the developers that participate in the JBoss Portal project.</para>
+ <para>Specifically:</para>
+ <para>
+ <itemizedlist>
+ <listitem>
+ Luca Stancapiano and Luc Boudreau for their localization contributions.
+ </listitem>
+ <listitem>
+ Antoine Herzog for his feedback, writing Wikis, and helping in the forums.
+ </listitem>
+ <listitem>
+ Mark Fernandes and Paul Tamaro from Novell, for their hard work in supplying the
+ portal project with usable and attractive themes and layouts in the 2.4 version of JBoss Portal.
+ </listitem>
+ <listitem>
+ Martin Holzner from Novell, for his work on themes in the 2.4 version of JBoss Portal.
+ </listitem>
+ <listitem>
+ Kev "kevs3d" Roast for supplying us with two working portlets that integrate existing
+ frameworks in to the portal: Sun JSF-RI and Spring MVC portlets.
+ </listitem>
+ <listitem>
+ Swarn "sdhaliwal" Dhaliwal for supplying us with the Struts-Bridge, that will allow
+ for existing Apache Struts applications to work with JBoss Portal.
+ </listitem>
+ <listitem>
+ A few Red Hat employees: Remy Maucherat for Apache Tomcat configuration, Magesh Kumar Bojan and Martin Putz for always being there to help our customers,
+ Prabhat Jha for making sure that JBoss Portal runs great everywhere, Noel Rocher for his contributions and early feedback on JBoss Portal 2.6, and James Cobb for the renaissance theme.
+ </listitem>
+ <listitem>
+ The JBoss Labs (<ulink url="http://www.jboss.org" />) team for building a great infrastructure on top of JBoss Portal 2.6, providing very useful feedback, and
+ giving us the initial Drag and Drop implementation.
+ </listitem>
+ <listitem>
+ Everyone in general who participates in the forums and on the Wiki.
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>Contributions of any kind are always welcome. You can contribute by providing ideas,
+ filing bug reports, producing code, designing a theme, writing documentation, and so on. If you think your name is missing from this page, please let us know.</para>
</preface>
\ No newline at end of file
Modified: docs/branches/JBoss_Portal_Branch_2_6/common/en/modules/featurelist.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/common/en/modules/featurelist.xml 2008-07-02 23:14:56 UTC (rev 11275)
+++ docs/branches/JBoss_Portal_Branch_2_6/common/en/modules/featurelist.xml 2008-07-02 23:20:49 UTC (rev 11276)
@@ -1,287 +1,284 @@
<preface id="features">
- <title>Feature List</title>
- <para>The following list details features found in this document's related release. For a
- technical view of our features, view the
- <ulink
- url="http://jira.jboss.com/jira/browse/JBPORTAL">Project Roadmap and Task List</ulink>
- .
- </para>
- <para>
- <emphasis role="bold">Technology and Architecture</emphasis>
- <itemizedlist>
- <listitem>
- <emphasis role="bold">JEMS:</emphasis>
- leverages the power of JBoss Enterprise Middleware
- Services: JBoss Application Server, JBoss Cache, JGroups, and Hibernate.
- </listitem>
- <listitem>
- <emphasis role="bold">Database Agnostic:</emphasis>
- works with any RDBMS supported by Hibernate.
- </listitem>
- <listitem>
- <emphasis role="bold">JAAS Authentication:</emphasis>
- custom authentication via JAAS login modules.
- </listitem>
- <listitem>
- <emphasis role="bold">Caching:</emphasis>
- utilizes render-view caching for improved performance.
- </listitem>
- <listitem>
- <emphasis role="bold">Clustering:</emphasis>
- cluster support allows the portal state to be
- clustered for all portal instances.
- </listitem>
- <listitem>
- <emphasis role="bold">Hot-Deployment:</emphasis>
- leverages JBoss dynamic auto-deployment
- features.
- </listitem>
- <listitem>
- <emphasis role="bold">SAR Installer:</emphasis>
- browser-based installer makes installation
- and initial configuration a breeze.
- </listitem>
+ <title>Feature List</title>
+ <para>The following list details features found in this release of JBoss Portal. For a
+ technical view of the JBoss Portal features, refer to the
+ <ulink
+ url="http://jira.jboss.com/jira/browse/JBPORTAL">Project Roadmap and Task List</ulink>
+ .
+ </para>
+ <para>
+ <emphasis role="bold">Technology and Architecture</emphasis>
+ <itemizedlist>
+ <listitem>
+ <emphasis role="bold">JEMS:</emphasis>
+ leverages the power of JBoss Enterprise Middleware
+ Services: JBoss Application Server, JBoss Cache, JGroups, and Hibernate.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Database Agnostic:</emphasis>
+ works with any RDBMS supported by Hibernate.
+ </listitem>
+ <listitem>
+ <emphasis role="bold"><trademark class="trade">Java</trademark> Authentication and Authorization Service (JAAS):</emphasis>
+ custom authentication via JAAS login modules.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Caching:</emphasis>
+ utilizes render-view caching for improved performance.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Clustering:</emphasis>
+ cluster support allows the portal state to be
+ clustered for all portal instances.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Hot-deployment:</emphasis>
+ leverages JBoss dynamic auto-deployment
+ features.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">SAR Installer:</emphasis>
+ browser-based installer makes installation
+ and initial configuration a breeze.
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ <emphasis role="bold">Single Sign On</emphasis>
+ <itemizedlist>
+ <listitem>
+ <emphasis role="bold">Leverages Apache Tomcat and JBoss Single Sign On (SSO) solutions.</emphasis>
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Integrates with Java Open Single Sign-On (JOSSO) and Central Authentication Service (CAS) out of the box. Experimental support for the Open Web SSO project (OpenSSO).</emphasis>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ <emphasis role="bold">LDAP</emphasis>
+ <itemizedlist>
+ <listitem>
+ <emphasis role="bold">Connect to virtually any LDAP server.</emphasis>
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Integrates with <trademark class="trade">Sun</trademark> Active Directory and OpenLDAP out of the box. Experimental support for <trademark class="registered">Microsoft</trademark> <trademark class="registered">Active Directory</trademark>.</emphasis>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ <emphasis role="bold">Supported Standards</emphasis>
+ <itemizedlist>
+ <listitem>
+ <emphasis role="bold">Portlet Specification and API 1.0 (JSR-168).</emphasis>
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Content Repository for <trademark class="trade">Java</trademark> technology API (JSR-170).</emphasis>
+ </listitem>
+ <listitem>
+ <emphasis role="bold"><trademark class="trade">JavaServer</trademark> Faces 1.2 (JSR-252).</emphasis>
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Java Management Extension (<trademark class="trade">JMX</trademark>) 1.2.</emphasis>
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Web Services for Remote Portlets (WSRP) 1.0:</emphasis>
+ refer to <ulink url="http://docs.jboss.com/jbportal/v2.6.5/referenceGuide/html/wsrp.html#wsrp_...">WSRP
+ support in JBoss Portal</ulink> for further details.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Full <trademark class="trade">J2EE</trademark> 1.4 compliance when used with JBoss Application Server.</emphasis>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ <emphasis role="bold">Portal and Portal Container</emphasis>
+ </para>
+ <itemizedlist>
+ <listitem>
+ <emphasis role="bold">Multiple Portal Instances:</emphasis>
+ the ability to have multiple portal
+ instances running inside one portal container.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">IPC:</emphasis>
+ the Inter-Portlet Communication API enables portlets to create links to other
+ objects, such as pages, portals, and windows.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Dynamic:</emphasis>
+ the ability for administrators and users to create and destroy objects such as
+ portlets, pages, portals, themes, and layouts at runtime.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Internationalization:</emphasis>
+ the ability to use internationalization
+ resource files for every portlet.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Pluggable Services:</emphasis>
+ with authentication performed by the
+ servlet container and JAAS, it is possible to swap the authentication scheme.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Page-based Architecture:</emphasis>
+ allows the grouping and division
+ of portlets on a per-page basis.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Existing Framework Support:</emphasis>
+ portlets utilizing Apache Struts,
+ Spring Web MVC, Sun JSF-RI, AJAX, and Apache MyFaces are supported.
+ </listitem>
+ </itemizedlist>
+ <para>
+ <emphasis role="bold">Themes and Layouts</emphasis>
+ </para>
+ <itemizedlist>
+ <listitem>
+ <emphasis role="bold">Swapping Themes and Layouts:</emphasis>
+ new themes and layouts
+ containing images can easily be deployed in WAR archives.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Flexible API:</emphasis>
+ the Theme and Layout APIs are designed to
+ separate the business layer from the presentation layer.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Per-page Layout Strategy:</emphasis>
+ different layouts can be
+ assigned to different pages.
+ </listitem>
+ </itemizedlist>
+ <para>
+ <emphasis role="bold">User and Group Functionality</emphasis>
+ </para>
+ <itemizedlist>
+ <listitem>
+ <emphasis role="bold">User Registration and Validation:</emphasis>
+ configurable registration
+ parameters allow user email validation before activation.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Workflow:</emphasis>
+ ability to define your own jBPM workflow on user registration.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">User Log In:</emphasis>
+ makes use of servlet container authentication.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Create and Edit Users:</emphasis>
+ ability for administrators to
+ create and edit user profiles.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Create and Edit Roles:</emphasis>
+ ability for administrators to create and edit
+ roles.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Role Assignment:</emphasis>
+ ability for administrators to assign
+ users to roles.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">CAPTCHA Support:</emphasis>
+ distinguish between humans and machines when registering.
+ </listitem>
+ </itemizedlist>
+ <para>
+ <emphasis role="bold">Permissions Management</emphasis>
+ </para>
+ <itemizedlist>
+ <listitem>
+ <emphasis role="bold">Extendable Permissions API:</emphasis>
+ allows custom portlet
+ permissions based on role definition.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Administrative Interface:</emphasis>
+ allows permission
+ assignments to roles at any time for any deployed portlet, page, or portal instance.
+ </listitem>
+ </itemizedlist>
+ <para>
+ <emphasis role="bold">Content Management System</emphasis>
+ </para>
+ <itemizedlist>
+ <listitem>
+ <emphasis role="bold">JCR-compliant:</emphasis>
+ the CMS is powered by Apache Jackrabbit, an open source implementation
+ of the <trademark class="trade">Java</trademark> content repository API.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Database and File System Store Support:</emphasis>
+ configure the content store
+ for either a file system or an RDBMS.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">External Blob Support:</emphasis>
+ configurable content store, allowing
+ large blobs to reside on a file system, and content node references and properties to reside in an
+ RDBMS.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Version and History Support:</emphasis>
+ all content edited and created is
+ auto-versioned with a history of edits, that can be viewed at any time.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Content Serving Search-engine-friendly URLS:</emphasis>
+ http://<replaceable>your-domain</replaceable>/portal/content/index.html (does not apply to portlet actions).
+ </listitem>
+ <listitem>
+ <emphasis role="bold">No Long Portal URLS:</emphasis>
+ serve binaries with simple URLs
+ (http://<replaceable>your-domain</replaceable>/files/products.pdf).
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Multiple HTML Portlet Instance Support:</emphasis>
+ allows extra
+ instances of static content from the CMS to be served under separate windows.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Directory Support:</emphasis>
+ create, move, delete, copy, and upload
+ entire directory trees.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">File Functions:</emphasis>
+ create, move, delete, copy, and upload files.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Embedded Directory-browser:</emphasis>
+ when creating, moving, deleting, or copying files, administrators can navigate the directory tree to find
+ the collection they want to perform the action on.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Ease-of-use Architecture:</emphasis>
+ all actions to be performed on
+ files and folder are one mouse-click away.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Full-featured HTML Editor:</emphasis>
+ the HTML editor contains a WYSIWYG
+ mode, preview functionality, and HTML source editting mode. HTML commands support tables,
+ fonts, zooming, image and URL linking, flash movie support, bullet and numbered list, and
+ dozens more.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Editor Style Sheet Support:</emphasis>
+ to easily chose classes, the WYSIWYG editor displays the current portal style sheet.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Internationalization Support:</emphasis>
+ content can be attributed to a specific locale, and then served
+ to the user based on his or hers Web browser settings.
+ </listitem>
+ <listitem>
+ <emphasis role="bold">Workflow Support:</emphasis>
+ basic submit for review and approval process.
+ </listitem>
</itemizedlist>
- </para>
- <para>
- <emphasis role="bold">Single Sign-on</emphasis>
- <itemizedlist>
- <listitem>
- <emphasis role="bold">Leverages Apache Tomcat and JBoss Single sign-on (SSO) solutions.</emphasis>
- </listitem>
- <listitem>
- <emphasis role="bold">Integrates with JOSSO and CAS out of the box (experimental support for Open SSO).</emphasis>
- </listitem>
- </itemizedlist>
- </para>
- <para>
- <emphasis role="bold">LDAP</emphasis>
- <itemizedlist>
- <listitem>
- <emphasis role="bold">Connect to virtually any LDAP server.</emphasis>
- </listitem>
- <listitem>
- <emphasis role="bold">Integrates with <trademark class="trade">Sun</trademark> Active Directory and OpenLDAP out of the box (experimental support for <trademark class="registered">Microsoft</trademark> <trademark class="registered">Active Directory</trademark>).</emphasis>
- </listitem>
- </itemizedlist>
- </para>
- <para>
- <emphasis role="bold">Supported Standards</emphasis>
- <itemizedlist>
- <listitem>
- <emphasis role="bold">Portlet Specification and API 1.0 (JSR-168).</emphasis>
- </listitem>
- <listitem>
- <emphasis role="bold">Content Repository for <trademark class="trade">Java</trademark> technology API (JSR-170).</emphasis>
- </listitem>
- <listitem>
- <emphasis role="bold"><trademark class="trade">JavaServer</trademark> Faces 1.2 (JSR-252).</emphasis>
- </listitem>
- <listitem>
- <emphasis role="bold">Java Management Extension (<trademark class="trade">JMX</trademark>) 1.2.</emphasis>
- </listitem>
- <listitem>
- <emphasis role="bold">Web Services for Remote Portlets (WSRP) 1.0:</emphasis>
- refer to <ulink url="http://docs.jboss.com/jbportal/v2.6.5/referenceGuide/html/wsrp.html#wsrp_...">WSRP
- support in JBoss Portal</ulink> for further details.
- </listitem>
- <listitem>
- <emphasis role="bold">Full <trademark class="trade">J2EE</trademark> 1.4 compliance when used with JBoss AS.</emphasis>
- </listitem>
- </itemizedlist>
- </para>
- <para>
- <emphasis role="bold">Portal and Portal Container</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <emphasis role="bold">Multiple Portal Instances:</emphasis>
- the ability to have multiple portal
- instances running inside one portal container.
- </listitem>
- <listitem>
- <emphasis role="bold">IPC:</emphasis>
- the Inter-Portlet Communication API enables portlets to create links to other
- objects, such as pages, portals, and windows.
- </listitem>
- <listitem>
- <emphasis role="bold">Dynamic:</emphasis>
- the ability for administrators and users to create and destroy objects such as
- portlets, pages, portals, themes, and layouts at runtime.
- </listitem>
- <listitem>
- <emphasis role="bold">Internationalization:</emphasis>
- the ability to use internationalization
- resource files for every portlet.
- </listitem>
- <listitem>
- <emphasis role="bold">Pluggable services:</emphasis>
- authentication performed by the
- servlet container and JAAS make it possible to swap the authentication scheme.
- </listitem>
- <listitem>
- <emphasis role="bold">Page-based Architecture:</emphasis>
- allows the grouping and division
- of portlets on a per-page basis.
- </listitem>
- <listitem>
- <emphasis role="bold">Existing Framework Support:</emphasis>
- portlets utilizing Apache Struts,
- Spring Web MVC, Sun JSF-RI, AJAX, and Apache MyFaces are supported.
- </listitem>
- </itemizedlist>
- <para>
- <emphasis role="bold">Themes and Layouts</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <emphasis role="bold">Swappable themes and layouts:</emphasis>
- new themes and layouts
- containing images can easily be deployed in WAR archives.
- </listitem>
- <listitem>
- <emphasis role="bold">Flexible API:</emphasis>
- the Theme and Layout APIs are designed to
- separate the business layer from the presentation layer.
- </listitem>
- <listitem>
- <emphasis role="bold">Per-page layout strategy:</emphasis>
- different layouts can be
- assigned to different pages.
- </listitem>
- </itemizedlist>
- <para>
- <emphasis role="bold">User and Group Functionality</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <emphasis role="bold">User Registration and Validation:</emphasis>
- configurable registration
- parameters allow user email validation before activation.
- </listitem>
- <listitem>
- <emphasis role="bold">Workflow:</emphasis>
- ability to define your own jBPM workflow on user registration.
- </listitem>
- <listitem>
- <emphasis role="bold">User Log In:</emphasis>
- makes use of servlet container authentication.
- </listitem>
- <listitem>
- <emphasis role="bold">Create and Edit Users:</emphasis>
- ability for administrators to
- create and edit user profiles.
- </listitem>
- <listitem>
- <emphasis role="bold">Create and Edit Roles:</emphasis>
- Ability for administrators create and edit
- roles.
- </listitem>
- <listitem>
- <emphasis role="bold">Role Assignment:</emphasis>
- ability for administrators to assign
- users to roles.
- </listitem>
- <listitem>
- <emphasis role="bold">CAPTCHA Support:</emphasis>
- to distinguish humans from machines when registering.
- </listitem>
- </itemizedlist>
- <para>
- <emphasis role="bold">Permissions Management</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <emphasis role="bold">Extendable permissions API:</emphasis>
- allows custom portlet
- permissions based on role definition.
- </listitem>
- <listitem>
- <emphasis role="bold">Administrative Interface:</emphasis>
- allows permission
- assignments to roles at any time for any deployed portlet, page, or portal instance.
- </listitem>
- </itemizedlist>
- <para>
- <emphasis role="bold">Content Management System</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <emphasis role="bold">JCR-compliant:</emphasis>
- the CMS is powered by Apache Jackrabbit, an open source implementation
- of the <trademark class="trade">Java</trademark> content repository API.
- </listitem>
- <listitem>
- <emphasis role="bold">Database and File System Store Support:</emphasis>
- configure the content store
- for either a file system or an RDBMS.
- </listitem>
- <listitem>
- <emphasis role="bold">External Blob Support:</emphasis>
- configurable content store, allowing
- large blobs to reside on a file system, and content node references and properties to reside in an
- RDBMS.
- </listitem>
- <listitem>
- <emphasis role="bold">Version and History Support:</emphasis>
- all content edited and created is
- autoversioned with a history of edits, that can be viewed at any time.
- </listitem>
- <listitem>
- <emphasis role="bold">Content Serving Search-engine-friendly URLS:</emphasis>
- http://yourdomain/portal/content/index.html (does not apply to portlet actions).
- </listitem>
- <listitem>
- <emphasis role="bold">No Long Portal URLS:</emphasis>
- serve binaries with simple URLs
- (http://domain/files/products.pdf).
- </listitem>
- <listitem>
- <emphasis role="bold">Multiple HTML Portlet Instance Support:</emphasis>
- allows extra
- instances of static content from the CMS to be served under separate windows.
- </listitem>
- <listitem>
- <emphasis role="bold">Directory Support:</emphasis>
- create, move, delete, copy, and upload
- entire directory trees.
- </listitem>
- <listitem>
- <emphasis role="bold">File Functions:</emphasis>
- create, move, copy, upload, and delete
- files.
- </listitem>
- <listitem>
- <emphasis role="bold">Embedded Directory-browser:</emphasis>
- when copying, moving,
- deleting, or creating files, administrators can simply navigate the directory tree to find
- the collection they want to perform the action on.
- </listitem>
- <listitem>
- <emphasis role="bold">Ease-of-use Architecture:</emphasis>
- all actions to be performed on
- files and folder are one mouse-click away.
- </listitem>
- <listitem>
- <emphasis role="bold">Full-featured HTML Editor:</emphasis>
- the HTML editor contains a WYSIWYG
- mode, preview functionality, and HTML source editting mode. HTML commands support tables,
- fonts, zooming, image and URL linking, flash movie support, bulleted and numbered list, and
- dozens more.
- </listitem>
- <listitem>
- <emphasis role="bold">Editor Style-sheet Support:</emphasis>
- the WYSIWYG editor displays
- the current portal style-sheet, for easy choosing of classes.
- </listitem>
- <listitem>
- <emphasis role="bold">Internationalization Support:</emphasis>
- content can be attributed to a specific locale, and then served
- to the user based on his or hers Web browser settings.
- </listitem>
- <listitem>
- <emphasis role="bold">Workflow Support:</emphasis>
- basic submit for review and approval process.
- </listitem>
- </itemizedlist>
</preface>
Modified: docs/branches/JBoss_Portal_Branch_2_6/common/en/modules/overview.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/common/en/modules/overview.xml 2008-07-02 23:14:56 UTC (rev 11275)
+++ docs/branches/JBoss_Portal_Branch_2_6/common/en/modules/overview.xml 2008-07-02 23:20:49 UTC (rev 11276)
@@ -7,74 +7,64 @@
</imageobject>
</para>
<para>Many IT organizations look to achieve a competitive advantage for the enterprise by
- improving business productivity and reducing costs. Today's top enterprises are realizing this
- goal by deploying enterprise portals within their IT infrastructure. Enterprise portals
- simplify access to information by providing a single source of interaction with corporate
- information. Although today's packaged portal frameworks help enterprises launch portals more
- quickly, only JBoss Portal can deliver the benefits of a zero-cost open source license,
- combined with a flexible and scalable underlying platform.</para>
+ improving business productivity and reducing costs. Today's top enterprises are realizing this
+ goal by deploying enterprise portals within their IT infrastructure. Enterprise portals
+ simplify access to information by providing a single source of interaction with corporate
+ information. Although today's packaged portal frameworks help enterprises launch portals more
+ quickly, only <trademark class="registered">JBoss</trademark> Portal can deliver the benefits of a zero-cost open source license,
+ combined with a flexible and scalable underlying platform.</para>
<para>JBoss Portal provides an open source and standards-based environment for hosting and
- serving a portal's Web interface, publishing and managing its content, and customizing its
- experience. It is entirely standards-based, and supports the JSR-168 portlet specification,
- which allows you to easily plug-in standards-compliant portlets to meet your specific portal
- needs. JBoss Portal is available through the business-friendly
- <ulink
- url="http://jboss.com/opensource/lgpl/faq">LGPL</ulink>
- open source license, and is
- supported by
- <ulink url="http://www.jboss.com/services/index">Red Hat Middleware, LLC Professional Support
- and Consulting
- </ulink>
- . JBoss support services are available to assist you in designing,
- developing, deploying, and ultimately managing your portal environment. JBoss Portal is
- currently developed by Red Hat Middleware, LLC developers, and community contributors.
+ serving a portal's Web interface, publishing and managing its content, and customizing its
+ experience. It is entirely standards-based, and supports the <ulink url="http://www.jcp.org/en/jsr/detail?id=168">JSR-168 Portlet Specification</ulink>,
+ which allows you to easily plug-in standards-compliant portlets to meet your specific portal
+ needs. JBoss Portal is available through the business-friendly <ulink url="http://jboss.com/opensource/lgpl/faq">LGPL</ulink> open source license, and is supported by <ulink url="http://www.jboss.com/services/index">JBoss Enterprise Middleware Professional Support and Consulting</ulink>. JBoss support services are available to assist you in designing, developing, deploying, and ultimately managing your portal environment. JBoss Portal is currently developed by JBoss Enterprise Middleware developers, and community contributors.
</para>
<para>The JBoss Portal framework and architecture include the portal container, and support a
- wide range of features, including standard portlets, single sign-on, clustering, and
- internationalization. Portal themes and layouts are configurable. Fine-grained security
- administration -- down to portlet permissions -- rounds out the security model.</para>
+ wide range of features, including standard portlets, single sign-on, clustering, and
+ internationalization. Portal themes and layouts are configurable. Fine-grained security
+ administration -- down to portlet permissions -- rounds out the security model.</para>
<para>
- <emphasis role="bold">JBoss Portal Resources:</emphasis>
- <orderedlist>
- <listitem>
- <para>
- <ulink url="http://labs.jboss.com/jbossportal">JBoss Portal Home Page</ulink>
- </para>
- </listitem>
- <listitem>
- <para>Forums:
- <ulink
- url="http://www.jboss.org/index.html?module=bb&op=viewforum&f=215"
- >User</ulink>
- |
- <ulink
- url="http://www.jboss.org/index.html?module=bb&op=viewforum&f=205"
- >Design</ulink>
- |
- <ulink url="http://jboss.org/index.html?module=bb&op=viewforum&f=232">WSRP</ulink>
- </para>
- </listitem>
- <listitem>
- <para>
- <ulink url="http://www.jboss.com/wiki/Wiki.jsp?page=JBossPortal">Wiki</ulink>
- </para>
- </listitem>
- <listitem>
- <para>
- <ulink url="http://www.portletswap.com">PortletSwap.com portlet exchange</ulink>
- </para>
- </listitem>
- <listitem>
- <para>
- <ulink
- url="http://jira.jboss.com/jira/browse/JBPORTAL?report=com.atlassian.jira.plug..."
- >Our Roadmap</ulink>
- </para>
- </listitem>
- </orderedlist>
+ <emphasis role="bold">JBoss Portal Resources:</emphasis>
+ <orderedlist>
+ <listitem>
+ <para>
+ <ulink url="http://labs.jboss.com/jbossportal">JBoss Portal Home Page</ulink>
+ </para>
+ </listitem>
+ <listitem>
+ <para>Forums:
+ <ulink
+ url="http://www.jboss.org/index.html?module=bb&op=viewforum&f=215"
+ >User</ulink>
+ |
+ <ulink
+ url="http://www.jboss.org/index.html?module=bb&op=viewforum&f=205"
+ >Design</ulink>
+ |
+ <ulink url="http://jboss.org/index.html?module=bb&op=viewforum&f=232">WSRP</ulink>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <ulink url="http://www.jboss.com/wiki/Wiki.jsp?page=JBossPortal">Wiki</ulink>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <ulink url="http://www.portletswap.com">PortletSwap.com Portlet Exchange</ulink>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <ulink
+ url="http://jira.jboss.com/jira/browse/JBPORTAL?report=com.atlassian.jira.plug..."
+ >Our Roadmap</ulink>
+ </para>
+ </listitem>
+ </orderedlist>
</para>
<para>The JBoss Portal team encourages you to use this guide to install and configure JBoss
- Portal. If you encounter any configuration issues or simply want to take part in our
- community, we would love to hear from you in our forums.
+ Portal. If you encounter any configuration issues or simply want to take part in our
+ community, we would love to hear from you in our forums.
</para>
</preface>
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/supported.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/supported.xml 2008-07-02 23:14:56 UTC (rev 11275)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/supported.xml 2008-07-02 23:20:49 UTC (rev 11276)
@@ -13,7 +13,7 @@
</chapterinfo>
<title>System Requirements</title>
<para>
- The following section details tested, or reported as working by users, hardware and software versions that are compatible with JBoss Portal. Before reporting a problem, make sure you are using compatible hardware and software.
+ The following section details hardware and software versions that are compatible with JBoss Portal. The hardware and software listed has been tested, or reported as working by users. Before reporting a problem, make sure you are using compatible hardware and software.
</para>
<para>
If you successfully installed JBoss Portal on versions not listed here, please let us know so it can be added to this section.
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/xmldescriptors.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/xmldescriptors.xml 2008-07-02 23:14:56 UTC (rev 11275)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/xmldescriptors.xml 2008-07-02 23:20:49 UTC (rev 11276)
@@ -9,7 +9,7 @@
</chapterinfo>
<title>XML Descriptors</title>
<sect1>
- <title>Changes from previous releases</title>
+ <title>Changes from previous Releases</title>
<para>The previous releases of JBoss Portal did not have an external schema to validate XML descriptors; however, they were internally validated by the portal. Since JBoss Portal 2.6, a Document Type Definition (DTD) has been provided to validate descriptors.
</para>
<para>
16 years
JBoss Portal SVN: r11275 - modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-07-02 19:14:56 -0400 (Wed, 02 Jul 2008)
New Revision: 11275
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
Log:
unused import
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-07-02 23:12:33 UTC (rev 11274)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-07-02 23:14:56 UTC (rev 11275)
@@ -31,7 +31,6 @@
import org.jboss.portal.presentation.test.state.mock.MockModel;
import org.jboss.portal.presentation.test.state.mock.impl.MockModelImpl;
import org.jboss.portal.presentation.test.state.mock.MockObject;
-import org.jboss.portal.presentation.test.model.UIObjectNode;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
16 years
JBoss Portal SVN: r11274 - in modules/presentation/trunk/presentation: src/test/java/org/jboss/portal/presentation/test and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-07-02 19:12:33 -0400 (Wed, 02 Jul 2008)
New Revision: 11274
Added:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AddChildTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/CustomScope.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/ModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MoveChildTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/NodeDef.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/NodeDefContext.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/RemoveChildTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/TraversalModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/TypeTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UIObjectNode.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UIObjectTree.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UpdateObjectTestCase.java
Removed:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockException.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/
Modified:
modules/presentation/trunk/presentation/pom.xml
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
Log:
proper refactoring
Modified: modules/presentation/trunk/presentation/pom.xml
===================================================================
--- modules/presentation/trunk/presentation/pom.xml 2008-07-02 22:14:58 UTC (rev 11273)
+++ modules/presentation/trunk/presentation/pom.xml 2008-07-02 23:12:33 UTC (rev 11274)
@@ -43,8 +43,6 @@
<forkMode>never</forkMode>
<argLine>-enableassertions</argLine>
<excludes>
- <exclude>org/jboss/portal/presentation/test/layout/TestFlexibleGrid.java</exclude>
- <exclude>org/jboss/portal/presentation/test/layout/TestRegionLayoutManager.java</exclude>
<exclude>org/jboss/portal/presentation/test/model/AbstractModelTestCase.java</exclude>
</excludes>
</configuration>
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-07-02 22:14:58 UTC (rev 11273)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -31,7 +31,7 @@
import org.jboss.portal.presentation.test.state.mock.MockModel;
import org.jboss.portal.presentation.test.state.mock.impl.MockModelImpl;
import org.jboss.portal.presentation.test.state.mock.MockObject;
-import org.jboss.portal.presentation.test.model3.UIObjectNode;
+import org.jboss.portal.presentation.test.model.UIObjectNode;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
@@ -49,11 +49,15 @@
/** . */
protected StructuralStateContext structuralStateContext;
+ /** . */
+ protected NodeDefContext context;
+
protected void setUp() throws Exception
{
mockModel = new MockModelImpl();
structuralStateContext = mockModel.getStructuralStateContext();
model = new UIModelImpl(new NavigationalStateContextImpl(), structuralStateContext);
+ context = new NodeDefContext(mockModel);
}
/**
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AddChildTestCase.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AddChildTestCase.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AddChildTestCase.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AddChildTestCase.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import org.jboss.portal.presentation.model.ObjectTraversalType;
+import org.jboss.portal.presentation.model.ViewPort;
+import org.jboss.portal.presentation.model.ViewPortScope;
+import org.jboss.portal.presentation.model.ui.UIPage;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class AddChildTestCase extends TraversalModelTestCase
+{
+
+ public void testAddChild()
+ {
+ test(1, null);
+ }
+
+ protected void test(ObjectTraversalType[] before, ObjectTraversalType[] after, Object handback)
+ {
+ NodeDef rootDef = NodeDef.create(context);
+ NodeDef fooDef = rootDef.addChild("foo");
+ fooDef.setTraversal(before[0]);
+
+ //
+ rootDef.populate(mockModel);
+
+ //
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
+ UIObjectTree context = new UIObjectTree();
+ ViewPort viewPort = model.createViewPort(context, scope);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
+
+ //
+ mockModel.getRoot().getChild("foo").addChild("juu", UIPage.class);
+ fooDef.addChild("juu");
+ fooDef.setTraversal(after[0]);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
+ }
+}
\ No newline at end of file
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/CustomScope.java (from rev 11272, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/CustomScope.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/CustomScope.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -0,0 +1,114 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import org.jboss.portal.presentation.model.ObjectTraversalType;
+import org.jboss.portal.presentation.model.UIModel;
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.model.ViewPortScope;
+import org.jboss.portal.presentation.test.state.mock.MockModel;
+import org.jboss.portal.presentation.test.state.mock.MockObject;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CustomScope implements ViewPortScope
+{
+
+ /** . */
+ private final MockModel mockModel;
+
+ /** . */
+ private final UIModel model;
+
+ /** . */
+ private final NodeDef root;
+
+ /** . */
+ private NodeDef current;
+
+ public CustomScope(MockModel mockModel, UIModel model, NodeDef root)
+ {
+ if (root == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.mockModel = mockModel;
+ this.model = model;
+ this.root = root;
+ this.current = null;
+ }
+
+ public String getRootId()
+ {
+ return model.getRootId();
+ }
+
+ public ObjectTraversalType enterObject(UIObject object)
+ {
+ if (current == null)
+ {
+ // It must be the root
+ if (!model.getRootId().equals(object.getId()))
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ current = root;
+ }
+ else
+ {
+ MockObject mockObject = mockModel.get(object.getId());
+
+ //
+ if (mockObject == null)
+ {
+ throw new IllegalStateException("No such mock object " + object.getId());
+ }
+
+ //
+ NodeDef child = current.getChild(mockObject.getName());
+
+ //
+ if (child == null)
+ {
+ throw new IllegalStateException("No such child " + object.getId());
+ }
+
+ //
+ current = child;
+ }
+
+ //
+ return current.getTraversal();
+ }
+
+ public void leaveObject(UIObject object)
+ {
+ current = current.getParent();
+ }
+}
\ No newline at end of file
Deleted: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockException.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockException.java 2008-07-02 22:14:58 UTC (rev 11273)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockException.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -1,56 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * 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. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class MockException extends RuntimeException
-{
-
- /** . */
- private ErrorCode code;
-
- public MockException(ErrorCode code)
- {
- this.code = code;
- }
-
- public MockException(String s, ErrorCode code)
- {
- super(s);
- this.code = code;
- }
-
- public enum ErrorCode
- {
- INVALID_OBJECT,
- CONSTRAINT_VIOLATION
- }
-
- public ErrorCode getCode()
- {
- return code;
- }
-}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/ModelTestCase.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/ModelTestCase.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/ModelTestCase.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/ModelTestCase.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import org.jboss.portal.presentation.model.ObjectTraversalType;
+import org.jboss.portal.presentation.model.ViewPort;
+import org.jboss.portal.presentation.model.ViewPortScope;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ModelTestCase extends TraversalModelTestCase
+{
+
+ public void testRefresh1() throws Exception
+ {
+ test(4, null);
+ }
+
+ protected void test(ObjectTraversalType[] before, ObjectTraversalType[] after, Object handback)
+ {
+ NodeDef rootDef = NodeDef.create(context);
+ NodeDef fooDef = rootDef.addChild("foo");
+ NodeDef barDef = rootDef.addChild("bar");
+ NodeDef juuDef = fooDef.addChild("juu");
+ NodeDef daaDef = fooDef.addChild("daa");
+
+ //
+ fooDef.setTraversal(before[0]);
+ barDef.setTraversal(before[1]);
+ juuDef.setTraversal(before[2]);
+ daaDef.setTraversal(before[3]);
+
+ //
+ rootDef.populate(mockModel);
+
+ //
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
+ UIObjectTree context = new UIObjectTree();
+ ViewPort viewPort = model.createViewPort(context, scope);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
+
+ //
+ fooDef.setTraversal(after[0]);
+ barDef.setTraversal(after[1]);
+ juuDef.setTraversal(after[2]);
+ daaDef.setTraversal(after[3]);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
+ }
+}
\ No newline at end of file
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MoveChildTestCase.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/MoveChildTestCase.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MoveChildTestCase.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MoveChildTestCase.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -0,0 +1,155 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import org.jboss.portal.presentation.model.ObjectTraversalType;
+import org.jboss.portal.presentation.model.ViewPort;
+import org.jboss.portal.presentation.model.ViewPortScope;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class MoveChildTestCase extends TraversalModelTestCase
+{
+
+ public void testMoveChild1()
+ {
+ test(0, new Runnable()
+ {
+ public void run()
+ {
+ NodeDef rootDef = NodeDef.create(context);
+ NodeDef fooDef = rootDef.addChild("foo");
+ NodeDef juuDef = fooDef.addChild("juu");
+ NodeDef barDef = rootDef.addChild("bar");
+
+ //
+ rootDef.populate(mockModel);
+
+ //
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
+ UIObjectTree context = new UIObjectTree();
+ ViewPort viewPort = model.createViewPort(context, scope);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
+
+ //
+ mockModel.getRoot().getChild("foo").getChild("juu").move(mockModel.getRoot().getChild("bar"));
+ fooDef.removeChild("juu");
+ barDef.addChild("juu");
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
+ }
+ });
+ }
+
+ public void testMoveChild2()
+ {
+ test(0, new Runnable()
+ {
+ public void run()
+ {
+ NodeDef rootDef = NodeDef.create(context);
+ NodeDef fooDef = rootDef.addChild("foo");
+ NodeDef barDef = rootDef.addChild("bar");
+ NodeDef juuDef = barDef.addChild("juu");
+
+ //
+ rootDef.populate(mockModel);
+
+ //
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
+ UIObjectTree context = new UIObjectTree();
+ ViewPort viewPort = model.createViewPort(context, scope);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
+
+ //
+ mockModel.getRoot().getChild("bar").getChild("juu").move(mockModel.getRoot().getChild("foo"));
+ barDef.removeChild("juu");
+ fooDef.addChild("juu");
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
+ }
+ });
+ }
+
+ public void testMoveChild3()
+ {
+ test(0, new Runnable()
+ {
+ public void run()
+ {
+ NodeDef rootDef = NodeDef.create(context);
+ NodeDef fooDef = rootDef.addChild("foo");
+ NodeDef juuDef = fooDef.addChild("juu");
+ NodeDef barDef = rootDef.addChild("bar");
+ NodeDef daaDef = barDef.addChild("daa");
+
+ //
+ rootDef.populate(mockModel);
+
+ //
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
+ UIObjectTree context = new UIObjectTree();
+ ViewPort viewPort = model.createViewPort(context, scope);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
+
+ //
+ mockModel.getRoot().getChild("foo").getChild("juu").move(mockModel.getRoot().getChild("bar"));
+ mockModel.getRoot().getChild("bar").getChild("daa").move(mockModel.getRoot().getChild("foo"));
+ fooDef.removeChild("juu");
+ barDef.addChild("juu");
+ barDef.removeChild("daa");
+ fooDef.addChild("daa");
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
+ }
+ });
+ }
+
+ protected void test(ObjectTraversalType[] before, ObjectTraversalType[] after, Object handback)
+ {
+ ((Runnable)handback).run();
+ }
+}
\ No newline at end of file
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/NodeDef.java (from rev 11272, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/NodeDef.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/NodeDef.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -0,0 +1,239 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import junit.framework.Assert;
+import org.jboss.portal.presentation.model.ObjectTraversalType;
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.model.ui.UIContext;
+import org.jboss.portal.presentation.model.ui.UIPage;
+import org.jboss.portal.presentation.test.state.mock.MockModel;
+import org.jboss.portal.presentation.test.state.mock.MockObject;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class NodeDef
+{
+
+ public static NodeDef create(NodeDefContext context)
+ {
+ return new NodeDef(context, "", UIContext.class);
+ }
+
+ /** . */
+ private final NodeDefContext context;
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final Map<String, NodeDef> children;
+
+ /** . */
+ private ObjectTraversalType traversal;
+
+ /** . */
+ private NodeDef parent;
+
+ /** . */
+ private final Class<? extends UIObject> type;
+
+ /** . */
+ private final Map<String, String> properties;
+
+ private NodeDef(NodeDefContext context, String name, Class<? extends UIObject> type)
+ {
+ this.context = context;
+ this.name = name;
+ this.type = type;
+ this.children = new HashMap<String, NodeDef>();
+ this.traversal = ObjectTraversalType.RECURSIVE;
+ this.parent = null;
+ this.properties = new HashMap<String, String>();
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public NodeDef getChild(String name)
+ {
+ return children.get(name);
+ }
+
+ public Collection<NodeDef> getChildren()
+ {
+ return children.values();
+ }
+
+ public NodeDef getParent()
+ {
+ return parent;
+ }
+
+ public ObjectTraversalType getTraversal()
+ {
+ return traversal;
+ }
+
+ public void setTraversal(ObjectTraversalType traversal)
+ {
+ this.traversal = traversal;
+ }
+
+ public void setProperty(String name, String value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (value != null)
+ {
+ properties.put(name, value);
+ }
+ else
+ {
+ properties.remove(name);
+ }
+ }
+
+ public String getProperty(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ return properties.get(name);
+ }
+
+ public NodeDef addChild(String name)
+ {
+ return addChild(name, UIPage.class);
+ }
+
+ public NodeDef addChild(String name, Class<? extends UIObject> type)
+ {
+ if (children.containsKey(name))
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ NodeDef child = new NodeDef(context, name, type);
+
+ //
+ children.put(name, child);
+ child.parent = this;
+
+ //
+ return child;
+ }
+
+ public void removeChild(String name)
+ {
+ NodeDef child = children.remove(name);
+
+ //
+ if (child == null)
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ child.parent = null;
+ }
+
+ public void populate(MockModel model)
+ {
+ populate(model.getRoot());
+ }
+
+ public void populate(MockObject object)
+ {
+ for (Map.Entry<String, NodeDef> childNodeEntry : children.entrySet())
+ {
+ MockObject child = object.addChild(childNodeEntry.getKey(), childNodeEntry.getValue().type, properties);
+ childNodeEntry.getValue().populate(child);
+ }
+ }
+
+ public void assertEquals(UIObjectNode objectNode)
+ {
+ Assert.assertEquals(properties.keySet(), objectNode.getProperties().keySet());
+ for (String propertyName : properties.keySet())
+ {
+ String expectedProperty = properties.get(propertyName);
+ String property = objectNode.getProperties().get(propertyName);
+ Assert.assertEquals(expectedProperty, property);
+ }
+
+ //
+ switch (traversal)
+ {
+ case SKIP:
+ Assert.fail();
+ break;
+ case SINGLE:
+ Assert.assertNull(objectNode.getChildren());
+ break;
+ case RECURSIVE:
+ Set<String> expectedChildrenNames = new HashSet<String>();
+ for (Map.Entry<String, NodeDef> entry : children.entrySet())
+ {
+ if (entry.getValue().getTraversal() != ObjectTraversalType.SKIP)
+ {
+ expectedChildrenNames.add(entry.getKey());
+ }
+ }
+
+ //
+ Set<String> childrenNames = new HashSet<String>();
+ for (UIObjectNode childObjectNode : objectNode.getChildren().values())
+ {
+ String childName = context.getName(childObjectNode);
+ childrenNames.add(childName);
+ NodeDef expectedChild = children.get(childName);
+ expectedChild.assertEquals(childObjectNode);
+ }
+
+ //
+ Assert.assertEquals(expectedChildrenNames, childrenNames);
+
+ //
+ break;
+ }
+ }
+}
\ No newline at end of file
Added: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/NodeDefContext.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/NodeDefContext.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/NodeDefContext.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import org.jboss.portal.presentation.test.state.mock.MockModel;
+import org.jboss.portal.presentation.test.state.mock.MockObject;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class NodeDefContext
+{
+
+ /** . */
+ private final MockModel model;
+
+ public NodeDefContext(MockModel model)
+ {
+ this.model = model;
+ }
+
+ public String getName(UIObjectNode objectNode)
+ {
+ MockObject mockObject = model.get(objectNode.getObject().getId());
+
+ //
+ if (mockObject == null)
+ {
+ return null;
+ }
+
+ //
+ return mockObject.getName();
+ }
+
+}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/RemoveChildTestCase.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/RemoveChildTestCase.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/RemoveChildTestCase.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/RemoveChildTestCase.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import org.jboss.portal.presentation.model.ObjectTraversalType;
+import org.jboss.portal.presentation.model.ViewPort;
+import org.jboss.portal.presentation.model.ViewPortScope;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class RemoveChildTestCase extends TraversalModelTestCase
+{
+
+ public void testRemoveChild()
+ {
+ test(1, null);
+ }
+
+ protected void test(ObjectTraversalType[] before, ObjectTraversalType[] after, Object handback)
+ {
+ NodeDef rootDef = NodeDef.create(context);
+ NodeDef fooDef = rootDef.addChild("foo");
+ NodeDef barDef = fooDef.addChild("bar");
+ NodeDef juuDef = fooDef.addChild("juu");
+
+ //
+ rootDef.populate(mockModel);
+
+ //
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
+ UIObjectTree context = new UIObjectTree();
+ ViewPort viewPort = model.createViewPort(context, scope);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+
+ //
+ mockModel.destroy(mockModel.getRoot().getChild("foo").getChild("juu"));
+ fooDef.removeChild("juu");
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
+ }
+}
\ No newline at end of file
Deleted: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java 2008-07-02 22:14:58 UTC (rev 11273)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -1,58 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * 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. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model;
-
-import org.jboss.portal.presentation.test.state.mock.MockModel;
-import org.jboss.portal.presentation.test.state.mock.MockObject;
-import org.jboss.portal.presentation.test.model3.UIObjectNode;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class Resolver
-{
-
- /** . */
- private final MockModel model;
-
- public Resolver(MockModel model)
- {
- this.model = model;
- }
-
- public String getName(UIObjectNode objectNode)
- {
- MockObject mockObject = model.get(objectNode.getObject().getId());
-
- //
- if (mockObject == null)
- {
- return null;
- }
-
- //
- return mockObject.getName();
- }
-
-}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/TraversalModelTestCase.java (from rev 11272, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/TraversalModelTestCase.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/TraversalModelTestCase.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -0,0 +1,132 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.jboss.portal.presentation.impl.model.UIModelImpl;
+import org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
+import org.jboss.portal.presentation.model.ObjectTraversalType;
+import org.jboss.portal.presentation.model.UIModel;
+import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.test.state.mock.MockModel;
+import org.jboss.portal.presentation.test.state.mock.impl.MockModelImpl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class TraversalModelTestCase extends TestCase
+{
+
+ /** . */
+ protected UIModel model;
+
+ /** . */
+ protected MockModel mockModel;
+
+ /** . */
+ protected StructuralStateContext structuralStateContext;
+
+ /** . */
+ protected NodeDefContext context;
+
+ public void test(int size, Object handback)
+ {
+ ObjectTraversalType[] before = new ObjectTraversalType[size];
+ ObjectTraversalType[] after = new ObjectTraversalType[size];
+ Collection<ObjectTraversalType[]> enumeration = generate(before.length + after.length);
+
+ //
+ for (ObjectTraversalType[] element : enumeration)
+ {
+ mockModel = new MockModelImpl();
+ structuralStateContext = mockModel.getStructuralStateContext();
+ model = new UIModelImpl(new NavigationalStateContextImpl(), structuralStateContext);
+ context = new NodeDefContext(mockModel);
+
+ //
+ Assert.assertEquals(before.length + after.length, element.length);
+ System.arraycopy(element, 0, before, 0, before.length);
+ System.arraycopy(element, before.length, after, 0, after.length);
+ boolean failed = true;
+ try
+ {
+ test(before, after, handback);
+ failed = false;
+ }
+ finally
+ {
+ if (failed)
+ {
+ System.out.println("Arrays.asList(before) = " + Arrays.asList(before));
+ System.out.println("Arrays.asList(after) = " + Arrays.asList(after));
+ }
+
+ //
+ mockModel = null;
+ structuralStateContext = null;
+ model = null;
+ context = null;
+ }
+ }
+ }
+
+ protected abstract void test(ObjectTraversalType[] before, ObjectTraversalType[] after, Object handback);
+
+ public static Collection<ObjectTraversalType[]> generate(int size)
+ {
+ if (size == 0)
+ {
+ return Collections.singleton(new ObjectTraversalType[0]);
+ }
+ else
+ {
+ Collection<ObjectTraversalType[]> enumeration = generate(size - 1);
+
+ //
+ ArrayList<ObjectTraversalType[]> augmentedEnumeration = new ArrayList<ObjectTraversalType[]>(enumeration.size() * 3);
+
+ //
+ for (ObjectTraversalType type : ObjectTraversalType.values())
+ {
+ for (ObjectTraversalType[] element : enumeration)
+ {
+ ObjectTraversalType[] augmentedElement = new ObjectTraversalType[1 + element.length];
+ System.arraycopy(element, 0, augmentedElement, 1, element.length);
+ augmentedElement[0] = type;
+ augmentedEnumeration.add(augmentedElement);
+ }
+ }
+
+ //
+ return augmentedEnumeration;
+ }
+ }
+
+}
\ No newline at end of file
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/TypeTestCase.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TypeTestCase.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/TypeTestCase.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/TypeTestCase.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import org.jboss.portal.presentation.model.ViewPort;
+import org.jboss.portal.presentation.model.ViewPortScope;
+import org.jboss.portal.presentation.model.ui.UIContext;
+import org.jboss.portal.presentation.model.ui.UIPage;
+import org.jboss.portal.presentation.model.ui.UIWindow;
+import org.jboss.portal.presentation.test.model.AbstractModelTestCase;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class TypeTestCase extends AbstractModelTestCase
+{
+
+ public void testType()
+ {
+ NodeDef rootDef = NodeDef.create(context);
+ NodeDef fooDef = rootDef.addChild("foo", UIPage.class);
+ NodeDef barDef = rootDef.addChild("bar", UIWindow.class);
+
+ //
+ rootDef.populate(mockModel);
+
+ //
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
+ UIObjectTree context = new UIObjectTree();
+ ViewPort viewPort = model.createViewPort(context, scope);
+
+ //
+ viewPort.refresh();
+
+ //
+ UIObjectNode root = context.getNode(mockModel.getStructuralStateContext().getRootId());
+ UIObjectNode foo = getChild(root, "foo");
+ UIObjectNode bar = getChild(root, "bar");
+
+ //
+ assertNotNull(foo);
+ assertNotNull(bar);
+
+ //
+ assertTrue(root.getObject() instanceof UIContext);
+ assertTrue("was not expecting: " + foo.getObject().getClass().getName(), foo.getObject() instanceof UIPage);
+ assertTrue("was not expecting: " + bar.getObject().getClass().getName(), bar.getObject() instanceof UIWindow);
+ }
+
+}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UIObjectNode.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectNode.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UIObjectNode.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UIObjectNode.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -0,0 +1,154 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.state.StateType;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class UIObjectNode
+{
+
+ /** . */
+ private final UIObject object;
+
+ /** . */
+ private Map<String, UIObjectNode> children;
+
+ /** . */
+ private Map<String, String> properties;
+
+ public UIObjectNode(UIObject object)
+ {
+ if (object == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.object = object;
+ this.properties = new HashMap<String, String>();
+
+ //
+ updateState();
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ public void updateState()
+ {
+ properties.clear();
+
+ for (String name : object.getPropertyNames(StateType.STRUCTURAL))
+ {
+ String value = object.getPropertyValue(StateType.STRUCTURAL, name, String.class);
+ properties.put(name, value);
+ }
+ }
+
+ public UIObject getObject()
+ {
+ return object;
+ }
+
+ public Map<String, UIObjectNode> getChildren()
+ {
+ return children;
+ }
+
+ public UIObjectNode getChild(String id)
+ {
+ return children.get(id);
+ }
+
+ public void addChild(UIObjectNode child)
+ {
+ if (children == null)
+ {
+ throw new IllegalStateException("Children not initialized");
+ }
+
+ //
+ String key = child.getObject().getId();
+
+ //
+ if (children.containsKey(key))
+ {
+ throw new IllegalStateException("Duplicate name " + key + " among " + children.keySet());
+ }
+
+ //
+ children.put(key, child);
+ }
+
+ public void removeChild(UIObjectNode child)
+ {
+ if (children == null)
+ {
+ throw new IllegalStateException("Children not initialized");
+ }
+
+ //
+ String key = child.getObject().getId();
+
+ //
+ if (!children.containsKey(key))
+ {
+ throw new IllegalStateException("No such child with name " + key + " among " + children.keySet());
+ }
+
+ //
+ children.remove(key);
+ }
+
+ public void createChildren()
+ {
+ if (children != null)
+ {
+ throw new IllegalStateException("Children already initialized");
+ }
+
+ //
+ children = new HashMap<String, UIObjectNode>();
+ }
+
+ public void destroyChildren()
+ {
+ if (children == null)
+ {
+ throw new IllegalStateException("Children never initialized");
+ }
+
+ //
+ children = null;
+ }
+}
\ No newline at end of file
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UIObjectTree.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectTree.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UIObjectTree.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UIObjectTree.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -0,0 +1,174 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import junit.framework.Assert;
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.model.ViewPortContext;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class UIObjectTree implements ViewPortContext
+{
+
+ /** . */
+ private final Map<String, UIObjectNode> nodes = new HashMap<String, UIObjectNode>();
+
+ public void assertConsistency(String rootId)
+ {
+ UIObjectNode root = nodes.get(rootId);
+ Assert.assertNotNull(root);
+ ArrayList<String> allIds = new ArrayList<String>();
+ collect(root, allIds);
+ Assert.assertEquals(new HashSet<String>(allIds).size(), allIds.size());
+ Assert.assertEquals(new HashSet<String>(allIds), nodes.keySet());
+ }
+
+ private void collect(UIObjectNode node, ArrayList<String> ids)
+ {
+ ids.add(node.getObject().getId());
+ if (node.getChildren() != null)
+ {
+ for (UIObjectNode child : node.getChildren().values())
+ {
+ collect(child, ids);
+ }
+ }
+ }
+
+ public UIObjectNode getNode(String objectId)
+ {
+ return nodes.get(objectId);
+ }
+
+ public UIObject getObject(String objectId)
+ {
+ UIObjectNode node = nodes.get(objectId);
+
+ //
+ return node != null ? node.getObject() : null;
+ }
+
+ public void updateObject(String objectId)
+ {
+ UIObjectNode node = nodes.get(objectId);
+ if (node == null)
+ {
+ throw new IllegalStateException("No such object " + objectId);
+ }
+
+ //
+ node.updateState();
+ }
+
+ public void removeObject(String objectId)
+ {
+ if (nodes.remove(objectId) == null)
+ {
+ throw new IllegalStateException("No such object " + objectId);
+ }
+ }
+
+ public void addObject(UIObject object)
+ {
+ String id = object.getId();
+
+ //
+ if (nodes.containsKey(id))
+ {
+ throw new IllegalStateException("Object with id " + id + " is already loaded");
+ }
+
+ //
+ nodes.put(id, new UIObjectNode(object));
+ }
+
+ public void addChild(String parentId, String childId)
+ {
+ UIObjectNode parent = nodes.get(parentId);
+ if (parent == null)
+ {
+ throw new IllegalStateException("No such object " + parentId);
+ }
+
+ //
+ UIObjectNode child = nodes.get(childId);
+ if (child == null)
+ {
+ throw new IllegalStateException("No such object " + childId);
+ }
+
+ //
+ parent.addChild(child);
+ }
+
+ public void removeChild(String parentId, String childId)
+ {
+ UIObjectNode parent = nodes.get(parentId);
+ if (parent == null)
+ {
+ throw new IllegalStateException("No such object " + parentId);
+ }
+
+ //
+ UIObjectNode child = nodes.get(childId);
+ if (child == null)
+ {
+ throw new IllegalStateException("No such object " + childId);
+ }
+
+ //
+ parent.removeChild(child);
+ }
+
+ public void createChildren(String parentId)
+ {
+ UIObjectNode parent = nodes.get(parentId);
+ if (parent == null)
+ {
+ throw new IllegalStateException("No such object " + parentId);
+ }
+
+ //
+ parent.createChildren();
+ }
+
+ public void destroyChildren(String parentId)
+ {
+ UIObjectNode parent =nodes.get(parentId);
+ if (parent == null)
+ {
+ throw new IllegalStateException("No such object " + parentId);
+ }
+
+ //
+ parent.destroyChildren();
+ }
+}
\ No newline at end of file
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UpdateObjectTestCase.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UpdateObjectTestCase.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UpdateObjectTestCase.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/UpdateObjectTestCase.java 2008-07-02 23:12:33 UTC (rev 11274)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import org.jboss.portal.presentation.model.ObjectTraversalType;
+import org.jboss.portal.presentation.model.ViewPort;
+import org.jboss.portal.presentation.model.ViewPortScope;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class UpdateObjectTestCase extends TraversalModelTestCase
+{
+
+ public void testUpdateObject()
+ {
+ test(0, null);
+ }
+
+ protected void test(ObjectTraversalType[] before, ObjectTraversalType[] after, Object handback)
+ {
+ NodeDef rootDef = NodeDef.create(context);
+ NodeDef fooDef = rootDef.addChild("foo");
+
+ //
+ rootDef.populate(mockModel);
+
+ //
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
+ UIObjectTree context = new UIObjectTree();
+ ViewPort viewPort = model.createViewPort(context, scope);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+
+ //
+ mockModel.getRoot().getChild("foo").setPropertyValue("juu", "daa");
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+
+ //
+ mockModel.getRoot().getChild("foo").setPropertyValue("juu", null);
+ mockModel.getRoot().getChild("foo").setPropertyValue("daa", "juu");
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ }
+}
16 years
JBoss Portal SVN: r11273 - in modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state: mock and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-07-02 18:14:58 -0400 (Wed, 02 Jul 2008)
New Revision: 11273
Added:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockException.java
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/AbstractStructuralStateContextTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockModel.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockObject.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockModelImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockObjectImpl.java
Log:
actually putting that stuff in a package related to state as it is what it does
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/AbstractStructuralStateContextTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/AbstractStructuralStateContextTestCase.java 2008-07-02 22:14:02 UTC (rev 11272)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/AbstractStructuralStateContextTestCase.java 2008-07-02 22:14:58 UTC (rev 11273)
@@ -32,7 +32,7 @@
import org.jboss.portal.presentation.state.structural.StructuralObject;
import org.jboss.portal.presentation.state.structural.StructuralState;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.MockException;
+import org.jboss.portal.presentation.test.state.mock.MockException;
import java.util.Collection;
import java.util.Collections;
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockException.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockException.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockException.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockException.java 2008-07-02 22:14:58 UTC (rev 11273)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.state.mock;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class MockException extends RuntimeException
+{
+
+ /** . */
+ private ErrorCode code;
+
+ public MockException(ErrorCode code)
+ {
+ this.code = code;
+ }
+
+ public MockException(String s, ErrorCode code)
+ {
+ super(s);
+ this.code = code;
+ }
+
+ public enum ErrorCode
+ {
+ INVALID_OBJECT,
+ CONSTRAINT_VIOLATION
+ }
+
+ public ErrorCode getCode()
+ {
+ return code;
+ }
+}
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockModel.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockModel.java 2008-07-02 22:14:02 UTC (rev 11272)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockModel.java 2008-07-02 22:14:58 UTC (rev 11273)
@@ -23,7 +23,7 @@
package org.jboss.portal.presentation.test.state.mock;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.MockException;
+import org.jboss.portal.presentation.test.state.mock.MockException;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockObject.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockObject.java 2008-07-02 22:14:02 UTC (rev 11272)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockObject.java 2008-07-02 22:14:58 UTC (rev 11273)
@@ -24,7 +24,6 @@
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.state.structural.StructuralObject;
-import org.jboss.portal.presentation.test.model.MockException;
import java.util.List;
import java.util.Map;
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockModelImpl.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockModelImpl.java 2008-07-02 22:14:02 UTC (rev 11272)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockModelImpl.java 2008-07-02 22:14:58 UTC (rev 11273)
@@ -31,7 +31,7 @@
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
import org.jboss.portal.presentation.test.state.mock.MockObject;
import org.jboss.portal.presentation.test.state.mock.MockModel;
-import org.jboss.portal.presentation.test.model.MockException;
+import org.jboss.portal.presentation.test.state.mock.MockException;
import java.util.ArrayList;
import java.util.Collection;
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockObjectImpl.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockObjectImpl.java 2008-07-02 22:14:02 UTC (rev 11272)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockObjectImpl.java 2008-07-02 22:14:58 UTC (rev 11273)
@@ -24,7 +24,7 @@
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.test.state.mock.MockObject;
-import org.jboss.portal.presentation.test.model.MockException;
+import org.jboss.portal.presentation.test.state.mock.MockException;
import java.util.ArrayList;
import java.util.Collections;
16 years
JBoss Portal SVN: r11272 - in modules/presentation/trunk: presentation/src/test/java/org/jboss/portal/presentation/test and 5 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-07-02 18:14:02 -0400 (Wed, 02 Jul 2008)
New Revision: 11272
Added:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/AbstractStructuralStateContextTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/
Removed:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractMockImplementationTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModel.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockObject.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/AbstractMockImplementationTestCase.java
Modified:
modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockModel.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockObject.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockModelImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockObjectImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/StructuralObjectHandle.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/StructuralObjectImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/StructuralStateImpl.java
Log:
actually putting that stuff in a package related to state as it is what it does
Modified: modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java
===================================================================
--- modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -27,7 +27,7 @@
import org.jboss.portal.presentation.model.ui.UIPage;
import org.jboss.portal.presentation.model.ui.UIWindow;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.mock.AbstractMockImplementationTestCase;
+import org.jboss.portal.presentation.test.state.AbstractStructuralStateContextTestCase;
import org.jboss.portal.presentation.impl.state.structural.adapter.StructuralStateContextImpl;
import org.jboss.portal.presentation.impl.state.structural.adapter.StructuralAdapter;
import org.jboss.portal.presentation.portal.model.layout.LayoutStore;
@@ -46,7 +46,7 @@
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class StructuralStateContextTestCase extends AbstractMockImplementationTestCase<PortalNode>
+public class StructuralStateContextTestCase extends AbstractStructuralStateContextTestCase<PortalNode>
{
/** . */
Deleted: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractMockImplementationTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractMockImplementationTestCase.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractMockImplementationTestCase.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -1,444 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * 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. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model;
-
-import junit.framework.TestCase;
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.model.ui.UIContext;
-import org.jboss.portal.presentation.model.ui.UIPage;
-import org.jboss.portal.presentation.state.NoSuchStateException;
-import org.jboss.portal.presentation.state.StaleStateException;
-import org.jboss.portal.presentation.state.StateException;
-import org.jboss.portal.presentation.state.structural.StructuralObject;
-import org.jboss.portal.presentation.state.structural.StructuralState;
-import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public abstract class AbstractMockImplementationTestCase<MockObject> extends TestCase
-{
-
- public AbstractMockImplementationTestCase()
- {
- }
-
- public AbstractMockImplementationTestCase(String testName)
- {
- super(testName);
- }
-
- protected abstract StructuralStateContext getStructuralStateContext();
-
- protected abstract MockObject getRoot();
-
- protected abstract Set<String> getPropertyNames(MockObject object);
-
- protected abstract MockObject getParent(MockObject object);
-
- protected abstract List<? extends MockObject> getChildren(MockObject object);
-
- protected abstract String getName(MockObject object);
-
- protected abstract boolean isValid(MockObject object);
-
- protected abstract Class<? extends UIObject> getType(MockObject object);
-
- protected abstract String getId(MockObject object);
-
- protected abstract MockObject addChild(MockObject object, String name, Class<? extends UIObject> modelType);
-
- protected abstract void destroy(MockObject object);
-
- protected abstract void setProperty(MockObject object, String propertyName, String propertyValue);
-
- protected abstract Serializable getProperty(MockObject object, String name);
-
- protected final StructuralObject getStructuralObject(MockObject object)
- {
- return getStructuralStateContext().load(getId(object));
- }
-
- public void testRoot()
- {
- MockObject mockRoot = getRoot();
- assertNotNull(mockRoot);
- assertEquals(Collections.EMPTY_SET, getPropertyNames(mockRoot));
- assertNull(getParent(mockRoot));
- assertEquals(Collections.EMPTY_LIST, getChildren(mockRoot));
- assertEquals(UIContext.class, getType(mockRoot));
- assertEquals("", getName(mockRoot));
- assertEquals(true, isValid(mockRoot));
-
- //
- String rootId = getStructuralStateContext().getRootId();
- assertNotNull(rootId);
- StructuralObject root = getStructuralStateContext().load(rootId);
- assertNotNull(root);
- assertEquals(rootId, root.getId());
- StructuralState state = root.getState();
- assertEquals(UIContext.class, state.getType());
- assertEquals(Collections.EMPTY_MAP, state.getProperties());
- }
-
- public void testAddChild()
- {
- MockObject mockRoot = getRoot();
- // int rootV0 = mockRoot.getVersion();
-
- //
- String rootId = getId(mockRoot);
- StructuralObject root = getStructuralStateContext().load(rootId);
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- assertNotNull(mockFoo);
- String fooId = getId(mockFoo);
-
- //
- assertNotNull(fooId);
- assertEquals("foo", getName(mockFoo));
- assertEquals(UIPage.class, getType(mockFoo));
- assertSame(mockRoot, getParent(mockFoo));
- assertEquals(Collections.singletonList(mockFoo), getChildren(mockRoot));
- assertEquals(Collections.EMPTY_SET, getPropertyNames(mockFoo));
- // assertTrue(mockRoot.getVersion() > rootV0);
-
- //
- try
- {
- getStructuralStateContext().loadParent(root);
- fail();
- }
- catch (StaleStateException ignore)
- {
- }
- try
- {
- getStructuralStateContext().loadChildren(root);
- fail();
- }
- catch (StaleStateException ignore)
- {
- }
-
- //
- root = getStructuralStateContext().load(rootId);
- assertNotNull(root);
- assertEquals(rootId, root.getId());
-
- //
- Collection<StructuralObject> children = getStructuralStateContext().loadChildren(root);
- assertNotNull(children);
- assertEquals(1, children.size());
- StructuralObject foo = children.iterator().next();
- assertNotNull(foo);
- assertEquals(fooId, foo.getId());
- StructuralState fooState = foo.getState();
- assertNotNull(fooState);
- assertEquals(Collections.EMPTY_MAP, fooState.getProperties());
- assertEquals(UIPage.class, fooState.getType());
- root = getStructuralStateContext().loadParent(foo);
- assertNotNull(root);
- assertEquals(rootId, root.getId());
- }
-
- public void testDestroy() throws MockException
- {
- MockObject mockRoot = getRoot();
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- MockObject mockBar = addChild(mockFoo, "bar", UIPage.class);
- MockObject mockJuu = addChild(mockFoo, "juu", UIPage.class);
-// int rootV0 = mockRoot.getVersion();
-// int fooV0 = mockFoo.getVersion();
-// int barV0 = mockBar.getVersion();
- String fooId = getId(mockFoo);
- String barId = getId(mockBar);
- String juuId = getId(mockJuu);
- StructuralObject foo0 = getStructuralStateContext().load(fooId);
- StructuralObject bar0 = getStructuralStateContext().load(barId);
- StructuralObject juu0 = getStructuralStateContext().load(juuId);
-
- //
- destroy(mockJuu);
-
- //
- StructuralObject foo1 = getStructuralStateContext().load(fooId);
- StructuralObject bar1 = getStructuralStateContext().load(barId);
- StructuralObject juu1 = getStructuralStateContext().load(juuId);
-// int rootV1 = mockRoot.getVersion();
-// int fooV1 = mockFoo.getVersion();
-// int barV1 = mockBar.getVersion();
-
- //
- assertStale(juu0);
- assertStale(foo0);
- assertNotStale(bar0);
- assertNull(juu1);
- assertNotStale(foo1);
- assertNotStale(bar1);
- assertEquals(Collections.singletonList(mockFoo), getChildren(mockRoot));
- assertEquals(Collections.singletonList(mockBar), getChildren(mockFoo));
- assertTrue(isValid(mockFoo));
- assertTrue(isValid(mockBar));
- assertFalse(isValid(mockJuu));
-// assertTrue(rootV1 == rootV0);
-// assertTrue(fooV1 > fooV0);
-// assertTrue(barV1 == barV0);
-
- //
- destroy(mockFoo);
-
-// int rootV2 = mockRoot.getVersion();
- StructuralObject foo2 = getStructuralStateContext().load(fooId);
- StructuralObject bar2 = getStructuralStateContext().load(barId);
- StructuralObject juu2 = getStructuralStateContext().load(juuId);
-
- //
- assertStale(juu0);
- assertStale(foo0);
- assertStale(bar0);
- assertNull(juu1);
- assertStale(foo1);
- assertStale(bar1);
- assertNull(foo2);
- assertNull(bar2);
- assertNull(juu2);
- assertEquals(Collections.emptyList(), getChildren(mockRoot));
- assertFalse(isValid(mockFoo));
- assertFalse(isValid(mockBar));
- assertFalse(isValid(mockJuu));
-// assertTrue(rootV2 > rootV1);
- }
-
- public void testUpdateProperty() throws MockException
- {
- MockObject mockRoot = getRoot();
- String rootId = getId(mockRoot);
-// int rootV0 = mockRoot.getVersion();
-
- //
- StructuralObject root0 = getStructuralStateContext().load(rootId);
- StructuralState rootState0 = root0.getState();
- assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
-
- // Set
- setProperty(mockRoot, "foo", "bar");
-
- //
-// int rootV1 = mockRoot.getVersion();
-// assertTrue(rootV1 > rootV0);
- assertEquals(Collections.singleton("foo"), getPropertyNames(mockRoot));
- assertEquals("bar", getProperty(mockRoot, "foo"));
- assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
- assertStale(root0);
- StructuralObject root1 = getStructuralStateContext().load(rootId);
- assertNotNull(root1);
- assertNotStale(root1);
- StructuralState rootState1 = root1.getState();
- assertEquals(Collections.singletonMap("foo", "bar"), rootState1.getProperties());
- }
-
- public void testInvalidatedByDestruction() throws MockException
- {
- MockObject mockRoot = getRoot();
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- MockObject mockBar = addChild(mockRoot, "bar", UIPage.class);
-
- //
- StructuralObject foo = getStructuralObject(mockFoo);
-
- //
- destroy(mockFoo);
-
- //
- assertValidity(foo, NoSuchStateException.class);
- }
-
- public void testInvalidatedByPropertyUpdate() throws MockException
- {
- MockObject mockRoot = getRoot();
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
-
- //
- StructuralObject foo = getStructuralObject(mockFoo);
-
- //
- setProperty(mockFoo, "a", "b");
-
- //
- assertValidity(foo, StaleStateException.class);
- }
-
- public void testInvalidatedByChildCreation() throws MockException
- {
- MockObject mockRoot = getRoot();
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
-
- //
- StructuralObject foo = getStructuralObject(mockFoo);
-
- //
- addChild(mockFoo, "juu", UIPage.class);
-
- //
- assertValidity(foo, StaleStateException.class);
- }
-
- public void testInvalidatedByChildDestruction() throws MockException
- {
- MockObject mockRoot = getRoot();
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- MockObject mockJuu = addChild(mockFoo, "juu", UIPage.class);
-
- //
- StructuralObject foo = getStructuralObject(mockFoo);
-
- //
- destroy(mockJuu);
-
- //
- assertValidity(foo, StaleStateException.class);
- }
-
-
- public void testRefresh() throws MockException
- {
- MockObject mockRoot = getRoot();
- String rootId = getId(mockRoot);
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- String fooId = getId(mockFoo);
- MockObject mockJuu = addChild(mockRoot, "juu", UIPage.class);
- String juuId = getId(mockJuu);
- MockObject mockFaa = addChild(mockRoot, "faa", UIPage.class);
- String faaId = getId(mockFaa);
- StructuralObject rootV0 = getStructuralStateContext().load(rootId);
-
- //
- MockObject mockBar = addChild(mockRoot, "bar", UIPage.class);
- String barId = getId(mockBar);
- destroy(mockFoo);
- setProperty(mockJuu, "blah", "blah");
-
- //
- StructuralObject.Refresh comparison = getStructuralStateContext().refresh(rootV0);
- assertNotNull(comparison);
- Set<String> removed = comparison.getRemovedChildren();
- assertNotNull(removed);
- assertEquals(1, removed.size());
- assertEquals(fooId, removed.iterator().next());
-
- //
- Set<StructuralObject> added = comparison.getAddedChildren();
- assertNotNull(added);
- assertEquals(1, added.size());
- assertEquals(barId, added.iterator().next().getId());
-
- //
- Map<String, StructuralObject> stale = comparison.getStaleChildren();
- assertNotNull(stale);
- assertTrue(stale.size() >= 1);
- StructuralObject juu = stale.get(getId(mockJuu));
- assertNotNull(juu);
- assertEquals(juuId, juu.getId());
- assertEquals("blah", juu.getState().getProperties().get("blah"));
-
- //
- Set<String> valid = comparison.getValidChildren();
- assertNotNull(valid);
- assertEquals(2 - stale.size(), valid.size());
- if (valid.size() >= 1)
- {
- assertTrue(valid.contains(faaId));
- }
- }
-
- protected final void assertValidity(StructuralObject object, Class<? extends StateException> expected) throws MockException
- {
- try
- {
- getStructuralStateContext().validate(object);
- fail();
- }
- catch (StateException e)
- {
- assertTrue(expected.isInstance(e));
- }
-
- //
- try
- {
- getStructuralStateContext().loadChildren(object);
- fail();
- }
- catch (StateException e)
- {
- assertTrue(expected.isInstance(e));
- }
-
- //
- try
- {
- getStructuralStateContext().loadParent(object);
- fail();
- }
- catch (StateException e)
- {
- assertTrue(expected.isInstance(e));
- }
-
- }
-
- protected final void assertStale(StructuralObject object)
- {
- try
- {
- getStructuralStateContext().validate(object);
- fail();
- }
- catch (StateException ignore)
- {
- }
- }
-
- protected final void assertNotStale(StructuralObject object)
- {
- getStructuralStateContext().validate(object);
- }
-}
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -28,9 +28,9 @@
import org.jboss.portal.presentation.model.UIModel;
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.mock.MockModel;
-import org.jboss.portal.presentation.test.model.mock.impl.MockModelImpl;
-import org.jboss.portal.presentation.test.model.mock.MockObject;
+import org.jboss.portal.presentation.test.state.mock.MockModel;
+import org.jboss.portal.presentation.test.state.mock.impl.MockModelImpl;
+import org.jboss.portal.presentation.test.state.mock.MockObject;
import org.jboss.portal.presentation.test.model3.UIObjectNode;
/**
Deleted: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModel.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModel.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModel.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -1,41 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * 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. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model;
-
-import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public interface MockModel
-{
-
- StructuralStateContext getStructuralStateContext();
-
- MockObject getRoot();
-
- void destroy(MockObject object) throws MockException;
-
- MockObject get(String id);
-}
Deleted: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockObject.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockObject.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockObject.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -1,110 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * 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. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model;
-
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.state.structural.StructuralObject;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public interface MockObject
-{
-
- public abstract static class UpdateBehavior
- {
- public static UpdateBehavior veto()
- {
- return new Veto();
- }
- public static UpdateBehavior failure(Throwable throwable)
- {
- return new Failure(throwable);
- }
- }
-
- static class Veto extends UpdateBehavior
- {
- }
-
- static class Failure extends UpdateBehavior
- {
-
- /** . */
- final Throwable throwable;
-
- public Failure(Throwable throwable)
- {
- this.throwable = throwable;
- }
-
- public <T extends Throwable> Failure throwAs(Class<T> type) throws T
- {
- if (type.isInstance(throwable))
- {
- throw type.cast(throwable);
- }
- return this;
- }
- }
-
- Class<? extends UIObject> getType();
-
- String getName();
-
- String getId();
-
- int getVersion();
-
- Serializable getPropertyValue(String propertyName) throws IllegalArgumentException;
-
- void setPropertyBehavior(String propertyName, UpdateBehavior propertyBehavior) throws IllegalArgumentException;
-
- UpdateBehavior getPropertyBehavior(String propertyName) throws IllegalArgumentException;
-
- void setPropertyValue(String propertyName, Serializable propertyValue) throws MockException;
-
- Set<String> getPropertyNames();
-
- MockObject addChild(String name, Class<? extends UIObject> type, Map<String, String> state) throws IllegalArgumentException, MockException;
-
- MockObject addChild(String name, Class<? extends UIObject> type) throws IllegalArgumentException, MockException;
-
- MockObject getParent();
-
- List<? extends MockObject> getChildren();
-
- MockObject getChild(String name);
-
- boolean isValid();
-
- StructuralObject takeSnapshot();
-
- void move(MockObject destination) throws IllegalArgumentException, MockException;
-}
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.portal.presentation.test.model;
-import org.jboss.portal.presentation.test.model.mock.MockModel;
-import org.jboss.portal.presentation.test.model.mock.MockObject;
+import org.jboss.portal.presentation.test.state.mock.MockModel;
+import org.jboss.portal.presentation.test.state.mock.MockObject;
import org.jboss.portal.presentation.test.model3.UIObjectNode;
/**
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -26,8 +26,8 @@
import org.jboss.portal.presentation.model.UIModel;
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.model.ViewPortScope;
-import org.jboss.portal.presentation.test.model.mock.MockModel;
-import org.jboss.portal.presentation.test.model.mock.MockObject;
+import org.jboss.portal.presentation.test.state.mock.MockModel;
+import org.jboss.portal.presentation.test.state.mock.MockObject;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -27,8 +27,8 @@
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.model.ui.UIContext;
import org.jboss.portal.presentation.model.ui.UIPage;
-import org.jboss.portal.presentation.test.model.mock.MockModel;
-import org.jboss.portal.presentation.test.model.mock.MockObject;
+import org.jboss.portal.presentation.test.state.mock.MockModel;
+import org.jboss.portal.presentation.test.state.mock.MockObject;
import org.jboss.portal.presentation.test.model.Resolver;
import java.util.HashMap;
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -29,8 +29,8 @@
import org.jboss.portal.presentation.model.ObjectTraversalType;
import org.jboss.portal.presentation.model.UIModel;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.mock.MockModel;
-import org.jboss.portal.presentation.test.model.mock.impl.MockModelImpl;
+import org.jboss.portal.presentation.test.state.mock.MockModel;
+import org.jboss.portal.presentation.test.state.mock.impl.MockModelImpl;
import org.jboss.portal.presentation.test.model.Resolver;
import java.util.ArrayList;
Added: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/AbstractStructuralStateContextTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/AbstractStructuralStateContextTestCase.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/AbstractStructuralStateContextTestCase.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -0,0 +1,447 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.state;
+
+import junit.framework.TestCase;
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.model.ui.UIContext;
+import org.jboss.portal.presentation.model.ui.UIPage;
+import org.jboss.portal.presentation.state.NoSuchStateException;
+import org.jboss.portal.presentation.state.StaleStateException;
+import org.jboss.portal.presentation.state.StateException;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+import org.jboss.portal.presentation.state.structural.StructuralState;
+import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.test.model.MockException;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.io.Serializable;
+
+/**
+ * Abstract test case for testing structural state.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class AbstractStructuralStateContextTestCase<MockObject> extends TestCase
+{
+
+ public AbstractStructuralStateContextTestCase()
+ {
+ }
+
+ public AbstractStructuralStateContextTestCase(String testName)
+ {
+ super(testName);
+ }
+
+ protected abstract StructuralStateContext getStructuralStateContext();
+
+ protected abstract MockObject getRoot();
+
+ protected abstract Set<String> getPropertyNames(MockObject object);
+
+ protected abstract MockObject getParent(MockObject object);
+
+ protected abstract List<? extends MockObject> getChildren(MockObject object);
+
+ protected abstract String getName(MockObject object);
+
+ protected abstract boolean isValid(MockObject object);
+
+ protected abstract Class<? extends UIObject> getType(MockObject object);
+
+ protected abstract String getId(MockObject object);
+
+ protected abstract MockObject addChild(MockObject object, String name, Class<? extends UIObject> modelType);
+
+ protected abstract void destroy(MockObject object);
+
+ protected abstract void setProperty(MockObject object, String propertyName, String propertyValue);
+
+ protected abstract Serializable getProperty(MockObject object, String name);
+
+ protected final StructuralObject getStructuralObject(MockObject object)
+ {
+ return getStructuralStateContext().load(getId(object));
+ }
+
+ public void testRoot()
+ {
+ MockObject mockRoot = getRoot();
+ assertNotNull(mockRoot);
+ assertEquals(Collections.EMPTY_SET, getPropertyNames(mockRoot));
+ assertNull(getParent(mockRoot));
+ assertEquals(Collections.EMPTY_LIST, getChildren(mockRoot));
+ assertEquals(UIContext.class, getType(mockRoot));
+ assertEquals("", getName(mockRoot));
+ assertEquals(true, isValid(mockRoot));
+
+ //
+ String rootId = getStructuralStateContext().getRootId();
+ assertNotNull(rootId);
+ StructuralObject root = getStructuralStateContext().load(rootId);
+ assertNotNull(root);
+ assertEquals(rootId, root.getId());
+ StructuralState state = root.getState();
+ assertEquals(UIContext.class, state.getType());
+ assertEquals(Collections.EMPTY_MAP, state.getProperties());
+ }
+
+ public void testAddChild()
+ {
+ MockObject mockRoot = getRoot();
+ // int rootV0 = mockRoot.getVersion();
+
+ //
+ String rootId = getId(mockRoot);
+ StructuralObject root = getStructuralStateContext().load(rootId);
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ assertNotNull(mockFoo);
+ String fooId = getId(mockFoo);
+
+ //
+ assertNotNull(fooId);
+ assertEquals("foo", getName(mockFoo));
+ assertEquals(UIPage.class, getType(mockFoo));
+ assertSame(mockRoot, getParent(mockFoo));
+ assertEquals(Collections.singletonList(mockFoo), getChildren(mockRoot));
+ assertEquals(Collections.EMPTY_SET, getPropertyNames(mockFoo));
+ // assertTrue(mockRoot.getVersion() > rootV0);
+
+ //
+ try
+ {
+ getStructuralStateContext().loadParent(root);
+ fail();
+ }
+ catch (StaleStateException ignore)
+ {
+ }
+ try
+ {
+ getStructuralStateContext().loadChildren(root);
+ fail();
+ }
+ catch (StaleStateException ignore)
+ {
+ }
+
+ //
+ root = getStructuralStateContext().load(rootId);
+ assertNotNull(root);
+ assertEquals(rootId, root.getId());
+
+ //
+ Collection<StructuralObject> children = getStructuralStateContext().loadChildren(root);
+ assertNotNull(children);
+ assertEquals(1, children.size());
+ StructuralObject foo = children.iterator().next();
+ assertNotNull(foo);
+ assertEquals(fooId, foo.getId());
+ StructuralState fooState = foo.getState();
+ assertNotNull(fooState);
+ assertEquals(Collections.EMPTY_MAP, fooState.getProperties());
+ assertEquals(UIPage.class, fooState.getType());
+ root = getStructuralStateContext().loadParent(foo);
+ assertNotNull(root);
+ assertEquals(rootId, root.getId());
+ }
+
+ public void testDestroy() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ MockObject mockBar = addChild(mockFoo, "bar", UIPage.class);
+ MockObject mockJuu = addChild(mockFoo, "juu", UIPage.class);
+// int rootV0 = mockRoot.getVersion();
+// int fooV0 = mockFoo.getVersion();
+// int barV0 = mockBar.getVersion();
+ String fooId = getId(mockFoo);
+ String barId = getId(mockBar);
+ String juuId = getId(mockJuu);
+ StructuralObject foo0 = getStructuralStateContext().load(fooId);
+ StructuralObject bar0 = getStructuralStateContext().load(barId);
+ StructuralObject juu0 = getStructuralStateContext().load(juuId);
+
+ //
+ destroy(mockJuu);
+
+ //
+ StructuralObject foo1 = getStructuralStateContext().load(fooId);
+ StructuralObject bar1 = getStructuralStateContext().load(barId);
+ StructuralObject juu1 = getStructuralStateContext().load(juuId);
+// int rootV1 = mockRoot.getVersion();
+// int fooV1 = mockFoo.getVersion();
+// int barV1 = mockBar.getVersion();
+
+ //
+ assertStale(juu0);
+ assertStale(foo0);
+ assertNotStale(bar0);
+ assertNull(juu1);
+ assertNotStale(foo1);
+ assertNotStale(bar1);
+ assertEquals(Collections.singletonList(mockFoo), getChildren(mockRoot));
+ assertEquals(Collections.singletonList(mockBar), getChildren(mockFoo));
+ assertTrue(isValid(mockFoo));
+ assertTrue(isValid(mockBar));
+ assertFalse(isValid(mockJuu));
+// assertTrue(rootV1 == rootV0);
+// assertTrue(fooV1 > fooV0);
+// assertTrue(barV1 == barV0);
+
+ //
+ destroy(mockFoo);
+
+// int rootV2 = mockRoot.getVersion();
+ StructuralObject foo2 = getStructuralStateContext().load(fooId);
+ StructuralObject bar2 = getStructuralStateContext().load(barId);
+ StructuralObject juu2 = getStructuralStateContext().load(juuId);
+
+ //
+ assertStale(juu0);
+ assertStale(foo0);
+ assertStale(bar0);
+ assertNull(juu1);
+ assertStale(foo1);
+ assertStale(bar1);
+ assertNull(foo2);
+ assertNull(bar2);
+ assertNull(juu2);
+ assertEquals(Collections.emptyList(), getChildren(mockRoot));
+ assertFalse(isValid(mockFoo));
+ assertFalse(isValid(mockBar));
+ assertFalse(isValid(mockJuu));
+// assertTrue(rootV2 > rootV1);
+ }
+
+ public void testUpdateProperty() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+ String rootId = getId(mockRoot);
+// int rootV0 = mockRoot.getVersion();
+
+ //
+ StructuralObject root0 = getStructuralStateContext().load(rootId);
+ StructuralState rootState0 = root0.getState();
+ assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
+
+ // Set
+ setProperty(mockRoot, "foo", "bar");
+
+ //
+// int rootV1 = mockRoot.getVersion();
+// assertTrue(rootV1 > rootV0);
+ assertEquals(Collections.singleton("foo"), getPropertyNames(mockRoot));
+ assertEquals("bar", getProperty(mockRoot, "foo"));
+ assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
+ assertStale(root0);
+ StructuralObject root1 = getStructuralStateContext().load(rootId);
+ assertNotNull(root1);
+ assertNotStale(root1);
+ StructuralState rootState1 = root1.getState();
+ assertEquals(Collections.singletonMap("foo", "bar"), rootState1.getProperties());
+ }
+
+ public void testInvalidatedByDestruction() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ MockObject mockBar = addChild(mockRoot, "bar", UIPage.class);
+
+ //
+ StructuralObject foo = getStructuralObject(mockFoo);
+
+ //
+ destroy(mockFoo);
+
+ //
+ assertValidity(foo, NoSuchStateException.class);
+ }
+
+ public void testInvalidatedByPropertyUpdate() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+
+ //
+ StructuralObject foo = getStructuralObject(mockFoo);
+
+ //
+ setProperty(mockFoo, "a", "b");
+
+ //
+ assertValidity(foo, StaleStateException.class);
+ }
+
+ public void testInvalidatedByChildCreation() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+
+ //
+ StructuralObject foo = getStructuralObject(mockFoo);
+
+ //
+ addChild(mockFoo, "juu", UIPage.class);
+
+ //
+ assertValidity(foo, StaleStateException.class);
+ }
+
+ public void testInvalidatedByChildDestruction() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ MockObject mockJuu = addChild(mockFoo, "juu", UIPage.class);
+
+ //
+ StructuralObject foo = getStructuralObject(mockFoo);
+
+ //
+ destroy(mockJuu);
+
+ //
+ assertValidity(foo, StaleStateException.class);
+ }
+
+
+ public void testRefresh() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+ String rootId = getId(mockRoot);
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ String fooId = getId(mockFoo);
+ MockObject mockJuu = addChild(mockRoot, "juu", UIPage.class);
+ String juuId = getId(mockJuu);
+ MockObject mockFaa = addChild(mockRoot, "faa", UIPage.class);
+ String faaId = getId(mockFaa);
+ StructuralObject rootV0 = getStructuralStateContext().load(rootId);
+
+ //
+ MockObject mockBar = addChild(mockRoot, "bar", UIPage.class);
+ String barId = getId(mockBar);
+ destroy(mockFoo);
+ setProperty(mockJuu, "blah", "blah");
+
+ //
+ StructuralObject.Refresh comparison = getStructuralStateContext().refresh(rootV0);
+ assertNotNull(comparison);
+ Set<String> removed = comparison.getRemovedChildren();
+ assertNotNull(removed);
+ assertEquals(1, removed.size());
+ assertEquals(fooId, removed.iterator().next());
+
+ //
+ Set<StructuralObject> added = comparison.getAddedChildren();
+ assertNotNull(added);
+ assertEquals(1, added.size());
+ assertEquals(barId, added.iterator().next().getId());
+
+ //
+ Map<String, StructuralObject> stale = comparison.getStaleChildren();
+ assertNotNull(stale);
+ assertTrue(stale.size() >= 1);
+ StructuralObject juu = stale.get(getId(mockJuu));
+ assertNotNull(juu);
+ assertEquals(juuId, juu.getId());
+ assertEquals("blah", juu.getState().getProperties().get("blah"));
+
+ //
+ Set<String> valid = comparison.getValidChildren();
+ assertNotNull(valid);
+ assertEquals(2 - stale.size(), valid.size());
+ if (valid.size() >= 1)
+ {
+ assertTrue(valid.contains(faaId));
+ }
+ }
+
+ protected final void assertValidity(StructuralObject object, Class<? extends StateException> expected) throws MockException
+ {
+ try
+ {
+ getStructuralStateContext().validate(object);
+ fail();
+ }
+ catch (StateException e)
+ {
+ assertTrue(expected.isInstance(e));
+ }
+
+ //
+ try
+ {
+ getStructuralStateContext().loadChildren(object);
+ fail();
+ }
+ catch (StateException e)
+ {
+ assertTrue(expected.isInstance(e));
+ }
+
+ //
+ try
+ {
+ getStructuralStateContext().loadParent(object);
+ fail();
+ }
+ catch (StateException e)
+ {
+ assertTrue(expected.isInstance(e));
+ }
+
+ }
+
+ protected final void assertStale(StructuralObject object)
+ {
+ try
+ {
+ getStructuralStateContext().validate(object);
+ fail();
+ }
+ catch (StateException ignore)
+ {
+ }
+ }
+
+ protected final void assertNotStale(StructuralObject object)
+ {
+ getStructuralStateContext().validate(object);
+ }
+}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock (from rev 11271, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock)
Deleted: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/AbstractMockImplementationTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/AbstractMockImplementationTestCase.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/AbstractMockImplementationTestCase.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -1,445 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * 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. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model.mock;
-
-import junit.framework.TestCase;
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.model.ui.UIContext;
-import org.jboss.portal.presentation.model.ui.UIPage;
-import org.jboss.portal.presentation.state.NoSuchStateException;
-import org.jboss.portal.presentation.state.StaleStateException;
-import org.jboss.portal.presentation.state.StateException;
-import org.jboss.portal.presentation.state.structural.StructuralObject;
-import org.jboss.portal.presentation.state.structural.StructuralState;
-import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.MockException;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public abstract class AbstractMockImplementationTestCase<MockObject> extends TestCase
-{
-
- public AbstractMockImplementationTestCase()
- {
- }
-
- public AbstractMockImplementationTestCase(String testName)
- {
- super(testName);
- }
-
- protected abstract StructuralStateContext getStructuralStateContext();
-
- protected abstract MockObject getRoot();
-
- protected abstract Set<String> getPropertyNames(MockObject object);
-
- protected abstract MockObject getParent(MockObject object);
-
- protected abstract List<? extends MockObject> getChildren(MockObject object);
-
- protected abstract String getName(MockObject object);
-
- protected abstract boolean isValid(MockObject object);
-
- protected abstract Class<? extends UIObject> getType(MockObject object);
-
- protected abstract String getId(MockObject object);
-
- protected abstract MockObject addChild(MockObject object, String name, Class<? extends UIObject> modelType);
-
- protected abstract void destroy(MockObject object);
-
- protected abstract void setProperty(MockObject object, String propertyName, String propertyValue);
-
- protected abstract Serializable getProperty(MockObject object, String name);
-
- protected final StructuralObject getStructuralObject(MockObject object)
- {
- return getStructuralStateContext().load(getId(object));
- }
-
- public void testRoot()
- {
- MockObject mockRoot = getRoot();
- assertNotNull(mockRoot);
- assertEquals(Collections.EMPTY_SET, getPropertyNames(mockRoot));
- assertNull(getParent(mockRoot));
- assertEquals(Collections.EMPTY_LIST, getChildren(mockRoot));
- assertEquals(UIContext.class, getType(mockRoot));
- assertEquals("", getName(mockRoot));
- assertEquals(true, isValid(mockRoot));
-
- //
- String rootId = getStructuralStateContext().getRootId();
- assertNotNull(rootId);
- StructuralObject root = getStructuralStateContext().load(rootId);
- assertNotNull(root);
- assertEquals(rootId, root.getId());
- StructuralState state = root.getState();
- assertEquals(UIContext.class, state.getType());
- assertEquals(Collections.EMPTY_MAP, state.getProperties());
- }
-
- public void testAddChild()
- {
- MockObject mockRoot = getRoot();
- // int rootV0 = mockRoot.getVersion();
-
- //
- String rootId = getId(mockRoot);
- StructuralObject root = getStructuralStateContext().load(rootId);
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- assertNotNull(mockFoo);
- String fooId = getId(mockFoo);
-
- //
- assertNotNull(fooId);
- assertEquals("foo", getName(mockFoo));
- assertEquals(UIPage.class, getType(mockFoo));
- assertSame(mockRoot, getParent(mockFoo));
- assertEquals(Collections.singletonList(mockFoo), getChildren(mockRoot));
- assertEquals(Collections.EMPTY_SET, getPropertyNames(mockFoo));
- // assertTrue(mockRoot.getVersion() > rootV0);
-
- //
- try
- {
- getStructuralStateContext().loadParent(root);
- fail();
- }
- catch (StaleStateException ignore)
- {
- }
- try
- {
- getStructuralStateContext().loadChildren(root);
- fail();
- }
- catch (StaleStateException ignore)
- {
- }
-
- //
- root = getStructuralStateContext().load(rootId);
- assertNotNull(root);
- assertEquals(rootId, root.getId());
-
- //
- Collection<StructuralObject> children = getStructuralStateContext().loadChildren(root);
- assertNotNull(children);
- assertEquals(1, children.size());
- StructuralObject foo = children.iterator().next();
- assertNotNull(foo);
- assertEquals(fooId, foo.getId());
- StructuralState fooState = foo.getState();
- assertNotNull(fooState);
- assertEquals(Collections.EMPTY_MAP, fooState.getProperties());
- assertEquals(UIPage.class, fooState.getType());
- root = getStructuralStateContext().loadParent(foo);
- assertNotNull(root);
- assertEquals(rootId, root.getId());
- }
-
- public void testDestroy() throws MockException
- {
- MockObject mockRoot = getRoot();
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- MockObject mockBar = addChild(mockFoo, "bar", UIPage.class);
- MockObject mockJuu = addChild(mockFoo, "juu", UIPage.class);
-// int rootV0 = mockRoot.getVersion();
-// int fooV0 = mockFoo.getVersion();
-// int barV0 = mockBar.getVersion();
- String fooId = getId(mockFoo);
- String barId = getId(mockBar);
- String juuId = getId(mockJuu);
- StructuralObject foo0 = getStructuralStateContext().load(fooId);
- StructuralObject bar0 = getStructuralStateContext().load(barId);
- StructuralObject juu0 = getStructuralStateContext().load(juuId);
-
- //
- destroy(mockJuu);
-
- //
- StructuralObject foo1 = getStructuralStateContext().load(fooId);
- StructuralObject bar1 = getStructuralStateContext().load(barId);
- StructuralObject juu1 = getStructuralStateContext().load(juuId);
-// int rootV1 = mockRoot.getVersion();
-// int fooV1 = mockFoo.getVersion();
-// int barV1 = mockBar.getVersion();
-
- //
- assertStale(juu0);
- assertStale(foo0);
- assertNotStale(bar0);
- assertNull(juu1);
- assertNotStale(foo1);
- assertNotStale(bar1);
- assertEquals(Collections.singletonList(mockFoo), getChildren(mockRoot));
- assertEquals(Collections.singletonList(mockBar), getChildren(mockFoo));
- assertTrue(isValid(mockFoo));
- assertTrue(isValid(mockBar));
- assertFalse(isValid(mockJuu));
-// assertTrue(rootV1 == rootV0);
-// assertTrue(fooV1 > fooV0);
-// assertTrue(barV1 == barV0);
-
- //
- destroy(mockFoo);
-
-// int rootV2 = mockRoot.getVersion();
- StructuralObject foo2 = getStructuralStateContext().load(fooId);
- StructuralObject bar2 = getStructuralStateContext().load(barId);
- StructuralObject juu2 = getStructuralStateContext().load(juuId);
-
- //
- assertStale(juu0);
- assertStale(foo0);
- assertStale(bar0);
- assertNull(juu1);
- assertStale(foo1);
- assertStale(bar1);
- assertNull(foo2);
- assertNull(bar2);
- assertNull(juu2);
- assertEquals(Collections.emptyList(), getChildren(mockRoot));
- assertFalse(isValid(mockFoo));
- assertFalse(isValid(mockBar));
- assertFalse(isValid(mockJuu));
-// assertTrue(rootV2 > rootV1);
- }
-
- public void testUpdateProperty() throws MockException
- {
- MockObject mockRoot = getRoot();
- String rootId = getId(mockRoot);
-// int rootV0 = mockRoot.getVersion();
-
- //
- StructuralObject root0 = getStructuralStateContext().load(rootId);
- StructuralState rootState0 = root0.getState();
- assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
-
- // Set
- setProperty(mockRoot, "foo", "bar");
-
- //
-// int rootV1 = mockRoot.getVersion();
-// assertTrue(rootV1 > rootV0);
- assertEquals(Collections.singleton("foo"), getPropertyNames(mockRoot));
- assertEquals("bar", getProperty(mockRoot, "foo"));
- assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
- assertStale(root0);
- StructuralObject root1 = getStructuralStateContext().load(rootId);
- assertNotNull(root1);
- assertNotStale(root1);
- StructuralState rootState1 = root1.getState();
- assertEquals(Collections.singletonMap("foo", "bar"), rootState1.getProperties());
- }
-
- public void testInvalidatedByDestruction() throws MockException
- {
- MockObject mockRoot = getRoot();
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- MockObject mockBar = addChild(mockRoot, "bar", UIPage.class);
-
- //
- StructuralObject foo = getStructuralObject(mockFoo);
-
- //
- destroy(mockFoo);
-
- //
- assertValidity(foo, NoSuchStateException.class);
- }
-
- public void testInvalidatedByPropertyUpdate() throws MockException
- {
- MockObject mockRoot = getRoot();
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
-
- //
- StructuralObject foo = getStructuralObject(mockFoo);
-
- //
- setProperty(mockFoo, "a", "b");
-
- //
- assertValidity(foo, StaleStateException.class);
- }
-
- public void testInvalidatedByChildCreation() throws MockException
- {
- MockObject mockRoot = getRoot();
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
-
- //
- StructuralObject foo = getStructuralObject(mockFoo);
-
- //
- addChild(mockFoo, "juu", UIPage.class);
-
- //
- assertValidity(foo, StaleStateException.class);
- }
-
- public void testInvalidatedByChildDestruction() throws MockException
- {
- MockObject mockRoot = getRoot();
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- MockObject mockJuu = addChild(mockFoo, "juu", UIPage.class);
-
- //
- StructuralObject foo = getStructuralObject(mockFoo);
-
- //
- destroy(mockJuu);
-
- //
- assertValidity(foo, StaleStateException.class);
- }
-
-
- public void testRefresh() throws MockException
- {
- MockObject mockRoot = getRoot();
- String rootId = getId(mockRoot);
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- String fooId = getId(mockFoo);
- MockObject mockJuu = addChild(mockRoot, "juu", UIPage.class);
- String juuId = getId(mockJuu);
- MockObject mockFaa = addChild(mockRoot, "faa", UIPage.class);
- String faaId = getId(mockFaa);
- StructuralObject rootV0 = getStructuralStateContext().load(rootId);
-
- //
- MockObject mockBar = addChild(mockRoot, "bar", UIPage.class);
- String barId = getId(mockBar);
- destroy(mockFoo);
- setProperty(mockJuu, "blah", "blah");
-
- //
- StructuralObject.Refresh comparison = getStructuralStateContext().refresh(rootV0);
- assertNotNull(comparison);
- Set<String> removed = comparison.getRemovedChildren();
- assertNotNull(removed);
- assertEquals(1, removed.size());
- assertEquals(fooId, removed.iterator().next());
-
- //
- Set<StructuralObject> added = comparison.getAddedChildren();
- assertNotNull(added);
- assertEquals(1, added.size());
- assertEquals(barId, added.iterator().next().getId());
-
- //
- Map<String, StructuralObject> stale = comparison.getStaleChildren();
- assertNotNull(stale);
- assertTrue(stale.size() >= 1);
- StructuralObject juu = stale.get(getId(mockJuu));
- assertNotNull(juu);
- assertEquals(juuId, juu.getId());
- assertEquals("blah", juu.getState().getProperties().get("blah"));
-
- //
- Set<String> valid = comparison.getValidChildren();
- assertNotNull(valid);
- assertEquals(2 - stale.size(), valid.size());
- if (valid.size() >= 1)
- {
- assertTrue(valid.contains(faaId));
- }
- }
-
- protected final void assertValidity(StructuralObject object, Class<? extends StateException> expected) throws MockException
- {
- try
- {
- getStructuralStateContext().validate(object);
- fail();
- }
- catch (StateException e)
- {
- assertTrue(expected.isInstance(e));
- }
-
- //
- try
- {
- getStructuralStateContext().loadChildren(object);
- fail();
- }
- catch (StateException e)
- {
- assertTrue(expected.isInstance(e));
- }
-
- //
- try
- {
- getStructuralStateContext().loadParent(object);
- fail();
- }
- catch (StateException e)
- {
- assertTrue(expected.isInstance(e));
- }
-
- }
-
- protected final void assertStale(StructuralObject object)
- {
- try
- {
- getStructuralStateContext().validate(object);
- fail();
- }
- catch (StateException ignore)
- {
- }
- }
-
- protected final void assertNotStale(StructuralObject object)
- {
- getStructuralStateContext().validate(object);
- }
-}
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockModel.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/MockModel.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockModel.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.presentation.test.model.mock;
+package org.jboss.portal.presentation.test.state.mock;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
import org.jboss.portal.presentation.test.model.MockException;
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockObject.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/MockObject.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/MockObject.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.presentation.test.model.mock;
+package org.jboss.portal.presentation.test.state.mock;
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.state.structural.StructuralObject;
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockModelImpl.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/MockModelImpl.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockModelImpl.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.presentation.test.model.mock.impl;
+package org.jboss.portal.presentation.test.state.mock.impl;
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.model.ui.UIContext;
@@ -29,8 +29,8 @@
import org.jboss.portal.presentation.state.StateException;
import org.jboss.portal.presentation.state.structural.StructuralObject;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.mock.MockObject;
-import org.jboss.portal.presentation.test.model.mock.MockModel;
+import org.jboss.portal.presentation.test.state.mock.MockObject;
+import org.jboss.portal.presentation.test.state.mock.MockModel;
import org.jboss.portal.presentation.test.model.MockException;
import java.util.ArrayList;
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockObjectImpl.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/MockObjectImpl.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockObjectImpl.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -20,10 +20,10 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.presentation.test.model.mock.impl;
+package org.jboss.portal.presentation.test.state.mock.impl;
import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.test.model.mock.MockObject;
+import org.jboss.portal.presentation.test.state.mock.MockObject;
import org.jboss.portal.presentation.test.model.MockException;
import java.util.ArrayList;
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/StructuralObjectHandle.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralObjectHandle.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/StructuralObjectHandle.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.presentation.test.model.mock.impl;
+package org.jboss.portal.presentation.test.state.mock.impl;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/StructuralObjectImpl.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralObjectImpl.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/StructuralObjectImpl.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.presentation.test.model.mock.impl;
+package org.jboss.portal.presentation.test.state.mock.impl;
import org.jboss.portal.presentation.state.structural.StructuralObject;
import org.jboss.portal.presentation.state.structural.StructuralState;
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/StructuralStateImpl.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralStateImpl.java 2008-07-02 22:07:44 UTC (rev 11271)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/StructuralStateImpl.java 2008-07-02 22:14:02 UTC (rev 11272)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.presentation.test.model.mock.impl;
+package org.jboss.portal.presentation.test.state.mock.impl;
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.state.structural.StructuralState;
16 years
JBoss Portal SVN: r11271 - in modules/presentation/trunk: presentation/src/test/java/org/jboss/portal/presentation/test/model and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-07-02 18:07:44 -0400 (Wed, 02 Jul 2008)
New Revision: 11271
Added:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/AbstractMockImplementationTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/MockModel.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/MockObject.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/MockModelImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/MockObjectImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralObjectHandle.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralObjectImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralStateImpl.java
Removed:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/
Modified:
modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java
Log:
refactoring packages
Modified: modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java
===================================================================
--- modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
+++ modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -27,7 +27,7 @@
import org.jboss.portal.presentation.model.ui.UIPage;
import org.jboss.portal.presentation.model.ui.UIWindow;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.AbstractMockImplementationTestCase;
+import org.jboss.portal.presentation.test.model.mock.AbstractMockImplementationTestCase;
import org.jboss.portal.presentation.impl.state.structural.adapter.StructuralStateContextImpl;
import org.jboss.portal.presentation.impl.state.structural.adapter.StructuralAdapter;
import org.jboss.portal.presentation.portal.model.layout.LayoutStore;
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -28,9 +28,9 @@
import org.jboss.portal.presentation.model.UIModel;
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.MockModel;
-import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
-import org.jboss.portal.presentation.test.model.MockObject;
+import org.jboss.portal.presentation.test.model.mock.MockModel;
+import org.jboss.portal.presentation.test.model.mock.impl.MockModelImpl;
+import org.jboss.portal.presentation.test.model.mock.MockObject;
import org.jboss.portal.presentation.test.model3.UIObjectNode;
/**
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java 2008-07-02 22:02:20 UTC (rev 11270)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.portal.presentation.test.model;
-import org.jboss.portal.presentation.test.model.MockModel;
-import org.jboss.portal.presentation.test.model.MockObject;
+import org.jboss.portal.presentation.test.model.mock.MockModel;
+import org.jboss.portal.presentation.test.model.mock.MockObject;
import org.jboss.portal.presentation.test.model3.UIObjectNode;
/**
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/AbstractMockImplementationTestCase.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractMockImplementationTestCase.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/AbstractMockImplementationTestCase.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/AbstractMockImplementationTestCase.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -0,0 +1,445 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model.mock;
+
+import junit.framework.TestCase;
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.model.ui.UIContext;
+import org.jboss.portal.presentation.model.ui.UIPage;
+import org.jboss.portal.presentation.state.NoSuchStateException;
+import org.jboss.portal.presentation.state.StaleStateException;
+import org.jboss.portal.presentation.state.StateException;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+import org.jboss.portal.presentation.state.structural.StructuralState;
+import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.test.model.MockException;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class AbstractMockImplementationTestCase<MockObject> extends TestCase
+{
+
+ public AbstractMockImplementationTestCase()
+ {
+ }
+
+ public AbstractMockImplementationTestCase(String testName)
+ {
+ super(testName);
+ }
+
+ protected abstract StructuralStateContext getStructuralStateContext();
+
+ protected abstract MockObject getRoot();
+
+ protected abstract Set<String> getPropertyNames(MockObject object);
+
+ protected abstract MockObject getParent(MockObject object);
+
+ protected abstract List<? extends MockObject> getChildren(MockObject object);
+
+ protected abstract String getName(MockObject object);
+
+ protected abstract boolean isValid(MockObject object);
+
+ protected abstract Class<? extends UIObject> getType(MockObject object);
+
+ protected abstract String getId(MockObject object);
+
+ protected abstract MockObject addChild(MockObject object, String name, Class<? extends UIObject> modelType);
+
+ protected abstract void destroy(MockObject object);
+
+ protected abstract void setProperty(MockObject object, String propertyName, String propertyValue);
+
+ protected abstract Serializable getProperty(MockObject object, String name);
+
+ protected final StructuralObject getStructuralObject(MockObject object)
+ {
+ return getStructuralStateContext().load(getId(object));
+ }
+
+ public void testRoot()
+ {
+ MockObject mockRoot = getRoot();
+ assertNotNull(mockRoot);
+ assertEquals(Collections.EMPTY_SET, getPropertyNames(mockRoot));
+ assertNull(getParent(mockRoot));
+ assertEquals(Collections.EMPTY_LIST, getChildren(mockRoot));
+ assertEquals(UIContext.class, getType(mockRoot));
+ assertEquals("", getName(mockRoot));
+ assertEquals(true, isValid(mockRoot));
+
+ //
+ String rootId = getStructuralStateContext().getRootId();
+ assertNotNull(rootId);
+ StructuralObject root = getStructuralStateContext().load(rootId);
+ assertNotNull(root);
+ assertEquals(rootId, root.getId());
+ StructuralState state = root.getState();
+ assertEquals(UIContext.class, state.getType());
+ assertEquals(Collections.EMPTY_MAP, state.getProperties());
+ }
+
+ public void testAddChild()
+ {
+ MockObject mockRoot = getRoot();
+ // int rootV0 = mockRoot.getVersion();
+
+ //
+ String rootId = getId(mockRoot);
+ StructuralObject root = getStructuralStateContext().load(rootId);
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ assertNotNull(mockFoo);
+ String fooId = getId(mockFoo);
+
+ //
+ assertNotNull(fooId);
+ assertEquals("foo", getName(mockFoo));
+ assertEquals(UIPage.class, getType(mockFoo));
+ assertSame(mockRoot, getParent(mockFoo));
+ assertEquals(Collections.singletonList(mockFoo), getChildren(mockRoot));
+ assertEquals(Collections.EMPTY_SET, getPropertyNames(mockFoo));
+ // assertTrue(mockRoot.getVersion() > rootV0);
+
+ //
+ try
+ {
+ getStructuralStateContext().loadParent(root);
+ fail();
+ }
+ catch (StaleStateException ignore)
+ {
+ }
+ try
+ {
+ getStructuralStateContext().loadChildren(root);
+ fail();
+ }
+ catch (StaleStateException ignore)
+ {
+ }
+
+ //
+ root = getStructuralStateContext().load(rootId);
+ assertNotNull(root);
+ assertEquals(rootId, root.getId());
+
+ //
+ Collection<StructuralObject> children = getStructuralStateContext().loadChildren(root);
+ assertNotNull(children);
+ assertEquals(1, children.size());
+ StructuralObject foo = children.iterator().next();
+ assertNotNull(foo);
+ assertEquals(fooId, foo.getId());
+ StructuralState fooState = foo.getState();
+ assertNotNull(fooState);
+ assertEquals(Collections.EMPTY_MAP, fooState.getProperties());
+ assertEquals(UIPage.class, fooState.getType());
+ root = getStructuralStateContext().loadParent(foo);
+ assertNotNull(root);
+ assertEquals(rootId, root.getId());
+ }
+
+ public void testDestroy() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ MockObject mockBar = addChild(mockFoo, "bar", UIPage.class);
+ MockObject mockJuu = addChild(mockFoo, "juu", UIPage.class);
+// int rootV0 = mockRoot.getVersion();
+// int fooV0 = mockFoo.getVersion();
+// int barV0 = mockBar.getVersion();
+ String fooId = getId(mockFoo);
+ String barId = getId(mockBar);
+ String juuId = getId(mockJuu);
+ StructuralObject foo0 = getStructuralStateContext().load(fooId);
+ StructuralObject bar0 = getStructuralStateContext().load(barId);
+ StructuralObject juu0 = getStructuralStateContext().load(juuId);
+
+ //
+ destroy(mockJuu);
+
+ //
+ StructuralObject foo1 = getStructuralStateContext().load(fooId);
+ StructuralObject bar1 = getStructuralStateContext().load(barId);
+ StructuralObject juu1 = getStructuralStateContext().load(juuId);
+// int rootV1 = mockRoot.getVersion();
+// int fooV1 = mockFoo.getVersion();
+// int barV1 = mockBar.getVersion();
+
+ //
+ assertStale(juu0);
+ assertStale(foo0);
+ assertNotStale(bar0);
+ assertNull(juu1);
+ assertNotStale(foo1);
+ assertNotStale(bar1);
+ assertEquals(Collections.singletonList(mockFoo), getChildren(mockRoot));
+ assertEquals(Collections.singletonList(mockBar), getChildren(mockFoo));
+ assertTrue(isValid(mockFoo));
+ assertTrue(isValid(mockBar));
+ assertFalse(isValid(mockJuu));
+// assertTrue(rootV1 == rootV0);
+// assertTrue(fooV1 > fooV0);
+// assertTrue(barV1 == barV0);
+
+ //
+ destroy(mockFoo);
+
+// int rootV2 = mockRoot.getVersion();
+ StructuralObject foo2 = getStructuralStateContext().load(fooId);
+ StructuralObject bar2 = getStructuralStateContext().load(barId);
+ StructuralObject juu2 = getStructuralStateContext().load(juuId);
+
+ //
+ assertStale(juu0);
+ assertStale(foo0);
+ assertStale(bar0);
+ assertNull(juu1);
+ assertStale(foo1);
+ assertStale(bar1);
+ assertNull(foo2);
+ assertNull(bar2);
+ assertNull(juu2);
+ assertEquals(Collections.emptyList(), getChildren(mockRoot));
+ assertFalse(isValid(mockFoo));
+ assertFalse(isValid(mockBar));
+ assertFalse(isValid(mockJuu));
+// assertTrue(rootV2 > rootV1);
+ }
+
+ public void testUpdateProperty() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+ String rootId = getId(mockRoot);
+// int rootV0 = mockRoot.getVersion();
+
+ //
+ StructuralObject root0 = getStructuralStateContext().load(rootId);
+ StructuralState rootState0 = root0.getState();
+ assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
+
+ // Set
+ setProperty(mockRoot, "foo", "bar");
+
+ //
+// int rootV1 = mockRoot.getVersion();
+// assertTrue(rootV1 > rootV0);
+ assertEquals(Collections.singleton("foo"), getPropertyNames(mockRoot));
+ assertEquals("bar", getProperty(mockRoot, "foo"));
+ assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
+ assertStale(root0);
+ StructuralObject root1 = getStructuralStateContext().load(rootId);
+ assertNotNull(root1);
+ assertNotStale(root1);
+ StructuralState rootState1 = root1.getState();
+ assertEquals(Collections.singletonMap("foo", "bar"), rootState1.getProperties());
+ }
+
+ public void testInvalidatedByDestruction() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ MockObject mockBar = addChild(mockRoot, "bar", UIPage.class);
+
+ //
+ StructuralObject foo = getStructuralObject(mockFoo);
+
+ //
+ destroy(mockFoo);
+
+ //
+ assertValidity(foo, NoSuchStateException.class);
+ }
+
+ public void testInvalidatedByPropertyUpdate() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+
+ //
+ StructuralObject foo = getStructuralObject(mockFoo);
+
+ //
+ setProperty(mockFoo, "a", "b");
+
+ //
+ assertValidity(foo, StaleStateException.class);
+ }
+
+ public void testInvalidatedByChildCreation() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+
+ //
+ StructuralObject foo = getStructuralObject(mockFoo);
+
+ //
+ addChild(mockFoo, "juu", UIPage.class);
+
+ //
+ assertValidity(foo, StaleStateException.class);
+ }
+
+ public void testInvalidatedByChildDestruction() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ MockObject mockJuu = addChild(mockFoo, "juu", UIPage.class);
+
+ //
+ StructuralObject foo = getStructuralObject(mockFoo);
+
+ //
+ destroy(mockJuu);
+
+ //
+ assertValidity(foo, StaleStateException.class);
+ }
+
+
+ public void testRefresh() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+ String rootId = getId(mockRoot);
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ String fooId = getId(mockFoo);
+ MockObject mockJuu = addChild(mockRoot, "juu", UIPage.class);
+ String juuId = getId(mockJuu);
+ MockObject mockFaa = addChild(mockRoot, "faa", UIPage.class);
+ String faaId = getId(mockFaa);
+ StructuralObject rootV0 = getStructuralStateContext().load(rootId);
+
+ //
+ MockObject mockBar = addChild(mockRoot, "bar", UIPage.class);
+ String barId = getId(mockBar);
+ destroy(mockFoo);
+ setProperty(mockJuu, "blah", "blah");
+
+ //
+ StructuralObject.Refresh comparison = getStructuralStateContext().refresh(rootV0);
+ assertNotNull(comparison);
+ Set<String> removed = comparison.getRemovedChildren();
+ assertNotNull(removed);
+ assertEquals(1, removed.size());
+ assertEquals(fooId, removed.iterator().next());
+
+ //
+ Set<StructuralObject> added = comparison.getAddedChildren();
+ assertNotNull(added);
+ assertEquals(1, added.size());
+ assertEquals(barId, added.iterator().next().getId());
+
+ //
+ Map<String, StructuralObject> stale = comparison.getStaleChildren();
+ assertNotNull(stale);
+ assertTrue(stale.size() >= 1);
+ StructuralObject juu = stale.get(getId(mockJuu));
+ assertNotNull(juu);
+ assertEquals(juuId, juu.getId());
+ assertEquals("blah", juu.getState().getProperties().get("blah"));
+
+ //
+ Set<String> valid = comparison.getValidChildren();
+ assertNotNull(valid);
+ assertEquals(2 - stale.size(), valid.size());
+ if (valid.size() >= 1)
+ {
+ assertTrue(valid.contains(faaId));
+ }
+ }
+
+ protected final void assertValidity(StructuralObject object, Class<? extends StateException> expected) throws MockException
+ {
+ try
+ {
+ getStructuralStateContext().validate(object);
+ fail();
+ }
+ catch (StateException e)
+ {
+ assertTrue(expected.isInstance(e));
+ }
+
+ //
+ try
+ {
+ getStructuralStateContext().loadChildren(object);
+ fail();
+ }
+ catch (StateException e)
+ {
+ assertTrue(expected.isInstance(e));
+ }
+
+ //
+ try
+ {
+ getStructuralStateContext().loadParent(object);
+ fail();
+ }
+ catch (StateException e)
+ {
+ assertTrue(expected.isInstance(e));
+ }
+
+ }
+
+ protected final void assertStale(StructuralObject object)
+ {
+ try
+ {
+ getStructuralStateContext().validate(object);
+ fail();
+ }
+ catch (StateException ignore)
+ {
+ }
+ }
+
+ protected final void assertNotStale(StructuralObject object)
+ {
+ getStructuralStateContext().validate(object);
+ }
+}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/MockModel.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModel.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/MockModel.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/MockModel.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model.mock;
+
+import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.test.model.MockException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface MockModel
+{
+
+ StructuralStateContext getStructuralStateContext();
+
+ MockObject getRoot();
+
+ void destroy(MockObject object) throws MockException;
+
+ MockObject get(String id);
+}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/MockObject.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockObject.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/MockObject.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/MockObject.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model.mock;
+
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+import org.jboss.portal.presentation.test.model.MockException;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface MockObject
+{
+
+ public abstract static class UpdateBehavior
+ {
+ public static UpdateBehavior veto()
+ {
+ return new Veto();
+ }
+ public static UpdateBehavior failure(Throwable throwable)
+ {
+ return new Failure(throwable);
+ }
+ }
+
+ static class Veto extends UpdateBehavior
+ {
+ }
+
+ static class Failure extends UpdateBehavior
+ {
+
+ /** . */
+ final Throwable throwable;
+
+ public Failure(Throwable throwable)
+ {
+ this.throwable = throwable;
+ }
+
+ public <T extends Throwable> Failure throwAs(Class<T> type) throws T
+ {
+ if (type.isInstance(throwable))
+ {
+ throw type.cast(throwable);
+ }
+ return this;
+ }
+ }
+
+ Class<? extends UIObject> getType();
+
+ String getName();
+
+ String getId();
+
+ int getVersion();
+
+ Serializable getPropertyValue(String propertyName) throws IllegalArgumentException;
+
+ void setPropertyBehavior(String propertyName, UpdateBehavior propertyBehavior) throws IllegalArgumentException;
+
+ UpdateBehavior getPropertyBehavior(String propertyName) throws IllegalArgumentException;
+
+ void setPropertyValue(String propertyName, Serializable propertyValue) throws MockException;
+
+ Set<String> getPropertyNames();
+
+ MockObject addChild(String name, Class<? extends UIObject> type, Map<String, String> state) throws IllegalArgumentException, MockException;
+
+ MockObject addChild(String name, Class<? extends UIObject> type) throws IllegalArgumentException, MockException;
+
+ MockObject getParent();
+
+ List<? extends MockObject> getChildren();
+
+ MockObject getChild(String name);
+
+ boolean isValid();
+
+ StructuralObject takeSnapshot();
+
+ void move(MockObject destination) throws IllegalArgumentException, MockException;
+}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/MockModelImpl.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModelImpl.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/MockModelImpl.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/MockModelImpl.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -0,0 +1,287 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model.mock.impl;
+
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.model.ui.UIContext;
+import org.jboss.portal.presentation.state.NoSuchStateException;
+import org.jboss.portal.presentation.state.StaleStateException;
+import org.jboss.portal.presentation.state.StateException;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.test.model.mock.MockObject;
+import org.jboss.portal.presentation.test.model.mock.MockModel;
+import org.jboss.portal.presentation.test.model.MockException;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class MockModelImpl implements MockModel
+{
+
+ /** . */
+ private int generator = 0;
+
+ /** . */
+ private final Map<String, MockObjectImpl> universe = new HashMap<String, MockObjectImpl>();
+
+ /** . */
+ private final MockObjectImpl root = createObject(UIContext.class, "");
+
+ public StructuralStateContext getStructuralStateContext()
+ {
+ return structuralStateContext;
+ }
+
+ public MockObject getRoot()
+ {
+ return root;
+ }
+
+ public MockObject get(String id)
+ {
+ return universe.get(id);
+ }
+
+ public void destroy(MockObject object) throws MockException
+ {
+ destroy((MockObjectImpl)object, new ArrayList<String>());
+ }
+
+ void destroy(MockObjectImpl object, List<String> ids) throws MockException
+ {
+ universe.remove(object.getId());
+
+ // Remove children recursively
+ for (MockObjectImpl child : object.getChildren())
+ {
+ destroy(child, ids);
+ }
+
+ //
+ object.destroy();
+
+ //
+ ids.add(object.getId());
+ }
+
+ MockObjectImpl createObject(Class<? extends UIObject> type, String name)
+ {
+ MockObjectImpl mockObject = new MockObjectImpl(this, name, type, "" + generator++);
+ universe.put(mockObject.getId(), mockObject);
+ return mockObject;
+ }
+
+ private final StructuralStateContext structuralStateContext = new StructuralStateContext()
+ {
+ public StructuralObject load(String objectId) throws IllegalArgumentException
+ {
+ if (objectId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ MockObjectImpl object = universe.get(objectId);
+
+ //
+ return object != null ? object.takeSnapshot() : null;
+ }
+
+ public String getRootId()
+ {
+ return root.getId();
+ }
+
+ public void validate(StructuralObject object) throws StateException
+ {
+ getValidMockObject(object);
+ }
+
+ public StructuralObject.Refresh refresh(StructuralObject object) throws IllegalArgumentException, StateException
+ {
+ MockObjectImpl mockObject = getMockObject(object, false);
+
+ //
+ StructuralObjectImpl previous = (StructuralObjectImpl)object;
+ StructuralObjectImpl current = mockObject.takeSnapshot();
+
+ //
+ StructuralObject parent = null;
+ if (previous.parentHandle != null)
+ {
+ if (!current.parentHandle.equals(previous.handle))
+ {
+ parent = getMockObject(current.parentHandle, true).takeSnapshot();
+ }
+ }
+
+ //
+ Map<String, StructuralObjectHandle> previousChildren = new HashMap<String, StructuralObjectHandle>();
+ for (StructuralObjectHandle childHandle : previous.childrenHandles)
+ {
+ previousChildren.put(childHandle.id, childHandle);
+ }
+
+ //
+ Map<String, StructuralObjectHandle> currentChildren = new HashMap<String, StructuralObjectHandle>();
+ for (StructuralObjectHandle childHandle : current.childrenHandles)
+ {
+ currentChildren.put(childHandle.id, childHandle);
+ }
+
+ //
+ Map<String, StructuralObjectHandle> addedChildrenHandleMap = new HashMap<String, StructuralObjectHandle>(currentChildren);
+ addedChildrenHandleMap.keySet().removeAll(previousChildren.keySet());
+ Set<StructuralObject> addedChildren = new HashSet<StructuralObject>();
+ for (StructuralObjectHandle handle : addedChildrenHandleMap.values())
+ {
+ StructuralObject snapshot = getMockObject(handle, true).takeSnapshot();
+ addedChildren.add(snapshot);
+ }
+
+ //
+ Map<String, StructuralObjectHandle> removedChildrenHandleMap = new HashMap<String, StructuralObjectHandle>(previousChildren);
+ removedChildrenHandleMap.keySet().removeAll(currentChildren.keySet());
+ Set<String> removedChildren = new HashSet<String>();
+ for (StructuralObjectHandle handle : removedChildrenHandleMap.values())
+ {
+ removedChildren.add(handle.id);
+ }
+
+ //
+ Map<String, StructuralObjectHandle> commonCurrentChildrenHandleMap = new HashMap<String, StructuralObjectHandle>(currentChildren);
+ commonCurrentChildrenHandleMap.keySet().retainAll(previousChildren.keySet());
+
+ //
+ Map<String, StructuralObjectHandle> commonPreviousChildrenHandleMap = new HashMap<String, StructuralObjectHandle>(previousChildren);
+ commonPreviousChildrenHandleMap.keySet().retainAll(currentChildren.keySet());
+
+ //
+ Set<StructuralObjectHandle> validChildrenHandleSet = new HashSet<StructuralObjectHandle>(commonPreviousChildrenHandleMap.values());
+ validChildrenHandleSet.retainAll(commonCurrentChildrenHandleMap.values());
+ Set<String> validChildren = new HashSet<String>();
+ for (StructuralObjectHandle handle : validChildrenHandleSet)
+ {
+ validChildren.add(handle.id);
+ }
+
+ //
+ Set<StructuralObjectHandle> staleChildrenHandleSet = new HashSet<StructuralObjectHandle>(commonPreviousChildrenHandleMap.values());
+ staleChildrenHandleSet.removeAll(commonCurrentChildrenHandleMap.values());
+
+ //
+ Map<String, StructuralObject> staleChildrenHandleMap = new HashMap<String, StructuralObject>();
+ for (StructuralObjectHandle previousHandle : staleChildrenHandleSet)
+ {
+ String id = previousHandle.id;
+ StructuralObjectHandle handle = commonCurrentChildrenHandleMap.get(id);
+ StructuralObject snapshot = getMockObject(handle, true).takeSnapshot();
+ staleChildrenHandleMap.put(id, snapshot);
+ }
+
+ //
+ return new StructuralObject.Refresh(parent, current, addedChildren, removedChildren, staleChildrenHandleMap, validChildren);
+ }
+
+ public Collection<StructuralObject> loadChildren(StructuralObject parent)
+ {
+ MockObject mockParent = getValidMockObject(parent);
+
+ //
+ List<StructuralObject> tmp = new ArrayList<StructuralObject>();
+ for (MockObject mockChild : mockParent.getChildren())
+ {
+ tmp.add(mockChild.takeSnapshot());
+ }
+ return tmp;
+ }
+
+ public StructuralObject loadParent(StructuralObject child) throws StateException
+ {
+ MockObject mockchild = getValidMockObject(child);
+ MockObject mockParent = mockchild.getParent();
+ return mockParent != null ? mockParent.takeSnapshot() : null;
+ }
+
+ private MockObjectImpl getValidMockObject(StructuralObject object) throws StateException
+ {
+ return getMockObject(object, true);
+ }
+
+ private MockObjectImpl getMockObject(StructuralObject object, boolean validateVersion)
+ {
+ if (object == null)
+ {
+ throw new IllegalArgumentException("No null object accepted");
+ }
+
+ //
+ StructuralObjectImpl structuralObject = (StructuralObjectImpl)object;
+
+ //
+ return getMockObject(structuralObject.handle, validateVersion);
+ }
+
+ private MockObjectImpl getMockObject(StructuralObjectHandle handle, boolean validateVersion)
+ {
+ if (handle == null)
+ {
+ throw new IllegalArgumentException("No null object accepted");
+ }
+
+ //
+ MockObjectImpl mockObject = universe.get(handle.id);
+
+ //
+ if (mockObject == null)
+ {
+ throw new NoSuchStateException();
+ }
+
+ //
+ if (!mockObject.isValid())
+ {
+ throw new StaleStateException();
+ }
+
+ //
+ if (validateVersion && (mockObject.getVersion() != handle.version))
+ {
+ throw new StaleStateException("Version has changed obtained=" + mockObject.getVersion() + " wanted=" + handle.version);
+ }
+
+ //
+ return mockObject;
+ }
+ };
+}
\ No newline at end of file
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/MockObjectImpl.java (from rev 11270, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObjectImpl.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/MockObjectImpl.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/MockObjectImpl.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -0,0 +1,333 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model.mock.impl;
+
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.test.model.mock.MockObject;
+import org.jboss.portal.presentation.test.model.MockException;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+class MockObjectImpl implements MockObject
+{
+
+ /** . */
+ private static final Map<String, String> EMPTY_STATE = Collections.emptyMap();
+
+ /** . */
+ private final Class<? extends UIObject> type;
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final Map<String, Serializable> propertyValues;
+
+ /** . */
+ private final Map<String, UpdateBehavior> propertyBehaviors;
+
+ /** . */
+ private final LinkedHashMap<String, MockObjectImpl> children;
+
+ /** . */
+ private final MockModelImpl model;
+
+ /** . */
+ private MockObjectImpl parent;
+
+ /** . */
+ private boolean valid;
+
+ /** The version id. */
+ private StructuralObjectHandle handle;
+
+ MockObjectImpl(MockModelImpl model, String name, Class<? extends UIObject> type, String id)
+ {
+ this.model = model;
+ this.name = name;
+ this.type = type;
+ this.children = new LinkedHashMap<String, MockObjectImpl>();
+ this.propertyValues = new HashMap<String, Serializable>();
+ this.propertyBehaviors = new HashMap<String, UpdateBehavior>();
+ this.valid = true;
+ this.handle = new StructuralObjectHandle(id, 0);
+ }
+
+ public Class<? extends UIObject> getType()
+ {
+ return type;
+ }
+
+ public boolean isValid()
+ {
+ return valid;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getId()
+ {
+ return handle.id;
+ }
+
+ public Serializable getPropertyValue(String propertyName)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return propertyValues.get(propertyName);
+ }
+
+ public MockObjectImpl getParent()
+ {
+ return parent;
+ }
+
+ public List<MockObjectImpl> getChildren()
+ {
+ return Collections.unmodifiableList(new ArrayList<MockObjectImpl>(children.values()));
+ }
+
+ public MockObjectImpl getChild(String name)
+ {
+ if (!valid)
+ {
+ throw new MockException(MockException.ErrorCode.INVALID_OBJECT);
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ for (MockObjectImpl child : children.values())
+ {
+ if (child.name.equals(name))
+ {
+ return child;
+ }
+ }
+
+ //
+ return null;
+ }
+
+ public MockObjectImpl addChild(String name, Class<? extends UIObject> type) throws MockException
+ {
+ return addChild(name, type, EMPTY_STATE);
+ }
+
+ public Set<String> getPropertyNames()
+ {
+ return Collections.unmodifiableSet(propertyValues.keySet());
+ }
+
+ public MockObjectImpl addChild(String name, Class<? extends UIObject> type, Map<String, String> state) throws MockException
+ {
+ if (!valid)
+ {
+ throw new MockException(MockException.ErrorCode.INVALID_OBJECT);
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (getChild(name) != null)
+ {
+ throw new MockException(MockException.ErrorCode.CONSTRAINT_VIOLATION);
+ }
+
+ //
+ MockObjectImpl child = model.createObject(type, name);
+
+ //
+ for (Map.Entry<String, String> entry : state.entrySet())
+ {
+ if (entry.getValue() == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ child.propertyValues.put(entry.getKey(), entry.getValue());
+ }
+
+ //
+ child.parent = this;
+ children.put(child.handle.id, child);
+ handle = handle.nextHandle();
+
+ //
+ return child;
+ }
+
+ public void setPropertyBehavior(String propertyName, UpdateBehavior propertyBehavior)
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (propertyBehavior != null)
+ {
+ propertyBehaviors.put(propertyName, propertyBehavior);
+ }
+ else
+ {
+ propertyBehaviors.remove(propertyName);
+ }
+ }
+
+ public UpdateBehavior getPropertyBehavior(String propertyName)
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return propertyBehaviors.get(propertyName);
+ }
+
+ public void setPropertyValue(String propertyName, Serializable propertyValue) throws MockException
+ {
+ if (!valid)
+ {
+ throw new MockException(MockException.ErrorCode.INVALID_OBJECT);
+ }
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (propertyValue != null)
+ {
+ propertyValues.put(propertyName, propertyValue);
+ }
+ else
+ {
+ propertyValues.remove(propertyName);
+ }
+
+ //
+ handle = handle.nextHandle();
+ }
+
+ public int getVersion()
+ {
+ return handle.version;
+ }
+
+ public StructuralObjectImpl takeSnapshot()
+ {
+ StructuralObjectHandle parentHandle = parent == null ? null : parent.handle;
+
+ //
+ List<StructuralObjectHandle> childrenHandles = new ArrayList<StructuralObjectHandle>();
+ for (MockObjectImpl child : children.values())
+ {
+ childrenHandles.add(child.handle);
+ }
+
+ //
+ StructuralStateImpl state = new StructuralStateImpl(type, new HashMap<String, Serializable>(propertyValues));
+
+ //
+ return new StructuralObjectImpl(handle, parentHandle, childrenHandles, state);
+ }
+
+ public void move(MockObject destination) throws IllegalStateException, MockException
+ {
+ move((MockObjectImpl)destination);
+ }
+
+ private void move(MockObjectImpl destination) throws MockException
+ {
+ if (!valid)
+ {
+ throw new MockException(MockException.ErrorCode.INVALID_OBJECT);
+ }
+ if (destination == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ // The source cannot an ancestor of the destination
+ for (MockObject current = destination;current != null;current = current.getParent())
+ {
+ if (current == this)
+ {
+ throw new MockException(MockException.ErrorCode.CONSTRAINT_VIOLATION);
+ }
+ }
+
+ // No duplicate child name
+ for (MockObjectImpl child : destination.children.values())
+ {
+ if (name.equals(child.name))
+ {
+ throw new MockException(MockException.ErrorCode.CONSTRAINT_VIOLATION);
+ }
+ }
+
+ //
+ parent.children.remove(handle.id);
+ parent.handle = parent.handle.nextHandle();
+
+ //
+ destination.children.put(handle.id, this);
+ destination.handle = destination.handle.nextHandle();
+
+ //
+ parent = destination;
+ handle = handle.nextHandle();
+ }
+
+ public void destroy() throws MockException
+ {
+ if (!valid)
+ {
+ throw new MockException(MockException.ErrorCode.INVALID_OBJECT);
+ }
+
+ // Detach from parent
+ if (parent != null)
+ {
+ parent.children.remove(handle.id);
+ parent.handle = parent.handle.nextHandle();
+ parent = null;
+ }
+
+ // We cannot use it anymore
+ valid = false;
+ }
+}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralObjectHandle.java (from rev 11193, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralObjectHandle.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralObjectHandle.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralObjectHandle.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -0,0 +1,81 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model.mock.impl;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+class StructuralObjectHandle
+{
+
+ /** . */
+ final String id;
+
+ /** . */
+ final int version;
+
+ StructuralObjectHandle(String id, int version)
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.id = id;
+ this.version = version;
+ }
+
+ public int hashCode()
+ {
+ return id.hashCode() * version;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (o instanceof StructuralObjectHandle)
+ {
+ StructuralObjectHandle that = (StructuralObjectHandle)o;
+
+ //
+ return id.equals(that.id) && version == that.version;
+ }
+ return false;
+ }
+
+ StructuralObjectHandle nextHandle()
+ {
+ return new StructuralObjectHandle(id, version + 1);
+ }
+
+ public String toString()
+ {
+ return "StructuralObjectHandle[id=" + id + ",version=" + version + "]";
+ }
+
+}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralObjectImpl.java (from rev 11193, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralObjectImpl.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralObjectImpl.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralObjectImpl.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model.mock.impl;
+
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+import org.jboss.portal.presentation.state.structural.StructuralState;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+class StructuralObjectImpl implements StructuralObject
+{
+
+ /** . */
+ final StructuralObjectHandle handle;
+
+ /** . */
+ final StructuralObjectHandle parentHandle;
+
+ /** . */
+ final List<StructuralObjectHandle> childrenHandles;
+
+ /** . */
+ private final StructuralStateImpl state;
+
+ public StructuralObjectImpl(
+ StructuralObjectHandle handle,
+ StructuralObjectHandle parentHandle,
+ List<StructuralObjectHandle> childrenHandles,
+ StructuralStateImpl state)
+ {
+ this.handle = handle;
+ this.parentHandle = parentHandle;
+ this.childrenHandles = childrenHandles;
+ this.state = state;
+ }
+
+ public String getId()
+ {
+ return handle.id;
+ }
+
+ public StructuralState getState()
+ {
+ return state;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof StructuralObjectImpl)
+ {
+ StructuralObjectImpl that = (StructuralObjectImpl)obj;
+
+ //
+ return handle.equals(that.handle);
+ }
+ return false;
+ }
+}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralStateImpl.java (from rev 11212, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/StructuralStateImpl.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralStateImpl.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/mock/impl/StructuralStateImpl.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model.mock.impl;
+
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.state.structural.StructuralState;
+
+import java.util.Map;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+class StructuralStateImpl implements StructuralState
+{
+
+ /** . */
+ private final Class<? extends UIObject> type;
+
+ /** . */
+ private final Map<String, Serializable> properties;
+
+ public StructuralStateImpl(Class<? extends UIObject> type, Map<String, Serializable> properties)
+ {
+ this.type = type;
+ this.properties = properties;
+ }
+
+ public Class<? extends UIObject> getType()
+ {
+ return type;
+ }
+
+ public Map<String, Serializable> getProperties()
+ {
+ return properties;
+ }
+}
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java 2008-07-02 22:02:20 UTC (rev 11270)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -26,8 +26,8 @@
import org.jboss.portal.presentation.model.UIModel;
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.model.ViewPortScope;
-import org.jboss.portal.presentation.test.model.MockModel;
-import org.jboss.portal.presentation.test.model.MockObject;
+import org.jboss.portal.presentation.test.model.mock.MockModel;
+import org.jboss.portal.presentation.test.model.mock.MockObject;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java 2008-07-02 22:02:20 UTC (rev 11270)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -27,8 +27,8 @@
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.model.ui.UIContext;
import org.jboss.portal.presentation.model.ui.UIPage;
-import org.jboss.portal.presentation.test.model.MockModel;
-import org.jboss.portal.presentation.test.model.MockObject;
+import org.jboss.portal.presentation.test.model.mock.MockModel;
+import org.jboss.portal.presentation.test.model.mock.MockObject;
import org.jboss.portal.presentation.test.model.Resolver;
import java.util.HashMap;
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java 2008-07-02 22:07:44 UTC (rev 11271)
@@ -29,9 +29,9 @@
import org.jboss.portal.presentation.model.ObjectTraversalType;
import org.jboss.portal.presentation.model.UIModel;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.MockModel;
+import org.jboss.portal.presentation.test.model.mock.MockModel;
+import org.jboss.portal.presentation.test.model.mock.impl.MockModelImpl;
import org.jboss.portal.presentation.test.model.Resolver;
-import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
import java.util.ArrayList;
import java.util.Arrays;
16 years
JBoss Portal SVN: r11270 - in modules/presentation/trunk: ajax/src/main/java/org/jboss/portal/presentation/ajax/server/model and 6 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-07-02 18:02:20 -0400 (Wed, 02 Jul 2008)
New Revision: 11270
Added:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractMockImplementationTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockException.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModel.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockObject.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java
Removed:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockException.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModel.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObject.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/server/PresentationClientServlet.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/server/model/AjaxViewPortContext.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/ModelAdapter.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/LayoutStore.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/SimpleStructure.java
modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModelImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObjectImpl.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AddChildTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/ModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/MoveChildTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/RemoveChildTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TypeTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectNode.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UpdateObjectTestCase.java
Log:
fixing test cases
Modified: modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/server/PresentationClientServlet.java
===================================================================
--- modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/server/PresentationClientServlet.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/server/PresentationClientServlet.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -94,6 +94,10 @@
viewPort.refresh();
//
+ HttpServletRequest req = getThreadLocalRequest();
+ req.getSession().setAttribute("ViewPort", viewPort);
+
+ //
return viewPortContext.getDelta();
}
@@ -137,8 +141,10 @@
ActionDecoder decoder = (ActionDecoder)getServletContext().getAttribute("ActionDecoder");
//
- System.out.println("Should handle action " + action);
+ System.out.println("handling action " + action);
+ //
+ ProtocolAction protocolAction = null;
if (action instanceof OpaqueWindowAction)
{
OpaqueWindowAction windowAction = (OpaqueWindowAction)action;
@@ -174,10 +180,20 @@
body = null;
}
- ProtocolAction protocolAction = decoder.decode(new AjaxActionDecoderContext(WebRequest.Verb.GET, path, queryParameterMap, body));
+ protocolAction = decoder.decode(new AjaxActionDecoderContext(WebRequest.Verb.GET, path, queryParameterMap, body));
+ }
+ else if (action instanceof DestroyObjectAction)
+ {
+ DestroyObjectAction ajaxAction = (DestroyObjectAction)action;
- System.out.println("decoded protocolAction = " + protocolAction);
+ protocolAction = new DestroyUIObjectAction(ajaxAction.getObjectId());
+ }
+ //
+ if (protocolAction != null)
+ {
+ System.out.println("decoded protocol action = " + protocolAction);
+
// Now we execute
PresentationServer server = getPresentationServer();
@@ -190,52 +206,45 @@
PresentationResponse response = server.process(client, prequest);
System.out.println("response = " + response);
- System.out.println("Stale objects " + response.getStaleObjects());
+ System.out.println("stale objects " + response.getStaleObjects());
DelegatingNavigationalStateContext nsc = client.getNavigationalStateContext();
//
Set<String> blahIds = nsc.flush();
- System.out.println("Stale objects = " + blahIds);
+ System.out.println("stale objects = " + blahIds);
//
Set<String> tmp = new HashSet<String>(response.getStaleObjects());
tmp.addAll(blahIds);
//
- return new AjaxResponse(tmp.toArray(new String[tmp.size()]));
- }
- catch (PresentationServerException e)
- {
- e.printStackTrace();
+ HttpServletRequest req = getThreadLocalRequest();
+ ViewPort viewPort = (ViewPort)req.getSession().getAttribute("ViewPort");
- return new AjaxResponse();
- }
- }
- else if (action instanceof DestroyObjectAction)
- {
- DestroyObjectAction ajaxAction = (DestroyObjectAction)action;
+ //
+ viewPort.refresh();
- DestroyUIObjectAction destroyAction = new DestroyUIObjectAction(ajaxAction.getObjectId());
+ //
+ ModelUpdate[] updates = ((AjaxViewPortContext)viewPort.getContext()).getDelta();
- // Now we execute
- PresentationServer server = getPresentationServer();
+ //
+ for (int i = 0; i < updates.length; i++)
+ {
+ ModelUpdate update = updates[i];
+ System.out.println("update = " + update);
+ }
- PresentationClientImpl client = createPresentationClient();
- PresentationRequest prequest = new PresentationRequest(destroyAction);
-
- try
- {
- server.process(client, prequest);
+ //
+ return new AjaxResponse(tmp.toArray(new String[tmp.size()]));
}
catch (PresentationServerException e)
{
e.printStackTrace();
+
+ return new AjaxResponse();
}
-
- //
- return new AjaxResponse();
}
else
{
Modified: modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/server/model/AjaxViewPortContext.java
===================================================================
--- modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/server/model/AjaxViewPortContext.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/server/model/AjaxViewPortContext.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -118,6 +118,8 @@
public void updateObject(String objectId)
{
+ updates
+
throw new NotYetImplemented();
}
Modified: modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/ModelAdapter.java
===================================================================
--- modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/ModelAdapter.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/ModelAdapter.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -73,6 +73,12 @@
String objectId = item.getRef();
return nodeManager.getNode(objectId);
}
+ else if (o instanceof SimpleStructure)
+ {
+ SimpleStructure item = (SimpleStructure)o;
+ String objectId = item.getRef();
+ return nodeManager.getNode(objectId);
+ }
else
{
return o;
@@ -114,7 +120,7 @@
if (o instanceof SimpleStructure)
{
SimpleStructure simpleStructure = (SimpleStructure)o;
- String objectId = simpleStructure.getObjectRef();
+ String objectId = simpleStructure.getRef();
parent = nodeManager.getNode(objectId);
}
else if (o instanceof SimpleElement)
@@ -228,12 +234,12 @@
}
else
{
- throw new NotYetImplemented();
+ throw new NotYetImplemented("Cannot get type of object " + o);
}
}
else
{
- throw new NotYetImplemented();
+ throw new NotYetImplemented("Cannot get type of object " + o);
}
}
Modified: modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/LayoutStore.java
===================================================================
--- modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/LayoutStore.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/LayoutStore.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -103,7 +103,7 @@
String objectRef = null;
if (targetElement instanceof SimpleStructure)
{
- objectRef = ((SimpleStructure)targetElement).getObjectRef();
+ objectRef = ((SimpleStructure)targetElement).getRef();
}
else if (targetElement instanceof SimpleElement)
{
@@ -173,7 +173,7 @@
String objectRef = null;
if (element instanceof SimpleStructure)
{
- objectRef = ((SimpleStructure)element).getObjectRef();
+ objectRef = ((SimpleStructure)element).getRef();
}
else if (element instanceof SimpleElement)
{
@@ -204,7 +204,7 @@
String objectRef = null;
if (element instanceof SimpleStructure)
{
- objectRef = ((SimpleStructure)element).getObjectRef();
+ objectRef = ((SimpleStructure)element).getRef();
}
else if (element instanceof SimpleElement)
{
Modified: modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/SimpleStructure.java
===================================================================
--- modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/SimpleStructure.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/SimpleStructure.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -30,21 +30,21 @@
{
/** . */
- private final String objectRef;
+ private final String ref;
- SimpleStructure(String objectRef)
+ SimpleStructure(String ref)
{
- if (objectRef == null)
+ if (ref == null)
{
throw new IllegalArgumentException();
}
//
- this.objectRef = objectRef;
+ this.ref = ref;
}
- public String getObjectRef()
+ public String getRef()
{
- return objectRef;
+ return ref;
}
}
Modified: modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java
===================================================================
--- modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/portal/src/test/java/org/jboss/portal/presentation/portal/model/StructuralStateContextTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -27,7 +27,7 @@
import org.jboss.portal.presentation.model.ui.UIPage;
import org.jboss.portal.presentation.model.ui.UIWindow;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.AbstractModelTestCase;
+import org.jboss.portal.presentation.test.model.AbstractMockImplementationTestCase;
import org.jboss.portal.presentation.impl.state.structural.adapter.StructuralStateContextImpl;
import org.jboss.portal.presentation.impl.state.structural.adapter.StructuralAdapter;
import org.jboss.portal.presentation.portal.model.layout.LayoutStore;
@@ -46,7 +46,7 @@
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class StructuralStateContextTestCase extends AbstractModelTestCase<PortalNode>
+public class StructuralStateContextTestCase extends AbstractMockImplementationTestCase<PortalNode>
{
/** . */
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractMockImplementationTestCase.java (from rev 11212, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractMockImplementationTestCase.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractMockImplementationTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -0,0 +1,444 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import junit.framework.TestCase;
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.model.ui.UIContext;
+import org.jboss.portal.presentation.model.ui.UIPage;
+import org.jboss.portal.presentation.state.NoSuchStateException;
+import org.jboss.portal.presentation.state.StaleStateException;
+import org.jboss.portal.presentation.state.StateException;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+import org.jboss.portal.presentation.state.structural.StructuralState;
+import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class AbstractMockImplementationTestCase<MockObject> extends TestCase
+{
+
+ public AbstractMockImplementationTestCase()
+ {
+ }
+
+ public AbstractMockImplementationTestCase(String testName)
+ {
+ super(testName);
+ }
+
+ protected abstract StructuralStateContext getStructuralStateContext();
+
+ protected abstract MockObject getRoot();
+
+ protected abstract Set<String> getPropertyNames(MockObject object);
+
+ protected abstract MockObject getParent(MockObject object);
+
+ protected abstract List<? extends MockObject> getChildren(MockObject object);
+
+ protected abstract String getName(MockObject object);
+
+ protected abstract boolean isValid(MockObject object);
+
+ protected abstract Class<? extends UIObject> getType(MockObject object);
+
+ protected abstract String getId(MockObject object);
+
+ protected abstract MockObject addChild(MockObject object, String name, Class<? extends UIObject> modelType);
+
+ protected abstract void destroy(MockObject object);
+
+ protected abstract void setProperty(MockObject object, String propertyName, String propertyValue);
+
+ protected abstract Serializable getProperty(MockObject object, String name);
+
+ protected final StructuralObject getStructuralObject(MockObject object)
+ {
+ return getStructuralStateContext().load(getId(object));
+ }
+
+ public void testRoot()
+ {
+ MockObject mockRoot = getRoot();
+ assertNotNull(mockRoot);
+ assertEquals(Collections.EMPTY_SET, getPropertyNames(mockRoot));
+ assertNull(getParent(mockRoot));
+ assertEquals(Collections.EMPTY_LIST, getChildren(mockRoot));
+ assertEquals(UIContext.class, getType(mockRoot));
+ assertEquals("", getName(mockRoot));
+ assertEquals(true, isValid(mockRoot));
+
+ //
+ String rootId = getStructuralStateContext().getRootId();
+ assertNotNull(rootId);
+ StructuralObject root = getStructuralStateContext().load(rootId);
+ assertNotNull(root);
+ assertEquals(rootId, root.getId());
+ StructuralState state = root.getState();
+ assertEquals(UIContext.class, state.getType());
+ assertEquals(Collections.EMPTY_MAP, state.getProperties());
+ }
+
+ public void testAddChild()
+ {
+ MockObject mockRoot = getRoot();
+ // int rootV0 = mockRoot.getVersion();
+
+ //
+ String rootId = getId(mockRoot);
+ StructuralObject root = getStructuralStateContext().load(rootId);
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ assertNotNull(mockFoo);
+ String fooId = getId(mockFoo);
+
+ //
+ assertNotNull(fooId);
+ assertEquals("foo", getName(mockFoo));
+ assertEquals(UIPage.class, getType(mockFoo));
+ assertSame(mockRoot, getParent(mockFoo));
+ assertEquals(Collections.singletonList(mockFoo), getChildren(mockRoot));
+ assertEquals(Collections.EMPTY_SET, getPropertyNames(mockFoo));
+ // assertTrue(mockRoot.getVersion() > rootV0);
+
+ //
+ try
+ {
+ getStructuralStateContext().loadParent(root);
+ fail();
+ }
+ catch (StaleStateException ignore)
+ {
+ }
+ try
+ {
+ getStructuralStateContext().loadChildren(root);
+ fail();
+ }
+ catch (StaleStateException ignore)
+ {
+ }
+
+ //
+ root = getStructuralStateContext().load(rootId);
+ assertNotNull(root);
+ assertEquals(rootId, root.getId());
+
+ //
+ Collection<StructuralObject> children = getStructuralStateContext().loadChildren(root);
+ assertNotNull(children);
+ assertEquals(1, children.size());
+ StructuralObject foo = children.iterator().next();
+ assertNotNull(foo);
+ assertEquals(fooId, foo.getId());
+ StructuralState fooState = foo.getState();
+ assertNotNull(fooState);
+ assertEquals(Collections.EMPTY_MAP, fooState.getProperties());
+ assertEquals(UIPage.class, fooState.getType());
+ root = getStructuralStateContext().loadParent(foo);
+ assertNotNull(root);
+ assertEquals(rootId, root.getId());
+ }
+
+ public void testDestroy() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ MockObject mockBar = addChild(mockFoo, "bar", UIPage.class);
+ MockObject mockJuu = addChild(mockFoo, "juu", UIPage.class);
+// int rootV0 = mockRoot.getVersion();
+// int fooV0 = mockFoo.getVersion();
+// int barV0 = mockBar.getVersion();
+ String fooId = getId(mockFoo);
+ String barId = getId(mockBar);
+ String juuId = getId(mockJuu);
+ StructuralObject foo0 = getStructuralStateContext().load(fooId);
+ StructuralObject bar0 = getStructuralStateContext().load(barId);
+ StructuralObject juu0 = getStructuralStateContext().load(juuId);
+
+ //
+ destroy(mockJuu);
+
+ //
+ StructuralObject foo1 = getStructuralStateContext().load(fooId);
+ StructuralObject bar1 = getStructuralStateContext().load(barId);
+ StructuralObject juu1 = getStructuralStateContext().load(juuId);
+// int rootV1 = mockRoot.getVersion();
+// int fooV1 = mockFoo.getVersion();
+// int barV1 = mockBar.getVersion();
+
+ //
+ assertStale(juu0);
+ assertStale(foo0);
+ assertNotStale(bar0);
+ assertNull(juu1);
+ assertNotStale(foo1);
+ assertNotStale(bar1);
+ assertEquals(Collections.singletonList(mockFoo), getChildren(mockRoot));
+ assertEquals(Collections.singletonList(mockBar), getChildren(mockFoo));
+ assertTrue(isValid(mockFoo));
+ assertTrue(isValid(mockBar));
+ assertFalse(isValid(mockJuu));
+// assertTrue(rootV1 == rootV0);
+// assertTrue(fooV1 > fooV0);
+// assertTrue(barV1 == barV0);
+
+ //
+ destroy(mockFoo);
+
+// int rootV2 = mockRoot.getVersion();
+ StructuralObject foo2 = getStructuralStateContext().load(fooId);
+ StructuralObject bar2 = getStructuralStateContext().load(barId);
+ StructuralObject juu2 = getStructuralStateContext().load(juuId);
+
+ //
+ assertStale(juu0);
+ assertStale(foo0);
+ assertStale(bar0);
+ assertNull(juu1);
+ assertStale(foo1);
+ assertStale(bar1);
+ assertNull(foo2);
+ assertNull(bar2);
+ assertNull(juu2);
+ assertEquals(Collections.emptyList(), getChildren(mockRoot));
+ assertFalse(isValid(mockFoo));
+ assertFalse(isValid(mockBar));
+ assertFalse(isValid(mockJuu));
+// assertTrue(rootV2 > rootV1);
+ }
+
+ public void testUpdateProperty() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+ String rootId = getId(mockRoot);
+// int rootV0 = mockRoot.getVersion();
+
+ //
+ StructuralObject root0 = getStructuralStateContext().load(rootId);
+ StructuralState rootState0 = root0.getState();
+ assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
+
+ // Set
+ setProperty(mockRoot, "foo", "bar");
+
+ //
+// int rootV1 = mockRoot.getVersion();
+// assertTrue(rootV1 > rootV0);
+ assertEquals(Collections.singleton("foo"), getPropertyNames(mockRoot));
+ assertEquals("bar", getProperty(mockRoot, "foo"));
+ assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
+ assertStale(root0);
+ StructuralObject root1 = getStructuralStateContext().load(rootId);
+ assertNotNull(root1);
+ assertNotStale(root1);
+ StructuralState rootState1 = root1.getState();
+ assertEquals(Collections.singletonMap("foo", "bar"), rootState1.getProperties());
+ }
+
+ public void testInvalidatedByDestruction() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ MockObject mockBar = addChild(mockRoot, "bar", UIPage.class);
+
+ //
+ StructuralObject foo = getStructuralObject(mockFoo);
+
+ //
+ destroy(mockFoo);
+
+ //
+ assertValidity(foo, NoSuchStateException.class);
+ }
+
+ public void testInvalidatedByPropertyUpdate() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+
+ //
+ StructuralObject foo = getStructuralObject(mockFoo);
+
+ //
+ setProperty(mockFoo, "a", "b");
+
+ //
+ assertValidity(foo, StaleStateException.class);
+ }
+
+ public void testInvalidatedByChildCreation() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+
+ //
+ StructuralObject foo = getStructuralObject(mockFoo);
+
+ //
+ addChild(mockFoo, "juu", UIPage.class);
+
+ //
+ assertValidity(foo, StaleStateException.class);
+ }
+
+ public void testInvalidatedByChildDestruction() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+
+ //
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ MockObject mockJuu = addChild(mockFoo, "juu", UIPage.class);
+
+ //
+ StructuralObject foo = getStructuralObject(mockFoo);
+
+ //
+ destroy(mockJuu);
+
+ //
+ assertValidity(foo, StaleStateException.class);
+ }
+
+
+ public void testRefresh() throws MockException
+ {
+ MockObject mockRoot = getRoot();
+ String rootId = getId(mockRoot);
+ MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
+ String fooId = getId(mockFoo);
+ MockObject mockJuu = addChild(mockRoot, "juu", UIPage.class);
+ String juuId = getId(mockJuu);
+ MockObject mockFaa = addChild(mockRoot, "faa", UIPage.class);
+ String faaId = getId(mockFaa);
+ StructuralObject rootV0 = getStructuralStateContext().load(rootId);
+
+ //
+ MockObject mockBar = addChild(mockRoot, "bar", UIPage.class);
+ String barId = getId(mockBar);
+ destroy(mockFoo);
+ setProperty(mockJuu, "blah", "blah");
+
+ //
+ StructuralObject.Refresh comparison = getStructuralStateContext().refresh(rootV0);
+ assertNotNull(comparison);
+ Set<String> removed = comparison.getRemovedChildren();
+ assertNotNull(removed);
+ assertEquals(1, removed.size());
+ assertEquals(fooId, removed.iterator().next());
+
+ //
+ Set<StructuralObject> added = comparison.getAddedChildren();
+ assertNotNull(added);
+ assertEquals(1, added.size());
+ assertEquals(barId, added.iterator().next().getId());
+
+ //
+ Map<String, StructuralObject> stale = comparison.getStaleChildren();
+ assertNotNull(stale);
+ assertTrue(stale.size() >= 1);
+ StructuralObject juu = stale.get(getId(mockJuu));
+ assertNotNull(juu);
+ assertEquals(juuId, juu.getId());
+ assertEquals("blah", juu.getState().getProperties().get("blah"));
+
+ //
+ Set<String> valid = comparison.getValidChildren();
+ assertNotNull(valid);
+ assertEquals(2 - stale.size(), valid.size());
+ if (valid.size() >= 1)
+ {
+ assertTrue(valid.contains(faaId));
+ }
+ }
+
+ protected final void assertValidity(StructuralObject object, Class<? extends StateException> expected) throws MockException
+ {
+ try
+ {
+ getStructuralStateContext().validate(object);
+ fail();
+ }
+ catch (StateException e)
+ {
+ assertTrue(expected.isInstance(e));
+ }
+
+ //
+ try
+ {
+ getStructuralStateContext().loadChildren(object);
+ fail();
+ }
+ catch (StateException e)
+ {
+ assertTrue(expected.isInstance(e));
+ }
+
+ //
+ try
+ {
+ getStructuralStateContext().loadParent(object);
+ fail();
+ }
+ catch (StateException e)
+ {
+ assertTrue(expected.isInstance(e));
+ }
+
+ }
+
+ protected final void assertStale(StructuralObject object)
+ {
+ try
+ {
+ getStructuralStateContext().validate(object);
+ fail();
+ }
+ catch (StateException ignore)
+ {
+ }
+ }
+
+ protected final void assertNotStale(StructuralObject object)
+ {
+ getStructuralStateContext().validate(object);
+ }
+}
Deleted: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -1,445 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * 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. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model;
-
-import junit.framework.TestCase;
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.model.ui.UIContext;
-import org.jboss.portal.presentation.model.ui.UIPage;
-import org.jboss.portal.presentation.state.NoSuchStateException;
-import org.jboss.portal.presentation.state.StaleStateException;
-import org.jboss.portal.presentation.state.StateException;
-import org.jboss.portal.presentation.state.structural.StructuralObject;
-import org.jboss.portal.presentation.state.structural.StructuralState;
-import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.state.structural.MockException;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public abstract class AbstractModelTestCase<MockObject> extends TestCase
-{
-
- public AbstractModelTestCase()
- {
- }
-
- public AbstractModelTestCase(String testName)
- {
- super(testName);
- }
-
- protected abstract StructuralStateContext getStructuralStateContext();
-
- protected abstract MockObject getRoot();
-
- protected abstract Set<String> getPropertyNames(MockObject object);
-
- protected abstract MockObject getParent(MockObject object);
-
- protected abstract List<? extends MockObject> getChildren(MockObject object);
-
- protected abstract String getName(MockObject object);
-
- protected abstract boolean isValid(MockObject object);
-
- protected abstract Class<? extends UIObject> getType(MockObject object);
-
- protected abstract String getId(MockObject object);
-
- protected abstract MockObject addChild(MockObject object, String name, Class<? extends UIObject> modelType);
-
- protected abstract void destroy(MockObject object);
-
- protected abstract void setProperty(MockObject object, String propertyName, String propertyValue);
-
- protected abstract Serializable getProperty(MockObject object, String name);
-
- protected final StructuralObject getStructuralObject(MockObject object)
- {
- return getStructuralStateContext().load(getId(object));
- }
-
- public void testRoot()
- {
- MockObject mockRoot = getRoot();
- assertNotNull(mockRoot);
- assertEquals(Collections.EMPTY_SET, getPropertyNames(mockRoot));
- assertNull(getParent(mockRoot));
- assertEquals(Collections.EMPTY_LIST, getChildren(mockRoot));
- assertEquals(UIContext.class, getType(mockRoot));
- assertEquals("", getName(mockRoot));
- assertEquals(true, isValid(mockRoot));
-
- //
- String rootId = getStructuralStateContext().getRootId();
- assertNotNull(rootId);
- StructuralObject root = getStructuralStateContext().load(rootId);
- assertNotNull(root);
- assertEquals(rootId, root.getId());
- StructuralState state = root.getState();
- assertEquals(UIContext.class, state.getType());
- assertEquals(Collections.EMPTY_MAP, state.getProperties());
- }
-
- public void testAddChild()
- {
- MockObject mockRoot = getRoot();
- // int rootV0 = mockRoot.getVersion();
-
- //
- String rootId = getId(mockRoot);
- StructuralObject root = getStructuralStateContext().load(rootId);
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- assertNotNull(mockFoo);
- String fooId = getId(mockFoo);
-
- //
- assertNotNull(fooId);
- assertEquals("foo", getName(mockFoo));
- assertEquals(UIPage.class, getType(mockFoo));
- assertSame(mockRoot, getParent(mockFoo));
- assertEquals(Collections.singletonList(mockFoo), getChildren(mockRoot));
- assertEquals(Collections.EMPTY_SET, getPropertyNames(mockFoo));
- // assertTrue(mockRoot.getVersion() > rootV0);
-
- //
- try
- {
- getStructuralStateContext().loadParent(root);
- fail();
- }
- catch (StaleStateException ignore)
- {
- }
- try
- {
- getStructuralStateContext().loadChildren(root);
- fail();
- }
- catch (StaleStateException ignore)
- {
- }
-
- //
- root = getStructuralStateContext().load(rootId);
- assertNotNull(root);
- assertEquals(rootId, root.getId());
-
- //
- Collection<StructuralObject> children = getStructuralStateContext().loadChildren(root);
- assertNotNull(children);
- assertEquals(1, children.size());
- StructuralObject foo = children.iterator().next();
- assertNotNull(foo);
- assertEquals(fooId, foo.getId());
- StructuralState fooState = foo.getState();
- assertNotNull(fooState);
- assertEquals(Collections.EMPTY_MAP, fooState.getProperties());
- assertEquals(UIPage.class, fooState.getType());
- root = getStructuralStateContext().loadParent(foo);
- assertNotNull(root);
- assertEquals(rootId, root.getId());
- }
-
- public void testDestroy() throws MockException
- {
- MockObject mockRoot = getRoot();
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- MockObject mockBar = addChild(mockFoo, "bar", UIPage.class);
- MockObject mockJuu = addChild(mockFoo, "juu", UIPage.class);
-// int rootV0 = mockRoot.getVersion();
-// int fooV0 = mockFoo.getVersion();
-// int barV0 = mockBar.getVersion();
- String fooId = getId(mockFoo);
- String barId = getId(mockBar);
- String juuId = getId(mockJuu);
- StructuralObject foo0 = getStructuralStateContext().load(fooId);
- StructuralObject bar0 = getStructuralStateContext().load(barId);
- StructuralObject juu0 = getStructuralStateContext().load(juuId);
-
- //
- destroy(mockJuu);
-
- //
- StructuralObject foo1 = getStructuralStateContext().load(fooId);
- StructuralObject bar1 = getStructuralStateContext().load(barId);
- StructuralObject juu1 = getStructuralStateContext().load(juuId);
-// int rootV1 = mockRoot.getVersion();
-// int fooV1 = mockFoo.getVersion();
-// int barV1 = mockBar.getVersion();
-
- //
- assertStale(juu0);
- assertStale(foo0);
- assertNotStale(bar0);
- assertNull(juu1);
- assertNotStale(foo1);
- assertNotStale(bar1);
- assertEquals(Collections.singletonList(mockFoo), getChildren(mockRoot));
- assertEquals(Collections.singletonList(mockBar), getChildren(mockFoo));
- assertTrue(isValid(mockFoo));
- assertTrue(isValid(mockBar));
- assertFalse(isValid(mockJuu));
-// assertTrue(rootV1 == rootV0);
-// assertTrue(fooV1 > fooV0);
-// assertTrue(barV1 == barV0);
-
- //
- destroy(mockFoo);
-
-// int rootV2 = mockRoot.getVersion();
- StructuralObject foo2 = getStructuralStateContext().load(fooId);
- StructuralObject bar2 = getStructuralStateContext().load(barId);
- StructuralObject juu2 = getStructuralStateContext().load(juuId);
-
- //
- assertStale(juu0);
- assertStale(foo0);
- assertStale(bar0);
- assertNull(juu1);
- assertStale(foo1);
- assertStale(bar1);
- assertNull(foo2);
- assertNull(bar2);
- assertNull(juu2);
- assertEquals(Collections.emptyList(), getChildren(mockRoot));
- assertFalse(isValid(mockFoo));
- assertFalse(isValid(mockBar));
- assertFalse(isValid(mockJuu));
-// assertTrue(rootV2 > rootV1);
- }
-
- public void testUpdateProperty() throws MockException
- {
- MockObject mockRoot = getRoot();
- String rootId = getId(mockRoot);
-// int rootV0 = mockRoot.getVersion();
-
- //
- StructuralObject root0 = getStructuralStateContext().load(rootId);
- StructuralState rootState0 = root0.getState();
- assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
-
- // Set
- setProperty(mockRoot, "foo", "bar");
-
- //
-// int rootV1 = mockRoot.getVersion();
-// assertTrue(rootV1 > rootV0);
- assertEquals(Collections.singleton("foo"), getPropertyNames(mockRoot));
- assertEquals("bar", getProperty(mockRoot, "foo"));
- assertEquals(Collections.EMPTY_MAP, rootState0.getProperties());
- assertStale(root0);
- StructuralObject root1 = getStructuralStateContext().load(rootId);
- assertNotNull(root1);
- assertNotStale(root1);
- StructuralState rootState1 = root1.getState();
- assertEquals(Collections.singletonMap("foo", "bar"), rootState1.getProperties());
- }
-
- public void testInvalidatedByDestruction() throws MockException
- {
- MockObject mockRoot = getRoot();
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- MockObject mockBar = addChild(mockRoot, "bar", UIPage.class);
-
- //
- StructuralObject foo = getStructuralObject(mockFoo);
-
- //
- destroy(mockFoo);
-
- //
- assertValidity(foo, NoSuchStateException.class);
- }
-
- public void testInvalidatedByPropertyUpdate() throws MockException
- {
- MockObject mockRoot = getRoot();
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
-
- //
- StructuralObject foo = getStructuralObject(mockFoo);
-
- //
- setProperty(mockFoo, "a", "b");
-
- //
- assertValidity(foo, StaleStateException.class);
- }
-
- public void testInvalidatedByChildCreation() throws MockException
- {
- MockObject mockRoot = getRoot();
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
-
- //
- StructuralObject foo = getStructuralObject(mockFoo);
-
- //
- addChild(mockFoo, "juu", UIPage.class);
-
- //
- assertValidity(foo, StaleStateException.class);
- }
-
- public void testInvalidatedByChildDestruction() throws MockException
- {
- MockObject mockRoot = getRoot();
-
- //
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- MockObject mockJuu = addChild(mockFoo, "juu", UIPage.class);
-
- //
- StructuralObject foo = getStructuralObject(mockFoo);
-
- //
- destroy(mockJuu);
-
- //
- assertValidity(foo, StaleStateException.class);
- }
-
-
- public void testRefresh() throws MockException
- {
- MockObject mockRoot = getRoot();
- String rootId = getId(mockRoot);
- MockObject mockFoo = addChild(mockRoot, "foo", UIPage.class);
- String fooId = getId(mockFoo);
- MockObject mockJuu = addChild(mockRoot, "juu", UIPage.class);
- String juuId = getId(mockJuu);
- MockObject mockFaa = addChild(mockRoot, "faa", UIPage.class);
- String faaId = getId(mockFaa);
- StructuralObject rootV0 = getStructuralStateContext().load(rootId);
-
- //
- MockObject mockBar = addChild(mockRoot, "bar", UIPage.class);
- String barId = getId(mockBar);
- destroy(mockFoo);
- setProperty(mockJuu, "blah", "blah");
-
- //
- StructuralObject.Refresh comparison = getStructuralStateContext().refresh(rootV0);
- assertNotNull(comparison);
- Set<String> removed = comparison.getRemovedChildren();
- assertNotNull(removed);
- assertEquals(1, removed.size());
- assertEquals(fooId, removed.iterator().next());
-
- //
- Set<StructuralObject> added = comparison.getAddedChildren();
- assertNotNull(added);
- assertEquals(1, added.size());
- assertEquals(barId, added.iterator().next().getId());
-
- //
- Map<String, StructuralObject> stale = comparison.getStaleChildren();
- assertNotNull(stale);
- assertTrue(stale.size() >= 1);
- StructuralObject juu = stale.get(getId(mockJuu));
- assertNotNull(juu);
- assertEquals(juuId, juu.getId());
- assertEquals("blah", juu.getState().getProperties().get("blah"));
-
- //
- Set<String> valid = comparison.getValidChildren();
- assertNotNull(valid);
- assertEquals(2 - stale.size(), valid.size());
- if (valid.size() >= 1)
- {
- assertTrue(valid.contains(faaId));
- }
- }
-
- protected final void assertValidity(StructuralObject object, Class<? extends StateException> expected) throws MockException
- {
- try
- {
- getStructuralStateContext().validate(object);
- fail();
- }
- catch (StateException e)
- {
- assertTrue(expected.isInstance(e));
- }
-
- //
- try
- {
- getStructuralStateContext().loadChildren(object);
- fail();
- }
- catch (StateException e)
- {
- assertTrue(expected.isInstance(e));
- }
-
- //
- try
- {
- getStructuralStateContext().loadParent(object);
- fail();
- }
- catch (StateException e)
- {
- assertTrue(expected.isInstance(e));
- }
-
- }
-
- protected final void assertStale(StructuralObject object)
- {
- try
- {
- getStructuralStateContext().validate(object);
- fail();
- }
- catch (StateException ignore)
- {
- }
- }
-
- protected final void assertNotStale(StructuralObject object)
- {
- getStructuralStateContext().validate(object);
- }
-}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java (from rev 11193, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/AbstractModelTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -0,0 +1,106 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import junit.framework.TestCase;
+import org.jboss.portal.presentation.impl.model.UIModelImpl;
+import org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
+import org.jboss.portal.presentation.model.UIModel;
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.test.model.MockModel;
+import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
+import org.jboss.portal.presentation.test.model.MockObject;
+import org.jboss.portal.presentation.test.model3.UIObjectNode;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class AbstractModelTestCase extends TestCase
+{
+
+ /** . */
+ protected UIModel model;
+
+ /** . */
+ protected MockModel mockModel;
+
+ /** . */
+ protected StructuralStateContext structuralStateContext;
+
+ protected void setUp() throws Exception
+ {
+ mockModel = new MockModelImpl();
+ structuralStateContext = mockModel.getStructuralStateContext();
+ model = new UIModelImpl(new NavigationalStateContextImpl(), structuralStateContext);
+ }
+
+ /**
+ * @param objectNode the object node
+ * @return the name
+ * @see #getName(org.jboss.portal.presentation.model.ui.UIObject)
+ */
+ public String getName(UIObjectNode objectNode)
+ {
+ return getName(objectNode.getObject());
+ }
+
+ /**
+ * Returns the name of a ui object node.
+ *
+ * @param object the object
+ * @return the name
+ */
+ public String getName(UIObject object)
+ {
+ MockObject mockObject = mockModel.get(object.getId());
+
+ //
+ if (mockObject == null)
+ {
+ throw new IllegalArgumentException("No such mock object " + object.getId());
+ }
+
+ //
+ return mockObject.getName();
+ }
+
+ public UIObjectNode getChild(UIObjectNode objectNode, String name)
+ {
+ MockObject mockObject = mockModel.get(objectNode.getObject().getId());
+
+ //
+ MockObject mockChild = mockObject.getChild(name);
+
+ //
+ if (mockChild == null)
+ {
+ return null;
+ }
+
+ //
+ return objectNode.getChild(mockChild.getId());
+ }
+
+}
\ No newline at end of file
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockException.java (from rev 11193, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockException.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockException.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockException.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class MockException extends RuntimeException
+{
+
+ /** . */
+ private ErrorCode code;
+
+ public MockException(ErrorCode code)
+ {
+ this.code = code;
+ }
+
+ public MockException(String s, ErrorCode code)
+ {
+ super(s);
+ this.code = code;
+ }
+
+ public enum ErrorCode
+ {
+ INVALID_OBJECT,
+ CONSTRAINT_VIOLATION
+ }
+
+ public ErrorCode getCode()
+ {
+ return code;
+ }
+}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModel.java (from rev 11193, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModel.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModel.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockModel.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface MockModel
+{
+
+ StructuralStateContext getStructuralStateContext();
+
+ MockObject getRoot();
+
+ void destroy(MockObject object) throws MockException;
+
+ MockObject get(String id);
+}
Copied: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockObject.java (from rev 11193, modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObject.java)
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockObject.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/MockObject.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -0,0 +1,110 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.state.structural.StructuralObject;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface MockObject
+{
+
+ public abstract static class UpdateBehavior
+ {
+ public static UpdateBehavior veto()
+ {
+ return new Veto();
+ }
+ public static UpdateBehavior failure(Throwable throwable)
+ {
+ return new Failure(throwable);
+ }
+ }
+
+ static class Veto extends UpdateBehavior
+ {
+ }
+
+ static class Failure extends UpdateBehavior
+ {
+
+ /** . */
+ final Throwable throwable;
+
+ public Failure(Throwable throwable)
+ {
+ this.throwable = throwable;
+ }
+
+ public <T extends Throwable> Failure throwAs(Class<T> type) throws T
+ {
+ if (type.isInstance(throwable))
+ {
+ throw type.cast(throwable);
+ }
+ return this;
+ }
+ }
+
+ Class<? extends UIObject> getType();
+
+ String getName();
+
+ String getId();
+
+ int getVersion();
+
+ Serializable getPropertyValue(String propertyName) throws IllegalArgumentException;
+
+ void setPropertyBehavior(String propertyName, UpdateBehavior propertyBehavior) throws IllegalArgumentException;
+
+ UpdateBehavior getPropertyBehavior(String propertyName) throws IllegalArgumentException;
+
+ void setPropertyValue(String propertyName, Serializable propertyValue) throws MockException;
+
+ Set<String> getPropertyNames();
+
+ MockObject addChild(String name, Class<? extends UIObject> type, Map<String, String> state) throws IllegalArgumentException, MockException;
+
+ MockObject addChild(String name, Class<? extends UIObject> type) throws IllegalArgumentException, MockException;
+
+ MockObject getParent();
+
+ List<? extends MockObject> getChildren();
+
+ MockObject getChild(String name);
+
+ boolean isValid();
+
+ StructuralObject takeSnapshot();
+
+ void move(MockObject destination) throws IllegalArgumentException, MockException;
+}
Added: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java (rev 0)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/Resolver.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.model;
+
+import org.jboss.portal.presentation.test.model.MockModel;
+import org.jboss.portal.presentation.test.model.MockObject;
+import org.jboss.portal.presentation.test.model3.UIObjectNode;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class Resolver
+{
+
+ /** . */
+ private final MockModel model;
+
+ public Resolver(MockModel model)
+ {
+ this.model = model;
+ }
+
+ public String getName(UIObjectNode objectNode)
+ {
+ MockObject mockObject = model.get(objectNode.getObject().getId());
+
+ //
+ if (mockObject == null)
+ {
+ return null;
+ }
+
+ //
+ return mockObject.getName();
+ }
+
+}
Deleted: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockException.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockException.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockException.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -1,56 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * 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. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model.state.structural;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class MockException extends RuntimeException
-{
-
- /** . */
- private ErrorCode code;
-
- public MockException(ErrorCode code)
- {
- this.code = code;
- }
-
- public MockException(String s, ErrorCode code)
- {
- super(s);
- this.code = code;
- }
-
- public enum ErrorCode
- {
- INVALID_OBJECT,
- CONSTRAINT_VIOLATION
- }
-
- public ErrorCode getCode()
- {
- return code;
- }
-}
Deleted: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModel.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModel.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModel.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -1,40 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * 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. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model.state.structural;
-
-import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public interface MockModel
-{
-
- StructuralStateContext getStructuralStateContext();
-
- MockObject getRoot();
-
- void destroy(MockObject object) throws MockException;
-
-}
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModelImpl.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModelImpl.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockModelImpl.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -29,6 +29,9 @@
import org.jboss.portal.presentation.state.StateException;
import org.jboss.portal.presentation.state.structural.StructuralObject;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.test.model.MockObject;
+import org.jboss.portal.presentation.test.model.MockModel;
+import org.jboss.portal.presentation.test.model.MockException;
import java.util.ArrayList;
import java.util.Collection;
@@ -64,6 +67,11 @@
return root;
}
+ public MockObject get(String id)
+ {
+ return universe.get(id);
+ }
+
public void destroy(MockObject object) throws MockException
{
destroy((MockObjectImpl)object, new ArrayList<String>());
Deleted: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObject.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObject.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObject.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -1,110 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * 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. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model.state.structural;
-
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.state.structural.StructuralObject;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public interface MockObject
-{
-
- public abstract static class UpdateBehavior
- {
- public static UpdateBehavior veto()
- {
- return new Veto();
- }
- public static UpdateBehavior failure(Throwable throwable)
- {
- return new Failure(throwable);
- }
- }
-
- static class Veto extends UpdateBehavior
- {
- }
-
- static class Failure extends UpdateBehavior
- {
-
- /** . */
- final Throwable throwable;
-
- public Failure(Throwable throwable)
- {
- this.throwable = throwable;
- }
-
- public <T extends Throwable> Failure throwAs(Class<T> type) throws T
- {
- if (type.isInstance(throwable))
- {
- throw type.cast(throwable);
- }
- return this;
- }
- }
-
- Class<? extends UIObject> getType();
-
- String getName();
-
- String getId();
-
- int getVersion();
-
- Serializable getPropertyValue(String propertyName) throws IllegalArgumentException;
-
- void setPropertyBehavior(String propertyName, UpdateBehavior propertyBehavior) throws IllegalArgumentException;
-
- UpdateBehavior getPropertyBehavior(String propertyName) throws IllegalArgumentException;
-
- void setPropertyValue(String propertyName, Serializable propertyValue) throws MockException;
-
- Set<String> getPropertyNames();
-
- MockObject addChild(String name, Class<? extends UIObject> type, Map<String, String> state) throws IllegalArgumentException, MockException;
-
- MockObject addChild(String name, Class<? extends UIObject> type) throws IllegalArgumentException, MockException;
-
- MockObject getParent();
-
- List<? extends MockObject> getChildren();
-
- MockObject getChild(String name);
-
- boolean isValid();
-
- StructuralObject takeSnapshot();
-
- void move(MockObject destination) throws IllegalArgumentException, MockException;
-}
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObjectImpl.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObjectImpl.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/structural/MockObjectImpl.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -23,6 +23,8 @@
package org.jboss.portal.presentation.test.model.state.structural;
import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.test.model.MockObject;
+import org.jboss.portal.presentation.test.model.MockException;
import java.util.ArrayList;
import java.util.Collections;
Deleted: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -1,55 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * 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. *
- ******************************************************************************/
-package org.jboss.portal.presentation.test.model3;
-
-import junit.framework.TestCase;
-import org.jboss.portal.presentation.impl.model.UIModelImpl;
-import org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
-import org.jboss.portal.presentation.model.UIModel;
-import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.state.structural.MockModel;
-import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public abstract class AbstractModelTestCase extends TestCase
-{
-
- /** . */
- protected UIModel model;
-
- /** . */
- protected MockModel mockModel;
-
- /** . */
- protected StructuralStateContext structuralStateContext;
-
- protected void setUp() throws Exception
- {
- mockModel = new MockModelImpl();
- structuralStateContext = mockModel.getStructuralStateContext();
- model = new UIModelImpl(new NavigationalStateContextImpl(), structuralStateContext);
- }
-}
\ No newline at end of file
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AddChildTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AddChildTestCase.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AddChildTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -49,13 +49,13 @@
rootDef.populate(mockModel);
//
- ViewPortScope scope = new CustomScope(model, rootDef);
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
UIObjectTree context = new UIObjectTree();
ViewPort viewPort = model.createViewPort(context, scope);
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
context.assertConsistency(model.getRootId());
//
@@ -65,7 +65,7 @@
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
context.assertConsistency(model.getRootId());
}
}
\ No newline at end of file
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/CustomScope.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -26,6 +26,8 @@
import org.jboss.portal.presentation.model.UIModel;
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.model.ViewPortScope;
+import org.jboss.portal.presentation.test.model.MockModel;
+import org.jboss.portal.presentation.test.model.MockObject;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
@@ -35,6 +37,9 @@
{
/** . */
+ private final MockModel mockModel;
+
+ /** . */
private final UIModel model;
/** . */
@@ -43,7 +48,7 @@
/** . */
private NodeDef current;
- public CustomScope(UIModel model, NodeDef root)
+ public CustomScope(MockModel mockModel, UIModel model, NodeDef root)
{
if (root == null)
{
@@ -51,6 +56,7 @@
}
//
+ this.mockModel = mockModel;
this.model = model;
this.root = root;
this.current = null;
@@ -76,9 +82,18 @@
}
else
{
- NodeDef child = current.getChild(object.getId());
+ MockObject mockObject = mockModel.get(object.getId());
//
+ if (mockObject == null)
+ {
+ throw new IllegalStateException("No such mock object " + object.getId());
+ }
+
+ //
+ NodeDef child = current.getChild(mockObject.getName());
+
+ //
if (child == null)
{
throw new IllegalStateException("No such child " + object.getId());
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/ModelTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/ModelTestCase.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/ModelTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -56,18 +56,18 @@
rootDef.populate(mockModel);
//
- ViewPortScope scope = new CustomScope(model, rootDef);
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
UIObjectTree context = new UIObjectTree();
ViewPort viewPort = model.createViewPort(context, scope);
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
context.assertConsistency(model.getRootId());
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
context.assertConsistency(model.getRootId());
//
@@ -78,7 +78,7 @@
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
context.assertConsistency(model.getRootId());
}
}
\ No newline at end of file
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/MoveChildTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/MoveChildTestCase.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/MoveChildTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -48,13 +48,13 @@
rootDef.populate(mockModel);
//
- ViewPortScope scope = new CustomScope(model, rootDef);
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
UIObjectTree context = new UIObjectTree();
ViewPort viewPort = model.createViewPort(context, scope);
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
context.assertConsistency(model.getRootId());
//
@@ -64,7 +64,7 @@
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
context.assertConsistency(model.getRootId());
}
});
@@ -85,13 +85,13 @@
rootDef.populate(mockModel);
//
- ViewPortScope scope = new CustomScope(model, rootDef);
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
UIObjectTree context = new UIObjectTree();
ViewPort viewPort = model.createViewPort(context, scope);
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
context.assertConsistency(model.getRootId());
//
@@ -101,7 +101,7 @@
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
context.assertConsistency(model.getRootId());
}
});
@@ -123,13 +123,13 @@
rootDef.populate(mockModel);
//
- ViewPortScope scope = new CustomScope(model, rootDef);
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
UIObjectTree context = new UIObjectTree();
ViewPort viewPort = model.createViewPort(context, scope);
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
context.assertConsistency(model.getRootId());
//
@@ -142,7 +142,7 @@
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
context.assertConsistency(model.getRootId());
}
});
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/NodeDef.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -27,13 +27,15 @@
import org.jboss.portal.presentation.model.ui.UIObject;
import org.jboss.portal.presentation.model.ui.UIContext;
import org.jboss.portal.presentation.model.ui.UIPage;
-import org.jboss.portal.presentation.test.model.state.structural.MockModel;
-import org.jboss.portal.presentation.test.model.state.structural.MockObject;
+import org.jboss.portal.presentation.test.model.MockModel;
+import org.jboss.portal.presentation.test.model.MockObject;
+import org.jboss.portal.presentation.test.model.Resolver;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.Collection;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
@@ -85,6 +87,11 @@
return children.get(name);
}
+ public Collection<NodeDef> getChildren()
+ {
+ return children.values();
+ }
+
public NodeDef getParent()
{
return parent;
@@ -180,7 +187,7 @@
}
}
- public void assertEquals(UIObjectNode objectNode)
+ public void assertEquals(Resolver resolver, UIObjectNode objectNode)
{
Assert.assertEquals(properties.keySet(), objectNode.getProperties().keySet());
for (String propertyName : properties.keySet())
@@ -210,13 +217,19 @@
}
//
- Assert.assertEquals(expectedChildrenNames, objectNode.getChildren().keySet());
-
- //
+ Set<String> childrenNames = new HashSet<String>();
for (UIObjectNode childObjectNode : objectNode.getChildren().values())
{
- child.assertEquals(childObjectNode);
+ String childName = resolver.getName(childObjectNode);
+ childrenNames.add(childName);
+ NodeDef expectedChild = children.get(childName);
+ expectedChild.assertEquals(resolver, childObjectNode);
}
+
+ //
+ Assert.assertEquals(expectedChildrenNames, childrenNames);
+
+ //
break;
}
}
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/RemoveChildTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/RemoveChildTestCase.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/RemoveChildTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -49,13 +49,13 @@
rootDef.populate(mockModel);
//
- ViewPortScope scope = new CustomScope(model, rootDef);
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
UIObjectTree context = new UIObjectTree();
ViewPort viewPort = model.createViewPort(context, scope);
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
//
mockModel.destroy(mockModel.getRoot().getChild("foo").getChild("juu"));
@@ -63,7 +63,7 @@
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
context.assertConsistency(model.getRootId());
}
}
\ No newline at end of file
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -29,7 +29,8 @@
import org.jboss.portal.presentation.model.ObjectTraversalType;
import org.jboss.portal.presentation.model.UIModel;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.test.model.state.structural.MockModel;
+import org.jboss.portal.presentation.test.model.MockModel;
+import org.jboss.portal.presentation.test.model.Resolver;
import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
import java.util.ArrayList;
@@ -53,6 +54,9 @@
/** . */
protected StructuralStateContext structuralStateContext;
+ /** . */
+ protected Resolver resolver;
+
public void test(int size, Object handback)
{
ObjectTraversalType[] before = new ObjectTraversalType[size];
@@ -65,7 +69,8 @@
mockModel = new MockModelImpl();
structuralStateContext = mockModel.getStructuralStateContext();
model = new UIModelImpl(new NavigationalStateContextImpl(), structuralStateContext);
-
+ resolver = new Resolver(mockModel);
+
//
Assert.assertEquals(before.length + after.length, element.length);
System.arraycopy(element, 0, before, 0, before.length);
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TypeTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TypeTestCase.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TypeTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -27,6 +27,7 @@
import org.jboss.portal.presentation.model.ui.UIContext;
import org.jboss.portal.presentation.model.ui.UIPage;
import org.jboss.portal.presentation.model.ui.UIWindow;
+import org.jboss.portal.presentation.test.model.AbstractModelTestCase;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
@@ -45,7 +46,7 @@
rootDef.populate(mockModel);
//
- ViewPortScope scope = new CustomScope(model, rootDef);
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
UIObjectTree context = new UIObjectTree();
ViewPort viewPort = model.createViewPort(context, scope);
@@ -54,14 +55,17 @@
//
UIObjectNode root = context.getNode(mockModel.getStructuralStateContext().getRootId());
- UIObjectNode foo = root.getChild("foo");
- UIObjectNode bar = root.getChild("bar");
+ UIObjectNode foo = getChild(root, "foo");
+ UIObjectNode bar = getChild(root, "bar");
//
+ assertNotNull(foo);
+ assertNotNull(bar);
+
+ //
assertTrue(root.getObject() instanceof UIContext);
assertTrue("was not expecting: " + foo.getObject().getClass().getName(), foo.getObject() instanceof UIPage);
assertTrue("was not expecting: " + bar.getObject().getClass().getName(), bar.getObject() instanceof UIWindow);
-
}
}
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectNode.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectNode.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UIObjectNode.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -85,9 +85,9 @@
return children;
}
- public UIObjectNode getChild(String name)
+ public UIObjectNode getChild(String id)
{
- return children.get(name);
+ return children.get(id);
}
public void addChild(UIObjectNode child)
Modified: modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UpdateObjectTestCase.java
===================================================================
--- modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UpdateObjectTestCase.java 2008-07-02 20:50:40 UTC (rev 11269)
+++ modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/UpdateObjectTestCase.java 2008-07-02 22:02:20 UTC (rev 11270)
@@ -47,20 +47,20 @@
rootDef.populate(mockModel);
//
- ViewPortScope scope = new CustomScope(model, rootDef);
+ ViewPortScope scope = new CustomScope(mockModel, model, rootDef);
UIObjectTree context = new UIObjectTree();
ViewPort viewPort = model.createViewPort(context, scope);
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
//
mockModel.getRoot().getChild("foo").setPropertyValue("juu", "daa");
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
//
mockModel.getRoot().getChild("foo").setPropertyValue("juu", null);
@@ -68,6 +68,6 @@
//
viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
+ rootDef.assertEquals(resolver, context.getNode(model.getRootId()));
}
}
16 years