Author: chris.laprun(a)jboss.com
Date: 2008-02-08 04:46:47 -0500 (Fri, 08 Feb 2008)
New Revision: 9865
Modified:
tags/JBoss_Portal_2_6_4/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java
tags/JBoss_Portal_2_6_4/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
Log:
- JBPORTAL-1876: Removed optimization on getRegistrationData as it is not always refreshed
when it should be. Added test case.
Modified:
tags/JBoss_Portal_2_6_4/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java
===================================================================
---
tags/JBoss_Portal_2_6_4/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java 2008-02-08
09:07:20 UTC (rev 9864)
+++
tags/JBoss_Portal_2_6_4/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java 2008-02-08
09:46:47 UTC (rev 9865)
@@ -302,12 +302,8 @@
info.setRegistrationPropertyValue("prop0", "value0");
assertTrue(info.isModified());
RegistrationData registrationData = info.getRegistrationData();
- assertNotNull(registrationData);
- Property[] properties = registrationData.getRegistrationProperties();
- assertNotNull(properties);
- assertEquals(1, properties.length);
- assertEquals("prop0", properties[0].getName());
- assertEquals("value0", properties[0].getStringValue());
+ checkRegistrationData(registrationData, "value0");
+ Property[] properties;
// check that setRegistrationValidInternalState properly updates RegistrationData
if required
info.setRegistrationPropertyValue("prop0", "value1");
@@ -318,6 +314,28 @@
assertEquals("value1", properties[0].getStringValue());
}
+ private void checkRegistrationData(RegistrationData registrationData, String
prop0Value)
+ {
+ assertNotNull(registrationData);
+ Property[] properties = registrationData.getRegistrationProperties();
+ assertNotNull(properties);
+ assertEquals(1, properties.length);
+ assertEquals("prop0", properties[0].getName());
+ assertEquals(prop0Value, properties[0].getStringValue());
+ }
+
+ public void testGetRegistrationDataWithInitialWrongValue()
+ {
+ info.setRegistrationPropertyValue("prop0", "incorrect");
+ info.refresh(createServiceDescription(true, 1), producerId, true, true, false);
+ checkRegistrationData(info.getRegistrationData(), "incorrect");
+
+ info.setRegistrationPropertyValue("prop0", "value0");
+ RefreshResult res = info.refresh(createServiceDescription(true, 1), producerId,
true, true, false);
+ assertFalse(res.hasIssues());
+ checkRegistrationData(info.getRegistrationData(), "value0");
+ }
+
public void testRefreshWhileRegisteredAndProducerNotSendingPropertyDescriptions()
{
info.setRegistrationPropertyValue("prop0", "value0");
Modified:
tags/JBoss_Portal_2_6_4/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
---
tags/JBoss_Portal_2_6_4/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2008-02-08
09:07:20 UTC (rev 9864)
+++
tags/JBoss_Portal_2_6_4/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2008-02-08
09:46:47 UTC (rev 9865)
@@ -236,26 +236,23 @@
public RegistrationData getRegistrationData()
{
- if (isModified() || registrationData == null)
+ registrationData = WSRPTypeFactory.createDefaultRegistrationData();
+ registrationData.setConsumerName(persistentConsumerName);
+ List<Property> properties = new ArrayList<Property>();
+ Map regProps = getRegistrationProperties();
+ if (!regProps.isEmpty())
{
- registrationData = WSRPTypeFactory.createDefaultRegistrationData();
- registrationData.setConsumerName(persistentConsumerName);
- List<Property> properties = new ArrayList<Property>();
- Map regProps = getRegistrationProperties();
- if (!regProps.isEmpty())
+ for (Object o : regProps.values())
{
- for (Object o : regProps.values())
+ RegistrationProperty prop = (RegistrationProperty)o;
+ String value = prop.getValue();
+ if (value != null && !prop.isDeterminedInvalid())
{
- RegistrationProperty prop = (RegistrationProperty)o;
- String value = prop.getValue();
- if (value != null && !prop.isDeterminedInvalid())
- {
- properties.add(WSRPTypeFactory.createProperty(prop.getName(),
prop.getLang(), prop.getValue()));
- }
+ properties.add(WSRPTypeFactory.createProperty(prop.getName(),
prop.getLang(), prop.getValue()));
}
-
- registrationData.setRegistrationProperties(properties.toArray(new
Property[regProps.size()]));
}
+
+ registrationData.setRegistrationProperties(properties.toArray(new
Property[regProps.size()]));
}
return registrationData;