Author: chris.laprun(a)jboss.com
Date: 2009-11-18 18:03:17 -0500 (Wed, 18 Nov 2009)
New Revision: 654
Added:
portal/branches/wsrp-integration/component/wsrp/src/test/
portal/branches/wsrp-integration/component/wsrp/src/test/java/
portal/branches/wsrp-integration/component/wsrp/src/test/java/org/
portal/branches/wsrp-integration/component/wsrp/src/test/java/org/gatein/
portal/branches/wsrp-integration/component/wsrp/src/test/java/org/gatein/portal/
portal/branches/wsrp-integration/component/wsrp/src/test/java/org/gatein/portal/wsrp/
portal/branches/wsrp-integration/component/wsrp/src/test/java/org/gatein/portal/wsrp/state/
portal/branches/wsrp-integration/component/wsrp/src/test/java/org/gatein/portal/wsrp/state/consumer/
portal/branches/wsrp-integration/component/wsrp/src/test/java/org/gatein/portal/wsrp/state/consumer/ConsumerRegistryTestCase.java
Modified:
portal/branches/wsrp-integration/component/wsrp/pom.xml
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/ConsumerRegistry.java
portal/branches/wsrp-integration/pom.xml
Log:
- Use SNAPSHOT versions of common and WSRP modules.
- Updated ConsumerRegistry code.
- Added ConsumerRegistryTestCase based on the class of the same name in WSRP consumer
tests. Ideally, I would be able to share that code, not
sure how to do it cleanly... :( Note also that the test currently doesn't pass as it
needs proper chromattic and jcr setup.
Modified: portal/branches/wsrp-integration/component/wsrp/pom.xml
===================================================================
--- portal/branches/wsrp-integration/component/wsrp/pom.xml 2009-11-18 18:52:08 UTC (rev
653)
+++ portal/branches/wsrp-integration/component/wsrp/pom.xml 2009-11-18 23:03:17 UTC (rev
654)
@@ -95,7 +95,20 @@
<groupId>org.chromattic</groupId>
<artifactId>chromattic.api</artifactId>
<version>${version.chromattic}</version>
+ <scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.chromattic</groupId>
+ <artifactId>chromattic.core</artifactId>
+ <version>${version.chromattic}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.chromattic</groupId>
+ <artifactId>chromattic.exo</artifactId>
+ <version>${version.chromattic}</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
Modified:
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/ConsumerRegistry.java
===================================================================
---
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/ConsumerRegistry.java 2009-11-18
18:52:08 UTC (rev 653)
+++
portal/branches/wsrp-integration/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/consumer/ConsumerRegistry.java 2009-11-18
23:03:17 UTC (rev 654)
@@ -52,9 +52,8 @@
private static final String WSRP_SERVICES_PATH = RegistryService.EXO_SERVICES +
"/wsrp/";
private static final String PRODUCER_INFOS_PATH = WSRP_SERVICES_PATH +
"producerinfos";
- public ConsumerRegistry(InitParams params, RegistryService jcrRegistry) throws
Exception
+ public ConsumerRegistry() throws Exception
{
-
ChromatticBuilder builder = ChromatticBuilder.create();
builder.setOption(ChromatticBuilder.INSTRUMENTOR_CLASSNAME,
"org.chromattic.apt.InstrumentorImpl");
@@ -68,6 +67,11 @@
chrome = builder.build();
}
+ public ConsumerRegistry(InitParams params, RegistryService jcrRegistry) throws
Exception
+ {
+ this();
+ }
+
@Override
protected void save(ProducerInfo info, String messageOnError)
{
@@ -98,7 +102,7 @@
}
@Override
- protected Iterator getAllProducerInfos()
+ protected Iterator<ProducerInfo> getProducerInfosFromStorage()
{
ChromatticSession session = chrome.openSession();
ProducerInfosMapping producerInfosMapping =
session.findByPath(ProducerInfosMapping.class, PRODUCER_INFOS_PATH);
@@ -124,7 +128,7 @@
}
session.persist(infos); // todo: is that sufficient?
- producerInfos = new ConsumerToProducerInfoIterator(consumers.iterator());
+ producerInfos = new ProducerInfoIterator(consumers.iterator());
}
else
{
@@ -162,35 +166,6 @@
return null; // todo: implement
}
- private static class ConsumerToProducerInfoIterator implements
Iterator<ProducerInfo>
- {
-
- private final Iterator<WSRPConsumer> consumers;
-
- public ConsumerToProducerInfoIterator(Iterator<WSRPConsumer> consumers)
- {
- this.consumers = consumers;
- }
-
- @Override
- public boolean hasNext()
- {
- return consumers.hasNext();
- }
-
- @Override
- public ProducerInfo next()
- {
- return consumers.next().getProducerInfo();
- }
-
- @Override
- public void remove()
- {
- throw new UnsupportedOperationException("Remove not supported!");
- }
- }
-
private static class MappingToProducerInfoIterator implements
Iterator<ProducerInfo>
{
private Iterator<ProducerInfoMapping> mappings;
Added:
portal/branches/wsrp-integration/component/wsrp/src/test/java/org/gatein/portal/wsrp/state/consumer/ConsumerRegistryTestCase.java
===================================================================
---
portal/branches/wsrp-integration/component/wsrp/src/test/java/org/gatein/portal/wsrp/state/consumer/ConsumerRegistryTestCase.java
(rev 0)
+++
portal/branches/wsrp-integration/component/wsrp/src/test/java/org/gatein/portal/wsrp/state/consumer/ConsumerRegistryTestCase.java 2009-11-18
23:03:17 UTC (rev 654)
@@ -0,0 +1,150 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, 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.gatein.portal.wsrp.state.consumer;
+
+import junit.framework.TestCase;
+import org.gatein.pc.federation.impl.FederatingPortletInvokerService;
+import org.gatein.wsrp.WSRPConsumer;
+import org.gatein.wsrp.consumer.ConsumerException;
+import org.gatein.wsrp.consumer.EndpointConfigurationInfo;
+import org.gatein.wsrp.consumer.ProducerInfo;
+import org.gatein.wsrp.consumer.RegistrationInfo;
+
+import java.util.Collection;
+
+/**
+ * This is essentially the same class as
org.gatein.wsrp.state.consumer.ConsumerRegistryTestCase in WSRP consumer module
+ * tests.
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ConsumerRegistryTestCase extends TestCase
+{
+ private ConsumerRegistry registry;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ registry = new ConsumerRegistry();
+ registry.setFederatingPortletInvoker(new FederatingPortletInvokerService());
+ }
+
+ public void testCreateAndGet()
+ {
+ String id = "test";
+ WSRPConsumer consumer = registry.createConsumer(id, null);
+ assertNotNull(consumer);
+ assertEquals(id, consumer.getProducerId());
+ ProducerInfo info = consumer.getProducerInfo();
+ assertNotNull(info);
+ assertEquals(consumer.getProducerId(), info.getId());
+ EndpointConfigurationInfo endpoint = info.getEndpointConfigurationInfo();
+ assertNotNull(endpoint);
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ assertTrue(regInfo.isUndetermined());
+
+ WSRPConsumer fromRegistry = registry.getConsumer(id);
+ assertNotNull(fromRegistry);
+ assertEquals(consumer.getProducerId(), fromRegistry.getProducerId());
+ ProducerInfo fromRegistryInfo = fromRegistry.getProducerInfo();
+ assertNotNull(fromRegistryInfo);
+ assertEquals(fromRegistry.getProducerId(), fromRegistryInfo.getId());
+ assertNotNull(fromRegistryInfo.getEndpointConfigurationInfo());
+ assertTrue(fromRegistryInfo.getRegistrationInfo().isUndetermined());
+
+ assertEquals(info.getId(), fromRegistryInfo.getId());
+ assertEquals(info.getEndpointConfigurationInfo(),
fromRegistryInfo.getEndpointConfigurationInfo());
+ assertEquals(info.getRegistrationInfo(), fromRegistryInfo.getRegistrationInfo());
+
+ Collection consumers = registry.getConfiguredConsumers();
+ assertNotNull(consumers);
+ assertEquals(1, consumers.size());
+ assertTrue(consumers.contains(consumer));
+ }
+
+ public void testGetConsumer()
+ {
+ assertNull(registry.getConsumer("inexistent"));
+ }
+
+ public void testGetProducerInfoByKey()
+ {
+ WSRPConsumer consumer = registry.createConsumer("id", null);
+ ProducerInfo info = consumer.getProducerInfo();
+
+ String key = info.getKey();
+ assertNotNull(key);
+
+ assertEquals(info, registry.getProducerInfoByKey(key));
+ }
+
+ public void testDoubleRegistrationOfConsumerWithSameId()
+ {
+ String id = "foo";
+
+ registry.createConsumer(id, null);
+
+ try
+ {
+ registry.createConsumer(id, null);
+ fail("Shouldn't be possible to create a consumer with an existing
id");
+ }
+ catch (ConsumerException expected)
+ {
+ }
+ }
+
+ public void testDelete()
+ {
+ String id = "id";
+
+ WSRPConsumer consumer = registry.createConsumer(id, null);
+ assertEquals(consumer, registry.getConsumer(id));
+
+ String key = consumer.getProducerInfo().getKey();
+
+ registry.destroyConsumer(id);
+
+ assertNull(registry.getConsumer(id));
+ assertNull(registry.getProducerInfoByKey(key));
+ }
+
+ public void testUpdateProducerInfo()
+ {
+ // create a foo consumer
+ String id = "foo";
+ WSRPConsumer consumer = registry.createConsumer(id, null);
+ ProducerInfo info = consumer.getProducerInfo();
+ String key = info.getKey();
+
+ // change the id on the consumer's producer info and save it
+ info.setId("bar");
+ registry.updateProducerInfo(info);
+
+ assertNull(registry.getConsumer(id));
+ assertEquals(info, consumer.getProducerInfo());
+ assertEquals(info, registry.getProducerInfoByKey(key));
+ assertEquals(consumer, registry.getConsumer("bar"));
+ }
+}
Modified: portal/branches/wsrp-integration/pom.xml
===================================================================
--- portal/branches/wsrp-integration/pom.xml 2009-11-18 18:52:08 UTC (rev 653)
+++ portal/branches/wsrp-integration/pom.xml 2009-11-18 23:03:17 UTC (rev 654)
@@ -19,7 +19,8 @@
-->
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -43,27 +44,27 @@
<org.exoplatform.jcr.version>1.12.0-Beta02</org.exoplatform.jcr.version>
<org.jibx.version>1.2.1</org.jibx.version>
<org.shindig.version>SNAPSHOT-r790473</org.shindig.version>
- <org.gatein.common.version>2.0.0-Beta03</org.gatein.common.version>
+
<org.gatein.common.version>2.0.0-CR1-SNAPSHOT</org.gatein.common.version>
<org.gatein.wci.version>2.0.0-Beta02</org.gatein.wci.version>
<org.gatein.pc.version>2.1.0-Beta02</org.gatein.pc.version>
<org.jboss.identity.idm>1.0.0.Beta3</org.jboss.identity.idm>
- <org.gatein.wsrp.version>1.0.0-Beta01</org.gatein.wsrp.version>
+
<org.gatein.wsrp.version>1.0.0-Beta02-SNAPSHOT</org.gatein.wsrp.version>
<org.gatein.mop.version>1.0.0-Beta09</org.gatein.mop.version>
<version.chromattic>1.0.0-beta6</version.chromattic>
<version.reflect>1.0.0-beta3</version.reflect>
-
+
<!-- ************** -->
<!-- Build settings -->
<!-- ************** -->
-
+
<!-- maven-enforcer-plugin -->
<jdk.min.version>1.6</jdk.min.version>
<!-- maven-release-plugin -->
- <arguments>-Prelease,pkg-tomcat,pkg-jbossas
-Dmaven.test.skip=true</arguments>
-
- </properties>
-
+ <arguments>-Prelease,pkg-tomcat,pkg-jbossas
-Dmaven.test.skip=true</arguments>
+
+ </properties>
+
<scm>
<
connection>scm:svn:http://anonsvn.jboss.org/repos/gatein/portal/trunk&...
<
developerConnection>scm:svn:http://svn.jboss.org/repos/gatein/portal/t...
@@ -90,7 +91,7 @@
<scope>test</scope>
</dependency>
</dependencies>
-
+
<build>
<resources>
<resource>
@@ -117,9 +118,9 @@
<pluginManagement>
<plugins>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.1.1</version>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -169,13 +170,17 @@
<rules>
<requireProperty>
<property>gatein.checkout.dir</property>
- <message>"You must define the property
gatein.checkout.dir to give the path of the root of your working
area"</message>
+ <message>"You must define the property
gatein.checkout.dir to give the path of the root of
+ your working area"
+ </message>
</requireProperty>
<requireFilesExist>
<files>
<file>${gatein.checkout.dir}/web/portal/src/main/webapp</file>
</files>
- <message>"The following directory doesn't exist
: ${gatein.checkout.dir}/web/portal/src/main/webapp"</message>
+ <message>"The following directory doesn't exist
:
+ ${gatein.checkout.dir}/web/portal/src/main/webapp"
+ </message>
</requireFilesExist>
</rules>
<fail>true</fail>
@@ -192,11 +197,12 @@
<phase>compile</phase>
<configuration>
<tasks>
- <copy failonerror="false"
todir="${project.build.directory}/${project.build.finalName}/WEB-INF/classes">
+ <copy failonerror="false"
+
todir="${project.build.directory}/${project.build.finalName}/WEB-INF/classes">
<fileset
dir="${basedir}/src/main/webapp/WEB-INF/classes">
- <include name="**/*_en.properties" />
+ <include name="**/*_en.properties"/>
</fileset>
- <globmapper from="*_en.properties"
to="*.properties" />
+ <globmapper from="*_en.properties"
to="*.properties"/>
</copy>
</tasks>
</configuration>