gatein SVN: r5967 - in components/wsrp/branches/2.0.x/producer/src: test/java/org/gatein/registration/policies and 1 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-03-03 15:51:36 -0500 (Thu, 03 Mar 2011)
New Revision: 5967
Added:
components/wsrp/branches/2.0.x/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPropertyValidator.java
Modified:
components/wsrp/branches/2.0.x/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java
components/wsrp/branches/2.0.x/producer/src/test/java/org/gatein/registration/policies/DefaultRegistrationPolicyTestCase.java
Log:
- GTNWSRP-203: Fixed improper error reporting. Added test case.
Modified: components/wsrp/branches/2.0.x/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java
===================================================================
--- components/wsrp/branches/2.0.x/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java 2011-03-03 20:48:36 UTC (rev 5966)
+++ components/wsrp/branches/2.0.x/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java 2011-03-03 20:51:36 UTC (rev 5967)
@@ -53,8 +53,10 @@
*/
public class DefaultRegistrationPolicy implements RegistrationPolicy
{
+ static final String MISSING_VALUE_ERROR_MSG_BEGIN = "Missing value for expected '";
private RegistrationPropertyValidator validator;
private static final Logger log = LoggerFactory.getLogger(DefaultRegistrationPolicy.class);
+ static final String INVALID_VALUE_ERROR_MSG_BEGIN = "Invalid value for property '";
public DefaultRegistrationPolicy()
{
@@ -129,14 +131,23 @@
{
QName name = entry.getKey();
Object value = registrationProperties.get(name);
- try
+
+ if (value == null || (value instanceof String && ((String)value).length() == 0))
{
- validator.validateValueFor(name, value);
+ message.append(MISSING_VALUE_ERROR_MSG_BEGIN).append(name.getLocalPart()).append("' property.\n");
+ consistentWithExpectations = false;
}
- catch (IllegalArgumentException e)
+ else
{
- message.append("Missing value for expected '").append(name.getLocalPart()).append("' property.\n");
- consistentWithExpectations = false;
+ try
+ {
+ validator.validateValueFor(name, value);
+ }
+ catch (IllegalArgumentException e)
+ {
+ message.append(INVALID_VALUE_ERROR_MSG_BEGIN).append(name.getLocalPart()).append("' property.\n").append(e.getLocalizedMessage()).append("\n");
+ consistentWithExpectations = false;
+ }
}
}
Modified: components/wsrp/branches/2.0.x/producer/src/test/java/org/gatein/registration/policies/DefaultRegistrationPolicyTestCase.java
===================================================================
--- components/wsrp/branches/2.0.x/producer/src/test/java/org/gatein/registration/policies/DefaultRegistrationPolicyTestCase.java 2011-03-03 20:48:36 UTC (rev 5966)
+++ components/wsrp/branches/2.0.x/producer/src/test/java/org/gatein/registration/policies/DefaultRegistrationPolicyTestCase.java 2011-03-03 20:51:36 UTC (rev 5967)
@@ -28,6 +28,7 @@
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.impl.RegistrationManagerImpl;
import org.gatein.registration.impl.RegistrationPersistenceManagerImpl;
+import org.gatein.wsrp.producer.config.TestRegistrationPropertyValidator;
import org.gatein.wsrp.registration.PropertyDescription;
import javax.xml.namespace.QName;
@@ -124,10 +125,34 @@
}
catch (RegistrationException e)
{
- assertTrue(e.getLocalizedMessage().contains("prop3"));
+ String message = e.getLocalizedMessage();
+ assertTrue(message.startsWith(DefaultRegistrationPolicy.MISSING_VALUE_ERROR_MSG_BEGIN));
+ assertTrue(message.contains("prop3"));
}
}
+ public void testValidateRegistrationDataFailedValidation()
+ {
+ expectations.put(PROP1, new TestPropertyDescription(PROP1));
+ expectations.put(PROP2, new TestPropertyDescription(PROP2));
+
+ // set validator for test
+ policy.setValidator(new TestRegistrationPropertyValidator());
+
+ try
+ {
+ policy.validateRegistrationDataFor(registrationProperties, CONSUMER, expectations, manager);
+ fail("Should have rejected properties based on values");
+ }
+ catch (RegistrationException e)
+ {
+ String message = e.getLocalizedMessage();
+ assertTrue(message.startsWith(DefaultRegistrationPolicy.INVALID_VALUE_ERROR_MSG_BEGIN));
+ assertTrue(message.contains("prop1"));
+ assertTrue(message.contains("prop2"));
+ }
+ }
+
public void testValidateRegistrationDataExtraProps()
{
expectations.put(PROP1, new TestPropertyDescription(PROP1));
Added: components/wsrp/branches/2.0.x/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPropertyValidator.java
===================================================================
--- components/wsrp/branches/2.0.x/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPropertyValidator.java (rev 0)
+++ components/wsrp/branches/2.0.x/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPropertyValidator.java 2011-03-03 20:51:36 UTC (rev 5967)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2011, 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;
+
+import org.gatein.registration.policies.RegistrationPropertyValidator;
+
+import javax.xml.namespace.QName;
+
+/** @author mvanco */
+public class TestRegistrationPropertyValidator implements RegistrationPropertyValidator
+{
+ public void validateValueFor(QName propertyName, Object value) throws IllegalArgumentException
+ {
+ System.out.println("TEST validator is called for " + propertyName + " with value " + value);
+ // accepts only non-null, String values containing: 'test'
+ if (!(value instanceof String) || !((String)value).contains("test"))
+ {
+ throw new IllegalArgumentException(value + " is not a valid value for property '" + propertyName
+ + "'. TestRegistrationPropertyValidator only accepts non-null String value containing 'test'.");
+ }
+ }
+
+}
13 years, 10 months
gatein SVN: r5966 - in components/wsrp/trunk/producer/src: test/java/org/gatein/registration/policies and 1 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-03-03 15:48:36 -0500 (Thu, 03 Mar 2011)
New Revision: 5966
Added:
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPropertyValidator.java
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java
components/wsrp/trunk/producer/src/test/java/org/gatein/registration/policies/DefaultRegistrationPolicyTestCase.java
Log:
- GTNWSRP-203: Fixed improper error reporting. Added test case.
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 2011-03-03 20:15:38 UTC (rev 5965)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java 2011-03-03 20:48:36 UTC (rev 5966)
@@ -53,8 +53,10 @@
*/
public class DefaultRegistrationPolicy implements RegistrationPolicy
{
+ static final String MISSING_VALUE_ERROR_MSG_BEGIN = "Missing value for expected '";
private RegistrationPropertyValidator validator;
private static final Logger log = LoggerFactory.getLogger(DefaultRegistrationPolicy.class);
+ static final String INVALID_VALUE_ERROR_MSG_BEGIN = "Invalid value for property '";
public DefaultRegistrationPolicy()
{
@@ -129,14 +131,23 @@
{
QName name = entry.getKey();
Object value = registrationProperties.get(name);
- try
+
+ if (value == null || (value instanceof String && ((String)value).isEmpty()))
{
- validator.validateValueFor(name, value);
+ message.append(MISSING_VALUE_ERROR_MSG_BEGIN).append(name.getLocalPart()).append("' property.\n");
+ consistentWithExpectations = false;
}
- catch (IllegalArgumentException e)
+ else
{
- message.append("Missing value for expected '").append(name.getLocalPart()).append("' property.\n");
- consistentWithExpectations = false;
+ try
+ {
+ validator.validateValueFor(name, value);
+ }
+ catch (IllegalArgumentException e)
+ {
+ message.append(INVALID_VALUE_ERROR_MSG_BEGIN).append(name.getLocalPart()).append("' property.\n").append(e.getLocalizedMessage()).append("\n");
+ consistentWithExpectations = false;
+ }
}
}
Modified: components/wsrp/trunk/producer/src/test/java/org/gatein/registration/policies/DefaultRegistrationPolicyTestCase.java
===================================================================
--- components/wsrp/trunk/producer/src/test/java/org/gatein/registration/policies/DefaultRegistrationPolicyTestCase.java 2011-03-03 20:15:38 UTC (rev 5965)
+++ components/wsrp/trunk/producer/src/test/java/org/gatein/registration/policies/DefaultRegistrationPolicyTestCase.java 2011-03-03 20:48:36 UTC (rev 5966)
@@ -28,6 +28,7 @@
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.impl.RegistrationManagerImpl;
import org.gatein.registration.impl.RegistrationPersistenceManagerImpl;
+import org.gatein.wsrp.producer.config.TestRegistrationPropertyValidator;
import org.gatein.wsrp.registration.PropertyDescription;
import javax.xml.namespace.QName;
@@ -124,10 +125,34 @@
}
catch (RegistrationException e)
{
- assertTrue(e.getLocalizedMessage().contains("prop3"));
+ String message = e.getLocalizedMessage();
+ assertTrue(message.startsWith(DefaultRegistrationPolicy.MISSING_VALUE_ERROR_MSG_BEGIN));
+ assertTrue(message.contains("prop3"));
}
}
+ public void testValidateRegistrationDataFailedValidation()
+ {
+ expectations.put(PROP1, new TestPropertyDescription(PROP1));
+ expectations.put(PROP2, new TestPropertyDescription(PROP2));
+
+ // set validator for test
+ policy.setValidator(new TestRegistrationPropertyValidator());
+
+ try
+ {
+ policy.validateRegistrationDataFor(registrationProperties, CONSUMER, expectations, manager);
+ fail("Should have rejected properties based on values");
+ }
+ catch (RegistrationException e)
+ {
+ String message = e.getLocalizedMessage();
+ assertTrue(message.startsWith(DefaultRegistrationPolicy.INVALID_VALUE_ERROR_MSG_BEGIN));
+ assertTrue(message.contains("prop1"));
+ assertTrue(message.contains("prop2"));
+ }
+ }
+
public void testValidateRegistrationDataExtraProps()
{
expectations.put(PROP1, new TestPropertyDescription(PROP1));
Added: components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPropertyValidator.java
===================================================================
--- components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPropertyValidator.java (rev 0)
+++ components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPropertyValidator.java 2011-03-03 20:48:36 UTC (rev 5966)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2011, 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;
+
+import org.gatein.registration.policies.RegistrationPropertyValidator;
+
+import javax.xml.namespace.QName;
+
+/** @author mvanco */
+public class TestRegistrationPropertyValidator implements RegistrationPropertyValidator
+{
+ public void validateValueFor(QName propertyName, Object value) throws IllegalArgumentException
+ {
+ System.out.println("TEST validator is called for " + propertyName + " with value " + value);
+ // accepts only non-null, String values containing: 'test'
+ if (!(value instanceof String) || !((String)value).contains("test"))
+ {
+ throw new IllegalArgumentException(value + " is not a valid value for property '" + propertyName
+ + "'. TestRegistrationPropertyValidator only accepts non-null String value containing 'test'.");
+ }
+ }
+
+}
\ No newline at end of file
13 years, 10 months
gatein SVN: r5965 - components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-03-03 15:15:38 -0500 (Thu, 03 Mar 2011)
New Revision: 5965
Modified:
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/ProducerRegistrationRequirementsTestCase.java
Log:
- GTNWSRP-204: Added test case.
Modified: components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/ProducerRegistrationRequirementsTestCase.java
===================================================================
--- components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/ProducerRegistrationRequirementsTestCase.java 2011-03-03 20:10:13 UTC (rev 5964)
+++ components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/ProducerRegistrationRequirementsTestCase.java 2011-03-03 20:15:38 UTC (rev 5965)
@@ -28,6 +28,8 @@
import org.gatein.registration.RegistrationPolicyChangeListener;
import org.gatein.registration.RegistrationPropertyChangeListener;
import org.gatein.registration.policies.DefaultRegistrationPolicy;
+import org.gatein.registration.policies.DefaultRegistrationPropertyValidator;
+import org.gatein.registration.policies.RegistrationPolicyWrapper;
import org.gatein.wsrp.WSRPConstants;
import org.gatein.wsrp.producer.config.impl.ProducerRegistrationRequirementsImpl;
import org.gatein.wsrp.registration.PropertyDescription;
@@ -89,6 +91,21 @@
assertNull(requirements.getValidatorClassName());
}
+ public void testChangeToDefaultPolicyWithEmptyValidatorName()
+ {
+ ProducerRegistrationRequirementsImpl requirements = new ProducerRegistrationRequirementsImpl();
+ requirements.setRegistrationRequired(true); // so that we load the policy
+
+ requirements.reloadPolicyFrom(ProducerRegistrationRequirements.DEFAULT_POLICY_CLASS_NAME, "");
+
+ RegistrationPolicy policy = requirements.getPolicy();
+ assertEquals(ProducerRegistrationRequirements.DEFAULT_POLICY_CLASS_NAME, policy.getClassName());
+ assertEquals(ProducerRegistrationRequirements.DEFAULT_VALIDATOR_CLASS_NAME, requirements.getValidatorClassName());
+
+ DefaultRegistrationPolicy unwrap = (DefaultRegistrationPolicy)RegistrationPolicyWrapper.unwrap(policy);
+ assertTrue(unwrap.getValidator() instanceof DefaultRegistrationPropertyValidator);
+ }
+
public void testSetUnchangedRegistrationProperties()
{
ProducerRegistrationRequirements requirements = new ProducerRegistrationRequirementsImpl();
13 years, 10 months
gatein SVN: r5964 - components/wsrp/branches/2.0.x/producer/src/test/java/org/gatein/wsrp/producer/config.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-03-03 15:10:13 -0500 (Thu, 03 Mar 2011)
New Revision: 5964
Modified:
components/wsrp/branches/2.0.x/producer/src/test/java/org/gatein/wsrp/producer/config/ProducerRegistrationRequirementsTestCase.java
Log:
- GTNWSRP-204: Added test case.
Modified: components/wsrp/branches/2.0.x/producer/src/test/java/org/gatein/wsrp/producer/config/ProducerRegistrationRequirementsTestCase.java
===================================================================
--- components/wsrp/branches/2.0.x/producer/src/test/java/org/gatein/wsrp/producer/config/ProducerRegistrationRequirementsTestCase.java 2011-03-03 18:46:53 UTC (rev 5963)
+++ components/wsrp/branches/2.0.x/producer/src/test/java/org/gatein/wsrp/producer/config/ProducerRegistrationRequirementsTestCase.java 2011-03-03 20:10:13 UTC (rev 5964)
@@ -28,6 +28,8 @@
import org.gatein.registration.RegistrationPolicyChangeListener;
import org.gatein.registration.RegistrationPropertyChangeListener;
import org.gatein.registration.policies.DefaultRegistrationPolicy;
+import org.gatein.registration.policies.DefaultRegistrationPropertyValidator;
+import org.gatein.registration.policies.RegistrationPolicyWrapper;
import org.gatein.wsrp.WSRPConstants;
import org.gatein.wsrp.producer.config.impl.ProducerRegistrationRequirementsImpl;
import org.gatein.wsrp.registration.PropertyDescription;
@@ -89,6 +91,21 @@
assertNull(requirements.getValidatorClassName());
}
+ public void testChangeToDefaultPolicyWithEmptyValidatorName()
+ {
+ ProducerRegistrationRequirementsImpl requirements = new ProducerRegistrationRequirementsImpl();
+ requirements.setRegistrationRequired(true); // so that we load the policy
+
+ requirements.reloadPolicyFrom(ProducerRegistrationRequirements.DEFAULT_POLICY_CLASS_NAME, "");
+
+ RegistrationPolicy policy = requirements.getPolicy();
+ assertEquals(ProducerRegistrationRequirements.DEFAULT_POLICY_CLASS_NAME, policy.getClassName());
+ assertEquals(ProducerRegistrationRequirements.DEFAULT_VALIDATOR_CLASS_NAME, requirements.getValidatorClassName());
+
+ DefaultRegistrationPolicy unwrap = (DefaultRegistrationPolicy)RegistrationPolicyWrapper.unwrap(policy);
+ assertTrue(unwrap.getValidator() instanceof DefaultRegistrationPropertyValidator);
+ }
+
public void testSetUnchangedRegistrationProperties()
{
ProducerRegistrationRequirements requirements = new ProducerRegistrationRequirementsImpl();
13 years, 10 months
gatein SVN: r5963 - in components/sso/trunk/agent/src/main/java/org/gatein/sso/agent: cas and 1 other directory.
by do-not-reply@jboss.org
Author: sohil.shah(a)jboss.com
Date: 2011-03-03 13:46:53 -0500 (Thu, 03 Mar 2011)
New Revision: 5963
Modified:
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/GenericSSOAgent.java
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/cas/CASAgent.java
Log:
externalizing the CAS service url value
Modified: components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/GenericSSOAgent.java
===================================================================
--- components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/GenericSSOAgent.java 2011-03-03 17:48:13 UTC (rev 5962)
+++ components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/GenericSSOAgent.java 2011-03-03 18:46:53 UTC (rev 5963)
@@ -47,6 +47,7 @@
private String ssoServerUrl;
private String ssoCookieName;
private boolean casRenewTicket;
+ private String casServiceUrl;
@Override
@@ -62,6 +63,12 @@
{
this.casRenewTicket = Boolean.parseBoolean(casRenewTicketConfig);
}
+
+ String casServiceUrlConfig = this.getServletConfig().getInitParameter("casServiceUrl");
+ if(casServiceUrlConfig != null && casServiceUrlConfig.trim().length()>0)
+ {
+ casServiceUrl = casServiceUrlConfig;
+ }
}
@Override
@@ -103,7 +110,7 @@
if (ticket != null && ticket.trim().length() > 0)
{
- CASAgent casagent = CASAgent.getInstance(this.ssoServerUrl);
+ CASAgent casagent = CASAgent.getInstance(this.ssoServerUrl,this.casServiceUrl);
casagent.setRenewTicket(this.casRenewTicket);
casagent.validateTicket(httpRequest, ticket);
}
Modified: components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/cas/CASAgent.java
===================================================================
--- components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/cas/CASAgent.java 2011-03-03 17:48:13 UTC (rev 5962)
+++ components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/cas/CASAgent.java 2011-03-03 18:46:53 UTC (rev 5963)
@@ -42,13 +42,15 @@
private String casServerUrl;
private boolean renewTicket;
+ private String casServiceUrl;
- private CASAgent(String casServerUrl)
+ private CASAgent(String casServerUrl, String casServiceUrl)
{
this.casServerUrl = casServerUrl;
+ this.casServiceUrl = casServiceUrl;
}
- public static CASAgent getInstance(String casServerUrl)
+ public static CASAgent getInstance(String casServerUrl,String casServiceUrl)
{
if(CASAgent.singleton == null)
{
@@ -56,7 +58,7 @@
{
if(CASAgent.singleton == null)
{
- CASAgent.singleton = new CASAgent(casServerUrl);
+ CASAgent.singleton = new CASAgent(casServerUrl,casServiceUrl);
}
}
}
@@ -79,12 +81,12 @@
Cas20ProxyTicketValidator ticketValidator = new Cas20ProxyTicketValidator(casServerUrl);
ticketValidator.setRenew(this.renewTicket);
- String serviceUrl = "http://"+ httpRequest.getServerName() +":" + httpRequest.getServerPort() +
- httpRequest.getContextPath() +"/private/classic";
- Assertion assertion = ticketValidator.validate(ticket, serviceUrl);
+ //String serviceUrl = "http://"+ httpRequest.getServerName() +":" + httpRequest.getServerPort() +
+ //httpRequest.getContextPath() +"/private/classic";
+ Assertion assertion = ticketValidator.validate(ticket, this.casServiceUrl);
log.debug("------------------------------------------------------------------------------------");
- log.debug("Service: "+serviceUrl);
+ log.debug("Service: "+this.casServiceUrl);
log.debug("Principal: "+assertion.getPrincipal().getName());
log.debug("------------------------------------------------------------------------------------");
13 years, 10 months
gatein SVN: r5962 - components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-03-03 12:48:13 -0500 (Thu, 03 Mar 2011)
New Revision: 5962
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java
Log:
- GTNWSRP-204: JSF sends empty String if no validator is passed so dealt with that case.
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 2011-03-03 17:47:15 UTC (rev 5961)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java 2011-03-03 17:48:13 UTC (rev 5962)
@@ -397,7 +397,7 @@
{
log.debug("Using default registration policy: " + DEFAULT_POLICY_CLASS_NAME);
RegistrationPropertyValidator validator;
- if (validatorClassName != null && !DEFAULT_VALIDATOR_CLASS_NAME.equals(validatorClassName))
+ if (validatorClassName != null && !validatorClassName.isEmpty() && !DEFAULT_VALIDATOR_CLASS_NAME.equals(validatorClassName))
{
log.debug("Using registration property validator: " + validatorClassName);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
13 years, 10 months
gatein SVN: r5961 - components/wsrp/branches/2.0.x/producer/src/main/java/org/gatein/wsrp/producer/config/impl.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-03-03 12:47:15 -0500 (Thu, 03 Mar 2011)
New Revision: 5961
Modified:
components/wsrp/branches/2.0.x/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java
Log:
- GTNWSRP-204: JSF sends empty String if no validator is passed so dealt with that case.
Modified: components/wsrp/branches/2.0.x/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java
===================================================================
--- components/wsrp/branches/2.0.x/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java 2011-03-03 15:59:11 UTC (rev 5960)
+++ components/wsrp/branches/2.0.x/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java 2011-03-03 17:47:15 UTC (rev 5961)
@@ -397,7 +397,7 @@
{
log.debug("Using default registration policy: " + DEFAULT_POLICY_CLASS_NAME);
RegistrationPropertyValidator validator;
- if (validatorClassName != null && !DEFAULT_VALIDATOR_CLASS_NAME.equals(validatorClassName))
+ if (validatorClassName != null && validatorClassName.length() > 0 && !DEFAULT_VALIDATOR_CLASS_NAME.equals(validatorClassName))
{
log.debug("Using registration property validator: " + validatorClassName);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
13 years, 10 months
gatein SVN: r5960 - in components/wsrp/branches/2.0.x/admin-gui/src/main: webapp/jsf/producer and 1 other directory.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-03-03 10:59:11 -0500 (Thu, 03 Mar 2011)
New Revision: 5960
Modified:
components/wsrp/branches/2.0.x/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ProducerBean.java
components/wsrp/branches/2.0.x/admin-gui/src/main/webapp/jsf/producer/producer.xhtml
Log:
- GTNWSRP-201: Fixed improper state management by making local configuration deal with strict mode as well. Made the registration required for full service description and strict mode immediate and with a value change listener to properly handle state change.
Modified: components/wsrp/branches/2.0.x/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ProducerBean.java
===================================================================
--- components/wsrp/branches/2.0.x/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ProducerBean.java 2011-03-03 15:50:49 UTC (rev 5959)
+++ components/wsrp/branches/2.0.x/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ProducerBean.java 2011-03-03 15:59:11 UTC (rev 5960)
@@ -54,7 +54,7 @@
private static final String PROPERTY = "property";
private static final String PRODUCER = "producer";
private String selectedProp;
- private RegistrationConfiguration registrationConfiguration;
+ private LocalProducerConfiguration localProducerConfiguration;
public ProducerConfigurationService getConfigurationService()
{
@@ -73,27 +73,27 @@
public boolean isRegistrationRequiredForFullDescription()
{
- return getRegRequirements().isRegistrationRequiredForFullDescription();
+ return getLocalConfiguration().isRegistrationRequiredForFullDescription();
}
public void setRegistrationRequiredForFullDescription(boolean requireRegForFullDescription)
{
- getRegRequirements().setRegistrationRequiredForFullDescription(requireRegForFullDescription);
+ getLocalConfiguration().setRegistrationRequiredForFullDescription(requireRegForFullDescription);
}
public boolean isRegistrationRequired()
{
- return getRegRequirements().isRegistrationRequired();
+ return getLocalConfiguration().isRegistrationRequired();
}
public void setRegistrationRequired(boolean requireRegistration)
{
- getRegRequirements().setRegistrationRequired(requireRegistration);
+ getLocalConfiguration().setRegistrationRequired(requireRegistration);
}
public String getRegistrationPolicyClassName()
{
- RegistrationPolicy policy = getRegRequirements().getPolicy();
+ RegistrationPolicy policy = getLocalConfiguration().getPolicy();
if (policy != null)
{
return policy.getClassName();
@@ -118,7 +118,7 @@
{
if (isDefaultRegistrationPolicy())
{
- DefaultRegistrationPolicy policy = (DefaultRegistrationPolicy)RegistrationPolicyWrapper.unwrap(getRegRequirements().getPolicy());
+ DefaultRegistrationPolicy policy = (DefaultRegistrationPolicy)RegistrationPolicyWrapper.unwrap(getLocalConfiguration().getPolicy());
return policy.getValidator().getClass().getName();
}
throw new IllegalStateException("getValidatorClassName shouldn't be called if we're not using the default registration");
@@ -131,17 +131,17 @@
public boolean isStrictMode()
{
- return getConfiguration().isUsingStrictMode();
+ return getLocalConfiguration().isUsingStrictMode();
}
public void setStrictMode(boolean strictMode)
{
- getConfiguration().setUsingStrictMode(strictMode);
+ getLocalConfiguration().setUsingStrictMode(strictMode);
}
public List<RegistrationPropertyDescription> getRegistrationProperties()
{
- return getRegRequirements().getRegistrationProperties();
+ return getLocalConfiguration().getRegistrationProperties();
}
public List<SelectItem> getSupportedPropertyTypes()
@@ -159,20 +159,24 @@
try
{
// replicate local state to producer state
- ProducerRegistrationRequirements registrationRequirements = getConfiguration().getRegistrationRequirements();
- RegistrationConfiguration configuration = getRegRequirements();
+ ProducerConfiguration currentlyPersistedConfiguration = getConfiguration();
+ LocalProducerConfiguration localConfiguration = getLocalConfiguration();
- registrationRequirements.setRegistrationRequiredForFullDescription(configuration.isRegistrationRequiredForFullDescription());
- registrationRequirements.setRegistrationRequired(configuration.isRegistrationRequired());
+ ProducerRegistrationRequirements registrationRequirements = currentlyPersistedConfiguration.getRegistrationRequirements();
+ registrationRequirements.setRegistrationRequiredForFullDescription(localConfiguration.isRegistrationRequiredForFullDescription());
+ registrationRequirements.setRegistrationRequired(localConfiguration.isRegistrationRequired());
+
registrationRequirements.reloadPolicyFrom(policyClassName, validatorClassName);
- registrationRequirements.setRegistrationProperties(configuration.getRegistrationRequirements().getRegistrationProperties());
+ registrationRequirements.setRegistrationProperties(localConfiguration.getRegistrationRequirements().getRegistrationProperties());
+ currentlyPersistedConfiguration.setUsingStrictMode(localConfiguration.isUsingStrictMode());
+
getConfigurationService().saveConfiguration();
// force a reload local state
- registrationConfiguration = null;
+ localProducerConfiguration = null;
beanContext.createInfoMessage("bean_producer_save_success");
}
@@ -191,7 +195,7 @@
getConfigurationService().reloadConfiguration();
// force a reload local state
- registrationConfiguration = null;
+ localProducerConfiguration = null;
beanContext.createInfoMessage("bean_producer_cancel_success");
}
@@ -205,13 +209,13 @@
public String addRegistrationProperty()
{
- getRegRequirements().addEmptyRegistrationProperty(PROPERTY + System.currentTimeMillis());
+ getLocalConfiguration().addEmptyRegistrationProperty(PROPERTY + System.currentTimeMillis());
return PRODUCER;
}
public String deleteRegistrationProperty()
{
- getRegRequirements().removeRegistrationProperty(selectedProp);
+ getLocalConfiguration().removeRegistrationProperty(selectedProp);
return PRODUCER;
}
@@ -223,6 +227,22 @@
FacesContext.getCurrentInstance().renderResponse();
}
+ public void strictModeListener(ValueChangeEvent event)
+ {
+ setStrictMode((Boolean)event.getNewValue());
+
+ // bypass the rest of the life cycle and re-display page
+ FacesContext.getCurrentInstance().renderResponse();
+ }
+
+ public void requireRegistrationForFullDescListener(ValueChangeEvent event)
+ {
+ setRegistrationRequiredForFullDescription((Boolean)event.getNewValue());
+
+ // bypass the rest of the life cycle and re-display page
+ FacesContext.getCurrentInstance().renderResponse();
+ }
+
public void selectProperty(ActionEvent event)
{
selectedProp = beanContext.getParameter("propName");
@@ -238,15 +258,16 @@
return false; // default implementation as not used
}
- private RegistrationConfiguration getRegRequirements()
+ private LocalProducerConfiguration getLocalConfiguration()
{
- if (registrationConfiguration == null)
+ if (localProducerConfiguration == null)
{
- registrationConfiguration = new RegistrationConfiguration();
- registrationConfiguration.initFrom(getConfiguration().getRegistrationRequirements());
+ localProducerConfiguration = new LocalProducerConfiguration();
+ ProducerConfiguration configuration = getConfiguration();
+ localProducerConfiguration.initFrom(configuration.getRegistrationRequirements(), configuration.isUsingStrictMode());
}
- return registrationConfiguration;
+ return localProducerConfiguration;
}
public String getV1WSDL()
@@ -259,18 +280,21 @@
return beanContext.getServerAddress() + "/wsrp-producer/v2/MarkupService?wsdl";
}
- private static class RegistrationConfiguration
+ private static class LocalProducerConfiguration
{
private List<RegistrationPropertyDescription> registrationProperties;
private ProducerRegistrationRequirements registrationRequirements;
+ private boolean strictMode;
- public void initFrom(ProducerRegistrationRequirements registrationRequirements)
+ public void initFrom(ProducerRegistrationRequirements registrationRequirements, boolean usingStrictMode)
{
this.registrationRequirements = new ProducerRegistrationRequirementsImpl(registrationRequirements);
Map descriptions = registrationRequirements.getRegistrationProperties();
registrationProperties = new LinkedList<RegistrationPropertyDescription>(descriptions.values());
Collections.sort(registrationProperties);
+
+ this.strictMode = usingStrictMode;
}
public boolean isRegistrationRequiredForFullDescription()
@@ -328,5 +352,15 @@
{
return registrationRequirements;
}
+
+ public boolean isUsingStrictMode()
+ {
+ return strictMode;
+ }
+
+ public void setUsingStrictMode(boolean usingStrictMode)
+ {
+ this.strictMode = usingStrictMode;
+ }
}
}
Modified: components/wsrp/branches/2.0.x/admin-gui/src/main/webapp/jsf/producer/producer.xhtml
===================================================================
--- components/wsrp/branches/2.0.x/admin-gui/src/main/webapp/jsf/producer/producer.xhtml 2011-03-03 15:50:49 UTC (rev 5959)
+++ components/wsrp/branches/2.0.x/admin-gui/src/main/webapp/jsf/producer/producer.xhtml 2011-03-03 15:59:11 UTC (rev 5960)
@@ -1,6 +1,6 @@
<!--
~ JBoss, a division of Red Hat
- ~ Copyright 2010, Red Hat Middleware, LLC, and individual
+ ~ Copyright 2011, 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.
@@ -41,9 +41,13 @@
<h:form id="producer-form">
<h:panelGrid columns="2" width="100%">
<h:selectBooleanCheckbox id="cons-reg-req-check"
- value="#{producer.registrationRequiredForFullDescription}"/>
+ value="#{producer.registrationRequiredForFullDescription}"
+ immediate="true"
+ valueChangeListener="#{producer.requireRegistrationForFullDescListener}"/>
<h:outputText value="#{i18n.producer_config_sd_requires_reg}"/>
- <h:selectBooleanCheckbox value="#{producer.strictMode}"/>
+ <h:selectBooleanCheckbox id="strict-mode-check" value="#{producer.strictMode}"
+ immediate="true"
+ valueChangeListener="#{producer.strictModeListener}"/>
<h:outputText value="#{i18n.producer_config_strict}"/>
<h:selectBooleanCheckbox id="req-reg-check" value="#{producer.registrationRequired}" immediate="true"
@@ -182,4 +186,4 @@
</h:form>
</ui:define>
-</ui:decorate>
\ No newline at end of file
+</ui:decorate>
13 years, 10 months
gatein SVN: r5959 - in components/wsrp/trunk/admin-gui/src/main: webapp/jsf/producer and 1 other directory.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-03-03 10:50:49 -0500 (Thu, 03 Mar 2011)
New Revision: 5959
Modified:
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ProducerBean.java
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/producer/producer.xhtml
Log:
- GTNWSRP-201: Fixed improper state management by making local configuration deal with strict mode as well. Made the registration required for full service description and strict mode immediate and with a value change listener to properly handle state change.
Modified: components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ProducerBean.java
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ProducerBean.java 2011-03-03 14:30:56 UTC (rev 5958)
+++ components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ProducerBean.java 2011-03-03 15:50:49 UTC (rev 5959)
@@ -54,7 +54,7 @@
private static final String PROPERTY = "property";
private static final String PRODUCER = "producer";
private String selectedProp;
- private RegistrationConfiguration registrationConfiguration;
+ private LocalProducerConfiguration localProducerConfiguration;
public ProducerConfigurationService getConfigurationService()
{
@@ -73,27 +73,27 @@
public boolean isRegistrationRequiredForFullDescription()
{
- return getRegRequirements().isRegistrationRequiredForFullDescription();
+ return getLocalConfiguration().isRegistrationRequiredForFullDescription();
}
public void setRegistrationRequiredForFullDescription(boolean requireRegForFullDescription)
{
- getRegRequirements().setRegistrationRequiredForFullDescription(requireRegForFullDescription);
+ getLocalConfiguration().setRegistrationRequiredForFullDescription(requireRegForFullDescription);
}
public boolean isRegistrationRequired()
{
- return getRegRequirements().isRegistrationRequired();
+ return getLocalConfiguration().isRegistrationRequired();
}
public void setRegistrationRequired(boolean requireRegistration)
{
- getRegRequirements().setRegistrationRequired(requireRegistration);
+ getLocalConfiguration().setRegistrationRequired(requireRegistration);
}
public String getRegistrationPolicyClassName()
{
- RegistrationPolicy policy = getRegRequirements().getPolicy();
+ RegistrationPolicy policy = getLocalConfiguration().getPolicy();
if (policy != null)
{
return policy.getClassName();
@@ -118,7 +118,7 @@
{
if (isDefaultRegistrationPolicy())
{
- DefaultRegistrationPolicy policy = (DefaultRegistrationPolicy)RegistrationPolicyWrapper.unwrap(getRegRequirements().getPolicy());
+ DefaultRegistrationPolicy policy = (DefaultRegistrationPolicy)RegistrationPolicyWrapper.unwrap(getLocalConfiguration().getPolicy());
return policy.getValidator().getClass().getName();
}
throw new IllegalStateException("getValidatorClassName shouldn't be called if we're not using the default registration");
@@ -131,17 +131,17 @@
public boolean isStrictMode()
{
- return getConfiguration().isUsingStrictMode();
+ return getLocalConfiguration().isUsingStrictMode();
}
public void setStrictMode(boolean strictMode)
{
- getConfiguration().setUsingStrictMode(strictMode);
+ getLocalConfiguration().setUsingStrictMode(strictMode);
}
public List<RegistrationPropertyDescription> getRegistrationProperties()
{
- return getRegRequirements().getRegistrationProperties();
+ return getLocalConfiguration().getRegistrationProperties();
}
public List<SelectItem> getSupportedPropertyTypes()
@@ -159,20 +159,24 @@
try
{
// replicate local state to producer state
- ProducerRegistrationRequirements registrationRequirements = getConfiguration().getRegistrationRequirements();
- RegistrationConfiguration configuration = getRegRequirements();
+ ProducerConfiguration currentlyPersistedConfiguration = getConfiguration();
+ LocalProducerConfiguration localConfiguration = getLocalConfiguration();
- registrationRequirements.setRegistrationRequiredForFullDescription(configuration.isRegistrationRequiredForFullDescription());
- registrationRequirements.setRegistrationRequired(configuration.isRegistrationRequired());
+ ProducerRegistrationRequirements registrationRequirements = currentlyPersistedConfiguration.getRegistrationRequirements();
+ registrationRequirements.setRegistrationRequiredForFullDescription(localConfiguration.isRegistrationRequiredForFullDescription());
+ registrationRequirements.setRegistrationRequired(localConfiguration.isRegistrationRequired());
+
registrationRequirements.reloadPolicyFrom(policyClassName, validatorClassName);
- registrationRequirements.setRegistrationProperties(configuration.getRegistrationRequirements().getRegistrationProperties());
+ registrationRequirements.setRegistrationProperties(localConfiguration.getRegistrationRequirements().getRegistrationProperties());
+ currentlyPersistedConfiguration.setUsingStrictMode(localConfiguration.isUsingStrictMode());
+
getConfigurationService().saveConfiguration();
// force a reload local state
- registrationConfiguration = null;
+ localProducerConfiguration = null;
beanContext.createInfoMessage("bean_producer_save_success");
}
@@ -191,7 +195,7 @@
getConfigurationService().reloadConfiguration();
// force a reload local state
- registrationConfiguration = null;
+ localProducerConfiguration = null;
beanContext.createInfoMessage("bean_producer_cancel_success");
}
@@ -205,13 +209,13 @@
public String addRegistrationProperty()
{
- getRegRequirements().addEmptyRegistrationProperty(PROPERTY + System.currentTimeMillis());
+ getLocalConfiguration().addEmptyRegistrationProperty(PROPERTY + System.currentTimeMillis());
return PRODUCER;
}
public String deleteRegistrationProperty()
{
- getRegRequirements().removeRegistrationProperty(selectedProp);
+ getLocalConfiguration().removeRegistrationProperty(selectedProp);
return PRODUCER;
}
@@ -223,6 +227,22 @@
FacesContext.getCurrentInstance().renderResponse();
}
+ public void strictModeListener(ValueChangeEvent event)
+ {
+ setStrictMode((Boolean)event.getNewValue());
+
+ // bypass the rest of the life cycle and re-display page
+ FacesContext.getCurrentInstance().renderResponse();
+ }
+
+ public void requireRegistrationForFullDescListener(ValueChangeEvent event)
+ {
+ setRegistrationRequiredForFullDescription((Boolean)event.getNewValue());
+
+ // bypass the rest of the life cycle and re-display page
+ FacesContext.getCurrentInstance().renderResponse();
+ }
+
public void selectProperty(ActionEvent event)
{
selectedProp = beanContext.getParameter("propName");
@@ -238,15 +258,16 @@
return false; // default implementation as not used
}
- private RegistrationConfiguration getRegRequirements()
+ private LocalProducerConfiguration getLocalConfiguration()
{
- if (registrationConfiguration == null)
+ if (localProducerConfiguration == null)
{
- registrationConfiguration = new RegistrationConfiguration();
- registrationConfiguration.initFrom(getConfiguration().getRegistrationRequirements());
+ localProducerConfiguration = new LocalProducerConfiguration();
+ ProducerConfiguration configuration = getConfiguration();
+ localProducerConfiguration.initFrom(configuration.getRegistrationRequirements(), configuration.isUsingStrictMode());
}
- return registrationConfiguration;
+ return localProducerConfiguration;
}
public String getV1WSDL()
@@ -259,18 +280,21 @@
return beanContext.getServerAddress() + "/wsrp-producer/v2/MarkupService?wsdl";
}
- private static class RegistrationConfiguration
+ private static class LocalProducerConfiguration
{
private List<RegistrationPropertyDescription> registrationProperties;
private ProducerRegistrationRequirements registrationRequirements;
+ private boolean strictMode;
- public void initFrom(ProducerRegistrationRequirements registrationRequirements)
+ public void initFrom(ProducerRegistrationRequirements registrationRequirements, boolean usingStrictMode)
{
this.registrationRequirements = new ProducerRegistrationRequirementsImpl(registrationRequirements);
Map descriptions = registrationRequirements.getRegistrationProperties();
registrationProperties = new LinkedList<RegistrationPropertyDescription>(descriptions.values());
Collections.sort(registrationProperties);
+
+ this.strictMode = usingStrictMode;
}
public boolean isRegistrationRequiredForFullDescription()
@@ -328,5 +352,15 @@
{
return registrationRequirements;
}
+
+ public boolean isUsingStrictMode()
+ {
+ return strictMode;
+ }
+
+ public void setUsingStrictMode(boolean usingStrictMode)
+ {
+ this.strictMode = usingStrictMode;
+ }
}
}
Modified: components/wsrp/trunk/admin-gui/src/main/webapp/jsf/producer/producer.xhtml
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/webapp/jsf/producer/producer.xhtml 2011-03-03 14:30:56 UTC (rev 5958)
+++ components/wsrp/trunk/admin-gui/src/main/webapp/jsf/producer/producer.xhtml 2011-03-03 15:50:49 UTC (rev 5959)
@@ -1,6 +1,6 @@
<!--
~ JBoss, a division of Red Hat
- ~ Copyright 2010, Red Hat Middleware, LLC, and individual
+ ~ Copyright 2011, 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.
@@ -41,9 +41,13 @@
<h:form id="producer-form">
<h:panelGrid columns="2" width="100%">
<h:selectBooleanCheckbox id="cons-reg-req-check"
- value="#{producer.registrationRequiredForFullDescription}"/>
+ value="#{producer.registrationRequiredForFullDescription}"
+ immediate="true"
+ valueChangeListener="#{producer.requireRegistrationForFullDescListener}"/>
<h:outputText value="#{i18n.producer_config_sd_requires_reg}"/>
- <h:selectBooleanCheckbox value="#{producer.strictMode}"/>
+ <h:selectBooleanCheckbox id="strict-mode-check" value="#{producer.strictMode}"
+ immediate="true"
+ valueChangeListener="#{producer.strictModeListener}"/>
<h:outputText value="#{i18n.producer_config_strict}"/>
<h:selectBooleanCheckbox id="req-reg-check" value="#{producer.registrationRequired}" immediate="true"
13 years, 10 months
gatein SVN: r5958 - in portal/trunk/testsuite/htmlunit-tests: src/test/java/org/jboss/gatein/htmlunit/common and 1 other directory.
by do-not-reply@jboss.org
Author: mstruk
Date: 2011-03-03 09:30:56 -0500 (Thu, 03 Mar 2011)
New Revision: 5958
Modified:
portal/trunk/testsuite/htmlunit-tests/pom.xml
portal/trunk/testsuite/htmlunit-tests/src/test/java/org/jboss/gatein/htmlunit/common/WebHelper.java
Log:
htmlunit-tests: added system properties to be able to override at mvn execution time + sensible defaults
Modified: portal/trunk/testsuite/htmlunit-tests/pom.xml
===================================================================
--- portal/trunk/testsuite/htmlunit-tests/pom.xml 2011-03-03 12:37:38 UTC (rev 5957)
+++ portal/trunk/testsuite/htmlunit-tests/pom.xml 2011-03-03 14:30:56 UTC (rev 5958)
@@ -33,6 +33,11 @@
<properties>
<testng.suite.file>testng.xml</testng.suite.file>
+ <test.host>localhost</test.host>
+ <test.port>8080</test.port>
+ <test.portalContainer>portal</test.portalContainer>
+ <test.waitTimeout>20</test.waitTimeout>
+ <test.shortPause>3</test.shortPause>
</properties>
<!-- no tests by default -->
@@ -78,6 +83,28 @@
<!--suiteXmlFiles>
<suiteXmlFile>src/test/resources/${testng.suite.file}</suiteXmlFile>
</suiteXmlFiles-->
+ <systemProperties>
+ <property>
+ <name>test.host</name>
+ <value>${test.host}</value>
+ </property>
+ <property>
+ <name>test.port</name>
+ <value>${test.port}</value>
+ </property>
+ <property>
+ <name>test.portalContainer</name>
+ <value>${test.portalContainer}</value>
+ </property>
+ <property>
+ <name>test.waitTimeout</name>
+ <value>${test.waitTimeout}</value>
+ </property>
+ <property>
+ <name>test.shortPause</name>
+ <value>${test.shortPause}</value>
+ </property>
+ </systemProperties>
</configuration>
</execution>
</executions>
Modified: portal/trunk/testsuite/htmlunit-tests/src/test/java/org/jboss/gatein/htmlunit/common/WebHelper.java
===================================================================
--- portal/trunk/testsuite/htmlunit-tests/src/test/java/org/jboss/gatein/htmlunit/common/WebHelper.java 2011-03-03 12:37:38 UTC (rev 5957)
+++ portal/trunk/testsuite/htmlunit-tests/src/test/java/org/jboss/gatein/htmlunit/common/WebHelper.java 2011-03-03 14:30:56 UTC (rev 5958)
@@ -44,20 +44,21 @@
private String host = "localhost";
/** Port to use for web session */
- private int port = 8888;
+ private int port = 8080;
/** Portal container to use for web session */
private String portalContainer = "portal";
- /** Current page */
- private HtmlPage page;
-
/** Time to wait (in seconds) for element or text to appear in the page */
- private int timeout = 20;
+ private int waitTimeout = 20;
/** Short pause period (in seconds)*/
private int shortPause = 3;
+ /** Current page */
+ private HtmlPage page;
+
+
/** Get HTMLUnit WebClient instance representing the current session */
public WebClient getWebClient()
{
@@ -66,10 +67,35 @@
webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setThrowExceptionOnScriptError(false);
+
+ initFromSystemProps();
}
return webClient;
}
+ private void initFromSystemProps()
+ {
+ String val = System.getProperty("test.host");
+ if (val != null)
+ host = val;
+
+ val = System.getProperty("test.port");
+ if (val != null)
+ port = Integer.parseInt(val);
+
+ val = System.getProperty("test.portalContainer");
+ if (val != null)
+ portalContainer = val;
+
+ val = System.getProperty("test.waitTimeout");
+ if (val != null)
+ waitTimeout = Integer.parseInt(val);
+
+ val = System.getProperty("test.shortPause");
+ if (val != null)
+ shortPause = Integer.parseInt(val);
+ }
+
/**
* Open GateIn's home page.
*
@@ -144,7 +170,7 @@
{
for (int second = 0; ; second++)
{
- if (second >= timeout)
+ if (second >= waitTimeout)
{
Assert.fail("Timeout at waitForElementPresent: " + el);
}
@@ -190,7 +216,7 @@
{
for (int second = 0; ; second++)
{
- if (second >= timeout)
+ if (second >= waitTimeout)
{
//System.out.println("[DEBUG] " + page.asXml());
Assert.fail("Timeout at waitForTextPresent: " + text);
@@ -207,7 +233,7 @@
{
for (int second = 0; ; second++)
{
- if (second >= timeout)
+ if (second >= waitTimeout)
{
Assert.fail("Timeout at waitForTextPresent: " + text);
}
13 years, 10 months