Author: chris.laprun(a)jboss.com
Date: 2007-11-28 22:05:54 -0500 (Wed, 28 Nov 2007)
New Revision: 9179
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
Log:
- JBPORTAL-1821:
+ Fixed RegistrationHandler to properly check the data before accepting to modify a
registration.
+ Added test case and fixed testModifyRegistration, which was indeed sending incorrect
data!
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2007-11-29
02:50:09 UTC (rev 9178)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2007-11-29
03:05:54 UTC (rev 9179)
@@ -194,6 +194,7 @@
org.jboss.portal.wsrp.core.Property[] newProps = new
org.jboss.portal.wsrp.core.Property[props.length + 1];
System.arraycopy(props, 0, newProps, 0, props.length);
newProps[props.length] = new org.jboss.portal.wsrp.core.Property(newPropName,
"en", "blah", null);
+ regData.setRegistrationProperties(newProps);
// Modify registration and get service description
registrationService.modifyRegistration(new ModifyRegistration(rc, regData));
@@ -201,6 +202,30 @@
checkServiceDescriptionWithOnlyBasicPortlet(gs);
}
+ public void testModifyRegistrationIncorrectData() throws Exception
+ {
+ // initiate registration
+ configureRegistrationSettings(true, false);
+ RegistrationContext rc = registerConsumer();
+
+ // now modify Producer's set of required registration info
+ String newPropName = "New Prop";
+ RegistrationPropertyDescription regProp = new
RegistrationPropertyDescription(newPropName,
+ new QName("urn:oasis:names:tc:wsrp:v1:types",
"LocalizedString", "ns1"));
+ regProp.setDefaultLabel("New Registration Property");
+ producer.getProducerRegistrationRequirements().addRegistrationProperty(regProp);
+
+ try
+ {
+ registrationService.modifyRegistration(new ModifyRegistration(rc,
createBaseRegData()));
+ ExtendedAssert.fail("Passing incorrect data should fail");
+ }
+ catch (OperationFailedFault operationFailedFault)
+ {
+ // expected
+ }
+ }
+
public void testRegister() throws Exception
{
configureRegistrationSettings(true, false);
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-11-29
02:50:09 UTC (rev 9178)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-11-29
03:05:54 UTC (rev 9179)
@@ -44,6 +44,7 @@
import org.jboss.portal.wsrp.core.RegistrationState;
import org.jboss.portal.wsrp.core.ReturnAny;
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
+import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
import javax.xml.namespace.QName;
import java.rmi.RemoteException;
@@ -211,7 +212,14 @@
try
{
Registration registration =
producer.getRegistrationManager().getRegistration(registrationHandle);
-
registration.updateProperties(createRegistrationProperties(registrationData));
+
+ Map properties = createRegistrationProperties(registrationData);
+
+ // check that the given registration properties are acceptable according to
expectations and policy
+ ProducerRegistrationRequirements req =
producer.getProducerRegistrationRequirements();
+ req.getPolicy().validateRegistrationDataFor(properties, consumerName);
+
+ registration.updateProperties(properties);
updateRegistrationInformation(registration, registrationData);
}
catch (NoSuchRegistrationException e)
@@ -227,6 +235,7 @@
}
+ log.debug("Modified registration with handle '" +
registrationHandle + "'");
return null;
}
Show replies by date