Author: sohil.shah(a)jboss.com
Date: 2008-02-28 05:15:38 -0500 (Thu, 28 Feb 2008)
New Revision: 10150
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockContext.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockInstance.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPage.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortal.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalObject.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalServer.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortlet.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockWindow.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/MainProcessor.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/PresentationServerImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralObjectImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateContextImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateImpl.java
Modified:
branches/presentation/core-presentation/build.xml
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java
branches/presentation/core-presentation/src/resources/presentation-sar/META-INF/jboss-service.xml
branches/presentation/presentation/build.xml
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/ajax/JBossUnitSandBox.java
Log:
testsuite - Integrating PF with a Mock Portal Server to be used in the test suite
Modified: branches/presentation/core-presentation/build.xml
===================================================================
--- branches/presentation/core-presentation/build.xml 2008-02-28 01:18:35 UTC (rev 10149)
+++ branches/presentation/core-presentation/build.xml 2008-02-28 10:15:38 UTC (rev 10150)
@@ -168,6 +168,8 @@
<copy file="${gwt.gwt.root}/lib/gwt-user.jar"
todir="${build.resources}/presentation-sar/lib" overwrite="true"/>
<copy file="${build.lib}/portal-core-presentation-lib.jar"
todir="${build.resources}/presentation-sar/lib" overwrite="true"/>
<copy
file="${jboss.portal-presentation.lib}/portal-presentation-lib.jar"
todir="${build.resources}/presentation-sar/lib" overwrite="true"/>
+ <!-- TODO: remove me -->
+ <copy
file="${jboss.portal-presentation.lib}/portal-presentation-test-lib.jar"
todir="${build.resources}/presentation-sar/lib" overwrite="true"/>
<copy todir="${build.resources}/presentation-sar">
<fileset dir="${jboss.portal-presentation.lib}"
includes="presentation.war"/>
</copy>
Modified:
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java
===================================================================
---
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java 2008-02-28
01:18:35 UTC (rev 10149)
+++
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -188,7 +188,7 @@
decoder.decode(getActivation.getQueryParameters(), formParameters);
- // We assume that for now
+ //TODO: We assume that for now
UIWindow uiWindow =
(UIWindow)presentationContext.getUIContext().getObject(id);
//
Modified:
branches/presentation/core-presentation/src/resources/presentation-sar/META-INF/jboss-service.xml
===================================================================
---
branches/presentation/core-presentation/src/resources/presentation-sar/META-INF/jboss-service.xml 2008-02-28
01:18:35 UTC (rev 10149)
+++
branches/presentation/core-presentation/src/resources/presentation-sar/META-INF/jboss-service.xml 2008-02-28
10:15:38 UTC (rev 10150)
@@ -23,7 +23,6 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<server>
-
<mbean
code="org.jboss.portal.presentation.client.controller.UIController"
name="portal:service=Controller,type=Presentation"
@@ -59,7 +58,27 @@
<depends
optional-attribute-name="Controller"
proxy-type="attribute">portal:service=Controller,type=Ajax/Presentation</depends>
+ </mbean>
+ <mbean
+
code="org.jboss.portal.core.presentation.model.StructuralStateContextImpl"
+ name="portal:container=ModelLoader"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends optional-attribute-name="PortalObjectContainer"
proxy-type="attribute">portal:container=PortalObject</depends>
+ <depends>portal:container=PortalObject</depends>
+ <depends>portal:service=PageService</depends>
+ <depends>portal:commandFactory=DefaultPortal</depends>
+ <depends>portal:urlFactory=Delegating</depends>
+ <depends>portal:service=InterceptorStackFactory,type=Command</depends>
+ <depends>portal:container=Instance</depends>
+ <depends>portal:service=PortalAuthorizationManagerFactory</depends>
+ <depends>portal:service=CustomizationManager</depends>
+ <depends>portal:service=ContentProviderRegistry</depends>
+ <depends>portal:service=ResponseHandler,type=Selector</depends>
+ <depends>portal:service=ControlPolicy,type=Page</depends>
</mbean>
+ <!--
<mbean
code="org.jboss.portal.core.presentation.server.PresentationServerImpl"
name="portal:service=PresentationServer"
@@ -81,6 +100,8 @@
<depends>portal:service=ResponseHandler,type=Selector</depends>
<depends>portal:service=ControlPolicy,type=Page</depends>
</mbean>
+ -->
+ <!--
<mbean
code="org.jboss.portal.core.presentation.server.MainProcessor"
name="portal:service=Processor"
@@ -99,24 +120,20 @@
<depends optional-attribute-name="PortalObjectContainer"
proxy-type="attribute">portal:container=PortalObject</depends>
<depends optional-attribute-name="CustomizationManager"
proxy-type="attribute">portal:service=CustomizationManager</depends>
</mbean>
+ -->
<mbean
-
code="org.jboss.portal.core.presentation.model.StructuralStateContextImpl"
- name="portal:container=ModelLoader"
+
code="org.jboss.portal.presentation.test.portal.plugin.PresentationServerImpl"
+ name="portal:service=PresentationServer"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
- <depends optional-attribute-name="PortalObjectContainer"
proxy-type="attribute">portal:container=PortalObject</depends>
- <depends>portal:container=PortalObject</depends>
- <depends>portal:service=PageService</depends>
- <depends>portal:commandFactory=DefaultPortal</depends>
- <depends>portal:urlFactory=Delegating</depends>
- <depends>portal:service=InterceptorStackFactory,type=Command</depends>
- <depends>portal:container=Instance</depends>
- <depends>portal:service=PortalAuthorizationManagerFactory</depends>
- <depends>portal:service=CustomizationManager</depends>
- <depends>portal:service=ContentProviderRegistry</depends>
- <depends>portal:service=ResponseHandler,type=Selector</depends>
- <depends>portal:service=ControlPolicy,type=Page</depends>
+ <depends optional-attribute-name="Processor"
proxy-type="attribute">portal:service=Processor</depends>
</mbean>
-
+ <mbean
+ code="org.jboss.portal.presentation.test.portal.plugin.MainProcessor"
+ name="portal:service=Processor"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
</server>
Modified: branches/presentation/presentation/build.xml
===================================================================
--- branches/presentation/presentation/build.xml 2008-02-28 01:18:35 UTC (rev 10149)
+++ branches/presentation/presentation/build.xml 2008-02-28 10:15:38 UTC (rev 10150)
@@ -243,8 +243,7 @@
<arg line="-out ${build.resources}/presentation.war/"/>
<arg line="org.jboss.portal.uiserver.ajax.PartialRefresh"/>
</java>
- -->
-
+ -->
<path id="full.gwt.classpath">
<path refid="gwt.gwt.classpath"/>
<path refid="mygwt.mygwt.classpath"/>
@@ -257,7 +256,9 @@
</classpath>
<arg line="-out ${build.lib}/ajax/"/>
<arg line="org.jboss.portal.presentation.ajax.Portal"/>
- </java>
+ </java>
+
+
<jar jarfile="${build.lib}/presentation.war">
<fileset
dir="${build.resources}/presentation-war"></fileset>
<fileset
dir="${build.lib}/ajax/org.jboss.portal.presentation.ajax.Portal"></fileset>
@@ -327,11 +328,17 @@
</target>
<target name="test-jbossunit" depends="init">
- <taskdef name="jboss-unit"
classname="org.jboss.unit.tooling.ant.JBossUnitTask"
classpathref="library.classpath"/>
+ <path id="jboss-unit.classpath">
+ <pathelement
location="/home/soshah/.m2/repository/org/jboss/unit/jboss-unit/1.2.0-SNAPSHOT/jboss-unit-1.2.0-SNAPSHOT.jar"/>
+ <pathelement
location="/home/soshah/.m2/repository/org/jboss/unit/jboss-unit-tooling-ant/1.2.0-SNAPSHOT/jboss-unit-tooling-ant-1.2.0-SNAPSHOT.jar"/>
+ <pathelement
location="/home/soshah/.m2/repository/org/jboss/unit/jboss-unit-tooling-core/1.2.0-SNAPSHOT/jboss-unit-tooling-core-1.2.0-SNAPSHOT.jar"/>
+ <pathelement
location="${build.lib}/portal-presentation-test-lib.jar"/>
+ </path>
+ <taskdef name="jboss-unit"
classname="org.jboss.unit.tooling.ant.JBossUnitTask"
classpathref="jboss-unit.classpath"/>
<jboss-unit>
<tests config="src/resources/jboss-unit/config/jboss-unit.xml"/>
<classpath>
- <path refid="library.classpath"/>
+ <path refid="jboss-unit.classpath"/>
</classpath>
</jboss-unit>
</target>
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-02-28
01:18:35 UTC (rev 10149)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/ajax/JBossUnitSandBox.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -23,7 +23,9 @@
package org.jboss.portal.presentation.test.ajax;
import org.jboss.unit.api.pojo.annotations.Test;
+import static org.jboss.unit.api.Assert.*;
+
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
@@ -33,6 +35,6 @@
@Test
public void test()
{
- System.out.println("Simple JBossUnit Test in the PresentationFramework
successfully executed....");
+ fail("Simple JBossUnit Test in the PresentationFramework successfully
executed....");
}
}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockContext.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockContext.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockContext.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockContext extends MockPortalObject
+{
+ /**
+ *
+ */
+ private List portals = null;
+
+ /**
+ *
+ * @param id
+ */
+ public MockContext(String id, List portals)
+ {
+ super(id);
+ this.portals = portals;
+ }
+
+ /**
+ *
+ */
+ public List getChildren()
+ {
+ return this.portals;
+ }
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockInstance.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockInstance.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockInstance.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockInstance
+{
+ /**
+ * Invoke the instance
+ *
+ * @param invocation the invocation
+ */
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
+ {
+ return null;
+ }
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPage.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPage.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPage.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockPage extends MockPortalObject
+{
+ /**
+ *
+ */
+ private List windows = null;
+
+ /**
+ *
+ * @param id
+ * @param windows
+ */
+ public MockPage(String id, List windows)
+ {
+ super(id);
+ this.windows = windows;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public List getWindows()
+ {
+ return windows;
+ }
+
+ /**
+ *
+ * @param windows
+ */
+ public void setWindows(List windows)
+ {
+ this.windows = windows;
+ }
+
+ /**
+ *
+ */
+ public List getChildren()
+ {
+ return this.windows;
+ }
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortal.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortal.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortal.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockPortal extends MockPortalObject
+{
+ /**
+ *
+ */
+ private List pages = null;
+
+ /**
+ *
+ * @param id
+ */
+ public MockPortal(String id, List pages)
+ {
+ super(id);
+ this.pages = pages;
+ }
+
+ /**
+ *
+ */
+ public List getChildren()
+ {
+ return this.pages;
+ }
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalObject.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalObject.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalObject.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public abstract class MockPortalObject
+{
+ /**
+ *
+ */
+ protected String id = null;
+
+ /**
+ *
+ * @param id
+ */
+ public MockPortalObject(String id)
+ {
+ this.id = id;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getId()
+ {
+ return this.id;
+ }
+
+ /**
+ *
+ */
+ public abstract List getChildren();
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalServer.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalServer.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalServer.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -0,0 +1,136 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import java.util.Map;
+import java.util.List;
+import java.util.HashMap;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockPortalServer
+{
+ /**
+ *
+ */
+ private static MockPortalServer singleton = null;
+
+ /**
+ *
+ */
+ private Map instances = null;
+
+ /**
+ *
+ *
+ */
+ private MockPortalServer()
+ {
+ //load up the MockPortal instances
+ this.instances = new HashMap();
+
+ //Create 3 MockPortlets
+ MockPortlet portlet1 = new MockPortlet("<div><b>Portlet
1:</b><br/></div>");
+ MockPortlet portlet2 = new MockPortlet("<div><b>Portlet
2:</b><br/></div>");
+ MockPortlet portlet3 = new MockPortlet("<div><b>Portlet
3:</b><br/></div>");
+
+ MockWindow window1 = new MockWindow("default/default/window1",portlet1);
+ MockWindow window2 = new MockWindow("default/default/window2",portlet2);
+ MockWindow window3 = new MockWindow("default/default/window3",portlet3);
+
+ List windows = new ArrayList();
+ windows.add(window1);
+ windows.add(window2);
+ windows.add(window3);
+
+ MockPage page1 = new MockPage("default/default", windows);
+
+ List pages = new ArrayList();
+ pages.add(page1);
+
+ MockPortal mockPortal = new MockPortal("default", pages);
+
+ List portals = new ArrayList();
+ portals.add(mockPortal);
+
+ MockContext mockContext = new MockContext("/", portals);
+
+ this.instances.put("/", mockContext);
+ this.instances.put("default", mockPortal);
+ this.instances.put("default/default", page1);
+ this.instances.put("default/default/window1", window1);
+ this.instances.put("default/default/window2", window2);
+ this.instances.put("default/default/window3", window3);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static MockPortalServer getInstance()
+ {
+ if(MockPortalServer.singleton == null)
+ {
+ MockPortalServer.singleton = new MockPortalServer();
+ }
+ return MockPortalServer.singleton;
+ }
+
+ /**
+ *
+ * @param id
+ * @return
+ */
+ public MockPortalObject getPortalObject(String id)
+ {
+ MockPortalObject portalObject = null;
+
+ if(!id.equals("/") && id.startsWith("/"))
+ {
+ id = id.substring(1);
+ }
+
+ portalObject = (MockPortalObject)this.instances.get(id);
+
+ return portalObject;
+ }
+
+ /**
+ *
+ * @param id
+ */
+ public void invoke(String id, Map queryParameters)
+ {
+ String[] action = (String[])queryParameters.get("action");
+
+ MockWindow window = (MockWindow)this.getPortalObject(id);
+
+ if(action != null && action[0].equals("2"))
+ {
+ window.getPortlet().processAction();
+ }
+ }
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortlet.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortlet.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortlet.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockPortlet
+{
+ /**
+ *
+ */
+ private String content = null;
+ private boolean actionActivated = false;
+
+ /**
+ *
+ *
+ */
+ public MockPortlet(String content)
+ {
+ this.content = content;
+ }
+
+ /**
+ *
+ *
+ */
+ public void processAction()
+ {
+ this.content += "<div><p>Action called:</p><br/><a
href=\"default/default/window1?action=1\">View
Window1</a><br/><a
href=\"default/default/window2?action=1\">View
Window2</a><br/><a
href=\"default/default/window3?action=1\">View
Window3</a><br/></div>";
+ this.actionActivated = true;
+ }
+
+ /**
+ *
+ *
+ */
+ public void doView()
+ {
+ if(!actionActivated)
+ {
+ this.content += "<div><p>View called:</p><br/><a
href=\"default/default/window1?action=2\">Action
Window1</a><br/><a
href=\"default/default/window2?action=2\">Action
Window2</a><br/><a
href=\"default/default/window3?action=2\">Action
Window3</a><br/></div>";
+ }
+ actionActivated = false;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getContent()
+ {
+ return this.content;
+ }
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockWindow.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockWindow.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockWindow.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockWindow extends MockPortalObject
+{
+ /**
+ *
+ */
+ private MockPortlet portlet = null;
+
+ /**
+ *
+ * @param id
+ * @param portlet
+ */
+ public MockWindow(String id, MockPortlet portlet)
+ {
+ super(id);
+ this.portlet = portlet;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public MockPortlet getPortlet()
+ {
+ return portlet;
+ }
+
+ /**
+ *
+ * @param portlet
+ */
+ public void setPortlet(MockPortlet portlet)
+ {
+ this.portlet = portlet;
+ }
+
+ /**
+ *
+ */
+ public List getChildren()
+ {
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getMarkup()
+ {
+ this.portlet.doView();
+ return this.portlet.getContent();
+ }
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/MainProcessor.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/MainProcessor.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/MainProcessor.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal.plugin;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.impl.PortletRequestDecoder;
+
+import org.jboss.portal.web.Body;
+
+import org.jboss.portal.server.ServerException;
+
+import org.jboss.portal.presentation.server.Processor;
+import org.jboss.portal.presentation.server.ProcessorRequest;
+import org.jboss.portal.presentation.server.ProcessorResponse;
+
+import org.jboss.portal.presentation.client.PresentationContext;
+
+import org.jboss.portal.presentation.model.StateType;
+import org.jboss.portal.presentation.model.UIWindow;
+
+import org.jboss.portal.presentation.protocol.LinkActivation;
+import org.jboss.portal.presentation.protocol.PostActivation;
+import org.jboss.portal.presentation.protocol.ServerAction;
+import org.jboss.portal.presentation.protocol.ServerResponse;
+import org.jboss.portal.presentation.protocol.ShowUIObjectResponse;
+import org.jboss.portal.presentation.protocol.ViewUIObjectAction;
+
+import org.jboss.portal.presentation.test.portal.MockPortalServer;
+
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MainProcessor implements Processor
+{
+
+ /** . */
+ private static Logger log = Logger.getLogger(MainProcessor.class);
+
+ /**
+ *
+ */
+ public ProcessorResponse process(PresentationContext presentationContext,
ProcessorRequest request) throws ServerException
+ {
+ try
+ {
+
+ ServerAction serverAction = request.getAction();
+
+ ServerResponse response = null;
+
+ if(serverAction instanceof ViewUIObjectAction)
+ {
+ ViewUIObjectAction viewAction = (ViewUIObjectAction)serverAction;
+ response = new ShowUIObjectResponse(viewAction.getTargetId());
+ }
+ else if (serverAction instanceof LinkActivation)
+ {
+ LinkActivation getActivation = (LinkActivation)serverAction;
+ String id = getActivation.getTargetId();
+ PortletRequestDecoder decoder = new PortletRequestDecoder();
+
+ // Get form parameters if any
+ Map formParameters = null;
+ if (serverAction instanceof PostActivation)
+ {
+ PostActivation post = (PostActivation)serverAction;
+ Body body = post.getBody();
+ if (body instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)body).getParameters();
+ }
+ }
+
+ decoder.decode(getActivation.getQueryParameters(), formParameters);
+ StateString contentState = decoder.getNavigationalState();
+
+ //TODO: We assume that for now
+ UIWindow uiWindow =
(UIWindow)presentationContext.getUIContext().getObject(id);
+
+
+ //Make an invocation on the Mock Portal Server
+ MockPortalServer.getInstance().invoke(id,
getActivation.getQueryParameters());
+
+ // It means we went through a successful action or it is a render
+ uiWindow.setProperty(StateType.NAVIGATIONAL, "content",
contentState);
+ response = new ShowUIObjectResponse(uiWindow.getParent().getId());
+ }
+
+ return new ProcessorResponse(response);
+ }
+ catch(Exception e)
+ {
+ throw new ServerException(e);
+ }
+ }
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/PresentationServerImpl.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/PresentationServerImpl.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/PresentationServerImpl.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal.plugin;
+
+import org.jboss.portal.presentation.client.PresentationContext;
+import org.jboss.portal.presentation.server.Processor;
+import org.jboss.portal.presentation.server.PresentationServer;
+import org.jboss.portal.presentation.model.UIWindow;
+import org.jboss.portal.presentation.model.content.WindowContent;
+import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+
+import org.jboss.portal.presentation.test.portal.MockPortalServer;
+import org.jboss.portal.presentation.test.portal.MockWindow;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class PresentationServerImpl implements PresentationServer
+{
+
+ /**
+ *
+ */
+ private Processor processor;
+
+ /**
+ *
+ */
+ private StructuralStateContext structuralStateContext;
+
+
+ /**
+ *
+ *
+ */
+ public PresentationServerImpl()
+ {
+
+ }
+
+ /**
+ *
+ *
+ */
+ public void start()
+ {
+ this.structuralStateContext = new StructuralStateContextImpl();
+ }
+
+ /**
+ *
+ *
+ */
+ public void stop()
+ {
+
+ }
+
+ /**
+ *
+ */
+ public StructuralStateContext getStructuralStateManager()
+ {
+ return structuralStateContext;
+ }
+
+ /**
+ *
+ * @param structuralStateContext
+ */
+ public void setModelLoader(StructuralStateContext structuralStateContext)
+ {
+ this.structuralStateContext = structuralStateContext;
+ }
+
+ /**
+ *
+ */
+ public Processor getProcessor()
+ {
+ return this.processor;
+ }
+
+ /**
+ *
+ * @param processor
+ */
+ public void setProcessor(Processor processor)
+ {
+ this.processor = processor;
+ }
+
+ /**
+ *
+ */
+ public WindowContent render(PresentationContext context, UIWindow uiwindow) throws
Exception
+ {
+ MockWindow window =
(MockWindow)MockPortalServer.getInstance().getPortalObject(uiwindow.getId());
+ return new WindowContent(-1, "Blah:", window.getMarkup());
+ }
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralObjectImpl.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralObjectImpl.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralObjectImpl.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal.plugin;
+
+import org.jboss.portal.presentation.model.state.structural.StructuralObject;
+import org.jboss.portal.presentation.model.state.structural.StructuralState;
+
+import org.jboss.portal.presentation.test.portal.MockPortalObject;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class StructuralObjectImpl implements StructuralObject
+{
+
+ /** . */
+ private final String id;
+
+ /** . */
+ private final StructuralStateImpl state;
+
+ public StructuralObjectImpl(MockPortalObject portalObject)
+ {
+ this.id = portalObject.getId();
+ this.state = new StructuralStateImpl(portalObject);
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public StructuralState getState()
+ {
+ return state;
+ }
+
+ public boolean compareTo(StructuralObject other)
+ {
+ return true;
+ }
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateContextImpl.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateContextImpl.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateContextImpl.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -0,0 +1,168 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal.plugin;
+
+
+import org.jboss.portal.presentation.model.state.StateException;
+import
org.jboss.portal.presentation.model.state.structural.AbstractStructuralStateContext;
+import org.jboss.portal.presentation.model.state.structural.StructuralObject;
+import org.jboss.portal.common.NotYetImplemented;
+
+import org.jboss.portal.presentation.test.portal.MockPortalServer;
+import org.jboss.portal.presentation.test.portal.MockPortalObject;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class StructuralStateContextImpl extends AbstractStructuralStateContext
+{
+ /**
+ *
+ */
+ public String getRootId()
+ {
+ return "/";
+ }
+
+ /**
+ * The implementation only validate that an object is present.
+ */
+ public void validate(StructuralObject object) throws IllegalArgumentException,
StateException
+ {
+
+ }
+
+ /**
+ *
+ */
+ public StructuralObject.Refresh refresh(StructuralObject object) throws
IllegalArgumentException, StateException
+ {
+ throw new NotYetImplemented();
+ }
+
+ /**
+ *
+ */
+ public StructuralObject load(String objectId) throws IllegalArgumentException
+ {
+ StructuralObject cour = null;
+
+ MockPortalObject portalObject =
MockPortalServer.getInstance().getPortalObject(objectId);
+ if(portalObject != null)
+ {
+ cour = new StructuralObjectImpl(portalObject);
+ }
+
+ return cour;
+ }
+
+ /**
+ *
+ */
+ public Collection<StructuralObject> loadChildren(StructuralObject parent)
+ {
+ Collection<StructuralObject> children = null;
+
+ MockPortalObject parentPortalObject =
MockPortalServer.getInstance().getPortalObject(parent.getId());
+ List cour = parentPortalObject.getChildren();
+
+ if(cour != null)
+ {
+ children = new ArrayList<StructuralObject>();
+ for(int i=0; i<cour.size(); i++)
+ {
+ MockPortalObject child = (MockPortalObject)cour.get(i);
+ children.add(new StructuralObjectImpl(child));
+ }
+ }
+
+ return children;
+ }
+
+ /**
+ *
+ */
+ public StructuralObject loadParent(StructuralObject child)
+ {
+ StructuralObject parent = null;
+
+ String id = child.getId();
+ int lastIndex = id.lastIndexOf('/');
+ String parentId = id.substring(0, lastIndex);
+
+ MockPortalObject parentObject =
MockPortalServer.getInstance().getPortalObject(parentId);
+ if(parentObject != null)
+ {
+ parent = new StructuralObjectImpl(parentObject);
+ }
+
+ return parent;
+ }
+
+ /**
+ *
+ * @param left
+ * @param right
+ * @return
+ */
+ public boolean equals(StructuralObject left, StructuralObject right)
+ {
+ if (left == null)
+ {
+ return right == null;
+ }
+ else
+ {
+ if (right == null)
+ {
+ return false;
+ }
+ StructuralObjectImpl lefti = (StructuralObjectImpl)left;
+ StructuralObjectImpl righti = (StructuralObjectImpl)right;
+ return lefti.getId().equals(righti.getId());
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ public void start()
+ {
+
+ }
+
+ /**
+ *
+ *
+ */
+ public void stop()
+ {
+
+ }
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateImpl.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateImpl.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateImpl.java 2008-02-28
10:15:38 UTC (rev 10150)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal.plugin;
+
+import org.jboss.portal.presentation.model.state.structural.StructuralState;
+import org.jboss.portal.presentation.model.UIObject;
+import org.jboss.portal.presentation.model.UIContext;
+import org.jboss.portal.presentation.model.UIPortal;
+import org.jboss.portal.presentation.model.UIPage;
+import org.jboss.portal.presentation.model.UIWindow;
+
+import org.jboss.portal.presentation.test.portal.MockPortalObject;
+import org.jboss.portal.presentation.test.portal.MockContext;
+import org.jboss.portal.presentation.test.portal.MockPortal;
+import org.jboss.portal.presentation.test.portal.MockPage;
+import org.jboss.portal.presentation.test.portal.MockWindow;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class StructuralStateImpl implements StructuralState
+{
+
+ /** . */
+ private Class<? extends UIObject> type;
+
+ /** . */
+ private String name;
+
+ /** . */
+ private Map<String, String> properties;
+
+ StructuralStateImpl(MockPortalObject portalObject)
+ {
+ type = this.getType(portalObject);
+ this.name = portalObject.getId();
+ }
+
+ public Class<? extends UIObject> getType()
+ {
+ return type;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ /**
+ *
+ * @param portalObject
+ * @return
+ */
+ private Class<? extends UIObject> getType(MockPortalObject portalObject)
+ {
+ Class<? extends UIObject> type = null;
+
+ if(portalObject instanceof MockContext)
+ {
+ type = UIContext.class;
+ }
+ else if(portalObject instanceof MockPortal)
+ {
+ type = UIPortal.class;
+ }
+ else if(portalObject instanceof MockPage)
+ {
+ type = UIPage.class;
+ }
+ else if(portalObject instanceof MockWindow)
+ {
+ type = UIWindow.class;
+ }
+
+ return type;
+ }
+}