[gatein-commits] gatein SVN: r2939 - in components/wsrp/trunk: producer/src/main/java/org/gatein/registration and 6 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon May 3 09:56:43 EDT 2010


Author: chris.laprun at jboss.com
Date: 2010-05-03 09:56:42 -0400 (Mon, 03 May 2010)
New Revision: 2939

Modified:
   components/wsrp/trunk/pom.xml
   components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java
   components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java
   components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java
   components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java
   components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java
   components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RegistrationHandler.java
   components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/AbstractProducerConfigurationService.java
   components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java
   components/wsrp/trunk/producer/src/test/java/org/gatein/registration/ConsumerGroupTestCase.java
   components/wsrp/trunk/producer/src/test/java/org/gatein/registration/ConsumerTestCase.java
   components/wsrp/trunk/producer/src/test/java/org/gatein/registration/DefaultRegistrationPolicyTestCase.java
   components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationManagerTestCase.java
   components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationTestCase.java
   components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPolicy.java
Log:
- GTNWSRP-35: refactored registration validation to move towards a more stateless model
  + Adding a registration now requires a check against the producer expectations.
  + Some RegistrationPolicy methods now requires passing producer expectations and the contextual RegistrationManager instead of recording references to these.
    This reduces problems with improper state management when the policy is changed and/or reloaded from persistent storage.
  + Trigger listeners after the producer configuration is reloaded so that they can be informed of changes. 
- Do not notify listeners if the new policy is equal to the old one.

Modified: components/wsrp/trunk/pom.xml
===================================================================
--- components/wsrp/trunk/pom.xml	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/pom.xml	2010-05-03 13:56:42 UTC (rev 2939)
@@ -21,7 +21,8 @@
   ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   -->
 
-<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>
 
@@ -47,7 +48,7 @@
 
    <properties>
       <version.gatein.pc>2.1.1-GA</version.gatein.pc>
-      <version.gatein.common>2.0.2-GA</version.gatein.common>
+      <version.gatein.common>2.0.3-GA-SNAPSHOT</version.gatein.common>
       <version.gatein.wci>2.0.1-GA</version.gatein.wci>
 
       <version.jsf>1.2_12</version.jsf>

Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -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.
@@ -23,6 +23,8 @@
 
 package org.gatein.registration;
 
+import org.gatein.wsrp.registration.PropertyDescription;
+
 import javax.xml.namespace.QName;
 import java.util.Collection;
 import java.util.Map;
@@ -44,7 +46,7 @@
 
    void setPersistenceManager(RegistrationPersistenceManager persistenceManager);
 
-   Registration addRegistrationTo(String consumerName, Map<QName, Object> registrationProperties, boolean createConsumerIfNeeded)
+   Registration addRegistrationTo(String consumerName, Map<QName, Object> registrationProperties, final Map<QName, ? extends PropertyDescription> expectations, boolean createConsumerIfNeeded)
       throws RegistrationException;
 
    Consumer createConsumer(String name) throws RegistrationException, InvalidConsumerDataException;

Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -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.
@@ -48,10 +48,13 @@
     *                               property value (Object) mappings
     * @param consumerIdentity       the Consumer identity (as returned by {@link #getConsumerIdFrom(String,
     *                               java.util.Map)}) for which the registration properties must be ascertained
+    * @param expectations           a Map containing the registration expectations of the producer
+    * @param manager                the RegistrationManager in which context this RegistrationPolicy is invoked
     * @throws IllegalArgumentException if any of the registration properties is invalid for the specified Consumer
     * @throws RegistrationException    if an exception occured in the registration service
     */
-   void validateRegistrationDataFor(Map<QName, Object> registrationProperties, String consumerIdentity)
+   void validateRegistrationDataFor(Map<QName, Object> registrationProperties, String consumerIdentity,
+                                    final Map<QName, ? extends PropertyDescription> expectations, final RegistrationManager manager)
       throws IllegalArgumentException, RegistrationException;
 
    /**
@@ -100,10 +103,11 @@
     * names must be unique.
     *
     * @param consumerName the name of the Consumer as passed during the registration process
+    * @param manager      the RegistrationManager in which context this RegistrationPolicy is invoked
     * @throws IllegalArgumentException if the specified Consumer name if <code>null</code> or empty
     * @throws RegistrationException    if an exception occurred in the Registration service
     */
