Author: chris.laprun(a)jboss.com
Date: 2010-06-23 09:13:02 -0400 (Wed, 23 Jun 2010)
New Revision: 3433
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java
components/wsrp/trunk/producer/src/test/java/org/gatein/registration/AbstractRegistrationPersistenceManagerTestCase.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/V1ProducerBaseTest.java
Log:
- createConsumer should return a Consumer with an initialized persistent key. Added
associated test case, which reminds me that we should have the same test for the JCR
implementation. :/
- Fixed V1ProducerBaseTest which was setting the persistent key when it really should have
been done by the RegistrationManager during Consumer creation.
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java 2010-06-23
10:22:08 UTC (rev 3432)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java 2010-06-23
13:13:02 UTC (rev 3433)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * Copyright 2010, 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.
@@ -126,7 +126,9 @@
@Override
protected ConsumerSPI internalCreateConsumer(String consumerId, String consumerName)
{
- return newConsumerSPI(consumerId, consumerName);
+ ConsumerSPI consumerSPI = newConsumerSPI(consumerId, consumerName);
+ consumerSPI.setPersistentKey(consumerId);
+ return consumerSPI;
}
public ConsumerSPI newConsumerSPI(String consumerId, String consumerName)
@@ -149,7 +151,9 @@
@Override
protected ConsumerGroupSPI internalCreateConsumerGroup(String name)
{
- return newConsumerGroupSPI(name);
+ ConsumerGroupSPI groupSPI = newConsumerGroupSPI(name);
+ groupSPI.setPersistentKey(name);
+ return groupSPI;
}
public ConsumerGroupSPI newConsumerGroupSPI(String name)
Modified:
components/wsrp/trunk/producer/src/test/java/org/gatein/registration/AbstractRegistrationPersistenceManagerTestCase.java
===================================================================
---
components/wsrp/trunk/producer/src/test/java/org/gatein/registration/AbstractRegistrationPersistenceManagerTestCase.java 2010-06-23
10:22:08 UTC (rev 3432)
+++
components/wsrp/trunk/producer/src/test/java/org/gatein/registration/AbstractRegistrationPersistenceManagerTestCase.java 2010-06-23
13:13:02 UTC (rev 3433)
@@ -1,25 +1,25 @@
-/******************************************************************************
- * 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. *
- ******************************************************************************/
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.registration;
import junit.framework.TestCase;
@@ -80,15 +80,40 @@
stopInteraction();
}
- public void testAddGroup() throws Exception
+ public void testCreateConsumer() throws RegistrationException
{
startInteraction();
+ Consumer consumer = getManager().createConsumer("Bar", "Bar");
+ assertNotNull(consumer);
+ assertEquals("Bar", consumer.getName());
+ assertTrue(consumer.getRegistrations().isEmpty());
+ assertNull(consumer.getGroup());
+ assertNotNull(consumer.getPersistentKey());
+ assertNull(consumer.getConsumerAgent());
+ assertNotNull(consumer.getCapabilities());
+ assertEquals(RegistrationStatus.PENDING, consumer.getStatus());
+ stopInteraction();
+ }
+
+ public void testCreateGroup() throws RegistrationException
+ {
+ startInteraction();
ConsumerGroup group = getManager().createConsumerGroup("Foo");
assertNotNull(group);
+ assertNotNull(group.getPersistentKey());
assertEquals("Foo", group.getName());
- assertEquals(Collections.EMPTY_LIST, new ArrayList(group.getConsumers()));
+ assertTrue(group.getConsumers().isEmpty());
+ assertEquals(RegistrationStatus.PENDING, group.getStatus());
stopInteraction();
+ }
+ public void testAddGroup() throws Exception
+ {
+ startInteraction();
+ ConsumerGroup group = getManager().createConsumerGroup("Foo");
+ assertNotNull(group);
+ stopInteraction();
+
// Test by retrieving the same consumer
startInteraction();
group = getManager().getConsumerGroup("Foo");
@@ -201,9 +226,6 @@
startInteraction();
Consumer consumer = getManager().createConsumer("Bar", "Bar");
group.addConsumer(consumer);
- assertNotNull(consumer);
- assertEquals("Bar", consumer.getName());
- assertEquals(Collections.EMPTY_LIST, new ArrayList(consumer.getRegistrations()));
assertEquals("Foo", consumer.getGroup().getName());
stopInteraction();
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/V1ProducerBaseTest.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/V1ProducerBaseTest.java 2010-06-23
10:22:08 UTC (rev 3432)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/V1ProducerBaseTest.java 2010-06-23
13:13:02 UTC (rev 3433)
@@ -23,10 +23,8 @@
package org.gatein.wsrp.protocol.v1;
-import org.gatein.registration.Consumer;
import org.gatein.registration.RegistrationException;
import org.gatein.registration.RegistrationManager;
-import org.gatein.registration.impl.ConsumerImpl;
import org.gatein.registration.policies.DefaultRegistrationPolicy;
import org.gatein.registration.policies.DefaultRegistrationPropertyValidator;
import org.gatein.wsrp.WSRPConstants;
@@ -179,8 +177,7 @@
// create consumer for policy to be able to make decisions properly
try
{
- Consumer consumer = registrationManager.createConsumer(CONSUMER);
-
((ConsumerImpl)consumer).setPersistentKey("test_consumer_persistent_key");
+ registrationManager.createConsumer(CONSUMER);
}
catch (RegistrationException e)
{