JBoss Portal SVN: r10389 - docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: mmcallis
Date: 2008-03-27 03:08:25 -0400 (Thu, 27 Mar 2008)
New Revision: 10389
Modified:
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/xmldescriptors.xml
Log:
6.2.1. *-object.xml Descriptors
- revising content, and copying a little content from
6.1.2. The JBoss Portlet Instance DTD
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-03-27 03:48:14 UTC (rev 10388)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/xmldescriptors.xml 2008-03-27 07:08:25 UTC (rev 10389)
@@ -977,9 +977,9 @@
The following sections describe the descriptors used to define portal objects, such as portals, pages, portlet instances, windows, and portlets. Refer to <xref linkend="tutorials_tutorials"/> and <xref linkend="desc_examples"/> for examples on using these descriptors within a portlet application.
</para>
<sect2 id="desc_objectxml">
- <title><filename>*-object.xml</filename> Files</title>
+ <title><filename>*-object.xml</filename> Descriptors</title>
<para>
- The <filename>*-object.xml</filename> files are used to define portal instances, pages, windows, and the window layout. As well, themes and layouts for specific portal instances, pages, and windows, can be defined. The following example defines a portlet window being added to the default page, in the default portal. For advanced functionality using this descriptor, refer to <xref linkend="desc_examples"/>:
+ The <filename>*-object.xml</filename> descriptors are used to define portal instances, pages, windows, and the window layout. As well, themes and layouts for specific portal instances, pages, and windows, can be defined. The following example defines a portlet window being added to the <computeroutput>default</computeroutput> page, in the <computeroutput>default</computeroutput> portal. For advanced functionality using these descriptors, refer to <xref linkend="desc_examples"/>:
</para>
<para>
<programlisting><![CDATA[
@@ -1003,45 +1003,34 @@
<listitem>
<para>
<programlisting><![CDATA[<deployments>...</deployments>]]></programlisting>
- The
- <emphasis>deployments</emphasis>
- tag, encapsulates the entire document. You may specify more than one deployment within this tag.
+ The <computeroutput><deployments></computeroutput> element encapsulates the entire document. Multiple deployments can be specified within the <computeroutput><deployments></computeroutput> tag.
</para>
</listitem>
<listitem>
<para>
<programlisting><![CDATA[<deployment>...</deployment>]]></programlisting>
- The
- <emphasis>deployment</emphasis>
- tag is used to specify object deployments: portals, pages, windows, etc...
+ </para>
+ <para>
+ The <computeroutput><deployment></computeroutput> element is used to specify object deployments, such as portals, pages, windows, and so on.
</para>
</listitem>
<listitem>
<para>
<programlisting><![CDATA[<if-exists>...</if-exists>]]></programlisting>
- Possible values are
- <emphasis>overwrite</emphasis>
- or
- <emphasis>keep</emphasis>
- .
- <emphasis>Overwrite</emphasis>
- will destroy the existing object in the database and create a new one, based on the
- content of the deployment.
- <emphasis>Keep</emphasis>
- will maintain the existing object deployment or create a new one if
- it does not yet exist.
- </para>
+ </para>
+ <para>
+ The <computeroutput><if-exists></computeroutput> element is used to define the action to take if an instance with the same name already exists. Accepted values are <computeroutput>overwrite</computeroutput> and <computeroutput>keep</computeroutput>. The <computeroutput>overwrite</computeroutput> option will destroy the existing object and create a new one based on the content of the deployment. The <computeroutput>keep</computeroutput> option will maintain the existing object deployment, or create a new one if it does not exist.
+ </para>
</listitem>
<listitem>
<para>
<programlisting><![CDATA[<parent-ref>...</parent-ref>]]></programlisting>
- The
- <emphasis>parent-ref</emphasis>
- tag specifies where a particulare object will exist within the portal object tree. In our example,
- above, we are defining a window and assigning it to
- <emphasis>default.default</emphasis>
- , interpreted, this means the window will appear in the default portal and the default page within
- it.
+ </para>
+ <para>
+ The <computeroutput><parent-ref></computeroutput> element contains a reference to the parent object. The naming convention for naming objects is to concatenate the names of the path to the object, and separate the names by a period. If the path is empty, then the empty string must be used. The <computeroutput><parent-ref></computeroutput> element tells the portal where the portlet should appear. The syntax for the <computeroutput><parent-ref></computeroutput> element is <computeroutput><replaceable>portal-instance</replaceable>.<replaceable>portal-page</replaceable></computeroutput>.
+ </para>
+ <para>
+ In the example above, a window is defined, and assigned to <computeroutput>default.default</computeroutput>. This means the window will appear in the <computeroutput>default</computeroutput> page, in the <computeroutput>default</computeroutput> portal.
</para>
</listitem>
<listitem>
18 years, 1 month
JBoss Portal SVN: r10388 - in branches/JBoss_Portal_Branch_2_7: wsrp/src/main/org/jboss/portal/test/wsrp/consumer and 6 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-03-26 23:48:14 -0400 (Wed, 26 Mar 2008)
New Revision: 10388
Modified:
branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/registration/RegistrationUtils.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/handler/RequestHeaderClientHandlerTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPConstants.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/handler/RequestHeaderClientHandler.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
Log:
- Multiple cookies were not properly escaped (used ';' instead of ',').
- WSRPConstants.DEFAULT_LOCALES now uses the default locale instead of hardcoding en-US.
- JBPORTAL-1963: Added support for multiple Set-Cookie headers. Needs more testing.
- JBPORTAL-1964: Added strict mode on producer configuration. Need to work on GUI and consumer configuration.
Modified: branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/registration/RegistrationUtils.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/registration/RegistrationUtils.java 2008-03-27 01:07:32 UTC (rev 10387)
+++ branches/JBoss_Portal_Branch_2_7/registration/src/main/org/jboss/portal/registration/RegistrationUtils.java 2008-03-27 03:48:14 UTC (rev 10388)
@@ -23,6 +23,7 @@
package org.jboss.portal.registration;
+import org.jboss.logging.Logger;
import org.jboss.portal.common.util.ParameterValidation;
/**
@@ -32,6 +33,15 @@
*/
public class RegistrationUtils
{
+ private static boolean strict = true;
+ private static Logger log = Logger.getLogger(RegistrationUtils.class);
+
+ public static void setStrict(boolean strict)
+ {
+ RegistrationUtils.strict = strict;
+ log.debug("Using " + (strict ? "strict" : "lenient") + " Consumer Agent validation mode.");
+ }
+
/**
* @param consumerAgent
* @throws IllegalArgumentException
@@ -52,6 +62,15 @@
return;
}
}
- throw new IllegalArgumentException("'" + consumerAgent + "' is not a valid Consumer Agent.");
+
+ String msg = "'" + consumerAgent + "' is not a valid Consumer Agent. Please notify your Consumer provider that it is not WSRP-compliant.";
+ if (strict)
+ {
+ throw new IllegalArgumentException(msg);
+ }
+ else
+ {
+ log.debug(msg);
+ }
}
}
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java 2008-03-27 01:07:32 UTC (rev 10387)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java 2008-03-27 03:48:14 UTC (rev 10388)
@@ -59,7 +59,7 @@
cookies = new Cookie[]{createCookie("name1", "value1", 1), createCookie("name2", "value2", 3)};
info.setUserCookie(cookies);
- assertEquals("name1=value1;name2=value2", info.getUserCookie());
+ assertEquals("name1=value1,name2=value2", info.getUserCookie());
Thread.sleep(1000);
assertEquals("name2=value2", info.getUserCookie());
@@ -93,7 +93,7 @@
info.setGroupCookieFor(groupId, new Cookie[]{createCookie("name1", "value1", 1),
createCookie("name2", "value2", WSRPConstants.SESSION_NEVER_EXPIRES)});
- assertEquals("name1=value1;name2=value2", info.getGroupCookieFor(groupId));
+ assertEquals("name1=value1,name2=value2", info.getGroupCookieFor(groupId));
Thread.sleep(1000);
assertEquals("name2=value2", info.getGroupCookieFor(groupId));
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/handler/RequestHeaderClientHandlerTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/handler/RequestHeaderClientHandlerTestCase.java 2008-03-27 01:07:32 UTC (rev 10387)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/handler/RequestHeaderClientHandlerTestCase.java 2008-03-27 03:48:14 UTC (rev 10388)
@@ -116,7 +116,7 @@
MimeHeaders headers = message.getMimeHeaders();
String[] cookie = headers.getHeader("Cookie");
assertEquals(1, cookie.length);
- assertEquals("name=value;usercookie=uservalue", cookie[0]);
+ assertEquals("name=value,usercookie=uservalue", cookie[0]);
}
public void testCookieWithoutInitHandleResponse()
@@ -134,6 +134,21 @@
assertFalse(info.isPerGroupCookies());
}
+ public void testMultipleCookiesInResponse()
+ {
+ MockSOAPMessage message = new MockSOAPMessage();
+ SOAPMessageContext msgContext = MockSOAPMessageContext.createMessageContext(message, getClass().getClassLoader());
+ MimeHeaders headers = new MimeHeaders();
+ headers.addHeader("Set-Cookie", "name1=value1");
+ headers.addHeader("Set-Cookie", "name2=value2");
+ headers.addHeader("Set-Cookie", "name3=value3");
+ message.setMimeHeaders(headers);
+
+ handler.handleResponse(msgContext);
+ ProducerSessionInformation info = RequestHeaderClientHandler.getCurrentProducerSessionInformation();
+ assertEquals("name1=value1,name2=value2,name3=value3", info.getUserCookie());
+ }
+
public void testCurrentInfo()
{
assertNull(RequestHeaderClientHandler.getCurrentProducerSessionInformation());
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPConstants.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPConstants.java 2008-03-27 01:07:32 UTC (rev 10387)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPConstants.java 2008-03-27 03:48:14 UTC (rev 10388)
@@ -28,6 +28,7 @@
import javax.xml.namespace.QName;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.util.Locale;
import java.util.Random;
/**
@@ -116,8 +117,16 @@
/** Default character set used to generate markup. */
public static final String DEFAULT_CHARACTER_SET = "UTF-8";
+
/** Default locales. */
- public static final String[] DEFAULT_LOCALES = new String[]{"en-US", "en"};
+ public static final String[] DEFAULT_LOCALES;
+
+ static
+ {
+ String defaultLocale = WSRPUtils.toString(Locale.getDefault());
+ DEFAULT_LOCALES = new String[]{defaultLocale, "en"};
+ }
+
/** Default MIME types. */
public static final String[] DEFAULT_MIME_TYPES = new String[]{"text/html"};
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java 2008-03-27 01:07:32 UTC (rev 10387)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java 2008-03-27 03:48:14 UTC (rev 10388)
@@ -340,13 +340,14 @@
{
if (cookies != null && cookies.length != 0)
{
- StringBuffer sb = new StringBuffer(64);
- for (int i = 0; i < cookies.length; i++)
+ int cookieNumber = cookies.length;
+ StringBuffer sb = new StringBuffer(128 * cookieNumber);
+ for (int i = 0; i < cookieNumber; i++)
{
sb.append(cookies[i].toExternalForm());
- if (i != cookies.length - 1)
+ if (i != cookieNumber - 1)
{
- sb.append(";");
+ sb.append(","); // multiple cookies are separated by commas: http://www.ietf.org/rfc/rfc2109.txt, 4.2.2
}
}
return sb.toString();
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/handler/RequestHeaderClientHandler.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/handler/RequestHeaderClientHandler.java 2008-03-27 01:07:32 UTC (rev 10387)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/handler/RequestHeaderClientHandler.java 2008-03-27 03:48:14 UTC (rev 10388)
@@ -25,6 +25,7 @@
import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.cookie.MalformedCookieException;
import org.apache.commons.httpclient.cookie.RFC2109Spec;
+import org.jboss.logging.Logger;
import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
import javax.xml.namespace.QName;
@@ -48,6 +49,7 @@
{
private static final ThreadLocal local = new ThreadLocal();
private static final RFC2109Spec cookieParser = new RFC2109Spec();
+ private static final Logger log = Logger.getLogger(RequestHeaderClientHandler.class);
public QName[] getHeaders()
{
@@ -91,7 +93,7 @@
{
if (cookie.length() != 0)
{
- cookie.append(";");
+ cookie.append(','); // multiple cookies are separated by commas: http://www.ietf.org/rfc/rfc2109.txt, 4.2.2
}
cookie.append(userCookie);
}
@@ -113,20 +115,10 @@
if (cookieValues != null)
{
- if (cookieValues.length > 1)
- {
- StringBuffer sb = new StringBuffer(128);
- sb.append("Cookie headers:\n");
- for (int i = 0; i < cookieValues.length; i++)
- {
- sb.append("\t").append(i).append(":\t").append(cookieValues[i]).append("\n");
+ String cookieValue = coalesceCookies(cookieValues);
- }
- throw new IllegalArgumentException("Too many cookie headers!\n" + sb.toString());
- }
+ Cookie[] cookies = extractCookies((String)msgContext.getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY), cookieValue);
- Cookie[] cookies = extractCookies((String)msgContext.getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY), cookieValues);
-
CurrentInfo info = getCurrentInfo(true);
ProducerSessionInformation sessionInfo = info.sessionInfo;
@@ -148,8 +140,53 @@
return super.handleResponse(msgContext);
}
- private Cookie[] extractCookies(String endpointAddress, String[] cookieValues)
+ /**
+ * Coalesce several Set-Cookie headers into one and returning the resulting concatenated String.
+ *
+ * @param cookieValues the array containing the values of the different Set-Cookie headers to be coalesced
+ * @return the concatenated value that could be used as one Set-Cookie header
+ */
+ private String coalesceCookies(String[] cookieValues)
{
+ assert cookieValues != null;
+
+ StringBuffer logBuffer = null;
+ if (log.isDebugEnabled())
+ {
+ logBuffer = new StringBuffer(128);
+ logBuffer.append("Cookie headers:\n");
+ }
+
+ int cookieNumber = cookieValues.length;
+ StringBuffer cookieBuffer = new StringBuffer(cookieNumber * 128);
+ String cookieValue;
+ for (int i = 0; i < cookieNumber; i++)
+ {
+ cookieValue = cookieValues[i];
+ cookieBuffer.append(cookieValue);
+
+ // multiple cookies are separated by commas: http://www.ietf.org/rfc/rfc2109.txt, 4.2.2
+ if (i < cookieNumber - 1)
+ {
+ cookieBuffer.append(',');
+ }
+
+ if (log.isDebugEnabled())
+ {
+ logBuffer.append("\t").append(i).append(":\t").append(cookieValue).append("\n");
+ }
+ }
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(logBuffer.toString());
+ }
+
+ return cookieBuffer.toString();
+ }
+
+ private Cookie[] extractCookies(String endpointAddress, String cookieValue)
+ {
if (endpointAddress == null)
{
throw new NullPointerException("Was expecting an endpoint address but none was provided in the MessageContext");
@@ -166,7 +203,6 @@
throw new IllegalArgumentException(endpointAddress + " is not a valid URL for the endpoint address.");
}
- String cookie = cookieValues[0];
Cookie[] cookies;
try
{
@@ -179,16 +215,16 @@
String path = hostURL.getPath();
boolean secure = hostURL.getProtocol().endsWith("s"); // todo: is that correct?
- cookies = cookieParser.parse(host, port, path, secure, cookie);
+ cookies = cookieParser.parse(host, port, path, secure, cookieValue);
- for (int i = 0; i < cookies.length; i++)
+ for (Cookie cookie : cookies)
{
- cookieParser.validate(host, port, path, secure, cookies[i]);
+ cookieParser.validate(host, port, path, secure, cookie);
}
}
catch (MalformedCookieException e)
{
- throw new IllegalArgumentException("Malformed cookie: " + cookie);
+ throw new IllegalArgumentException("Malformed cookie: " + cookieValue);
}
return cookies;
}
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2008-03-27 01:07:32 UTC (rev 10387)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2008-03-27 03:48:14 UTC (rev 10388)
@@ -34,6 +34,7 @@
import org.jboss.portal.registration.Registration;
import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.registration.RegistrationManager;
+import org.jboss.portal.registration.RegistrationUtils;
import org.jboss.portal.wsrp.ResponseDebugFactory;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
import org.jboss.portal.wsrp.WSRPProducer;
@@ -94,7 +95,7 @@
public class WSRPProducerImpl extends AbstractJBossService implements WSRPProducer
{
/** logger used for logging ;) */
- private final Logger log = Logger.getLogger(getClass());
+ private static final Logger log = Logger.getLogger(WSRPProducerImpl.class);
/** The invoker used to retrieve portlet information and invoke methods. */
private PortletInvoker invoker;
@@ -269,6 +270,11 @@
return configurationService;
}
+ public void setUseStrictMode(boolean strict)
+ {
+ RegistrationUtils.setStrict(strict);
+ }
+
protected void startService() throws Exception
{
super.startService();
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2008-03-27 01:07:32 UTC (rev 10387)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2008-03-27 03:48:14 UTC (rev 10388)
@@ -38,6 +38,8 @@
<depends optional-attribute-name="ProducerConfigurationService" proxy-type="attribute">
portal.wsrp:service=ProducerConfiguration
</depends>
+ <attribute name="UseStrictMode">true</attribute>
+ <!-- Set to false to switch to lenient mode -->
</mbean>
<!-- Registration manager -->
@@ -76,10 +78,12 @@
<attribute name="DTDMapping">
<properties>
<entry
- key="-//JBoss Portal//DTD WSRP Remote Producer Configuration 2.6//EN">dtd/jboss-wsrp-consumer_2_6.dtd
+ key="-//JBoss Portal//DTD WSRP Remote Producer Configuration 2.6//EN">
+ dtd/jboss-wsrp-consumer_2_6.dtd
</entry>
<entry
- key="-//JBoss Portal//DTD WSRP Local Producer Configuration 2.6//EN">dtd/jboss-wsrp-producer_2_6.dtd
+ key="-//JBoss Portal//DTD WSRP Local Producer Configuration 2.6//EN">
+ dtd/jboss-wsrp-producer_2_6.dtd
</entry>
<entry key="urn:jboss:portal:wsrp:consumer:v2_6">/xsd/jboss-wsrp-consumer_2_6.xsd</entry>
<entry key="urn:jboss:portal:wsrp:producer:v2_6">/xsd/jboss-wsrp-consumer_2_6.xsd</entry>
@@ -107,8 +111,8 @@
<xmbean/>
<depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>
<!-- Uncomment in clustered mode : hibernate depends on its tree cache service @portal.single.xml.close@
- <depends>portal:service=TreeCacheProvider,type=hibernate</depends>
- @portal.single.xml.open@ -->
+ <depends>portal:service=TreeCacheProvider,type=hibernate</depends>
+ @portal.single.xml.open@ -->
<attribute name="DoChecking">true</attribute>
<attribute name="ConfigLocation">conf/hibernate/consumer/hibernate.cfg.xml</attribute>
<attribute name="JNDIName">java:/portal/WSRPConsumerSessionFactory</attribute>
18 years, 1 month
JBoss Portal SVN: r10387 - in branches/presentation/presentation: src/main/org/jboss/portal/presentation/test/model2 and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-26 21:07:32 -0400 (Wed, 26 Mar 2008)
New Revision: 10387
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/MoveChildTestCase.java
Modified:
branches/presentation/presentation/build.xml
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectNode.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java
Log:
start to add a move test case (which is the critical feature to implement)
Modified: branches/presentation/presentation/build.xml
===================================================================
--- branches/presentation/presentation/build.xml 2008-03-27 00:58:57 UTC (rev 10386)
+++ branches/presentation/presentation/build.xml 2008-03-27 01:07:32 UTC (rev 10387)
@@ -311,12 +311,13 @@
-->
</x-sysproperty>
<x-test>
- <!--<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.MockModelTestCase"/>-->
- <!--<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.ModelTestCase"/>-->
- <!--<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.EventTestCase"/>-->
+ <test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.MockModelTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.ModelTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.EventTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model2.ModelTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model2.AddChildTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model2.RemoveChildTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.presentation.test.model2.MoveChildTestCase"/>
</x-test>
<x-classpath>
<path refid="jboss.portal/modules/common.classpath"/>
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/MoveChildTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/MoveChildTestCase.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/MoveChildTestCase.java 2008-03-27 01:07:32 UTC (rev 10387)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * 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.model2;
+
+import org.jboss.portal.presentation.model2.ObjectTraversalType;
+import org.jboss.portal.presentation.model2.ViewPortScope;
+import org.jboss.portal.presentation.model2.ViewPort;
+import org.jboss.portal.presentation.test.model.state.structural.MockObject;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class MoveChildTestCase extends TraversalModelTestCase
+{
+
+ public void testMoveChild()
+ {
+ test(0);
+ }
+
+ protected void test(ObjectTraversalType[] before, ObjectTraversalType[] after)
+ {
+ NodeDef rootDef = NodeDef.create();
+ NodeDef fooDef = rootDef.addChild("foo");
+ NodeDef juuDef = fooDef.addChild("juu");
+ NodeDef barDef = rootDef.addChild("bar");
+
+ //
+ rootDef.populate(mockModel);
+
+ //
+ ViewPortScope scope = new CustomScope(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());
+ }
+}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectNode.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectNode.java 2008-03-27 00:58:57 UTC (rev 10386)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectNode.java 2008-03-27 01:07:32 UTC (rev 10387)
@@ -101,7 +101,7 @@
children.remove(key);
}
- public void createrChildren()
+ public void createChildren()
{
if (children != null)
{
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java 2008-03-27 00:58:57 UTC (rev 10386)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java 2008-03-27 01:07:32 UTC (rev 10387)
@@ -27,7 +27,6 @@
import java.util.Map;
import java.util.HashMap;
-import java.util.Set;
import java.util.ArrayList;
import java.util.HashSet;
@@ -80,37 +79,85 @@
public void removeObject(String objectId)
{
- nodes.remove(objectId);
+ if (nodes.remove(objectId) == null)
+ {
+ throw new IllegalStateException("No such object " + objectId);
+ }
}
public void addObject(UIObject object)
{
- nodes.put(object.getId(), new UIObjectNode(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 initChildren(String parentId)
{
- UIObjectNode parent =nodes.get(parentId);
- parent.createrChildren();
+ 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();
}
}
18 years, 1 month
JBoss Portal SVN: r10386 - in branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core: portlet/info and 1 other directory.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-03-26 20:58:57 -0400 (Wed, 26 Mar 2008)
New Revision: 10386
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/info/WSRPInfoImpl.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/info/WSRPInfo.java
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/info/CoreInfoBuilder.java
Log:
oups
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/info/CoreInfoBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/info/CoreInfoBuilder.java 2008-03-27 00:21:45 UTC (rev 10385)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/info/CoreInfoBuilder.java 2008-03-27 00:58:57 UTC (rev 10386)
@@ -31,6 +31,7 @@
import org.jboss.portal.core.portlet.info.MarkupHeaderInfo;
import org.jboss.portal.core.portlet.info.PortletInfoInfo;
import org.jboss.portal.core.portlet.info.TransactionInfo;
+import org.jboss.portal.core.portlet.info.WSRPInfo;
import org.jboss.portal.portlet.deployment.jboss.InfoBuilder;
import org.jboss.portal.portlet.deployment.jboss.PortletApplicationContextImpl;
import org.jboss.portal.portlet.deployment.jboss.info.SessionInfo;
@@ -130,6 +131,12 @@
{
containerInfo.setAttachment(SessionInfo.class, new SessionInfoImpl(distributed));
}
+
+ Boolean remotable = jbossPortletMD.getRemotable();
+ if (remotable != null)
+ {
+ containerInfo.setAttachment(WSRPInfo.class, new WSRPInfoImpl(remotable));
+ }
}
portlets.put(name, containerInfo);
Added: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/info/WSRPInfoImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/info/WSRPInfoImpl.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/info/WSRPInfoImpl.java 2008-03-27 00:58:57 UTC (rev 10386)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * 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.core.impl.portlet.info;
+
+import org.jboss.portal.core.portlet.info.WSRPInfo;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class WSRPInfoImpl implements WSRPInfo
+{
+
+ private Boolean remotable;
+
+ public WSRPInfoImpl(Boolean remotable)
+ {
+ this.remotable = remotable;
+ }
+
+ public Boolean isRemotable()
+ {
+ return remotable;
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/info/WSRPInfo.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/info/WSRPInfo.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/info/WSRPInfo.java 2008-03-27 00:58:57 UTC (rev 10386)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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.core.portlet.info;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface WSRPInfo
+{
+ Boolean isRemotable();
+}
+
18 years, 1 month
JBoss Portal SVN: r10385 - in branches/presentation/presentation/src/main/org/jboss/portal/presentation: test/model2 and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-26 20:21:45 -0400 (Wed, 26 Mar 2008)
New Revision: 10385
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java
Log:
improved stuff
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java 2008-03-26 23:41:59 UTC (rev 10384)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java 2008-03-27 00:21:45 UTC (rev 10385)
@@ -75,7 +75,7 @@
refresh(rootId);
}
- private boolean refresh(String objectId)
+ private Status refresh(String objectId)
{
UIObjectImpl object = (UIObjectImpl)context.getObject(objectId);
@@ -89,18 +89,18 @@
StructuralObject structuralObject = structuralStateContext.load(objectId);
// It is not present, load it
- return load(structuralObject);
+ return load(structuralObject) ? Status.LOADED : Status.NOT_LOADED;
}
}
- private boolean refresh(StructuralObject structuralObject)
+ private Status refresh(StructuralObject structuralObject)
{
UIObjectImpl object = (UIObjectImpl)context.getObject(structuralObject.getId());
if (object == null)
{
- return load(structuralObject);
+ return load(structuralObject) ? Status.LOADED : Status.NOT_LOADED;
}
else
{
@@ -111,8 +111,15 @@
}
}
- private boolean refresh(UIObjectImpl object)
+ private enum Status
{
+ LOADED,
+ NOT_LOADED,
+ WANT_EVICT
+ }
+
+ private Status refresh(UIObjectImpl object)
+ {
ObjectTraversalType traversalType = scope.enterObject(object);
//
@@ -120,10 +127,7 @@
{
if (traversalType == ObjectTraversalType.SKIP)
{
- evict(object);
-
- //
- return false;
+ return Status.WANT_EVICT;
}
else if (traversalType == ObjectTraversalType.SINGLE)
{
@@ -149,7 +153,7 @@
}
//
- return true;
+ return Status.LOADED;
}
else
{
@@ -175,41 +179,55 @@
// Is it the same object with a new state or is it a new child with the same name ?
if (childEntry.getKey().equals(childId))
{
- boolean loaded = refresh(childEntry.getValue());
+ Status status = refresh(childEntry.getValue());
- //
- if (hadChildren)
+ switch (status)
{
- UIObjectImpl.ChildRef childRef = object.childrenRefs.get(childId);
-
- //
- if (loaded)
- {
- if (!childRef.loaded)
+ case LOADED:
+ if (hadChildren)
{
- childRef.loaded = true;
- context.addChild(objectId, childId);
+ UIObjectImpl.ChildRef childRef = object.childrenRefs.get(childId);
+ if (!childRef.loaded)
+ {
+ childRef.loaded = true;
+ context.addChild(objectId, childId);
+ }
}
- }
- else
- {
- if (childRef.loaded)
+ else
{
- childRef.loaded = false;
- context.removeChild(objectId, childId);
+ object.childrenRefs.put(childId, new UIObjectImpl.ChildRef(childId, true));
+ context.addChild(objectId, structuralChild.getId());
}
- }
+ break;
+ case NOT_LOADED:
+ if (hadChildren)
+ {
+ UIObjectImpl.ChildRef childRef = object.childrenRefs.get(childId);
+ if (childRef.loaded)
+ {
+ childRef.loaded = false;
+ context.removeChild(objectId, childId);
+ }
+ }
+ else
+ {
+ object.childrenRefs.put(childId, new UIObjectImpl.ChildRef(childId, false));
+ }
+ break;
+ case WANT_EVICT:
+ if (hadChildren)
+ {
+ UIObjectImpl.ChildRef childRef = object.childrenRefs.get(childId);
+ if (childRef.loaded)
+ {
+ context.removeChild(objectId, childId);
+ childRef.loaded = false;
+ UIObjectImpl child = (UIObjectImpl)context.getObject(childId);
+ evict(child);
+ }
+ }
+ break;
}
- else
- {
- object.childrenRefs.put(childId, new UIObjectImpl.ChildRef(childId, loaded));
-
- //
- if (loaded)
- {
- context.addChild(objectId, structuralChild.getId());
- }
- }
}
else
{
@@ -247,45 +265,59 @@
//
for (String childId : refresh.getValidChildren())
{
- boolean loaded = refresh(childId);
+ Status status = refresh(childId);
- //
- if (hadChildren)
+ switch (status)
{
- UIObjectImpl.ChildRef childRef = object.childrenRefs.get(childId);
-
- //
- if (childRef.loaded)
- {
- if (!loaded)
+ case LOADED:
+ if (hadChildren)
{
- childRef.loaded = false;
- context.removeChild(objectId, childId);
+ UIObjectImpl.ChildRef childRef = object.childrenRefs.get(childId);
+ if (!childRef.loaded)
+ {
+ childRef.loaded = true;
+ context.addChild(objectId, childId);
+ }
}
- }
- else
- {
- if (loaded)
+ else
{
- childRef.loaded = true;
+ object.childrenRefs.put(childId, new UIObjectImpl.ChildRef(childId, true));
context.addChild(objectId, childId);
}
- }
+ break;
+ case NOT_LOADED:
+ if (hadChildren)
+ {
+ UIObjectImpl.ChildRef childRef = object.childrenRefs.get(childId);
+ if (childRef.loaded)
+ {
+ childRef.loaded = false;
+ context.removeChild(objectId, childId);
+ }
+ }
+ else
+ {
+ object.childrenRefs.put(childId, new UIObjectImpl.ChildRef(childId, false));
+ }
+ break;
+ case WANT_EVICT:
+ if (hadChildren)
+ {
+ UIObjectImpl.ChildRef childRef = object.childrenRefs.get(childId);
+ if (childRef.loaded)
+ {
+ context.removeChild(objectId, childId);
+ childRef.loaded = false;
+ UIObjectImpl child = (UIObjectImpl)context.getObject(childId);
+ evict(child);
+ }
+ }
+ break;
}
- else
- {
- object.childrenRefs.put(childId, new UIObjectImpl.ChildRef(childId, loaded));
-
- //
- if (loaded)
- {
- context.addChild(objectId, childId);
- }
- }
}
//
- return true;
+ return Status.LOADED;
}
}
finally
@@ -305,11 +337,10 @@
UIObjectImpl child = (UIObjectImpl)context.getObject(childRef.id);
//
- evict(child);
+ context.removeChild(object.structuralObject.getId(), child.structuralObject.getId());
//
- context.removeChild(object.structuralObject.getId(), child.structuralObject.getId());
- context.removeObject(child.structuralObject.getId());
+ evict(child);
}
}
@@ -318,7 +349,7 @@
}
//
- // context.removeObject(object.structuralObject.getId());
+ context.removeObject(object.structuralObject.getId());
}
private boolean load(StructuralObject structuralObject)
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java 2008-03-26 23:41:59 UTC (rev 10384)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java 2008-03-27 00:21:45 UTC (rev 10385)
@@ -45,12 +45,12 @@
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());
+ 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)
18 years, 1 month
JBoss Portal SVN: r10384 - in branches/presentation/presentation: src/main/org/jboss/portal/presentation/impl/model2 and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-26 19:41:59 -0400 (Wed, 26 Mar 2008)
New Revision: 10384
Modified:
branches/presentation/presentation/build.xml
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AddChildTestCase.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/ModelTestCase.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/RemoveChildTestCase.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java
Log:
save changes
Modified: branches/presentation/presentation/build.xml
===================================================================
--- branches/presentation/presentation/build.xml 2008-03-26 22:43:38 UTC (rev 10383)
+++ branches/presentation/presentation/build.xml 2008-03-26 23:41:59 UTC (rev 10384)
@@ -311,9 +311,9 @@
-->
</x-sysproperty>
<x-test>
- <test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.MockModelTestCase"/>
- <test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.ModelTestCase"/>
- <test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.EventTestCase"/>
+ <!--<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.MockModelTestCase"/>-->
+ <!--<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.ModelTestCase"/>-->
+ <!--<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.EventTestCase"/>-->
<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model2.ModelTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model2.AddChildTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model2.RemoveChildTestCase"/>
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java 2008-03-26 22:43:38 UTC (rev 10383)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java 2008-03-26 23:41:59 UTC (rev 10384)
@@ -42,6 +42,11 @@
class Refresh
{
+ private enum Action
+ {
+ NO_OP, WANT_REMOVE, WANT_ADD
+ }
+
/** . */
private final ViewPortContext context;
@@ -54,7 +59,6 @@
/** The objects removed during the refresh operation. */
private final Map<String, UIObjectImpl> removedObjects;
-
Refresh(ViewPortImpl viewPort)
{
this.context = viewPort.context;
@@ -312,6 +316,9 @@
//
context.destroyChildren(object.structuralObject.getId());
}
+
+ //
+ // context.removeObject(object.structuralObject.getId());
}
private boolean load(StructuralObject structuralObject)
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AddChildTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AddChildTestCase.java 2008-03-26 22:43:38 UTC (rev 10383)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AddChildTestCase.java 2008-03-26 23:41:59 UTC (rev 10384)
@@ -56,6 +56,7 @@
//
viewPort.refresh();
rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
//
mockModel.getRoot().getChild("foo").addChild("juu", MockObject.Type.PORTAL);
@@ -65,5 +66,6 @@
//
viewPort.refresh();
rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
}
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/ModelTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/ModelTestCase.java 2008-03-26 22:43:38 UTC (rev 10383)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/ModelTestCase.java 2008-03-26 23:41:59 UTC (rev 10384)
@@ -63,10 +63,12 @@
//
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]);
@@ -77,5 +79,6 @@
//
viewPort.refresh();
rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
}
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/RemoveChildTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/RemoveChildTestCase.java 2008-03-26 22:43:38 UTC (rev 10383)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/RemoveChildTestCase.java 2008-03-26 23:41:59 UTC (rev 10384)
@@ -64,5 +64,6 @@
//
viewPort.refresh();
rootDef.assertEquals(context.getNode(model.getRootId()));
+ context.assertConsistency(model.getRootId());
}
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java 2008-03-26 22:43:38 UTC (rev 10383)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java 2008-03-26 23:41:59 UTC (rev 10384)
@@ -27,7 +27,12 @@
import java.util.Map;
import java.util.HashMap;
+import java.util.Set;
+import java.util.ArrayList;
+import java.util.HashSet;
+import junit.framework.Assert;
+
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
* @version $Revision: 630 $
@@ -38,6 +43,28 @@
/** . */
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);
18 years, 1 month
JBoss Portal SVN: r10383 - in modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit: reports and 1 other directory.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-03-26 18:43:38 -0400 (Wed, 26 Mar 2008)
New Revision: 10383
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/ResultProducingListener.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/TestCaseAnnotationProcessor.java
Log:
- Improve reports formatting
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-03-26 22:30:17 UTC (rev 10382)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-03-26 22:43:38 UTC (rev 10383)
@@ -1900,8 +1900,8 @@
" parameter must be the last entry in the parameter value array."),
EXT_PORTLET_RESPONSES_1(new EXT("PortletResponse"), "Test that character encoding is ignored as specified by the spec in PLT.12.3.1"),
- EXT_PORTLET_RESPONSES_2(new EXT("PortletResponse"), "Not setting the content type before getting a stream will use the content type defined\n" +
- " * by the portlet request response content type."),
+ EXT_PORTLET_RESPONSES_2(new EXT("PortletResponse"), "Not setting the content type before getting a stream will use the content type defined" +
+ " by the portlet request response content type."),
EXT_PORTLET_RESPONSES_3(new EXT("PortletResponse"), "Test adding coockies to response"),
EXT_PORTLET_RESPONSES_4(new EXT("PortletResponse"), "Test adding HTTP headers"),
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/ResultProducingListener.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/ResultProducingListener.java 2008-03-26 22:30:17 UTC (rev 10382)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/ResultProducingListener.java 2008-03-26 22:43:38 UTC (rev 10383)
@@ -43,14 +43,12 @@
{
public static String jsr168File = "./target/apt-jsr168-testcases.csv";
- public static int jsr168Max = 179;
-
public static String jsr286File = "./target/apt-jsr286-testcases.csv";
- public static int jsr286Max = 350;
-
public static String api286File = "./target/apt-api286-testcases.csv";
+ public static String extFile = "./target/apt-ext-testcases.csv";
+
public void roundComplete(RoundCompleteEvent event)
{
if (event.getRoundState().finalRound())
@@ -66,18 +64,23 @@
if (!TestCaseAnnotationProcessor.jsr168Assertions.keySet().isEmpty())
{
- printTCKReport(TestCaseAnnotationProcessor.jsr168Assertions, jsr168File, "JSR168_", jsr168Max);
+ printReport(TestCaseAnnotationProcessor.jsr168Assertions, jsr168File, "JSR168_");
}
if (!TestCaseAnnotationProcessor.jsr286Assertions.keySet().isEmpty())
{
- printTCKReport(TestCaseAnnotationProcessor.jsr286Assertions, jsr286File, "JSR286_", jsr286Max);
+ printReport(TestCaseAnnotationProcessor.jsr286Assertions, jsr286File, "JSR286_");
}
if (!TestCaseAnnotationProcessor.api286Assertions.keySet().isEmpty())
{
- printAPIReport(TestCaseAnnotationProcessor.api286Assertions, api286File);
+ printReport(TestCaseAnnotationProcessor.api286Assertions, api286File, TestCaseAnnotationProcessor.api286AssertionPre);
}
+
+ if (!TestCaseAnnotationProcessor.extAssertions.keySet().isEmpty())
+ {
+ printReport(TestCaseAnnotationProcessor.extAssertions, extFile, TestCaseAnnotationProcessor.extAssertionPre);
+ }
}
catch (Exception e)
{
@@ -111,9 +114,7 @@
}
}
-
-
- private void printTCKReport(Map<String, Set<String>> map, String fileName, String pre, int max) throws Exception
+ private void printReport(Map<String, Set<String>> map, String fileName, String assertionPre) throws Exception
{
// Simple stats
@@ -124,162 +125,123 @@
int inactive = 0;
File f = new File(fileName);
-
+
Writer writer = new FileWriter(f, false);
StringBuilder output = new StringBuilder();
- for (int i = 1; i <= max; i++)
+
+ // Line 1
+ // Columns
+
+ output
+ .append("ASSERTION:,")
+ .append("REF:,")
+ .append("STATUS:,")
+ .append("TEST_CASES:,")
+ .append("DESCRIPTION:,");
+
+ output.append("\n");
+
+ List<Assertion> apiAssertions = getAssertions(assertionPre);
+
+ for (Assertion assertion : apiAssertions)
{
total++;
- String assertionName = pre + i;
+ String assertionName = assertion.name();
- Set<String> testCases = map.get(assertionName);
+ Set<String> tcs = map.get(assertionName);
+ String[] testCases = null;
+ if (tcs != null)
+ {
+ testCases = tcs.toArray(new String[tcs.size()]);
+ }
- // Grab Assertion object based on name
+ String description = assertion.getDescription().replaceAll(",", " ").trim();
- Assertion assertion = getAssertion(assertionName);
+ // Line 2
- String description = assertion != null ? assertion.getDescription().replaceAll(",", " ").trim() : "";
+ // ASSERTION:
+ output.append(assertionName).append(",");
+ // REF:
- if (assertion != null && assertion.getRef() != null)
+ if (assertion.getRef() != null)
{
- output.append(assertionName).append(",").append(assertion.getRef().toString()).append('\n');
- output.append("DESCRIPTION: ,").append(description).append('\n');
+ output.append(assertion.getRef().toString()).append(",");
}
else
{
- output.append(assertionName).append(",").append(description).append('\n');
+ output.append(",");
}
+ // STATUS:
- if (assertion != null && assertion.getStatus() != null)
+ if (assertion.getStatus() != null)
{
Assertion.Status status = assertion.getStatus();
- output.append("STATUS:,").append(status).append("\n");
+ output.append(status).append(",");
if (status instanceof Assertion.Inactive || status instanceof Assertion.Duplicate)
{
inactive++;
}
}
-
-
- if (testCases != null)
- {
- tested++;
- for (String testCase : testCases)
- {
- output.append("TEST_CASE: ,").append(testCase).append("\n");
- }
- }
else
{
- not_tested++;
- output.append("TEST_CASE:,NOT_TESTED\n");
+ output.append(",");
}
- output.append(" ,\n");
- }
+ // TEST_CASES:
- output.append("\n\n");
+ if (testCases != null && testCases.length > 0)
+ {
+ tested++;
- writer.write("STATISTICS:,**************************\n");
- writer.write("TOTAL:," + total + "\n");
- writer.write("TESTED:," + tested + "\n");
- writer.write("NOT TESTED:," + not_tested + "\n");
- writer.write("INACTIVE:," + inactive + " (POSTPONED; TODO; DISABLED; UNTESTABLE or DUPLICATE) \n");
- float ratio = (float)tested/(float)(total-inactive);
- writer.write("TESTED RATIO:," + ratio + " ( TESTED/(TOTAL-INACTIVE) ) \n");
+ output.append(shortenClassname(testCases[0])).append(",");
- writer.write("\n\n\n\n");
- writer.write(output.toString());
- writer.write("\n");
-
- writer.close();
- }
-
- private void printAPIReport(Map<String, Set<String>> map, String fileName) throws Exception
- {
-
- // Simple stats
-
- int total = 0;
- int tested = 0;
- int not_tested = 0;
- int inactive = 0;
-
- File f = new File(fileName);
-
- Writer writer = new FileWriter(f, false);
-
- StringBuilder output = new StringBuilder();
-
- List<Assertion> apiAssertions = getApiAssertions();
-
- for (Assertion assertion : apiAssertions)
- {
- total++;
-
- String assertionName = assertion.name();
-
- Set<String> testCases = map.get(assertionName);
-
- String description = assertion.getDescription().replaceAll(",", " ").trim();
-
- if (assertion.getRef() != null)
- {
- output.append(assertionName).append(",").append(assertion.getRef().toString()).append('\n');
- output.append("DESCRIPTION: ,").append(description).append('\n');
}
else
{
- output.append(assertionName).append(",").append(description).append('\n');
+ not_tested++;
+ output.append("NOT_TESTED,");
}
+ // DESCRIPTION:
- if (assertion.getStatus() != null)
- {
- Assertion.Status status = assertion.getStatus();
- output.append("STATUS:,").append(status).append("\n");
+ output.append(description).append('\n');
- if (status instanceof Assertion.Inactive || status instanceof Assertion.Duplicate)
- {
- inactive++;
- }
- }
+ // Rest of testcases
- if (testCases != null)
+ if (testCases != null && testCases.length > 1)
{
- tested++;
- for (String testCase : testCases)
+ for (int i = 1; i < testCases.length; i++)
{
- output.append("TEST_CASE: ,").append(testCase).append("\n");
+ String testCase = testCases[i];
+ output.append(",,,").append(shortenClassname(testCase)).append("\n");
}
}
- else
- {
- not_tested++;
- output.append("TEST_CASE:,NOT_TESTED\n");
- }
- output.append(" ,\n");
+ output.append("\n");
}
output.append("\n\n");
- writer.write("STATISTICS:,**************************\n");
+ writer.write("STATISTICS:,***\n");
writer.write("TOTAL:," + total + "\n");
writer.write("TESTED:," + tested + "\n");
writer.write("NOT TESTED:," + not_tested + "\n");
- writer.write("INACTIVE:," + inactive + " (POSTPONED; TODO; DISABLED; UNTESTABLE or DUPLICATE) \n");
+
+ // (POSTPONED; TODO; DISABLED; UNTESTABLE or DUPLICATE)
+ writer.write("INACTIVE:," + inactive + "\n");
float ratio = (float)tested/(float)(total-inactive);
- writer.write("TESTED RATIO:," + ratio + " ( TESTED/(TOTAL-INACTIVE) ) \n");
+ // ( TESTED/(TOTAL-INACTIVE) )
+ writer.write("TESTED RATIO:," + ratio + "\n");
+
writer.write("\n\n\n\n");
writer.write(output.toString());
writer.write("\n");
@@ -287,7 +249,9 @@
writer.close();
}
- private List<Assertion> getApiAssertions()
+
+
+ private List<Assertion> getAssertions(String assertionPre)
{
List<Assertion> result = new LinkedList<Assertion>();
@@ -296,7 +260,7 @@
for (Assertion assertion : assertions)
{
- if (assertion.name().startsWith(TestCaseAnnotationProcessor.api286AssertionPre))
+ if (assertion.name().startsWith(assertionPre))
{
result.add(assertion);
}
@@ -329,4 +293,33 @@
return null;
}
+
+ private String shortenClassname(String className)
+ {
+ if (className == null)
+ {
+ throw new IllegalArgumentException("null argument");
+ }
+
+ String[] parts = className.split("\\.");
+
+ StringBuffer packed = new StringBuffer();
+
+ for (int i = 0; i < parts.length; i++)
+ {
+ String part = parts[i];
+
+ if (i != parts.length - 1)
+ {
+ packed.append(part.substring(0,1)).append(".");
+ }
+ else
+ {
+ packed.append(part);
+ }
+ }
+
+
+ return packed.toString();
+ }
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/TestCaseAnnotationProcessor.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/TestCaseAnnotationProcessor.java 2008-03-26 22:30:17 UTC (rev 10382)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/TestCaseAnnotationProcessor.java 2008-03-26 22:43:38 UTC (rev 10383)
@@ -73,12 +73,16 @@
public static String api286AssertionPre = "API286_";
+ public static String extAssertionPre = "EXT_";
+
public static Map<String, Set<String>> jsr168Assertions = new HashMap<String, Set<String>>();
public static Map<String, Set<String>> jsr286Assertions = new HashMap<String, Set<String>>();
public static Map<String, Set<String>> api286Assertions = new HashMap<String, Set<String>>();
+ public static Map<String, Set<String>> extAssertions = new HashMap<String, Set<String>>();
+
//private int counter;
public TestCaseAnnotationProcessor(AnnotationProcessorEnvironment env) {
@@ -145,6 +149,10 @@
{
am = api286Assertions;
}
+ else if (tck.startsWith(extAssertionPre))
+ {
+ am = extAssertions;
+ }
else
{
continue;
18 years, 1 month
JBoss Portal SVN: r10382 - in branches/presentation/presentation: src/main/org/jboss/portal/presentation/impl/model2 and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-26 18:30:17 -0400 (Wed, 26 Mar 2008)
New Revision: 10382
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/RemoveChildTestCase.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/TraversalModelTestCase.java
Modified:
branches/presentation/presentation/build.xml
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AddChildTestCase.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/ModelTestCase.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/NodeDef.java
Log:
test case for node removal
Modified: branches/presentation/presentation/build.xml
===================================================================
--- branches/presentation/presentation/build.xml 2008-03-26 21:30:57 UTC (rev 10381)
+++ branches/presentation/presentation/build.xml 2008-03-26 22:30:17 UTC (rev 10382)
@@ -316,6 +316,7 @@
<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.EventTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model2.ModelTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model2.AddChildTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.presentation.test.model2.RemoveChildTestCase"/>
</x-test>
<x-classpath>
<path refid="jboss.portal/modules/common.classpath"/>
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java 2008-03-26 21:30:57 UTC (rev 10381)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java 2008-03-26 22:30:17 UTC (rev 10382)
@@ -179,13 +179,22 @@
UIObjectImpl.ChildRef childRef = object.childrenRefs.get(childId);
//
- childRef.loaded = loaded;
-
- //
- if (!loaded)
+ if (loaded)
{
- throw new UnsupportedOperationException("todo");
+ if (!childRef.loaded)
+ {
+ childRef.loaded = true;
+ context.addChild(objectId, childId);
+ }
}
+ else
+ {
+ if (childRef.loaded)
+ {
+ childRef.loaded = false;
+ context.removeChild(objectId, childId);
+ }
+ }
}
else
{
@@ -222,7 +231,13 @@
//
for (String childId : refresh.getRemovedChildren())
{
- throw new UnsupportedOperationException("todo");
+ if (hadChildren)
+ {
+ object.childrenRefs.remove(childId);
+ context.removeChild(objectId, childId);
+ UIObjectImpl removedChild = (UIObjectImpl)context.getObject(childId);
+ evict(removedChild);
+ }
}
//
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AddChildTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AddChildTestCase.java 2008-03-26 21:30:57 UTC (rev 10381)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AddChildTestCase.java 2008-03-26 22:30:17 UTC (rev 10382)
@@ -31,73 +31,39 @@
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class AddChildTestCase extends AbstractModelTestCase
+public class AddChildTestCase extends TraversalModelTestCase
{
- private class Test
+ public void testAddChild()
{
+ test(1);
+ }
- /** . */
- private ObjectTraversalType traversal1;
+ protected void test(ObjectTraversalType[] before, ObjectTraversalType[] after)
+ {
+ NodeDef rootDef = NodeDef.create();
+ NodeDef fooDef = rootDef.addChild("foo");
+ fooDef.setTraversal(before[0]);
- /** . */
- private ObjectTraversalType traversal2;
+ //
+ rootDef.populate(mockModel);
- private Test(
- ObjectTraversalType traversal1,
- ObjectTraversalType traversal2)
- {
- this.traversal1 = traversal1;
- this.traversal2 = traversal2;
- }
+ //
+ ViewPortScope scope = new CustomScope(model, rootDef);
+ UIObjectTree context = new UIObjectTree();
+ ViewPort viewPort = model.createViewPort(context, scope);
- public void test()
- {
- NodeDef rootDef = NodeDef.create();
- NodeDef fooDef = rootDef.addChild("foo");
- fooDef.setTraversal(traversal1);
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
- //
- rootDef.populate(mockModel);
+ //
+ mockModel.getRoot().getChild("foo").addChild("juu", MockObject.Type.PORTAL);
+ fooDef.addChild("juu");
+ fooDef.setTraversal(after[0]);
- //
- ViewPortScope scope = new CustomScope(model, rootDef);
- UIObjectTree context = new UIObjectTree();
- ViewPort viewPort = model.createViewPort(context, scope);
-
- //
- viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
-
- //
- mockModel.getRoot().getChild("foo").addChild("juu", MockObject.Type.PORTAL);
- fooDef.addChild("juu");
- fooDef.setTraversal(traversal2);
-
- //
- viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
- }
-
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
}
-
- public void test1()
- {
- new Test(ObjectTraversalType.RECURSIVE, ObjectTraversalType.RECURSIVE).test();
- }
-
- public void test2()
- {
- new Test(ObjectTraversalType.RECURSIVE, ObjectTraversalType.SINGLE).test();
- }
-
- public void test3()
- {
- new Test(ObjectTraversalType.SINGLE, ObjectTraversalType.RECURSIVE).test();
- }
-
- public void test4()
- {
- new Test(ObjectTraversalType.SINGLE, ObjectTraversalType.SINGLE).test();
- }
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/ModelTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/ModelTestCase.java 2008-03-26 21:30:57 UTC (rev 10381)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/ModelTestCase.java 2008-03-26 22:30:17 UTC (rev 10382)
@@ -26,149 +26,56 @@
import org.jboss.portal.presentation.model2.ViewPort;
import org.jboss.portal.presentation.model2.ObjectTraversalType;
-import java.util.Collection;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-
-import junit.framework.TestCase;
-import junit.framework.Assert;
-
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class ModelTestCase extends TestCase
+public class ModelTestCase extends TraversalModelTestCase
{
- private class Test extends AbstractModelTestCase
+ public void testRefresh1() throws Exception
{
+ test(4);
+ }
- /** . */
- private ObjectTraversalType[] traversal1;
+ protected void test(ObjectTraversalType[] before, ObjectTraversalType[] after)
+ {
+ NodeDef rootDef = NodeDef.create();
+ NodeDef fooDef = rootDef.addChild("foo");
+ NodeDef barDef = rootDef.addChild("bar");
+ NodeDef juuDef = fooDef.addChild("juu");
+ NodeDef daaDef = fooDef.addChild("daa");
- /** . */
- private ObjectTraversalType[] traversal2;
+ //
+ fooDef.setTraversal(before[0]);
+ barDef.setTraversal(before[1]);
+ juuDef.setTraversal(before[2]);
+ daaDef.setTraversal(before[3]);
- private Test(ObjectTraversalType[] traversal1, ObjectTraversalType[] traversal2)
- {
- this.traversal1 = traversal1;
- this.traversal2 = traversal2;
- }
+ //
+ rootDef.populate(mockModel);
- public void test()
- {
- NodeDef rootDef = NodeDef.create();
- NodeDef fooDef = rootDef.addChild("foo");
- NodeDef barDef = rootDef.addChild("bar");
- NodeDef juuDef = fooDef.addChild("juu");
- NodeDef daaDef = fooDef.addChild("daa");
+ //
+ ViewPortScope scope = new CustomScope(model, rootDef);
+ UIObjectTree context = new UIObjectTree();
+ ViewPort viewPort = model.createViewPort(context, scope);
- //
- fooDef.setTraversal(traversal1[0]);
- barDef.setTraversal(traversal1[1]);
- juuDef.setTraversal(traversal1[2]);
- daaDef.setTraversal(traversal1[3]);
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
- //
- rootDef.populate(mockModel);
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
- //
- ViewPortScope scope = new CustomScope(model, rootDef);
- UIObjectTree context = new UIObjectTree();
- ViewPort viewPort = model.createViewPort(context, scope);
+ //
+ fooDef.setTraversal(after[0]);
+ barDef.setTraversal(after[1]);
+ juuDef.setTraversal(after[2]);
+ daaDef.setTraversal(after[3]);
- //
- viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
-
- //
- viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
-
- //
- fooDef.setTraversal(traversal2[0]);
- barDef.setTraversal(traversal2[1]);
- juuDef.setTraversal(traversal2[2]);
- daaDef.setTraversal(traversal2[3]);
-
- //
- viewPort.refresh();
- rootDef.assertEquals(context.getNode(model.getRootId()));
- }
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
}
-
- public void testRefresh1() throws Exception
- {
- ObjectTraversalType[] traversal1 = new ObjectTraversalType[4];
- ObjectTraversalType[] traversal2 = new ObjectTraversalType[4];
- Collection<ObjectTraversalType[]> enumeration = generate(traversal1.length + traversal2.length);
-/*
- Collection<ObjectTraversalType[]> enumeration = Collections.singletonList(
- new ObjectTraversalType[]{
- ObjectTraversalType.SKIP,
- ObjectTraversalType.SKIP,
- ObjectTraversalType.SKIP,
- ObjectTraversalType.SKIP,
- ObjectTraversalType.SKIP,
- ObjectTraversalType.SINGLE,
- ObjectTraversalType.SKIP,
- ObjectTraversalType.SKIP,
- }
- );
-*/
- for (ObjectTraversalType[] element : enumeration)
- {
- Assert.assertEquals(traversal1.length + traversal2.length, element.length);
- System.arraycopy(element, 0, traversal1, 0, traversal1.length);
- System.arraycopy(element, traversal1.length, traversal2, 0, traversal2.length);
- Test test = new Test(traversal1, traversal2);
- test.setUp();
- boolean failed = true;
- try
- {
- test.test();
- failed = false;
- }
- finally
- {
- if (failed)
- {
- System.out.println("Arrays.asList(traversal1) = " + Arrays.asList(traversal1));
- System.out.println("Arrays.asList(traversal2) = " + Arrays.asList(traversal2));
- }
- }
- }
-
- }
-
- private 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;
- }
- }
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/NodeDef.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/NodeDef.java 2008-03-26 21:30:57 UTC (rev 10381)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/NodeDef.java 2008-03-26 22:30:17 UTC (rev 10382)
@@ -108,6 +108,20 @@
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());
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/RemoveChildTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/RemoveChildTestCase.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/RemoveChildTestCase.java 2008-03-26 22:30:17 UTC (rev 10382)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * 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.model2;
+
+import org.jboss.portal.presentation.model2.ViewPortScope;
+import org.jboss.portal.presentation.model2.ViewPort;
+import org.jboss.portal.presentation.model2.ObjectTraversalType;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class RemoveChildTestCase extends TraversalModelTestCase
+{
+
+ public void testRemoveChild()
+ {
+ test(1);
+ }
+
+ protected void test(ObjectTraversalType[] before, ObjectTraversalType[] after)
+ {
+ NodeDef rootDef = NodeDef.create();
+ NodeDef fooDef = rootDef.addChild("foo");
+ NodeDef barDef = fooDef.addChild("bar");
+ NodeDef juuDef = fooDef.addChild("juu");
+
+ //
+ rootDef.populate(mockModel);
+
+ //
+ ViewPortScope scope = new CustomScope(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()));
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/TraversalModelTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/TraversalModelTestCase.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/TraversalModelTestCase.java 2008-03-26 22:30:17 UTC (rev 10382)
@@ -0,0 +1,128 @@
+/******************************************************************************
+ * 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.model2;
+
+import org.jboss.portal.presentation.model2.ObjectTraversalType;
+import org.jboss.portal.presentation.model2.UIModel;
+import org.jboss.portal.presentation.test.model.state.structural.MockModel;
+import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
+import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.impl.model2.UIModelImpl;
+import org.jboss.portal.presentation.impl.model.state.navigational.NavigationalStateContextImpl;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * @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;
+
+ public void test(int size)
+ {
+ 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);
+
+ //
+ 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);
+ 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;
+ }
+ }
+ }
+
+ protected abstract void test(ObjectTraversalType[] before, ObjectTraversalType[] after);
+
+ 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;
+ }
+ }
+
+}
18 years, 1 month
JBoss Portal SVN: r10381 - in branches/presentation/presentation: src/main/org/jboss/portal/presentation and 8 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-03-26 17:30:57 -0400 (Wed, 26 Mar 2008)
New Revision: 10381
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/UIModelImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/UIObjectImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/ViewPortImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ObjectTraversalType.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/UIModel.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/UIObject.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ViewPort.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ViewPortContext.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ViewPortScope.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AbstractModelTestCase.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AddChildTestCase.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/CustomScope.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/FullScope.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/ModelTestCase.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/NodeDef.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectNode.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java
Modified:
branches/presentation/presentation/build.xml
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralObject.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/ajax/JBossUnitSandBox.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/state/structural/MockException.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/state/structural/MockObject.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/state/structural/MockObjectImpl.java
Log:
initial commit for the model refactor based on the viewport concept
Modified: branches/presentation/presentation/build.xml
===================================================================
--- branches/presentation/presentation/build.xml 2008-03-26 21:25:30 UTC (rev 10380)
+++ branches/presentation/presentation/build.xml 2008-03-26 21:30:57 UTC (rev 10381)
@@ -305,15 +305,17 @@
<execute-tests>
<x-sysproperty>
<sysproperty key="test.root" value="${build.lib}"/>
- <!--
+<!--
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=7878,server=y,suspend=y"/>
- -->
+-->
</x-sysproperty>
<x-test>
<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.MockModelTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.ModelTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.presentation.test.model.EventTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.presentation.test.model2.ModelTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.presentation.test.model2.AddChildTestCase"/>
</x-test>
<x-classpath>
<path refid="jboss.portal/modules/common.classpath"/>
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/Refresh.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,358 @@
+/******************************************************************************
+ * 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.impl.model2;
+
+import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.model.state.structural.StructuralObject;
+import org.jboss.portal.presentation.model2.ViewPortContext;
+import org.jboss.portal.presentation.model2.ViewPortScope;
+import org.jboss.portal.presentation.model2.ObjectTraversalType;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collection;
+import java.util.ArrayList;
+
+/**
+ * A refresh operation.
+ *
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+class Refresh
+{
+
+ /** . */
+ private final ViewPortContext context;
+
+ /** . */
+ private final ViewPortScope scope;
+
+ /** . */
+ private final StructuralStateContext structuralStateContext;
+
+ /** The objects removed during the refresh operation. */
+ private final Map<String, UIObjectImpl> removedObjects;
+
+
+ Refresh(ViewPortImpl viewPort)
+ {
+ this.context = viewPort.context;
+ this.scope = viewPort.scope;
+ this.structuralStateContext = viewPort.model.structuralStateContext;
+ this.removedObjects = new HashMap<String, UIObjectImpl>();
+ }
+
+ void perform()
+ {
+ String rootId = scope.getRootId();
+
+ //
+ refresh(rootId);
+ }
+
+ private boolean refresh(String objectId)
+ {
+ UIObjectImpl object = (UIObjectImpl)context.getObject(objectId);
+
+ //
+ if (object != null)
+ {
+ return refresh(object);
+ }
+ else
+ {
+ StructuralObject structuralObject = structuralStateContext.load(objectId);
+
+ // It is not present, load it
+ return load(structuralObject);
+ }
+ }
+
+ private boolean refresh(StructuralObject structuralObject)
+ {
+
+ UIObjectImpl object = (UIObjectImpl)context.getObject(structuralObject.getId());
+
+ if (object == null)
+ {
+ return load(structuralObject);
+ }
+ else
+ {
+ // Update state
+
+ //
+ return refresh(object);
+ }
+ }
+
+ private boolean refresh(UIObjectImpl object)
+ {
+ ObjectTraversalType traversalType = scope.enterObject(object);
+
+ //
+ try
+ {
+ if (traversalType == ObjectTraversalType.SKIP)
+ {
+ evict(object);
+
+ //
+ return false;
+ }
+ else if (traversalType == ObjectTraversalType.SINGLE)
+ {
+ if (object.childrenRefs != null)
+ {
+ // Need to evict children if any
+ for (UIObjectImpl.ChildRef childRef : object.childrenRefs.values())
+ {
+ if (childRef.loaded)
+ {
+ UIObjectImpl childObject = (UIObjectImpl)context.getObject(childRef.id);
+
+ //
+ context.removeChild(object.getId(), childObject.getId());
+
+ //
+ evict(childObject);
+ }
+ }
+
+ //
+ context.destroyChildren(object.getId());
+ }
+
+ //
+ return true;
+ }
+ else
+ {
+ boolean hadChildren = object.childrenRefs != null;
+ String objectId = object.structuralObject.getId();
+
+ //
+ if (!hadChildren)
+ {
+ object.childrenRefs = new HashMap<String, UIObjectImpl.ChildRef>();
+ context.initChildren(objectId);
+ }
+
+ //
+ StructuralObject.Refresh refresh = structuralStateContext.refresh(object.structuralObject);
+
+ //
+ for (Map.Entry<String, StructuralObject> childEntry : refresh.getStaleChildren().entrySet())
+ {
+ StructuralObject structuralChild = childEntry.getValue();
+ String childId = structuralChild.getId();
+
+ // Is it the same object with a new state or is it a new child with the same name ?
+ if (childEntry.getKey().equals(childId))
+ {
+ boolean loaded = refresh(childEntry.getValue());
+
+ //
+ if (hadChildren)
+ {
+ UIObjectImpl.ChildRef childRef = object.childrenRefs.get(childId);
+
+ //
+ childRef.loaded = loaded;
+
+ //
+ if (!loaded)
+ {
+ throw new UnsupportedOperationException("todo");
+ }
+ }
+ else
+ {
+ object.childrenRefs.put(childId, new UIObjectImpl.ChildRef(childId, loaded));
+
+ //
+ if (loaded)
+ {
+ context.addChild(objectId, structuralChild.getId());
+ }
+ }
+ }
+ else
+ {
+ throw new UnsupportedOperationException("todo");
+ }
+ }
+
+ //
+ for (StructuralObject structuralChild : refresh.getAddedChildren())
+ {
+ boolean loaded = load(structuralChild);
+
+ //
+ object.childrenRefs.put(structuralChild.getId(), new UIObjectImpl.ChildRef(structuralChild.getId(), loaded));
+
+ //
+ if (loaded)
+ {
+ context.addChild(objectId, structuralChild.getId());
+ }
+ }
+
+ //
+ for (String childId : refresh.getRemovedChildren())
+ {
+ throw new UnsupportedOperationException("todo");
+ }
+
+ //
+ for (String childId : refresh.getValidChildren())
+ {
+ boolean loaded = refresh(childId);
+
+ //
+ if (hadChildren)
+ {
+ UIObjectImpl.ChildRef childRef = object.childrenRefs.get(childId);
+
+ //
+ if (childRef.loaded)
+ {
+ if (!loaded)
+ {
+ childRef.loaded = false;
+ context.removeChild(objectId, childId);
+ }
+ }
+ else
+ {
+ if (loaded)
+ {
+ childRef.loaded = true;
+ context.addChild(objectId, childId);
+ }
+ }
+ }
+ else
+ {
+ object.childrenRefs.put(childId, new UIObjectImpl.ChildRef(childId, loaded));
+
+ //
+ if (loaded)
+ {
+ context.addChild(objectId, childId);
+ }
+ }
+ }
+
+ //
+ return true;
+ }
+ }
+ finally
+ {
+ scope.leaveObject(object);
+ }
+ }
+
+ private void evict(UIObjectImpl object)
+ {
+ if (object.childrenRefs != null)
+ {
+ for (UIObjectImpl.ChildRef childRef : new ArrayList<UIObjectImpl.ChildRef>(object.childrenRefs.values()))
+ {
+ if (childRef.loaded)
+ {
+ UIObjectImpl child = (UIObjectImpl)context.getObject(childRef.id);
+
+ //
+ evict(child);
+
+ //
+ context.removeChild(object.structuralObject.getId(), child.structuralObject.getId());
+ context.removeObject(child.structuralObject.getId());
+ }
+ }
+
+ //
+ context.destroyChildren(object.structuralObject.getId());
+ }
+ }
+
+ private boolean load(StructuralObject structuralObject)
+ {
+ UIObjectImpl object = new UIObjectImpl(structuralObject);
+
+ //
+ ObjectTraversalType tmp = scope.enterObject(object);
+
+ //
+ try
+ {
+ if (tmp == ObjectTraversalType.SKIP)
+ {
+ return false;
+ }
+
+ //
+ context.addObject(object);
+
+ //
+ if (tmp == ObjectTraversalType.RECURSIVE)
+ {
+ Collection<StructuralObject> structuralChildren = structuralStateContext.loadChildren(object.structuralObject);
+
+ //
+ Map<String, UIObjectImpl.ChildRef> childrenRefs = new HashMap<String, UIObjectImpl.ChildRef>(structuralChildren.size());
+
+ //
+ context.initChildren(structuralObject.getId());
+
+ //
+ for (StructuralObject structuralChild : structuralChildren)
+ {
+ boolean loaded = load(structuralChild);
+
+ //
+ childrenRefs.put(structuralChild.getId(), new UIObjectImpl.ChildRef(structuralChild.getId(), loaded));
+
+ //
+ if (loaded)
+ {
+ context.addChild(structuralObject.getId(), structuralChild.getId());
+ }
+ }
+
+ // Update
+ object.childrenRefs = childrenRefs;
+ }
+
+ //
+ return true;
+ }
+ finally
+ {
+ scope.leaveObject(object);
+ }
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/UIModelImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/UIModelImpl.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/UIModelImpl.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * 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.impl.model2;
+
+import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.model.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.model2.UIModel;
+import org.jboss.portal.presentation.model2.ViewPortContext;
+import org.jboss.portal.presentation.model2.ViewPortScope;
+import org.jboss.portal.presentation.model2.ViewPort;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class UIModelImpl implements UIModel
+{
+
+ /** . */
+ final NavigationalStateContext navigationalStateContext;
+
+ /** . */
+ final StructuralStateContext structuralStateContext;
+
+ public UIModelImpl(NavigationalStateContext navigationalStateContext, StructuralStateContext structuralStateContext)
+ {
+ this.navigationalStateContext = navigationalStateContext;
+ this.structuralStateContext = structuralStateContext;
+ }
+
+ public NavigationalStateContext getNavigationalStateContext()
+ {
+ return navigationalStateContext;
+ }
+
+ public StructuralStateContext getStructuralStateContext()
+ {
+ return structuralStateContext;
+ }
+
+ public String getRootId()
+ {
+ return structuralStateContext.getRootId();
+ }
+
+ public ViewPort createViewPort(ViewPortContext context, ViewPortScope scope)
+ {
+ return new ViewPortImpl(this, context, scope);
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/UIObjectImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/UIObjectImpl.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/UIObjectImpl.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,124 @@
+/******************************************************************************
+ * 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.impl.model2;
+
+import org.jboss.portal.presentation.model2.UIObject;
+import org.jboss.portal.presentation.model.state.StateException;
+import org.jboss.portal.presentation.model.state.structural.StructuralObject;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class UIObjectImpl implements UIObject
+{
+
+ /** . */
+ final StructuralObject structuralObject;
+
+ /** We keep track of what was loaded by the scope. */
+ Map<String, ChildRef> childrenRefs;
+
+ public UIObjectImpl(StructuralObject structuralObject)
+ {
+ this.structuralObject = structuralObject;
+ }
+
+ public String getId()
+ {
+ return structuralObject.getId();
+ }
+
+ public String getName()
+ {
+ return structuralObject.getState().getName();
+ }
+
+ public <T> T getProperty(String propertyName, Class<T> propertyType) throws IllegalArgumentException, StateException
+ {
+ return safeCast(getProperty(propertyName), propertyType);
+ }
+
+ public Object getProperty(String propertyName) throws IllegalArgumentException, StateException
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return structuralObject.getState().getProperties().get(propertyName);
+ }
+
+ /**
+ * Attempt to cast the value argument to the provided type argument. If the value argument type is assignable
+ * to the provided type, the value is returned, otherwise if it is not or the value is null, null is returned.
+ *
+ * @param value the value to cast
+ * @param type the type to downcast
+ * @return the casted value or null
+ */
+ private <T> T safeCast(Object value, Class<T> type)
+ {
+ if (type == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (value == null)
+ {
+ return null;
+ }
+ else
+ {
+ if (type.isAssignableFrom(value.getClass()))
+ {
+ return type.cast(value);
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * A reference to a child.
+ */
+ static class ChildRef
+ {
+
+ /** The child id. */
+ final String id;
+
+ /** Whether or not the child is loaded. */
+ boolean loaded;
+
+ ChildRef(String id, boolean loaded)
+ {
+ this.id = id;
+ this.loaded = loaded;
+ }
+ }
+
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/ViewPortImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/ViewPortImpl.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model2/ViewPortImpl.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * 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.impl.model2;
+
+import org.jboss.portal.presentation.model2.ViewPort;
+import org.jboss.portal.presentation.model2.ViewPortContext;
+import org.jboss.portal.presentation.model2.ViewPortScope;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ViewPortImpl implements ViewPort
+{
+
+ /** . */
+ final UIModelImpl model;
+
+ /** . */
+ final ViewPortContext context;
+
+ /** . */
+ final ViewPortScope scope;
+
+ public ViewPortImpl(UIModelImpl model, ViewPortContext context, ViewPortScope scope)
+ {
+ this.model = model;
+ this.context = context;
+ this.scope = scope;
+ }
+
+ public void refresh()
+ {
+ new Refresh(this).perform();
+ }
+
+ public ViewPortContext getContext()
+ {
+ return context;
+ }
+
+ public ViewPortScope getScope()
+ {
+ return scope;
+ }
+}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralObject.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralObject.java 2008-03-26 21:25:30 UTC (rev 10380)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralObject.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -51,19 +51,16 @@
/** . */
private final StructuralObject object;
- /** . */
+ /** The children that were added. */
private final Set<StructuralObject> addedChildren;
- /** . */
+ /** The children that were removed. */
private final Set<String> removedChildren;
- /** . */
-// private final Set<String> destroyedChildren;
-
- /** . */
+ /** The children with a stale property state. */
private final Map<String, StructuralObject> staleChildren;
- /** . */
+ /** The children that are valid. */
private final Set<String> validChildren;
public Refresh(
@@ -72,8 +69,7 @@
Set<StructuralObject> addedChildren,
Set<String> removedChildren,
Map<String, StructuralObject> staleChildren,
- Set<String> validChildren/*,
- Set<String> destroyedChildren*/)
+ Set<String> validChildren)
{
if (addedChildren == null)
{
@@ -91,17 +87,12 @@
{
throw new IllegalArgumentException();
}
-// if (destroyedChildren == null)
-// {
-// throw new IllegalArgumentException();
-// }
this.parent = parent;
this.object = object;
this.addedChildren = addedChildren;
this.validChildren = validChildren;
this.staleChildren = staleChildren;
this.removedChildren = removedChildren;
-// this.destroyedChildren = destroyedChildren;
}
public StructuralObject getParent()
@@ -114,11 +105,6 @@
return object;
}
-// public Set<String> getDestroyedChildren()
-// {
-// return destroyedChildren;
-// }
-
public Set<StructuralObject> getAddedChildren()
{
return addedChildren;
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ObjectTraversalType.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ObjectTraversalType.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ObjectTraversalType.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * 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.model2;
+
+/**
+ * A type that describe the different ways to traverse an object.
+ *
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public enum ObjectTraversalType
+{
+
+ /**
+ * The object should not be visited.
+ */
+ SKIP,
+
+ /**
+ * The object should be visited but not its children.
+ */
+ SINGLE,
+
+ /**
+ * The object should be visited and its children.
+ */
+ RECURSIVE
+
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/UIModel.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/UIModel.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/UIModel.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * 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.model2;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface UIModel
+{
+
+ String getRootId();
+
+ ViewPort createViewPort(ViewPortContext context, ViewPortScope scope);
+
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/UIObject.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/UIObject.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/UIObject.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -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.model2;
+
+import org.jboss.portal.presentation.model.state.StateException;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface UIObject
+{
+
+ /**
+ * Returns the id.
+ *
+ * @return the id
+ */
+ String getId();
+
+ /**
+ * Returns the name.
+ *
+ * @return the name
+ */
+ String getName();
+
+ /**
+ * Returns a property value or null if it does not exist.
+ *
+ * @param propertyName the property name
+ * @param propertyType the expected property type
+ * @return the property value
+ * @throws IllegalArgumentException if any argument is null or not valid
+ * @throws org.jboss.portal.presentation.model.state.StateException any state exception
+ */
+ <T> T getProperty(String propertyName, Class<T> propertyType) throws IllegalArgumentException, StateException;
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ViewPort.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ViewPort.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ViewPort.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * 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.model2;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ViewPort
+{
+
+ /**
+ * Performs a refresh operation.
+ */
+ void refresh();
+
+ /**
+ * Returns the context associated with this viewport.
+ *
+ * @return the context
+ */
+ ViewPortContext getContext();
+
+ /**
+ * Returns the scope associated with this viewport.
+ *
+ * @return the scope
+ */
+ ViewPortScope getScope();
+
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ViewPortContext.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ViewPortContext.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ViewPortContext.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * 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.model2;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ViewPortContext
+{
+
+ UIObject getObject(String objectId);
+
+ void removeObject(String objectId);
+
+ void addObject(UIObject object);
+
+ void initChildren(String parentId);
+
+ void destroyChildren(String parentId);
+
+ void addChild(String parentId, String childId);
+
+ void removeChild(String parentId, String childId);
+
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ViewPortScope.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ViewPortScope.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model2/ViewPortScope.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * 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.model2;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ViewPortScope
+{
+ /**
+ * Returns the id of the root of the scope.
+ *
+ * @return the root id
+ */
+ String getRootId();
+
+ /**
+ * Returns how the object should be traversed.
+ *
+ * @param object the object
+ * @return true if it should be visited
+ */
+ ObjectTraversalType enterObject(UIObject object);
+
+ /**
+ * Callback to signal that an object visit is terminated
+ *
+ * @param object the object
+ */
+ void leaveObject(UIObject object);
+}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/ajax/JBossUnitSandBox.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/ajax/JBossUnitSandBox.java 2008-03-26 21:25:30 UTC (rev 10380)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/ajax/JBossUnitSandBox.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.portal.presentation.test.ajax;
-import org.jboss.unit.api.pojo.annotations.Test;
-import static org.jboss.unit.api.Assert.*;
+//import org.jboss.unit.api.pojo.annotations.Test;
+//import static org.jboss.unit.api.Assert.*;
/**
@@ -32,9 +32,9 @@
*/
public class JBossUnitSandBox
{
- @Test
+// @Test
public void test()
{
- fail("Simple JBossUnit Test in the PresentationFramework successfully executed....");
+// fail("Simple JBossUnit Test in the PresentationFramework successfully executed....");
}
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/state/structural/MockException.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/state/structural/MockException.java 2008-03-26 21:25:30 UTC (rev 10380)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/state/structural/MockException.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -26,7 +26,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class MockException extends Exception
+public class MockException extends RuntimeException
{
/** . */
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/state/structural/MockObject.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/state/structural/MockObject.java 2008-03-26 21:25:30 UTC (rev 10380)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/state/structural/MockObject.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -119,6 +119,8 @@
MockObject getParent();
List<? extends MockObject> getChildren();
+
+ MockObject getChild(String name);
boolean isValid();
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/state/structural/MockObjectImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/state/structural/MockObjectImpl.java 2008-03-26 21:25:30 UTC (rev 10380)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/state/structural/MockObjectImpl.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -118,6 +118,30 @@
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, MockObject.Type type) throws MockException
{
return addChild(name, type, EMPTY_STATE);
@@ -138,7 +162,7 @@
{
throw new IllegalArgumentException();
}
- if (children.containsKey(name))
+ if (getChild(name) != null)
{
throw new MockException(MockException.ErrorCode.CONSTRAINT_VIOLATION);
}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AbstractModelTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AbstractModelTestCase.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AbstractModelTestCase.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,107 @@
+/******************************************************************************
+ * 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.model2;
+
+import org.jboss.portal.presentation.model2.UIModel;
+import org.jboss.portal.presentation.test.model.state.structural.MockModel;
+import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
+import org.jboss.portal.presentation.test.model.state.structural.MockObject;
+import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.impl.model2.UIModelImpl;
+import org.jboss.portal.presentation.impl.model.state.navigational.NavigationalStateContextImpl;
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public 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);
+ }
+
+ protected abstract static class Population
+ {
+
+ /** . */
+ protected final MockObject root;
+
+ protected Population(MockObject root)
+ {
+ this.root = root;
+ }
+
+ protected Population(MockModel model)
+ {
+ this(model.getRoot());
+ }
+
+ protected abstract void populate();
+
+ protected abstract void check(UIObjectNode root);
+ }
+
+ protected static class Population1 extends Population
+ {
+
+ protected Population1(MockObject root)
+ {
+ super(root);
+ }
+
+ protected Population1(MockModel model)
+ {
+ super(model);
+ }
+
+ protected void populate()
+ {
+ MockObject foo = root.addChild("foo", MockObject.Type.PORTAL);
+ MockObject bar = root.addChild("bar", MockObject.Type.PORTAL);
+ foo.addChild("juu", MockObject.Type.PAGE);
+ foo.addChild("daa", MockObject.Type.PAGE);
+ }
+
+ protected void check(UIObjectNode root)
+ {
+ UIObjectNode foo = root.getChildren().get("foo");
+ UIObjectNode bar = root.getChildren().get("bar");
+ assertNotNull(foo);
+ assertNotNull(bar);
+ }
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AddChildTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AddChildTestCase.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/AddChildTestCase.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,103 @@
+/******************************************************************************
+ * 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.model2;
+
+import org.jboss.portal.presentation.model2.ViewPortScope;
+import org.jboss.portal.presentation.model2.ViewPort;
+import org.jboss.portal.presentation.model2.ObjectTraversalType;
+import org.jboss.portal.presentation.test.model.state.structural.MockObject;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class AddChildTestCase extends AbstractModelTestCase
+{
+
+ private class Test
+ {
+
+ /** . */
+ private ObjectTraversalType traversal1;
+
+ /** . */
+ private ObjectTraversalType traversal2;
+
+ private Test(
+ ObjectTraversalType traversal1,
+ ObjectTraversalType traversal2)
+ {
+ this.traversal1 = traversal1;
+ this.traversal2 = traversal2;
+ }
+
+ public void test()
+ {
+ NodeDef rootDef = NodeDef.create();
+ NodeDef fooDef = rootDef.addChild("foo");
+ fooDef.setTraversal(traversal1);
+
+ //
+ rootDef.populate(mockModel);
+
+ //
+ ViewPortScope scope = new CustomScope(model, rootDef);
+ UIObjectTree context = new UIObjectTree();
+ ViewPort viewPort = model.createViewPort(context, scope);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+
+ //
+ mockModel.getRoot().getChild("foo").addChild("juu", MockObject.Type.PORTAL);
+ fooDef.addChild("juu");
+ fooDef.setTraversal(traversal2);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ }
+
+ }
+
+ public void test1()
+ {
+ new Test(ObjectTraversalType.RECURSIVE, ObjectTraversalType.RECURSIVE).test();
+ }
+
+ public void test2()
+ {
+ new Test(ObjectTraversalType.RECURSIVE, ObjectTraversalType.SINGLE).test();
+ }
+
+ public void test3()
+ {
+ new Test(ObjectTraversalType.SINGLE, ObjectTraversalType.RECURSIVE).test();
+ }
+
+ public void test4()
+ {
+ new Test(ObjectTraversalType.SINGLE, ObjectTraversalType.SINGLE).test();
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/CustomScope.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/CustomScope.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/CustomScope.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * 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.model2;
+
+import org.jboss.portal.presentation.model2.ViewPortScope;
+import org.jboss.portal.presentation.model2.ObjectTraversalType;
+import org.jboss.portal.presentation.model2.UIObject;
+import org.jboss.portal.presentation.model2.UIModel;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CustomScope implements ViewPortScope
+{
+
+ /** . */
+ private final UIModel model;
+
+ /** . */
+ private final NodeDef root;
+
+ /** . */
+ private NodeDef current;
+
+ public CustomScope(UIModel model, NodeDef root)
+ {
+ if (root == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ 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
+ {
+ NodeDef child = current.getChild(object.getName());
+
+ //
+ if (child == null)
+ {
+ throw new IllegalStateException("No such child " + object.getName());
+ }
+
+ //
+ current = child;
+ }
+
+ //
+ return current.getTraversal();
+ }
+
+ public void leaveObject(UIObject object)
+ {
+ current = current.getParent();
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/FullScope.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/FullScope.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/FullScope.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -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.model2;
+
+import org.jboss.portal.presentation.model2.ViewPortScope;
+import org.jboss.portal.presentation.model2.ObjectTraversalType;
+import org.jboss.portal.presentation.model2.UIObject;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class FullScope implements ViewPortScope
+{
+
+ /** . */
+ private final String rootId;
+
+ public FullScope(String rootId)
+ {
+ this.rootId = rootId;
+ }
+
+ public String getRootId()
+ {
+ return rootId;
+ }
+
+ public ObjectTraversalType enterObject(UIObject object)
+ {
+ return ObjectTraversalType.RECURSIVE;
+ }
+
+ public void leaveObject(UIObject object)
+ {
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/ModelTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/ModelTestCase.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/ModelTestCase.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -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.model2;
+
+import org.jboss.portal.presentation.model2.ViewPortScope;
+import org.jboss.portal.presentation.model2.ViewPort;
+import org.jboss.portal.presentation.model2.ObjectTraversalType;
+
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ModelTestCase extends TestCase
+{
+
+ private class Test extends AbstractModelTestCase
+ {
+
+ /** . */
+ private ObjectTraversalType[] traversal1;
+
+ /** . */
+ private ObjectTraversalType[] traversal2;
+
+ private Test(ObjectTraversalType[] traversal1, ObjectTraversalType[] traversal2)
+ {
+ this.traversal1 = traversal1;
+ this.traversal2 = traversal2;
+ }
+
+ public void test()
+ {
+ NodeDef rootDef = NodeDef.create();
+ NodeDef fooDef = rootDef.addChild("foo");
+ NodeDef barDef = rootDef.addChild("bar");
+ NodeDef juuDef = fooDef.addChild("juu");
+ NodeDef daaDef = fooDef.addChild("daa");
+
+ //
+ fooDef.setTraversal(traversal1[0]);
+ barDef.setTraversal(traversal1[1]);
+ juuDef.setTraversal(traversal1[2]);
+ daaDef.setTraversal(traversal1[3]);
+
+ //
+ rootDef.populate(mockModel);
+
+ //
+ ViewPortScope scope = new CustomScope(model, rootDef);
+ UIObjectTree context = new UIObjectTree();
+ ViewPort viewPort = model.createViewPort(context, scope);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+
+ //
+ fooDef.setTraversal(traversal2[0]);
+ barDef.setTraversal(traversal2[1]);
+ juuDef.setTraversal(traversal2[2]);
+ daaDef.setTraversal(traversal2[3]);
+
+ //
+ viewPort.refresh();
+ rootDef.assertEquals(context.getNode(model.getRootId()));
+ }
+ }
+
+ public void testRefresh1() throws Exception
+ {
+ ObjectTraversalType[] traversal1 = new ObjectTraversalType[4];
+ ObjectTraversalType[] traversal2 = new ObjectTraversalType[4];
+ Collection<ObjectTraversalType[]> enumeration = generate(traversal1.length + traversal2.length);
+/*
+ Collection<ObjectTraversalType[]> enumeration = Collections.singletonList(
+ new ObjectTraversalType[]{
+ ObjectTraversalType.SKIP,
+ ObjectTraversalType.SKIP,
+ ObjectTraversalType.SKIP,
+ ObjectTraversalType.SKIP,
+ ObjectTraversalType.SKIP,
+ ObjectTraversalType.SINGLE,
+ ObjectTraversalType.SKIP,
+ ObjectTraversalType.SKIP,
+ }
+ );
+*/
+ for (ObjectTraversalType[] element : enumeration)
+ {
+ Assert.assertEquals(traversal1.length + traversal2.length, element.length);
+ System.arraycopy(element, 0, traversal1, 0, traversal1.length);
+ System.arraycopy(element, traversal1.length, traversal2, 0, traversal2.length);
+ Test test = new Test(traversal1, traversal2);
+ test.setUp();
+ boolean failed = true;
+ try
+ {
+ test.test();
+ failed = false;
+ }
+ finally
+ {
+ if (failed)
+ {
+ System.out.println("Arrays.asList(traversal1) = " + Arrays.asList(traversal1));
+ System.out.println("Arrays.asList(traversal2) = " + Arrays.asList(traversal2));
+ }
+ }
+ }
+
+ }
+
+ private 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;
+ }
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/NodeDef.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/NodeDef.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/NodeDef.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,160 @@
+/******************************************************************************
+ * 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.model2;
+
+import org.jboss.portal.presentation.model2.ObjectTraversalType;
+import org.jboss.portal.presentation.test.model.state.structural.MockObject;
+import org.jboss.portal.presentation.test.model.state.structural.MockModel;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
+
+import junit.framework.Assert;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class NodeDef
+{
+
+ public static NodeDef create()
+ {
+ return new NodeDef("");
+ }
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final Map<String, NodeDef> children;
+
+ /** . */
+ private ObjectTraversalType traversal;
+
+ /** . */
+ private NodeDef parent;
+
+ private NodeDef(String name)
+ {
+ this.name = name;
+ this.children = new HashMap<String, NodeDef>();
+ this.traversal = ObjectTraversalType.RECURSIVE;
+ this.parent = null;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public NodeDef getChild(String name)
+ {
+ return children.get(name);
+ }
+
+ public NodeDef getParent()
+ {
+ return parent;
+ }
+
+ public ObjectTraversalType getTraversal()
+ {
+ return traversal;
+ }
+
+ public void setTraversal(ObjectTraversalType traversal)
+ {
+ this.traversal = traversal;
+ }
+
+ public NodeDef addChild(String name)
+ {
+ if (children.containsKey(name))
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ NodeDef child = new NodeDef(name);
+
+ //
+ children.put(name, child);
+ child.parent = this;
+
+ //
+ return child;
+ }
+
+ 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(), MockObject.Type.PORTAL);
+ childNodeEntry.getValue().populate(child);
+ }
+ }
+
+ public void assertEquals(UIObjectNode objectNode)
+ {
+ Assert.assertEquals(name, objectNode.getObject().getName());
+
+ //
+ 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());
+ }
+ }
+
+ //
+ Assert.assertEquals(expectedChildrenNames, objectNode.getChildren().keySet());
+
+ //
+ for (UIObjectNode childObjectNode : objectNode.getChildren().values())
+ {
+ NodeDef child = children.get(childObjectNode.getObject().getName());
+ child.assertEquals(childObjectNode);
+ }
+ break;
+ }
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectNode.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectNode.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectNode.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,125 @@
+/******************************************************************************
+ * 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.model2;
+
+import org.jboss.portal.presentation.model2.UIObject;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @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;
+
+ public UIObjectNode(UIObject object)
+ {
+ if (object == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.object = object;
+ }
+
+ public UIObject getObject()
+ {
+ return object;
+ }
+
+ public Map<String, UIObjectNode> getChildren()
+ {
+ return children;
+ }
+
+ public void addChild(UIObjectNode child)
+ {
+ if (children == null)
+ {
+ throw new IllegalStateException("Children not initialized");
+ }
+
+ //
+ String key = child.getObject().getName();
+
+ //
+ 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().getName();
+
+ //
+ if (!children.containsKey(key))
+ {
+ throw new IllegalStateException("No such child with name " + key + " among " + children.keySet());
+ }
+
+ //
+ children.remove(key);
+ }
+
+ public void createrChildren()
+ {
+ 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;
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model2/UIObjectTree.java 2008-03-26 21:30:57 UTC (rev 10381)
@@ -0,0 +1,89 @@
+/******************************************************************************
+ * 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.model2;
+
+import org.jboss.portal.presentation.model2.ViewPortContext;
+import org.jboss.portal.presentation.model2.UIObject;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @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 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 removeObject(String objectId)
+ {
+ nodes.remove(objectId);
+ }
+
+ public void addObject(UIObject object)
+ {
+ nodes.put(object.getId(), new UIObjectNode(object));
+ }
+
+ public void addChild(String parentId, String childId)
+ {
+ UIObjectNode parent = nodes.get(parentId);
+ UIObjectNode child = nodes.get(childId);
+ parent.addChild(child);
+ }
+
+ public void removeChild(String parentId, String childId)
+ {
+ UIObjectNode parent = nodes.get(parentId);
+ UIObjectNode child = nodes.get(childId);
+ parent.removeChild(child);
+ }
+
+ public void initChildren(String parentId)
+ {
+ UIObjectNode parent =nodes.get(parentId);
+ parent.createrChildren();
+ }
+
+ public void destroyChildren(String parentId)
+ {
+ UIObjectNode parent =nodes.get(parentId);
+ parent.destroyChildren();
+ }
+}
18 years, 1 month
JBoss Portal SVN: r10380 - branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui and 12 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-03-26 17:25:30 -0400 (Wed, 26 Mar 2008)
New Revision: 10380
Removed:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/PortletInfoTest.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/model/instance/PortletSupport.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractUserContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/state/StateConverterV0.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/PortletInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ContentResponse.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/AbstractPropertyContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/InvalidStateIdException.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/NoSuchStateException.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/SimplePropertyMap.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/StateConversionException.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/consumer/ConsumerPortletInvoker.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/producer/PortletState.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/producer/PortletStateChangeRequiredException.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/support/info/PortletInfoSupport.java
Log:
JBPORTAL-1959: Migrate isRemotable to a WSRPInfo attachment
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/model/instance/PortletSupport.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/model/instance/PortletSupport.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/model/instance/PortletSupport.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -58,14 +58,14 @@
public PortletSupport()
{
- this(new ContainerPortletInfo(null, new ContainerPreferencesInfo(null), null, null, null, null, null, null, null, null, null));
+ this(new ContainerPortletInfo(null, new ContainerPreferencesInfo(null), null, null, null, null, null, null, null, null));
}
public PortletSupport(String displayName)
{
ContainerMetaInfo cmi = new ContainerMetaInfo();
cmi.addMetaValue(ContainerMetaInfo.DISPLAY_NAME, new LocalizedString(displayName, Locale.ENGLISH));
- this.info = new ContainerPortletInfo(null, new ContainerPreferencesInfo(null), cmi, null, null, null, null, null, null, null, null);
+ this.info = new ContainerPortletInfo(null, new ContainerPreferencesInfo(null), cmi, null, null, null, null, null, null, null);
this.valid = true;
}
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -34,6 +34,7 @@
import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.portlet.info.PortletIconInfo;
import org.jboss.portal.core.portlet.info.PortletInfoInfo;
+import org.jboss.portal.core.portlet.info.WSRPInfo;
import org.jboss.portal.core.ui.content.portlet.PortletContentEditorPortlet;
import org.jboss.portal.faces.el.DelegatingPropertyResolver;
import org.jboss.portal.faces.el.decorator.AbstractBeanDecorator;
@@ -162,7 +163,14 @@
{
Portlet portlet = (Portlet)bean;
PortletInfo info = portlet.getInfo();
- return info.isRemotable();
+ if (info.getAttachment(WSRPInfo.class) != null)
+ {
+ return info.getAttachment(WSRPInfo.class).isRemotable();
+ }
+ else
+ {
+ return Boolean.FALSE;
+ }
}
});
portletDecorator.setProperty("modes", new AbstractPropertyDecorator(Set.class)
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -24,6 +24,7 @@
package org.jboss.portal.wsrp.producer;
import org.jboss.logging.Logger;
+import org.jboss.portal.core.portlet.info.WSRPInfo;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.Portlet;
@@ -499,13 +500,17 @@
private boolean isRemotable(Portlet portlet)
{
PortletInfo portletInfo = portlet.getInfo();
- Boolean remotable = portletInfo.isRemotable();
- log.debug("Portlet " + portlet.getContext() + " remotable: " + remotable);
- if (remotable != null)
+ WSRPInfo wsrpInfo = portletInfo.getAttachment(WSRPInfo.class);
+ if (wsrpInfo != null)
{
- return remotable.booleanValue();
+ Boolean remotable = wsrpInfo.isRemotable();
+ log.debug("Portlet " + portlet.getContext() + " remotable: " + remotable);
+ if (remotable != null)
+ {
+ return remotable.booleanValue();
+ }
}
- else if (isRemotableByDefault() != null)
+ if (isRemotableByDefault() != null)
{
return isRemotableByDefault().booleanValue();
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -630,7 +630,6 @@
portletMD.getPortletClass(),
context.getApplicationName(),
Collections.unmodifiableMap(initParameters),
- null,
context.getBundleManager(portletMD)
);
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -75,9 +75,6 @@
private final Map<String, String> initParameters;
/** . */
- private final Boolean remotable;
-
- /** . */
private final ResourceBundleManager bundleManager;
/** . */
@@ -99,7 +96,6 @@
String className,
String applicationName,
Map<String, String> initParameters,
- Boolean remotable,
ResourceBundleManager bundleManager)
{
this.attachments = new HashMap<Class, Object>();
@@ -115,7 +111,6 @@
this.applicationName = applicationName;
this.className = className;
this.initParameters = initParameters;
- this.remotable = remotable;
this.bundleManager = bundleManager;
this.options = Collections.emptyMap();
}
@@ -150,7 +145,6 @@
this.applicationName = applicationName;
this.className = className;
this.initParameters = initParameters;
- this.remotable = remotable;
this.bundleManager = bundleManager;
this.options = options;
}
@@ -250,11 +244,6 @@
return cache;
}
- public Boolean isRemotable()
- {
- return remotable;
- }
-
public ContainerEventingInfo getEventing()
{
return events;
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -57,13 +57,14 @@
this(request, NO_COOKIES);
}
+ @SuppressWarnings("unchecked")
public AbstractClientContext(HttpServletRequest request, List<Cookie> additionalCookies)
{
MultiValuedPropertyMap<String> headers = new SimpleMultiValuedPropertyMap<String>();
- for (Enumeration e = request.getHeaderNames();e.hasMoreElements();)
+ for (Enumeration<String> e = request.getHeaderNames();e.hasMoreElements();)
{
String headerName = (String)e.nextElement();
- for (Enumeration f = request.getHeaders(headerName);f.hasMoreElements();)
+ for (Enumeration<String> f = request.getHeaders(headerName);f.hasMoreElements();)
{
String headerValue = (String)f.nextElement();
headers.addValue(headerName, headerValue);
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractUserContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractUserContext.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractUserContext.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -104,6 +104,7 @@
/**
* Returns the client request locales or an empty list if no request was provided.
*/
+ @SuppressWarnings("unchecked")
public List<Locale> getLocales()
{
if (clientRequest == null)
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/state/StateConverterV0.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/state/StateConverterV0.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/state/StateConverterV0.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -23,6 +23,7 @@
package org.jboss.portal.portlet.impl.state;
import org.jboss.portal.common.value.StringValue;
+import org.jboss.portal.common.value.Value;
import org.jboss.portal.portlet.state.PropertyMap;
import org.jboss.portal.portlet.state.SimplePropertyMap;
import org.jboss.portal.portlet.state.StateConversionException;
@@ -74,9 +75,9 @@
dos.writeUTF(state.getPortletId());
PropertyMap map = state.getProperties();
dos.writeInt(map.size());
- for (Iterator i = map.entrySet().iterator(); i.hasNext();)
+ for (Iterator<Map.Entry<String, Value>> i = map.entrySet().iterator(); i.hasNext();)
{
- Map.Entry entry = (Map.Entry)i.next();
+ Map.Entry<String, Value> entry = (Map.Entry<String, Value>)i.next();
String key = (String)entry.getKey();
StringValue value = (StringValue)entry.getValue();
String[] strings = (String[])value.asObjectArray();
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/PortletInfo.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/PortletInfo.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/PortletInfo.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -83,17 +83,6 @@
CacheInfo getCache();
/**
- * Determines whether the described portlet can be accessed remotely (such as via WSRP) or not. Clients of this
- * method should be prepare to handle a <code>null</code> return value expressing the fact that the remotable status
- * hasn't been explicitely set.
- *
- * @return <code>Boolean.TRUE</code> if the described portlet can be accessed remotely, <code>Boolean.FALSE</code> if
- * the described portlet cannot be accessed remotely, <code>null</code> if the value hasn't been specified
- * explicitely for the associated portlet.
- */
- Boolean isRemotable();
-
- /**
* Return the eventing information.
*
* @return the eventing information
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ContentResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ContentResponse.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ContentResponse.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -22,12 +22,10 @@
******************************************************************************/
package org.jboss.portal.portlet.invocation.response;
-import org.jboss.portal.portlet.cache.CacheControl;
-import org.jboss.portal.Mode;
-
-import java.util.Set;
import java.util.Map;
+import org.jboss.portal.portlet.cache.CacheControl;
+
/**
* Data produced.
*
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -22,18 +22,14 @@
******************************************************************************/
package org.jboss.portal.portlet.spi;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
+import java.io.IOException;
+import java.io.Writer;
+
import org.jboss.portal.common.invocation.InvocationContext;
import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.URLFormat;
-import java.io.IOException;
-import java.io.Writer;
-
/**
* Contract that defines what input/services the caller of a portlet container must provide.
*
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/AbstractPropertyContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/AbstractPropertyContext.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/AbstractPropertyContext.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -106,11 +106,11 @@
}
}
- public Set getKeys()
+ public Set<String> getKeys()
{
if (prefs == null)
{
- return Collections.EMPTY_SET;
+ return Collections.emptySet();
}
return prefs.keySet();
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/InvalidStateIdException.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/InvalidStateIdException.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/InvalidStateIdException.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -26,6 +26,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 5776 $
*/
+@SuppressWarnings("serial")
public class InvalidStateIdException extends Exception
{
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/NoSuchStateException.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/NoSuchStateException.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/NoSuchStateException.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -26,6 +26,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 5776 $
*/
+@SuppressWarnings("serial")
public class NoSuchStateException extends Exception
{
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/SimplePropertyMap.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/SimplePropertyMap.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/SimplePropertyMap.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -26,7 +26,6 @@
import java.util.HashMap;
import java.util.Map;
-import java.io.Serializable;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/StateConversionException.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/StateConversionException.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/StateConversionException.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -26,6 +26,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 5776 $
*/
+@SuppressWarnings("serial")
public class StateConversionException extends Exception
{
public StateConversionException()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/consumer/ConsumerPortletInvoker.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/consumer/ConsumerPortletInvoker.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/consumer/ConsumerPortletInvoker.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -23,7 +23,6 @@
package org.jboss.portal.portlet.state.consumer;
import org.jboss.portal.common.NotYetImplemented;
-import org.jboss.portal.common.FixMe;
import org.jboss.portal.portlet.InvalidPortletIdException;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.Portlet;
@@ -284,7 +283,7 @@
return failures;
}
- public PropertyMap getProperties(PortletContext portletContext, Set keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PropertyMap getProperties(PortletContext portletContext, Set<String> keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
ConsumerContext consumerContext = getConsumerContext(portletContext);
return producer.getProperties(consumerContext.producerPortletContext, keys);
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/producer/PortletState.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/producer/PortletState.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/producer/PortletState.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -32,6 +32,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 5873 $
*/
+@SuppressWarnings("serial")
public class PortletState implements Serializable
{
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/producer/PortletStateChangeRequiredException.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/producer/PortletStateChangeRequiredException.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/producer/PortletStateChangeRequiredException.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -30,6 +30,7 @@
* @version $Revision: 5776 $
* @since 2.6
*/
+@SuppressWarnings("serial")
public class PortletStateChangeRequiredException extends InvocationException
{
public PortletStateChangeRequiredException(String message)
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -460,7 +460,7 @@
return result;
}
- public PropertyMap getProperties(PortletContext portletContext, Set keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PropertyMap getProperties(PortletContext portletContext, Set<String> keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
if (keys == null)
{
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/support/info/PortletInfoSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/support/info/PortletInfoSupport.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/portlet/support/info/PortletInfoSupport.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -34,7 +34,6 @@
private String name;
private String applicationName;
- private Boolean remotable;
private PreferencesInfoSupport preferencesSupport = new PreferencesInfoSupport();
private SecurityInfoSupport securitySupport = new SecurityInfoSupport();
private CacheInfoSupport cacheSupport = new CacheInfoSupport();
@@ -87,16 +86,6 @@
return cacheSupport;
}
- public Boolean isRemotable()
- {
- return remotable;
- }
-
- public void setRemotable(Boolean remotable)
- {
- this.remotable = remotable;
- }
-
public EventingInfoSupport getEventing()
{
return eventsSupport;
Deleted: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/PortletInfoTest.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/PortletInfoTest.java 2008-03-26 21:11:35 UTC (rev 10379)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/info/PortletInfoTest.java 2008-03-26 21:25:30 UTC (rev 10380)
@@ -1,64 +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.test.portlet.info;
-
-import org.jboss.portal.portlet.container.managed.ManagedPortletContainer;
-import org.jboss.portal.portlet.info.PortletInfo;
-
-import static org.jboss.unit.api.Assert.*;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 6720 $
- */
-public class PortletInfoTest extends AbstractInfoTest
-{
-
- public PortletInfoTest()
- {
- super("PortletInfoTest");
- }
-
- public void execute()
- {
- //This asserts only .isRemotable() as rest is checked in other tests
- ManagedPortletContainer container = registry.getManagedPortletApplication("/test-info").getManagedPortletContainer("RemotablePortlet1");
- PortletInfo info = container.getInfo();
- assertEquals(Boolean.TRUE, info.isRemotable());
-
- //just simple test if we get other infos...
- assertNotNull(info.getCache());
- assertNotNull(info.getCapabilities());
- assertNotNull(info.getMeta());
- assertNotNull(info.getPreferences());
- assertNotNull(info.getSecurity());
-
- container = registry.getManagedPortletApplication("/test-info").getManagedPortletContainer("RemotablePortlet2");
- info = container.getInfo();
- assertEquals(Boolean.FALSE, info.isRemotable());
-
- container = registry.getManagedPortletApplication("/test-info").getManagedPortletContainer("RemotablePortlet3");
- info = container.getInfo();
- assertEquals(Boolean.TRUE, info.isRemotable());
- }
-}
18 years, 1 month