Author: julien(a)jboss.com
Date: 2007-01-22 11:18:18 -0500 (Mon, 22 Jan 2007)
New Revision: 6065
Added:
trunk/core/src/main/org/jboss/portal/test/core/model/content/
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContent.java
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentHandler.java
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
Log:
fix portal object test case in core
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java 2007-01-22
15:12:07 UTC (rev 6064)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java 2007-01-22
16:18:18 UTC (rev 6065)
@@ -63,6 +63,11 @@
/** . */
private CopyOnWriteRegistry contentHandlerRegistry;
+ protected AbstractPortalObjectContainer()
+ {
+ contentHandlerRegistry = new CopyOnWriteRegistry();
+ }
+
public InstanceContainer getInstanceContainer()
{
return instanceContainer;
@@ -71,7 +76,6 @@
public void setInstanceContainer(InstanceContainer instanceContainer)
{
this.instanceContainer = instanceContainer;
- this.contentHandlerRegistry = new CopyOnWriteRegistry();
}
public void registerHandler(ContentType contentType, ContentHandler handler) throws
IllegalArgumentException
@@ -212,6 +216,11 @@
return AbstractPortalObjectContainer.this;
}
+ public ContentType getDefaultContentType()
+ {
+ return ContentType.PORTLET;
+ }
+
/**
*/
public void destroyChild(ObjectNode node)
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-01-22
15:12:07 UTC (rev 6064)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-01-22
16:18:18 UTC (rev 6065)
@@ -118,8 +118,8 @@
String value = getDeclaredProperty(PORTAL_PROP_WINDOW_CONTENT_TYPE);
if (value == null)
{
- // For legacy content we chose to treat no value as portlet
- contentType = ContentType.PORTLET;
+ // If nothing is provided then we use the default content type
+ contentType = context.getDefaultContentType();
}
else
{
Added: trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContent.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContent.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContent.java 2007-01-22
16:18:18 UTC (rev 6065)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * 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.core.model.content;
+
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.common.util.LocalizedString;
+
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NullContent implements Content
+{
+
+ /** . */
+ private String contextId;
+
+ /** . */
+ private ContentState state;
+
+ public NullContent(String contextId, ContentState state)
+ {
+ this.contextId = contextId;
+ this.state = state;
+ }
+
+ public String getContextId()
+ {
+ return contextId;
+ }
+
+ public ContentState getState()
+ {
+ return state;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return new LocalizedString("Null content", Locale.ENGLISH);
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentHandler.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentHandler.java 2007-01-22
16:18:18 UTC (rev 6065)
@@ -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.test.core.model.content;
+
+import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.metadata.ContentMetaData;
+import org.jboss.portal.core.impl.model.content.AbstractContentHandler;
+import org.jboss.portal.common.NotYetImplemented;
+import org.w3c.dom.Element;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NullContentHandler extends AbstractContentHandler
+{
+ public Content newContent(String contextId, ContentState state)
+ {
+ return new NullContent(contextId, state);
+ }
+
+ public void createContent(String contextId, ContentState state)
+ {
+ }
+
+ public void destroyContent(String contextId, ContentState state)
+ {
+ }
+
+ public ContentMetaData newMetaData(Element windowElement)
+ {
+ throw new NotYetImplemented();
+ }
+}
Modified:
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-01-22
15:12:07 UTC (rev 6064)
+++
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-01-22
16:18:18 UTC (rev 6065)
@@ -31,10 +31,12 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.impl.model.content.portlet.PortletContent;
+import org.jboss.portal.core.model.content.spi.ContentState;
import org.jboss.portal.security.impl.JBossAuthorizationDomainRegistryImpl;
import org.jboss.portal.security.impl.jacc.JACCPortalAuthorizationManagerFactory;
import org.jboss.portal.test.core.PortalBaseTestCase;
+import org.jboss.portal.test.core.model.content.NullContentHandler;
+import org.jboss.portal.test.core.model.content.NullContent;
import org.jboss.portal.test.framework.embedded.DataSourceSupport;
import org.jboss.portal.common.test.TestParametrization;
import org.jboss.portal.common.test.junit.JUnitAdapter;
@@ -77,6 +79,7 @@
JBossAuthorizationDomainRegistryImpl registry;
JACCPortalAuthorizationManagerFactory factory;
+ NullContentHandler handler;
public void setUp() throws Exception
{
@@ -96,22 +99,33 @@
container.setPortalAuthorizationManagerFactory(factory);
//
+ handler = new NullContentHandler();
+ handler.setContentType(ContentType.PORTLET.toString());
+ handler.setRegistry(container);
+
+ //
registry.start();
factory.start();
+ container.start();
+ handler.start();
}
protected void tearDown() throws Exception
{
super.tearDown();
+ handler.destroy();
+ container.destroy();
+ factory.destroy();
+ registry.destroy();
container = null;
+ registry = null;
+ handler = null;
+ factory = null;
}
/** todo same with a transaction wrapping the start method */
public void testRootNodeCreation() throws Exception
{
- container.start();
-
- //
hibernate.openSession();
assertTrue(hibernate.commitTransaction());
@@ -120,16 +134,10 @@
PortalObject root = container.getRootObject();
assertNotNull(root);
assertTrue(hibernate.commitTransaction());
-
- //
- container.stop();
}
public void testCRUD() throws Exception
{
- container.start();
-
- //
hibernate.openSession();
assertTrue(hibernate.commitTransaction());
@@ -220,16 +228,10 @@
portal = ctx.getPortal("default");
assertNull(portal);
assertTrue(hibernate.commitTransaction());
-
- //
- container.stop();
}
public void testRecreate() throws Exception
{
- container.start();
-
- //
PortalObjectId defaultId = new PortalObjectId(new String[]{"default"});
//
@@ -251,16 +253,10 @@
assertNotNull(object);
assertTrue(hibernate.commitTransaction());
-
- //
- container.stop();
}
public void testCopy() throws Exception
{
- container.start();
-
- //
PortalObjectId defaultId = new PortalObjectId(new String[]{"portal"});
//
@@ -274,8 +270,11 @@
page.setDeclaredProperty("pagename", "pagevalue");
Window window = page.createWindow("window", ContentType.PORTLET);
window.setDeclaredProperty("windowname", "windowvalue");
- PortletContent content = (PortletContent)window.getContent();
- content.setInstanceRef("instance");
+ NullContent content = (NullContent)window.getContent();
+ assertNotNull(content);
+ ContentState contentState = content.getState();
+ assertNotNull(contentState);
+ contentState.setProperty("abc", "def");
assertTrue(hibernate.commitTransaction());
//
@@ -295,13 +294,12 @@
assertNotNull(window);
assertEquals("windowvalue",
window.getDeclaredProperty("windowname"));
assertEquals(ContentType.PORTLET, window.getContentType());
- content = (PortletContent)window.getContent();
+ content = (NullContent)window.getContent();
assertNotNull(content);
- assertEquals("instance", content.getInstanceRef());
+ contentState = content.getState();
+ assertNotNull(contentState);
+ assertEquals("def", contentState.getProperty("abc"));
assertTrue(hibernate.commitTransaction());
-
- //
- container.stop();
}
// private void constructPortalObjects() throws Exception