Author: chris.laprun(a)jboss.com
Date: 2007-02-07 15:52:40 -0500 (Wed, 07 Feb 2007)
New Revision: 6185
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java
trunk/wsrp/src/resources/tests/test-producer-configuration-lib-jar/custom-policy.xml
trunk/wsrp/src/resources/tests/test-producer-configuration-lib-jar/invalid3.xml
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/config/ProducerConfigurationTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerConfigurationFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java
Log:
- More validation on configuration and associated tests.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/config/ProducerConfigurationTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/config/ProducerConfigurationTestCase.java 2007-02-07
15:53:15 UTC (rev 6184)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/config/ProducerConfigurationTestCase.java 2007-02-07
20:52:40 UTC (rev 6185)
@@ -61,13 +61,21 @@
factory = new ProducerConfigurationFactory();
}
+ public void testCustomPolicyUnmarshalling() throws Exception
+ {
+ ProducerConfiguration producerConfiguration =
getProducerConfiguration("custom-policy.xml");
+ ProducerRegistrationRequirements requirements =
producerConfiguration.getRegistrationRequirements();
+ assertNotNull(requirements);
+ RegistrationPolicy policy = requirements.getPolicy();
+ assertTrue(policy instanceof TestRegistrationPolicy);
+ }
+
public void testExtendedUnmarshalling() throws Exception
{
ProducerConfiguration producerConfiguration =
getProducerConfiguration("extended.xml");
ProducerRegistrationRequirements requirements =
producerConfiguration.getRegistrationRequirements();
assertNotNull(requirements);
RegistrationPolicy policy = requirements.getPolicy();
- assertNotNull(policy);
assertTrue(policy instanceof DefaultRegistrationPolicy);
RegistrationPropertyValidator propertyValidator =
((DefaultRegistrationPolicy)policy).getValidator();
assertNotNull(propertyValidator);
@@ -113,6 +121,15 @@
catch (Exception expected)
{
}
+
+ try
+ {
+ getProducerConfiguration("invalid3.xml");
+ fail("Doesn't make sense to define a property validator if a
registration policy other than DefaultRegistrationPolicy");
+ }
+ catch (Exception expected)
+ {
+ }
}
private ProducerConfiguration getProducerConfiguration(String fileName)
Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java 2007-02-07
20:52:40 UTC (rev 6185)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * 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.config;
+
+import org.jboss.portal.registration.InvalidConsumerDataException;
+import org.jboss.portal.registration.RegistrationException;
+import org.jboss.portal.registration.RegistrationManager;
+import org.jboss.portal.registration.RegistrationPolicy;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class TestRegistrationPolicy implements RegistrationPolicy
+{
+ public void validateRegistrationDataFor(Map registrationProperties, String
consumerIdentity) throws IllegalArgumentException, RegistrationException
+ {
+ }
+
+ public String createRegistrationHandleFor(String registrationId) throws
IllegalArgumentException
+ {
+ return null;
+ }
+
+ public String getAutomaticGroupNameFor(String consumerName) throws
IllegalArgumentException
+ {
+ return null;
+ }
+
+ public String getConsumerIdFrom(String consumerName, Map registrationProperties)
throws IllegalArgumentException, InvalidConsumerDataException
+ {
+ return null;
+ }
+
+ public void validateConsumerName(String consumerName) throws IllegalArgumentException,
RegistrationException
+ {
+ }
+
+ public void validateConsumerGroupName(String groupName) throws
IllegalArgumentException, RegistrationException
+ {
+ }
+
+ public RegistrationManager getManager()
+ {
+ return null;
+ }
+
+ public void setManager(RegistrationManager manager)
+ {
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerConfigurationFactory.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerConfigurationFactory.java 2007-02-07
15:53:15 UTC (rev 6184)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerConfigurationFactory.java 2007-02-07
20:52:40 UTC (rev 6185)
@@ -208,6 +208,11 @@
System.out.println("addchild conf regReq " + localName);
}
+ if
(!ProducerRegistrationRequirementsImpl.DEFAULT_POLICY_CLASS_NAME.equals(regReq.getPolicyClassName())
&& regReq.getValidatorClassName() != null)
+ {
+ throw new IllegalStateException("Doesn't make sense to define a
property validator without using DefaultRegistrationPolicy!");
+ }
+
if (conf.getRegistrationRequirements() != null)
{
throw new IllegalStateException("ProducerConfiguration already has
registration information set!");
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java 2007-02-07
15:53:15 UTC (rev 6184)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java 2007-02-07
20:52:40 UTC (rev 6185)
@@ -55,6 +55,7 @@
/** property name (QName) -> PropertyDescription */
private Map registrationProperties;
+ public final static String DEFAULT_POLICY_CLASS_NAME =
"org.jboss.portal.registration.policies.DefaultRegistrationPolicy";
public ProducerRegistrationRequirementsImpl(boolean requiresMarshalling, boolean
requiresRegistration, boolean fullServiceDescriptionRequiresRegistration)
{
@@ -270,8 +271,23 @@
this.policyClassName = policyClassName;
}
+ public String getPolicyClassName()
+ {
+ if (policyClassName == null)
+ {
+ return DEFAULT_POLICY_CLASS_NAME;
+ }
+
+ return policyClassName;
+ }
+
public void setValidatorClassName(String validatorClassName)
{
this.validatorClassName = validatorClassName;
}
+
+ public String getValidatorClassName()
+ {
+ return validatorClassName;
+ }
}
Added:
trunk/wsrp/src/resources/tests/test-producer-configuration-lib-jar/custom-policy.xml
===================================================================
--- trunk/wsrp/src/resources/tests/test-producer-configuration-lib-jar/custom-policy.xml
(rev 0)
+++
trunk/wsrp/src/resources/tests/test-producer-configuration-lib-jar/custom-policy.xml 2007-02-07
20:52:40 UTC (rev 6185)
@@ -0,0 +1,28 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<producer-configuration>
+ <registration-configuration>
+
<registration-policy>org.jboss.portal.test.wsrp.config.TestRegistrationPolicy</registration-policy>
+ </registration-configuration>
+</producer-configuration>
\ No newline at end of file
Added: trunk/wsrp/src/resources/tests/test-producer-configuration-lib-jar/invalid3.xml
===================================================================
--- trunk/wsrp/src/resources/tests/test-producer-configuration-lib-jar/invalid3.xml
(rev 0)
+++
trunk/wsrp/src/resources/tests/test-producer-configuration-lib-jar/invalid3.xml 2007-02-07
20:52:40 UTC (rev 6185)
@@ -0,0 +1,28 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<producer-configuration>
+ <registration-configuration>
+
<registration-policy>org.jboss.portal.test.wsrp.config.TestRegistrationPolicy</registration-policy>
+
<registration-property-validator>org.test.package.SomePropertyValidator</registration-property-validator>
+ </registration-configuration>
+</producer-configuration>