-   void validateConsumerName(String consumerName)
+   void validateConsumerName(String consumerName, final RegistrationManager manager)
       throws IllegalArgumentException, RegistrationException;
 
    /**
@@ -111,32 +115,10 @@
     * created.
     *
     * @param groupName the name of the ConsumerGroup to be created
+    * @param manager   the RegistrationManager in which context this RegistrationPolicy is invoked
     * @throws IllegalArgumentException if the specified ConsumerGroup name if <code>null</code> or empty
     * @throws RegistrationException    if an exception occurred in the Registration service
     */
-   void validateConsumerGroupName(String groupName) throws IllegalArgumentException, RegistrationException;
+   void validateConsumerGroupName(String groupName, RegistrationManager manager) throws IllegalArgumentException, RegistrationException;
 
-   /**
-    * Retrieves the RegistrationManager with which this RegistrationPolicy is associated.
-    *
-    * @return the RegistrationManager with which this RegistrationPolicy is associated.
-    */
-   RegistrationManager getManager();
-
-   /**
-    * Associates this RegistrationPolicy with the specified RegistrationManager. This method should not be called
-    * directly by client code as it used in the wiring process of the Registration service.
-    *
-    * @param manager the RegistrationManager with which this RegistrationPolicy should be associated.
-    */
-   void setManager(RegistrationManager manager);
-
-   /**
-    * Define what the expectations are as far as acceptable registration properties go.
-    *
-    * @param registrationPropertyDescriptions
-    *         a map of containing the description of expected registrations
-    * @since 2.6.3
-    */
-   void setExpectations(Map<QName, ? extends PropertyDescription> registrationPropertyDescriptions);
 }

Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -68,7 +68,6 @@
    public void setPolicy(RegistrationPolicy policy)
    {
       this.policy = policy;
-      policy.setManager(this);
    }
 
    public RegistrationPersistenceManager getPersistenceManager()
@@ -81,14 +80,14 @@
       this.persistenceManager = persistenceManager;
    }
 
