Author: chris.laprun(a)jboss.com
Date: 2007-03-29 19:49:25 -0400 (Thu, 29 Mar 2007)
New Revision: 6875
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
Log:
- Fixed a bug in ProducerInfo where cache would always be bypassed if no POPs where
offered.
- Started adding tests for ProducerInfo.
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java 2007-03-29
23:49:25 UTC (rev 6875)
@@ -0,0 +1,149 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.wsrp.framework.support;
+
+import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.test.wsrp.framework.BehaviorRegistry;
+import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
+import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
+import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
+import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
+import org.jboss.portal.wsrp.services.ServiceFactory;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class BehaviorBackedServiceFactory implements ServiceFactory
+{
+ private BehaviorRegistry registry;
+ private final static String MARKUP = "markup";
+ private final static String SD_URL = "sd";
+ private final static String M_URL = "m";
+ private final static String PM_URL = "pm";
+ private final static String R_URL = "r";
+
+
+ public BehaviorBackedServiceFactory()
+ {
+ registry = new BehaviorRegistry();
+ }
+
+ public Object getService(Class clazz) throws Exception
+ {
+ if (WSRP_v1_ServiceDescription_PortType.class.isAssignableFrom(clazz))
+ {
+ return registry.getServiceDescriptionBehavior();
+ }
+ if (WSRP_v1_Markup_PortType.class.isAssignableFrom(clazz))
+ {
+ return registry.getMarkupBehaviorFor(MARKUP);
+ }
+ if (WSRP_v1_PortletManagement_PortType.class.isAssignableFrom(clazz))
+ {
+ return registry.getPortletManagementBehavior();
+ }
+ if (WSRP_v1_Registration_PortType.class.isAssignableFrom(clazz))
+ {
+ return registry.getRegistrationBehavior();
+ }
+ return null;
+ }
+
+ public BehaviorRegistry getRegistry()
+ {
+ return registry;
+ }
+
+ public void setRegistry(BehaviorRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ public boolean isAvailable()
+ {
+ return true;
+ }
+
+ public String getServiceDescriptionURL()
+ {
+ return SD_URL;
+ }
+
+ public String getMarkupURL()
+ {
+ return M_URL;
+ }
+
+ public String getRegistrationURL()
+ {
+ return R_URL;
+ }
+
+ public String getPortletManagementURL()
+ {
+ return PM_URL;
+ }
+
+ public void setServiceDescriptionURL(String serviceDescriptionURL)
+ {
+ throw new NotYetImplemented();
+ }
+
+ public void setMarkupURL(String markupURL)
+ {
+ throw new NotYetImplemented();
+ }
+
+ public void setRegistrationURL(String registrationURL)
+ {
+ throw new NotYetImplemented();
+ }
+
+ public void setPortletManagementURL(String portletManagementURL)
+ {
+ throw new NotYetImplemented();
+ }
+
+ public void create() throws Exception
+ {
+ throw new NotYetImplemented();
+ }
+
+ public void start() throws Exception
+ {
+ throw new NotYetImplemented();
+ }
+
+ public void stop()
+ {
+ throw new NotYetImplemented();
+ }
+
+ public void destroy()
+ {
+ throw new NotYetImplemented();
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/BehaviorBackedServiceFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java 2007-03-29
23:49:25 UTC (rev 6875)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.wsrp.other;
+
+import junit.framework.TestCase;
+import org.jboss.portal.test.wsrp.framework.ServiceDescriptionBehavior;
+import org.jboss.portal.test.wsrp.framework.support.BehaviorBackedServiceFactory;
+import org.jboss.portal.test.wsrp.framework.support.MockConsumerRegistry;
+import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
+import org.jboss.portal.wsrp.consumer.ProducerInfo;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ProducerInfoTestCase extends TestCase
+{
+ private ProducerInfo info;
+ private BehaviorBackedServiceFactory serviceFactory;
+
+
+ protected void setUp() throws Exception
+ {
+ info = new ProducerInfo();
+ info.setId("test");
+ serviceFactory = new BehaviorBackedServiceFactory();
+ new EndpointConfigurationInfo(info, serviceFactory);
+ info.setRegistry(new MockConsumerRegistry());
+ }
+
+ public void testRefreshAndCache() throws Exception
+ {
+ serviceFactory.getRegistry().setServiceDescriptionBehavior(new
ServiceDescriptionBehavior());
+
+ assertNull(info.getExpirationCacheSeconds());
+
+ assertTrue(info.refresh(false));
+ assertTrue(info.refresh(false));
+
+ info.setExpirationCacheSeconds(new Integer(1));
+ assertEquals(new Integer(1), info.getExpirationCacheSeconds());
+ assertTrue(info.refresh(false));
+ assertFalse(info.refresh(false));
+
+ // wait for cache expiration
+ Thread.sleep(1500);
+ assertTrue(info.refresh(false));
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-29
21:31:50 UTC (rev 6874)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-29
23:49:25 UTC (rev 6875)
@@ -146,7 +146,6 @@
return persistentEndpointInfo;
}
-
void setEndpointConfigurationInfo(EndpointConfigurationInfo
endpointConfigurationInfo)
{
this.persistentEndpointInfo = endpointConfigurationInfo;
@@ -221,8 +220,7 @@
return justRefreshed;
}
- private boolean internalRefresh(boolean forceRefresh)
- throws PortletInvokerException
+ private boolean internalRefresh(boolean forceRefresh) throws PortletInvokerException
{
ServiceDescription serviceDescription;
// might neeed a different cache value: right now, we cache the whole producer info
but we might want to cache
@@ -308,6 +306,7 @@
else
{
popsMap = Collections.EMPTY_MAP;
+ portletGroups = Collections.EMPTY_MAP;
}
//todo: could extract more information here... and rename method more
appropriately