Author: chris.laprun(a)jboss.com
Date: 2007-03-06 22:44:28 -0500 (Tue, 06 Mar 2007)
New Revision: 6572
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java
Removed:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java
Modified:
trunk/wsrp/build.xml
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
Log:
- RegistrationInfo is invalid at construction time.
- Better transactional handling in ConsumerRegistryService.startService.
- Re-added WSRPConsumer.setServiceFactory since it's required for wiring of tests.
- Moved MockConsumerRegistry to framework/support.
- Properly set the registry on ProducerInfo in V1ConsumerBaseTest.
- Re-added no-arg constructor on WSRPConsumerImpl since it's required for wiring of
tests.
- Tests should now all properly pass.
Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml 2007-03-07 02:39:54 UTC (rev 6571)
+++ trunk/wsrp/build.xml 2007-03-07 03:44:28 UTC (rev 6572)
@@ -736,6 +736,7 @@
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.ProducerSessionInformationTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.WSRPPortletURLTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.UserContextConverterTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.EndpointConfigurationInfoTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.handler.RequestHeaderClientHandlerTestCase"/>
</x-test>
<x-sysproperty>
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java 2007-03-07
02:39:54 UTC (rev 6571)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java 2007-03-07
03:44:28 UTC (rev 6572)
@@ -23,6 +23,7 @@
package org.jboss.portal.test.wsrp.deployment;
import junit.framework.TestCase;
+import org.jboss.portal.test.wsrp.framework.support.MockConsumerRegistry;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPConsumer;
import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
Deleted:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java 2007-03-07
02:39:54 UTC (rev 6571)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java 2007-03-07
03:44:28 UTC (rev 6572)
@@ -1,99 +0,0 @@
-/******************************************************************************
- * 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.deployment;
-
-import org.jboss.portal.common.util.ParameterValidation;
-import org.jboss.portal.portlet.federation.FederatingPortletInvoker;
-import org.jboss.portal.test.wsrp.framework.support.MockWSRPConsumer;
-import org.jboss.portal.wsrp.WSRPConsumer;
-import org.jboss.portal.wsrp.consumer.ConsumerException;
-import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
-import org.jboss.portal.wsrp.consumer.ProducerInfo;
-import org.jboss.portal.wsrp.consumer.RegistrationInfo;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class MockConsumerRegistry implements ConsumerRegistry
-{
- private Map consumers = new HashMap(3);
-
-
- public MockConsumerRegistry()
- {
- consumers.put("inDB", new MockWSRPConsumer("inDB"));
- MockWSRPConsumer consumer = new MockWSRPConsumer("inDB2");
- consumer.getProducerInfo().setActive(true);
- consumers.put("inDB2", consumer);
- }
-
- public Collection getConfiguredConsumers()
- {
- return consumers.values();
- }
-
- public WSRPConsumer getConsumer(String id)
- {
- return (WSRPConsumer)consumers.get(id);
- }
-
- public FederatingPortletInvoker getFederatingPortletInvoker()
- {
- return null;
- }
-
- public WSRPConsumer createConsumer(String id)
- {
- MockWSRPConsumer consumer = new MockWSRPConsumer(id);
- consumers.put(id, consumer);
- return consumer;
- }
-
- public void persistConsumer(WSRPConsumer consumer)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(consumer,
"WSRPConsumer");
- consumers.put(consumer.getProducerId(), consumer);
- }
-
- public void activateConsumerWith(String id) throws ConsumerException
- {
- // do nothing
- }
-
- public void updateProducerInfo(ProducerInfo producerInfo)
- {
- // do nothing
- }
-
- public RegistrationInfo getDefaultRegistrationInfo()
- {
- return new RegistrationInfo();
- }
-}
Copied:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java
(from rev 6571,
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/MockConsumerRegistry.java)
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java 2007-03-07
03:44:28 UTC (rev 6572)
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * 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.util.ParameterValidation;
+import org.jboss.portal.portlet.federation.FederatingPortletInvoker;
+import org.jboss.portal.wsrp.WSRPConsumer;
+import org.jboss.portal.wsrp.consumer.ConsumerException;
+import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
+import org.jboss.portal.wsrp.consumer.ProducerInfo;
+import org.jboss.portal.wsrp.consumer.RegistrationInfo;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class MockConsumerRegistry implements ConsumerRegistry
+{
+ private Map consumers = new HashMap(3);
+ private final static RegistrationInfo NULL_REGISTRATION_INFO = new
RegistrationInfo();
+
+
+ public MockConsumerRegistry()
+ {
+ consumers.put("inDB", new MockWSRPConsumer("inDB"));
+ MockWSRPConsumer consumer = new MockWSRPConsumer("inDB2");
+ consumer.getProducerInfo().setActive(true);
+ consumers.put("inDB2", consumer);
+ }
+
+ public Collection getConfiguredConsumers()
+ {
+ return consumers.values();
+ }
+
+ public WSRPConsumer getConsumer(String id)
+ {
+ return (WSRPConsumer)consumers.get(id);
+ }
+
+ public FederatingPortletInvoker getFederatingPortletInvoker()
+ {
+ return null;
+ }
+
+ public WSRPConsumer createConsumer(String id)
+ {
+ MockWSRPConsumer consumer = new MockWSRPConsumer(id);
+ consumers.put(id, consumer);
+ return consumer;
+ }
+
+ public void persistConsumer(WSRPConsumer consumer)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumer,
"WSRPConsumer");
+ consumers.put(consumer.getProducerId(), consumer);
+ }
+
+ public void activateConsumerWith(String id) throws ConsumerException
+ {
+ // do nothing
+ }
+
+ public void updateProducerInfo(ProducerInfo producerInfo)
+ {
+ // do nothing
+ }
+
+ public RegistrationInfo getDefaultRegistrationInfo()
+ {
+ return NULL_REGISTRATION_INFO;
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockConsumerRegistry.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-03-07
02:39:54 UTC (rev 6571)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-03-07
03:44:28 UTC (rev 6572)
@@ -59,6 +59,10 @@
return producerInfo.getId();
}
+ public void setServiceFactory(ServiceFactory serviceFactory)
+ {
+ }
+
public ServiceFactory getServiceFactory()
{
return producerInfo.getEndpointConfigurationInfo().getServiceFactory();
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2007-03-07
02:39:54 UTC (rev 6571)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java 2007-03-07
03:44:28 UTC (rev 6572)
@@ -28,6 +28,7 @@
import org.jboss.portal.test.wsrp.WSRPConsumerBaseTest;
import org.jboss.portal.test.wsrp.framework.BehaviorRegistry;
import org.jboss.portal.test.wsrp.framework.ServiceDescriptionBehavior;
+import org.jboss.portal.test.wsrp.framework.support.MockConsumerRegistry;
import org.jboss.portal.test.wsrp.framework.support.ServiceObjectFactory;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicMarkupBehavior;
import org.jboss.portal.test.wsrp.v1.consumer.behaviors.BasicPortletManagementBehavior;
@@ -61,7 +62,10 @@
public void setUp() throws Exception
{
super.setUp();
+
+ // reset producer state
producer.reset();
+
// reset the behaviors
BehaviorRegistry registry = producer.getBehaviorRegistry();
registry.setPortletManagementBehavior(new
BasicPortletManagementBehavior(registry));
@@ -71,7 +75,14 @@
registry.registerMarkupBehavior(new InitCookieMarkupBehavior(registry));
registry.registerMarkupBehavior(new NullMarkupBehavior(registry));
registry.registerMarkupBehavior(new SessionMarkupBehavior(registry));
+
+ // use a fresh ConsumerRegistry
+ consumer.getProducerInfo().setRegistry(new MockConsumerRegistry());
+
// make sure we use clean producer info for each test
consumer.refreshProducerInfo();
+
+ // use cache to avoid un-necessary calls
+ consumer.getProducerInfo().setExpirationCacheSeconds(new Integer(120));
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-03-07 02:39:54 UTC
(rev 6571)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-03-07 03:44:28 UTC
(rev 6572)
@@ -48,6 +48,14 @@
String getProducerId();
/**
+ * Sets the ServiceFactory this Consumer will use to access the associated
Producer's services. Required for wiring
+ * of services.
+ *
+ * @param serviceFactory the ServiceFactory this Consumer will use to access the
associated Producer's services.
+ */
+ void setServiceFactory(ServiceFactory serviceFactory);
+
+ /**
* Retrieves the ServiceFactory this Consumer will use to access the associated
Producer's services.
*
* @return the ServiceFactory this Consumer will use to access the associated
Producer's services.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-03-07
02:39:54 UTC (rev 6571)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-03-07
03:44:28 UTC (rev 6572)
@@ -124,8 +124,13 @@
// load the configured consumers
consumers = new TreeMap();
+
Session session = sessionFactory.getCurrentSession();
+
+ session.beginTransaction();
Iterator producerInfos = session.createQuery("from ProducerInfo pi order by
pi.id").iterate();
+
+ // load the configured producers
ProducerInfo producerInfo;
while (producerInfos.hasNext())
{
@@ -135,20 +140,30 @@
producerInfo.setRegistry(this);
createConsumerFrom(producerInfo);
- activateConsumerWith(producerInfo.getId());
+
+ // if the producer is marked as active, activate it fo' real! :)
+ if (producerInfo.isActive())
+ {
+ activateConsumerWith(producerInfo.getId());
+ }
}
+ session.getTransaction().commit();
+ session.beginTransaction();
nullRegistration = (RegistrationInfo)session.createQuery("from
RegistrationInfo where key = (select min(key) from
RegistrationInfo)").uniqueResult();
if (nullRegistration == null)
{
nullRegistration = new RegistrationInfo();
session.persist(nullRegistration);
}
+ session.getTransaction().commit();
+
+ session.close();
}
private WSRPConsumer createConsumerFrom(ProducerInfo producerInfo)
{
- WSRPConsumer consumer = new WSRPConsumerImpl(producerInfo, this);
+ WSRPConsumer consumer = new WSRPConsumerImpl(producerInfo);
consumers.put(producerInfo.getId(), consumer);
return consumer;
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-07
02:39:54 UTC (rev 6571)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-07
03:44:28 UTC (rev 6572)
@@ -558,7 +558,7 @@
private RegistrationContext getRegistrationContext()
{
- return persistentRegistrationInfo.getRegistrationContext();
+ return persistentRegistrationInfo == null ? null :
persistentRegistrationInfo.getRegistrationContext();
}
public void resetRegistration() throws PortletInvokerException
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-03-07
02:39:54 UTC (rev 6571)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-03-07
03:44:28 UTC (rev 6572)
@@ -75,7 +75,7 @@
public RegistrationInfo()
{
consumerName = WSRPConstants.DEFAULT_CONSUMER_NAME;
- isRegistrationValid = true;
+ isRegistrationValid = false;
requiresRegistration = false;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-07
02:39:54 UTC (rev 6571)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-07
03:44:28 UTC (rev 6572)
@@ -117,10 +117,14 @@
/** The set of supported user scopes */
private Set supportedUserScopes = WSRP_DEFAULT_USER_SCOPE; // todo: make it possible
to support different user scopes
- WSRPConsumerImpl(ProducerInfo info, ConsumerRegistry registry)
+ public WSRPConsumerImpl()
{
+ this(new ProducerInfo());
+ }
+
+ WSRPConsumerImpl(ProducerInfo info)
+ {
ParameterValidation.throwIllegalArgExceptionIfNull(info,
"ProducerInfo");
- ParameterValidation.throwIllegalArgExceptionIfNull(registry,
"ConsumerRegistry");
producerInfo = info;
actionHandler = new ActionHandler(this);
@@ -476,6 +480,11 @@
return producerInfo.getEndpointConfigurationInfo().getServiceFactory();
}
+ public void setServiceFactory(ServiceFactory serviceFactory)
+ {
+ producerInfo.getEndpointConfigurationInfo().setServiceFactory(serviceFactory);
+ }
+
public WSRP_v1_ServiceDescription_PortType getServiceDescriptionService() throws
PortletInvokerException
{
producerInfo.refresh(false);