-   public Registration addRegistrationTo(String consumerName, Map<QName, Object> registrationProperties, boolean createConsumerIfNeeded)
+   public Registration addRegistrationTo(String consumerName, Map<QName, Object> registrationProperties, final Map<QName, ? extends PropertyDescription> expectations, boolean createConsumerIfNeeded)
       throws RegistrationException
    {
       // the policy determines the identity of the consumer based on the given information (note that this might be obsoleted by using WS-Security)
       String identity = policy.getConsumerIdFrom(consumerName, registrationProperties);
 
       // validate the registration information
-      policy.validateRegistrationDataFor(registrationProperties, identity);
+      policy.validateRegistrationDataFor(registrationProperties, identity, expectations, this);
 
       Consumer consumer = getOrCreateConsumer(identity, createConsumerIfNeeded, consumerName);
 
@@ -105,7 +104,7 @@
    public Consumer createConsumer(String name) throws RegistrationException, InvalidConsumerDataException
    {
       // check with policy if we allow the consumer
-      policy.validateConsumerName(name);
+      policy.validateConsumerName(name, this);
 
       String identity = policy.getConsumerIdFrom(name, Collections.<QName, Object>emptyMap());
 
@@ -127,13 +126,13 @@
       // check with the policy if we allow the group name in case we need to create it
       if (createGroupIfNeeded)
       {
-         policy.validateConsumerGroupName(groupName);
+         policy.validateConsumerGroupName(groupName, this);
       }
 
       // check with policy if we allow the consumer name in case we need to create it
       if (createConsumerIfNeeded)
       {
-         policy.validateConsumerName(consumerName);
+         policy.validateConsumerName(consumerName, this);
       }
 
       ConsumerGroup group = getConsumerGroup(groupName);
@@ -170,7 +169,7 @@
    public ConsumerGroup createConsumerGroup(String groupName) throws RegistrationException
    {
       // check with the policy if we allow the group
-      policy.validateConsumerGroupName(groupName);
+      policy.validateConsumerGroupName(groupName, this);
 
       return persistenceManager.createConsumerGroup(groupName);
    }
@@ -330,7 +329,11 @@
     */
    public void propertiesHaveChanged(Map<QName, ? extends PropertyDescription> registrationProperties)
    {
-      log.debug("Registration properties have changed, existing registrations will be invalidated...");
+      if (log.isDebugEnabled())
+      {
+         log.debug("Registration properties have changed, existing registrations will be invalidated...");
+      }
+
       Collection registrations = persistenceManager.getRegistrations();
       for (Object registration : registrations)
       {
@@ -345,9 +348,6 @@
 
 //         reg.clearAssociatedState(); //todo: do we need to clear the associated state? If we do, should we wait until current operations are done?
       }
-
-      // make policy aware of new registration properties
-      policy.setExpectations(registrationProperties);
    }
 
    /**

Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -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.
@@ -52,25 +52,35 @@
  */
 public class DefaultRegistrationPolicy implements RegistrationPolicy
 {
-   private RegistrationManager manager;
    private RegistrationPropertyValidator validator;
-   private Map<QName, ? extends PropertyDescription> expectations;
    private static final Logger log = LoggerFactory.getLogger(DefaultRegistrationPolicy.class);
 
-
-   public RegistrationManager getManager()
+   @Override
+   public boolean equals(Object o)
    {
-      return manager;
-   }
+      if (this == o)
+      {
+         return true;
+      }
+      if (o == null || getClass() != o.getClass())
+      {
+         return false;
+      }
 
-   public void setManager(RegistrationManager manager)
-   {
-      this.manager = manager;
+      DefaultRegistrationPolicy that = (DefaultRegistrationPolicy)o;
+
+      if (!validator.equals(that.validator))
+      {
+         return false;
+      }
+
+      return true;
    }
 
-   public void setExpectations(Map<QName, ? extends PropertyDescription> registrationPropertyDescriptions)
+   @Override
+   public int hashCode()
    {
-      this.expectations = registrationPropertyDescriptions;
+      return validator.hashCode();
    }
 
    /**
@@ -80,7 +90,8 @@
     * @throws DuplicateRegistrationException if a Consumer with the same identity has already registered with the same
     *                                        registration properties.
     */
-   public void validateRegistrationDataFor(Map<QName, Object> registrationProperties, String consumerIdentity)
+   public void validateRegistrationDataFor(Map<QName, Object> registrationProperties, String consumerIdentity,
+                                           final Map<QName, ? extends PropertyDescription> expectations, final RegistrationManager manager)
       throws IllegalArgumentException, RegistrationException
    {
       ParameterValidation.throwIllegalArgExceptionIfNull(registrationProperties, "Registration properties");
@@ -169,7 +180,7 @@
    }
 
    /** Rejects registration if a Consumer with the specified name already exists. */
-   public void validateConsumerName(String consumerName) throws IllegalArgumentException, RegistrationException
+   public void validateConsumerName(String consumerName, final RegistrationManager manager) throws IllegalArgumentException, RegistrationException
    {
       ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerName, "Consumer name", null);
 
@@ -181,7 +192,7 @@
    }
 
    /** Rejects name if a ConsumerGroup with the specified name already exists. */
-   public void validateConsumerGroupName(String groupName) throws IllegalArgumentException, RegistrationException
+   public void validateConsumerGroupName(String groupName, RegistrationManager manager) throws IllegalArgumentException, RegistrationException
    {
       // this is already the behavior in the RegistrationPersistenceManager so no need to do anything
    }

Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -52,10 +52,10 @@
       return delegate;
    }
 
-   public void validateRegistrationDataFor(Map<QName, Object> registrationProperties, String consumerIdentity)
+   public void validateRegistrationDataFor(Map<QName, Object> registrationProperties, String consumerIdentity, final Map<QName, ? extends PropertyDescription> expectations, final RegistrationManager manager)
       throws IllegalArgumentException, RegistrationException
    {
-      delegate.validateRegistrationDataFor(registrationProperties, consumerIdentity);
+      delegate.validateRegistrationDataFor(registrationProperties, consumerIdentity, expectations, manager);
    }
 
    public String createRegistrationHandleFor(String registrationId)
@@ -76,33 +76,18 @@
       return delegate.getConsumerIdFrom(sanitizeConsumerName(consumerName), registrationProperties);
    }
 
-   public void validateConsumerName(String consumerName)
+   public void validateConsumerName(String consumerName, final RegistrationManager manager)
       throws IllegalArgumentException, RegistrationException
    {
-      delegate.validateConsumerName(consumerName);
+      delegate.validateConsumerName(consumerName, manager);
    }
 
-   public void validateConsumerGroupName(String groupName)
+   public void validateConsumerGroupName(String groupName, RegistrationManager manager)
       throws IllegalArgumentException, RegistrationException
    {
-      delegate.validateConsumerGroupName(groupName);
+      delegate.validateConsumerGroupName(groupName, manager);
    }
 
-   public RegistrationManager getManager()
-   {
-      return delegate.getManager();
-   }
-
-   public void setManager(RegistrationManager manager)
-   {
-      delegate.setManager(manager);
-   }
-
-   public void setExpectations(Map<QName, ? extends PropertyDescription> registrationPropertyDescriptions)
-   {
-      delegate.setExpectations(registrationPropertyDescriptions);
-   }
-
    static String sanitizeConsumerName(String consumerName)
    {
       ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerName, "Consumer name", null);

Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RegistrationHandler.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RegistrationHandler.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/RegistrationHandler.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -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.
@@ -71,7 +71,8 @@
 
    public RegistrationContext register(RegistrationData registrationData) throws MissingParameters, OperationFailed
    {
-      if (producer.getProducerRegistrationRequirements().isRegistrationRequired())
+      ProducerRegistrationRequirements registrationRequirements = producer.getProducerRegistrationRequirements();
+      if (registrationRequirements.isRegistrationRequired())
       {
          WSRPExceptionFactory.throwOperationFailedIfValueIsMissing(registrationData, "RegistrationData");
          String consumerName = registrationData.getConsumerName();
@@ -88,7 +89,7 @@
             // check that the consumer agent is valid before trying to register
             RegistrationUtils.validateConsumerAgent(consumerAgent);
 
-            registration = producer.getRegistrationManager().addRegistrationTo(consumerName, createRegistrationProperties(registrationData), true);
+            registration = producer.getRegistrationManager().addRegistrationTo(consumerName, createRegistrationProperties(registrationData), registrationRequirements.getRegistrationProperties(), true);
             updateRegistrationInformation(registration, registrationData);
          }
          catch (Exception e)
@@ -218,7 +219,7 @@
 
             // check that the given registration properties are acceptable according to expectations and policy
             ProducerRegistrationRequirements req = producer.getProducerRegistrationRequirements();
-            req.getPolicy().validateRegistrationDataFor(properties, consumerName);
+            req.getPolicy().validateRegistrationDataFor(properties, consumerName, req.getRegistrationProperties(), producer.getRegistrationManager());
 
             registration.updateProperties(properties);
             updateRegistrationInformation(registration, registrationData);

Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/AbstractProducerConfigurationService.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/AbstractProducerConfigurationService.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/AbstractProducerConfigurationService.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -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.
@@ -67,12 +67,13 @@
       // reload
       loadConfiguration();
 
-      // restore listeners
+      // restore listeners and trigger them
       if (listeners != null)
       {
          for (ProducerConfigurationChangeListener listener : listeners)
          {
             configuration.addChangeListener(listener);
+            listener.usingStrictModeChangedTo(configuration.isUsingStrictMode());
          }
       }
       registrationRequirements = configuration.getRegistrationRequirements();
@@ -83,6 +84,7 @@
             for (RegistrationPropertyChangeListener listener : propertyListeners)
             {
                registrationRequirements.addRegistrationPropertyChangeListener(listener);
+               listener.propertiesHaveChanged(registrationRequirements.getRegistrationProperties());
             }
          }
          if (policyListeners != null)
@@ -90,6 +92,7 @@
             for (RegistrationPolicyChangeListener listener : policyListeners)
             {
                registrationRequirements.addRegistrationPolicyChangeListener(listener);
+               listener.policyUpdatedTo(registrationRequirements.getPolicy());
             }
          }
       }

Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -260,22 +260,23 @@
 
    public void setPolicy(RegistrationPolicy policy)
    {
-      this.policy = policy;
-
-      if (policy != null)
+      if (ParameterValidation.isOldAndNewDifferent(this.policy, policy))
       {
-         policyClassName = policy.getClass().getName();
+         this.policy = policy;
 
-         if (policy instanceof DefaultRegistrationPolicy)
+         if (policy != null)
          {
-            DefaultRegistrationPolicy registrationPolicy = (DefaultRegistrationPolicy)policy;
-            validatorClassName = registrationPolicy.getValidator().getClass().getName();
+            policyClassName = policy.getClass().getName();
+
+            if (policy instanceof DefaultRegistrationPolicy)
+            {
+               DefaultRegistrationPolicy registrationPolicy = (DefaultRegistrationPolicy)policy;
+               validatorClassName = registrationPolicy.getValidator().getClass().getName();
+            }
          }
 
-         this.policy.setExpectations(registrationProperties);
+         notifyRegistrationPolicyChangeListeners();
       }
-
-      notifyRegistrationPolicyChangeListeners();
    }
 
    public RegistrationPolicy getPolicy()

Modified: components/wsrp/trunk/producer/src/test/java/org/gatein/registration/ConsumerGroupTestCase.java
===================================================================
--- components/wsrp/trunk/producer/src/test/java/org/gatein/registration/ConsumerGroupTestCase.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/test/java/org/gatein/registration/ConsumerGroupTestCase.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -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;
 
@@ -46,7 +46,6 @@
       RegistrationPolicy policy = new DefaultRegistrationPolicy();
       manager.setPolicy(policy);
       manager.setPersistenceManager(new RegistrationPersistenceManagerImpl());
-      policy.setManager(manager);
       group = manager.createConsumerGroup(NAME);
    }
 

Modified: components/wsrp/trunk/producer/src/test/java/org/gatein/registration/ConsumerTestCase.java
===================================================================
--- components/wsrp/trunk/producer/src/test/java/org/gatein/registration/ConsumerTestCase.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/test/java/org/gatein/registration/ConsumerTestCase.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -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;
 
@@ -27,6 +27,9 @@
 import org.gatein.registration.impl.RegistrationManagerImpl;
 import org.gatein.registration.impl.RegistrationPersistenceManagerImpl;
 import org.gatein.registration.policies.DefaultRegistrationPolicy;
+import org.gatein.registration.policies.DefaultRegistrationPropertyValidator;
+import org.gatein.wsrp.WSRPConstants;
+import org.gatein.wsrp.registration.RegistrationPropertyDescription;
 
 import javax.xml.namespace.QName;
 import java.util.Collections;
@@ -42,14 +45,15 @@
 {
    private Consumer consumer;
    private RegistrationManager manager;
+   private static final Map<QName, RegistrationPropertyDescription> EMPTY_EXPECTATIONS = Collections.emptyMap();
 
    protected void setUp() throws Exception
    {
       manager = new RegistrationManagerImpl();
-      RegistrationPolicy policy = new DefaultRegistrationPolicy();
+      DefaultRegistrationPolicy policy = new DefaultRegistrationPolicy();
+      policy.setValidator(new DefaultRegistrationPropertyValidator());
       manager.setPolicy(policy);
       manager.setPersistenceManager(new RegistrationPersistenceManagerImpl());
-      policy.setManager(manager);
       consumer = manager.createConsumer("name");
    }
 
@@ -65,7 +69,7 @@
       String name = consumer.getName();
 
       // adding a registration that isn't validated doesn't change the status
-      Registration registration = manager.addRegistrationTo(name, Collections.<QName, Object>emptyMap(), false);
+      Registration registration = manager.addRegistrationTo(name, Collections.<QName, Object>emptyMap(), EMPTY_EXPECTATIONS, false);
       assertEquals(RegistrationStatus.PENDING, consumer.getStatus());
 
       // but the consumer's status should become valid if the registration becomes so as well
@@ -75,8 +79,12 @@
       // adding a new registration makes the consumer's status pending
       // need to change the registration props to register this consumer again
       Map<QName, Object> props = new HashMap<QName, Object>(1);
-      props.put(new QName("prop"), "value");
-      registration = manager.addRegistrationTo(name, props, false);
+      QName propName = new QName("prop");
+      props.put(propName, "value");
+      // need to change the expectations to allow the new registration property
+      Map<QName, RegistrationPropertyDescription> expectations = new HashMap<QName, RegistrationPropertyDescription>();
+      expectations.put(propName, new RegistrationPropertyDescription(propName, WSRPConstants.XSD_STRING));
+      registration = manager.addRegistrationTo(name, props, expectations, false);
       assertEquals(2, consumer.getRegistrations().size());
       assertEquals(RegistrationStatus.PENDING, consumer.getStatus());
 

Modified: components/wsrp/trunk/producer/src/test/java/org/gatein/registration/DefaultRegistrationPolicyTestCase.java
===================================================================
--- components/wsrp/trunk/producer/src/test/java/org/gatein/registration/DefaultRegistrationPolicyTestCase.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/test/java/org/gatein/registration/DefaultRegistrationPolicyTestCase.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -1,5 +1,24 @@
 /*
- * Copyright (c) 2007, Your Corporation. All Rights Reserved.
+ * 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;
@@ -30,6 +49,7 @@
    private static final QName PROP1 = new QName("prop1");
    private static final QName PROP2 = new QName("prop2");
    private static final QName PROP3 = new QName("prop3");
+   private RegistrationManager manager;
 
    @Override
    protected void setUp() throws Exception
@@ -38,26 +58,23 @@
 
       policy.setValidator(new DefaultRegistrationPropertyValidator());
 
-      RegistrationManager manager = new RegistrationManagerImpl();
+      manager = new RegistrationManagerImpl();
       manager.setPolicy(policy);
       manager.setPersistenceManager(new RegistrationPersistenceManagerImpl());
       manager.createConsumer(CONSUMER);
 
-      policy.setManager(manager);
-
       registrationProperties = new HashMap<QName, Object>();
       registrationProperties.put(PROP1, "value1");
       registrationProperties.put(PROP2, "value2");
 
       expectations = new HashMap<QName, PropertyDescription>();
-      policy.setExpectations(expectations);
    }
 
    public void testValidateRegistrationDataForNull() throws RegistrationException
    {
       try
       {
-         policy.validateRegistrationDataFor(null, "foo");
+         policy.validateRegistrationDataFor(null, "foo", expectations, manager);
          fail("null data cannot be validated");
       }
       catch (IllegalArgumentException e)
@@ -67,7 +84,7 @@
 
       try
       {
-         policy.validateRegistrationDataFor(Collections.<QName, Object>emptyMap(), null);
+         policy.validateRegistrationDataFor(Collections.<QName, Object>emptyMap(), null, expectations, manager);
          fail("null data cannot be validated");
       }
       catch (IllegalArgumentException e)
@@ -80,7 +97,7 @@
    {
       try
       {
-         policy.validateRegistrationDataFor(Collections.<QName, Object>emptyMap(), "foo");
+         policy.validateRegistrationDataFor(Collections.<QName, Object>emptyMap(), "foo", expectations, manager);
       }
       catch (RegistrationException e)
       {
@@ -96,7 +113,7 @@
 
       try
       {
-         policy.validateRegistrationDataFor(registrationProperties, CONSUMER);
+         policy.validateRegistrationDataFor(registrationProperties, CONSUMER, expectations, manager);
          fail("Missing prop3 should have been detected");
       }
       catch (RegistrationException e)
@@ -111,7 +128,7 @@
 
       try
       {
-         policy.validateRegistrationDataFor(registrationProperties, CONSUMER);
+         policy.validateRegistrationDataFor(registrationProperties, CONSUMER, expectations, manager);
          fail("Extra prop2 should have been detected");
       }
       catch (RegistrationException e)
@@ -129,7 +146,7 @@
 
       try
       {
-         policy.validateRegistrationDataFor(registrationProperties, CONSUMER);
+         policy.validateRegistrationDataFor(registrationProperties, CONSUMER, expectations, manager);
          fail("Should have detected null value for prop1");
       }
       catch (RegistrationException e)

Modified: components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationManagerTestCase.java
===================================================================
--- components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationManagerTestCase.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationManagerTestCase.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -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;
 
@@ -27,6 +27,9 @@
 import org.gatein.registration.impl.RegistrationManagerImpl;
 import org.gatein.registration.impl.RegistrationPersistenceManagerImpl;
 import org.gatein.registration.policies.DefaultRegistrationPolicy;
+import org.gatein.registration.policies.DefaultRegistrationPropertyValidator;
+import org.gatein.wsrp.WSRPConstants;
+import org.gatein.wsrp.registration.RegistrationPropertyDescription;
 
 import javax.xml.namespace.QName;
 import java.util.Collection;
@@ -43,32 +46,38 @@
 
    private RegistrationManager manager;
    private Map<QName, Object> registrationProperties;
+   private Map<QName, RegistrationPropertyDescription> expectations;
 
    protected void setUp() throws Exception
    {
       manager = new RegistrationManagerImpl();
-      // todo: policy will need access to registration configuration information to validate properties
-      RegistrationPolicy policy = new DefaultRegistrationPolicy();
+
+      DefaultRegistrationPolicy policy = new DefaultRegistrationPolicy();
+      policy.setValidator(new DefaultRegistrationPropertyValidator());
       manager.setPolicy(policy);
       manager.setPersistenceManager(new RegistrationPersistenceManagerImpl());
-      policy.setManager(manager);
 
       //todo: registration properties setup will need to be updated when property validation is implemented
+      QName prop1Name = new QName("prop1");
+      QName prop2Name = new QName("prop2");
       registrationProperties = new HashMap<QName, Object>();
-      registrationProperties.put(new QName("prop1"), "value1");
-      registrationProperties.put(new QName("prop2"), "value2");
+      registrationProperties.put(prop1Name, "value1");
+      registrationProperties.put(prop2Name, "value2");
+
+      expectations = new HashMap<QName, RegistrationPropertyDescription>();
+      expectations.put(prop1Name, new RegistrationPropertyDescription(prop1Name, WSRPConstants.XSD_STRING));
+      expectations.put(prop2Name, new RegistrationPropertyDescription(prop2Name, WSRPConstants.XSD_STRING));
    }
 
    public void testPolicy()
    {
       RegistrationPolicy policy = manager.getPolicy();
       assertNotNull(policy);
-      assertEquals(manager, policy.getManager());
    }
 
    public void testAddRegistrationTo() throws Exception
    {
-      Registration registration = manager.addRegistrationTo("consumerName", registrationProperties, true);
+      Registration registration = manager.addRegistrationTo("consumerName", registrationProperties, expectations, true);
       assertNotNull(registration);
       assertNotNull(registration.getPersistentKey());
 
@@ -85,7 +94,7 @@
    {
       try
       {
-         manager.addRegistrationTo("consumerName", registrationProperties, false);
+         manager.addRegistrationTo("consumerName", registrationProperties, expectations, false);
          fail("Should have failed: consumer does not exist");
       }
       catch (NoSuchRegistrationException expected)
@@ -142,7 +151,6 @@
          }
       };
       manager.setPolicy(policy);
-      policy.setManager(manager);
 
       String name = "name";
       Consumer consumer = manager.createConsumer(name);
@@ -286,7 +294,7 @@
       Consumer consumer = manager.addConsumerToGroupNamed(consumerName, groupName, true, true);
       String consumerIdentity = consumer.getId();
 
-      Registration reg = manager.addRegistrationTo(consumerName, registrationProperties, false);
+      Registration reg = manager.addRegistrationTo(consumerName, registrationProperties, expectations, false);
       String handle = reg.getRegistrationHandle();
 
       ConsumerGroup group = manager.getConsumerGroup(groupName);
@@ -302,7 +310,7 @@
       Consumer consumer = manager.createConsumer(consumerName);
       String consumerIdentity = consumer.getId();
 
-      Registration reg = manager.addRegistrationTo(consumerName, registrationProperties, false);
+      Registration reg = manager.addRegistrationTo(consumerName, registrationProperties, expectations, false);
       String handle = reg.getRegistrationHandle();
 
       manager.removeConsumer(consumer);
@@ -315,7 +323,7 @@
       String consumerName = "consumer";
       Consumer consumer = manager.createConsumer(consumerName);
 
-      Registration reg = manager.addRegistrationTo(consumerName, registrationProperties, false);
+      Registration reg = manager.addRegistrationTo(consumerName, registrationProperties, expectations, false);
       String handle = reg.getRegistrationHandle();
 
       assertTrue(consumer.getRegistrations().contains(reg));
@@ -336,30 +344,35 @@
       String consumerName = "consumer";
       Consumer consumer = manager.createConsumer(consumerName);
 
-      Registration reg = manager.addRegistrationTo(consumerName, registrationProperties, false);
+      Registration reg = manager.addRegistrationTo(consumerName, registrationProperties, expectations, false);
       String handle = reg.getRegistrationHandle();
 
-      // todo: this won't work anymore when properties validation is implemented
-      registrationProperties.put(new QName("prop3"), "value3");
-      Registration r2 = manager.addRegistrationTo(consumerName, registrationProperties, false);
-
       RegistrationStatus status = consumer.getStatus();
-
       manager.removeRegistration(handle);
 
       // consumer status shouldn't have changed
       assertEquals(status, consumer.getStatus());
 
-      // should still be able to retrieve consumer from r2 handle
-      assertEquals(consumer, manager.getConsumerFor(r2.getRegistrationHandle()));
-
-      // ... but not from handle
+      // Shouldn't be possible to retrieve consumer from handle anymore
       assertNull(manager.getConsumerFor(handle));
    }
 
    public void testAddRegistrationWithInvalidRegistrationProperties() throws Exception
    {
-      // todo: implement
+      String consumerName = "consumer";
+      Consumer consumer = manager.createConsumer(consumerName);
+
+      registrationProperties.put(new QName("prop3"), "value3");
+      try
+      {
+         manager.addRegistrationTo(consumerName, registrationProperties, expectations, false);
+         fail("Expectations does not contain prop3, so trying to register with a value for it should fail");
+      }
+      catch (RegistrationException e)
+      {
+         assertTrue(e.getMessage().contains("prop3"));
+         assertEquals(0, consumer.getRegistrations().size());
+      }
    }
 
    public void testRemoveInexistentRegistration() throws RegistrationException
@@ -407,8 +420,8 @@
       manager.createConsumer("c2");
       manager.addConsumerToGroupNamed("c1g1", "g1", true, true);
       manager.createConsumerGroup("g2");
-      Registration r1 = manager.addRegistrationTo("c1", registrationProperties, false);
-      Registration r2 = manager.addRegistrationTo("c3", registrationProperties, true);
+      Registration r1 = manager.addRegistrationTo("c1", registrationProperties, expectations, false);
+      Registration r2 = manager.addRegistrationTo("c3", registrationProperties, expectations, true);
 
       manager.clear();
       assertTrue(manager.getConsumerGroups().isEmpty());

Modified: components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationTestCase.java
===================================================================
--- components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationTestCase.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationTestCase.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -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;
 
@@ -27,6 +27,9 @@
 import org.gatein.registration.impl.RegistrationManagerImpl;
 import org.gatein.registration.impl.RegistrationPersistenceManagerImpl;
 import org.gatein.registration.policies.DefaultRegistrationPolicy;
+import org.gatein.wsrp.WSRPConstants;
+import org.gatein.wsrp.registration.PropertyDescription;
+import org.gatein.wsrp.registration.RegistrationPropertyDescription;
 
 import javax.xml.namespace.QName;
 import java.util.HashMap;
@@ -47,20 +50,25 @@
       RegistrationManager manager = new RegistrationManagerImpl();
       RegistrationPolicy policy = new DefaultRegistrationPolicy()
       {
-         public void validateRegistrationDataFor(Map<QName, Object> registrationProperties, String consumerIdentity) throws IllegalArgumentException, RegistrationException, DuplicateRegistrationException
+         public void validateRegistrationDataFor(Map<QName, Object> registrationProperties, String consumerIdentity, final Map<QName, ? extends PropertyDescription> expectations, final RegistrationManager manager) throws IllegalArgumentException, RegistrationException, DuplicateRegistrationException
          {
             // accept any registration data here
          }
       };
       manager.setPolicy(policy);
       manager.setPersistenceManager(new RegistrationPersistenceManagerImpl());
-      policy.setManager(manager);
 
       registrationProperties = new HashMap<QName, Object>();
-      registrationProperties.put(new QName("prop1"), "value1");
-      registrationProperties.put(new QName("prop2"), "value2");
+      QName prop1Name = new QName("prop1");
+      registrationProperties.put(prop1Name, "value1");
+      QName prop2Name = new QName("prop2");
+      registrationProperties.put(prop2Name, "value2");
 
-      registration = manager.addRegistrationTo("name", registrationProperties, true);
+      Map<QName, RegistrationPropertyDescription> expectations = new HashMap<QName, RegistrationPropertyDescription>();
+      expectations.put(prop1Name, new RegistrationPropertyDescription(prop1Name, WSRPConstants.XSD_STRING));
+      expectations.put(prop2Name, new RegistrationPropertyDescription(prop2Name, WSRPConstants.XSD_STRING));
+
+      registration = manager.addRegistrationTo("name", registrationProperties, expectations, true);
    }
 
    public void testGetPropertiesIsUnmodifiable()

Modified: components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPolicy.java
===================================================================
--- components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPolicy.java	2010-05-03 13:39:39 UTC (rev 2938)
+++ components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPolicy.java	2010-05-03 13:56:42 UTC (rev 2939)
@@ -1,25 +1,25 @@
-/******************************************************************************
- * 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.                   *
- ******************************************************************************/
+/*
+ * 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.wsrp.producer.config;
 
@@ -39,7 +39,7 @@
  */
 public class TestRegistrationPolicy implements RegistrationPolicy
 {
-   public void validateRegistrationDataFor(Map<QName, Object> registrationProperties, String consumerIdentity) throws IllegalArgumentException, RegistrationException
+   public void validateRegistrationDataFor(Map<QName, Object> registrationProperties, String consumerIdentity, final Map<QName, ? extends PropertyDescription> expectations, final RegistrationManager manager) throws IllegalArgumentException, RegistrationException
    {
    }
 
@@ -58,24 +58,12 @@
       return null;
    }
 
-   public void validateConsumerName(String consumerName) throws IllegalArgumentException, RegistrationException
+   public void validateConsumerName(String consumerName, final RegistrationManager manager) throws IllegalArgumentException, RegistrationException
    {
    }
 
-   public void validateConsumerGroupName(String groupName) throws IllegalArgumentException, RegistrationException
+   public void validateConsumerGroupName(String groupName, RegistrationManager manager) throws IllegalArgumentException, RegistrationException
    {
    }
 
-   public RegistrationManager getManager()
-   {
-      return null;
-   }
-
-   public void setManager(RegistrationManager manager)
-   {
-   }
-
-   public void setExpectations(Map<QName, ? extends PropertyDescription> registrationPropertyDescriptions)
-   {
-   }
 }



More information about the gatein-commits mailing list