JBoss Rich Faces SVN: r11450 - in trunk/framework/impl/src: test/java/org/ajax4jsf and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-28 17:55:58 -0500 (Fri, 28 Nov 2008)
New Revision: 11450
Added:
trunk/framework/impl/src/test/java/org/ajax4jsf/resource/
trunk/framework/impl/src/test/java/org/ajax4jsf/resource/cached/
trunk/framework/impl/src/test/java/org/ajax4jsf/resource/cached/DualLRUMapTest.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java
Log:
RF-3586
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java 2008-11-28 20:18:11 UTC (rev 11449)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java 2008-11-28 22:55:58 UTC (rev 11450)
@@ -21,9 +21,12 @@
package org.ajax4jsf.resource.cached;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Set;
class DualLRUMap<K, V> extends LinkedHashMap<K, V> {
@@ -52,10 +55,27 @@
return v;
};
- public K getKey(Object key) {
- return reverseMap.get(key);
+ public V remove(Object key) {
+ V value = super.remove(key);
+
+ if (value != null) {
+ reverseMap.remove(value);
+ }
+
+ return value;
}
+ public K getKey(Object value) {
+ K key = reverseMap.get(value);
+
+ if (key != null) {
+ //update LRU
+ get(key);
+ }
+
+ return key;
+ }
+
@Override
protected boolean removeEldestEntry(java.util.Map.Entry<K, V> eldest) {
boolean remove = (size() > capacity);
@@ -66,4 +86,19 @@
return remove;
}
+
+ @Override
+ public Set<java.util.Map.Entry<K, V>> entrySet() {
+ return Collections.unmodifiableSet(super.entrySet());
+ }
+
+ @Override
+ public Set<K> keySet() {
+ return Collections.unmodifiableSet(super.keySet());
+ }
+
+ @Override
+ public Collection<V> values() {
+ return Collections.unmodifiableCollection(super.values());
+ }
}
\ No newline at end of file
Added: trunk/framework/impl/src/test/java/org/ajax4jsf/resource/cached/DualLRUMapTest.java
===================================================================
--- trunk/framework/impl/src/test/java/org/ajax4jsf/resource/cached/DualLRUMapTest.java (rev 0)
+++ trunk/framework/impl/src/test/java/org/ajax4jsf/resource/cached/DualLRUMapTest.java 2008-11-28 22:55:58 UTC (rev 11450)
@@ -0,0 +1,78 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.resource.cached;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class DualLRUMapTest extends TestCase {
+
+ public void testBasic() throws Exception {
+ DualLRUMap<String, String> map = new DualLRUMap<String, String>(16);
+
+ map.put("1", "a");
+ map.put("2", "b");
+ map.put("3", "c");
+
+ assertEquals("a", map.get("1"));
+ assertEquals("b", map.get("2"));
+ assertEquals("c", map.get("3"));
+
+ assertEquals("1", map.getKey("a"));
+ assertEquals("2", map.getKey("b"));
+ assertEquals("3", map.getKey("c"));
+
+ assertTrue(map.containsKey("1"));
+ assertTrue(map.containsValue("a"));
+ assertTrue(map.containsKey("2"));
+ assertTrue(map.containsValue("b"));
+ assertTrue(map.containsKey("3"));
+ assertTrue(map.containsValue("c"));
+
+ map.remove("2");
+ assertNull(map.get("2"));
+ assertNull(map.getKey("b"));
+
+ assertFalse(map.containsKey("2"));
+ assertFalse(map.containsValue("b"));
+ }
+
+ public void testRemoveEldest() throws Exception {
+ DualLRUMap<String,String> map = new DualLRUMap<String, String>(2);
+
+ map.put("1", "a");
+ map.put("2", "b");
+
+ assertNotNull(map.get("2"));
+ assertNotNull(map.get("1"));
+
+ map.put("3", "c");
+
+ assertNull(map.get("2"));
+ assertNull(map.getKey("b"));
+ }
+
+}
16 years
JBoss Rich Faces SVN: r11449 - trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-28 15:18:11 -0500 (Fri, 28 Nov 2008)
New Revision: 11449
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBean.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBytesDataBean.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceDataBean.java
Log:
RF-3586
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java 2008-11-28 19:06:24 UTC (rev 11448)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java 2008-11-28 20:18:11 UTC (rev 11449)
@@ -24,6 +24,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
+import java.util.UUID;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
@@ -37,165 +39,241 @@
import org.apache.commons.logging.LogFactory;
/**
- * @author shura
+ * This class is intended to generate predictable URIs for all resources handled by RichFaces.
+ * It creates mapping between resource key/data value and generated random string of known format
+ * for all resource requests. By default {@link UUID#toString()} is used. Mapping is maintained by LRU map
+ * having default capacity of {@value #DEFAULT_CAPACITY} so be aware that stale entries can be removed and
+ * application users will get errors then.
*
+ * How to use: add to application classpath META-INF/services/org.ajax4jsf.resource.InternetResourceBuilder
+ * file with the following content <code>org.ajax4jsf.resource.cached.CachedResourceBuilder</code>
+ *
+ * Limitations:
+ *
+ * <ol>
+ * <li>Doesn't work in clustered environments</li>
+ * <li>All resource URIs become invalid after server restart that can cause cache issues</li>
+ * <li>
+ * Diagnostic of resource loading errors becomes somewhat harder. Variant of code where random key
+ * is appended to resource name doesn't satisfy the requirement of no path depth > 8 as requested
+ * by users (see <a href="https://jira.jboss.org/jira/browse/RF-3586">RF-3586</a> for more info)
+ * </li>
+ * </ol>
+ *
+ * @author Alexander Smirnov
+ * @author Nick Belaevski
*/
public class CachedResourceBuilder extends ResourceBuilderImpl {
- private static final Log log = LogFactory
- .getLog(CachedResourceBuilder.class);
+ private static final Log log = LogFactory.getLog(CachedResourceBuilder.class);
- private static final int DEFAULT_CAPACITY = 10000;
+ protected static final int DEFAULT_CAPACITY = 10000;
- private long counter = 0;
+ private ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
+
+ private DualLRUMap cache;
- private DualLRUMap cache;
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceBuilderImpl#decrypt(byte[])
+ */
+ protected byte[] decrypt(byte[] data) {
+ // dummy - data not send via internet.
+ return data;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceBuilderImpl#decrypt(byte[])
- */
- protected byte[] decrypt(byte[] data) {
- // dummy - data not send via internet.
- return data;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceBuilderImpl#encrypt(byte[])
+ */
+ protected byte[] encrypt(byte[] data) {
+ // dummy - data not send via internet.
+ return data;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceBuilderImpl#encrypt(byte[])
- */
- protected byte[] encrypt(byte[] data) {
- // dummy - data not send via internet.
- return data;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceBuilderImpl#getResourceDataForKey(java.lang.String)
+ */
+ public Object getResourceDataForKey(String key) {
+ ResourceBean bean = null;
+ try {
+ readWriteLock.readLock().lock();
+ bean = (ResourceBean) cache.get(key);
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceBuilderImpl#getResourceDataForKey(java.lang.String)
- */
- public Object getResourceDataForKey(String key) {
- ResourceBean bean = (ResourceBean) cache.get(key);
- if (null == bean) {
- throw new ResourceNotFoundException("Resource for key " + key
- + "not present in cache");
+ if (null == bean) {
+ throw new ResourceNotFoundException("Resource for key " + key
+ + "not present in cache");
+ }
+
+ return bean.getData();
}
- return bean.getData();
- }
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceBuilderImpl#getResourceForKey(java.lang.String)
- */
- public InternetResource getResourceForKey(String key)
- throws ResourceNotFoundException {
- ResourceBean bean = (ResourceBean) cache.get(key);
- if (null == bean) {
- throw new ResourceNotFoundException("Resource for key " + key
- + "not present in cache");
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceBuilderImpl#getResourceForKey(java.lang.String)
+ */
+ public InternetResource getResourceForKey(String key)
+ throws ResourceNotFoundException {
+ ResourceBean bean = null;
+ try {
+ readWriteLock.readLock().lock();
+ bean = (ResourceBean) cache.get(key);
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+
+ if (null == bean) {
+ throw new ResourceNotFoundException("Resource for key " + key
+ + "not present in cache");
+ }
+
+ return super.getResourceForKey(bean.getKey());
}
- return super.getResourceForKey(bean.getKey());
- }
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceBuilderImpl#getUri(org.ajax4jsf.resource.InternetResource,
- * javax.faces.context.FacesContext, java.lang.Object)
- */
- public String getUri(InternetResource resource, FacesContext facesContext,
- Object data) {
- ResourceBean bean;
- if (null == data) {
- bean = new ResourceBean(resource.getKey());
- } else {
- if (data instanceof byte[]) {
- // Special case for simple bytes array data.
- bean = new ResourceBytesDataBean(resource.getKey(),
- (byte[]) data);
- } else {
- bean = new ResourceDataBean(resource.getKey(), data);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceBuilderImpl#getUri(org.ajax4jsf.resource.InternetResource,
+ * javax.faces.context.FacesContext, java.lang.Object)
+ */
+ public String getUri(InternetResource resource, FacesContext facesContext,
+ Object data) {
+ ResourceBean bean;
+ if (null == data) {
+ bean = new ResourceBean(resource.getKey());
+ } else {
+ if (data instanceof byte[]) {
+ // Special case for simple bytes array data.
+ bean = new ResourceBytesDataBean(resource.getKey(),
+ (byte[]) data);
+ } else {
+ bean = new ResourceDataBean(resource.getKey(), data);
+ }
+ }
+
+ String key = null;
+
+ try {
+ readWriteLock.readLock().lock();
+
+ key = (String) cache.getKey(bean);
+
+ if (key != null) {
+ // Refresh LRU
+ cache.get(key);
+ }
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+
+ if (key == null) {
+ try {
+ readWriteLock.writeLock().lock();
+
+ key = (String) cache.getKey(bean);
+ if (null == key) {
+ key = createNextKey();
+ while (cache.containsKey(key)) {
+ key = createNextKey();
+ }
+
+ cache.put(key, bean);
+ } else {
+ // Refresh LRU
+ cache.get(key);
+ }
+
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ }
+
+ boolean isGlobal = !resource.isSessionAware();
+
+ String resourceURL = getFacesResourceURL(facesContext, key, isGlobal);
+ if (!isGlobal) {
+ resourceURL = facesContext.getExternalContext().encodeResourceURL(
+ resourceURL);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_URI_INFO,
+ resource.getKey(), resourceURL));
+ }
+ return resourceURL;// context.getExternalContext().encodeResourceURL(resourceURL);
}
- String key = (String) cache.getKey(bean);
- if (null == key) {
- synchronized (this) {
- counter++;
- key = bean.hashCode() + "c" + counter;
- }
- cache.put(key, bean);
- } else {
- // Refresh LRU
- cache.get(key);
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceBuilderImpl#init(javax.servlet.ServletContext,
+ * java.lang.String)
+ */
+ public void init() throws FacesException {
+ super.init();
+
+ Properties properties = getProperties("cache.properties");
+ int capacity = getCapacity(properties);
+ if (capacity <= 0) {
+ capacity = DEFAULT_CAPACITY;
+ log.info("Using default capacity: " + DEFAULT_CAPACITY);
+ }
+
+ cache = new DualLRUMap(capacity);
}
+
+ /**
+ * Get properties file from classpath
+ *
+ * @param name
+ * @return
+ */
+ protected Properties getProperties(String name) {
+ Properties properties = new Properties();
+ InputStream props = URLToStreamHelper.urlToStreamSafe(CachedResourceBuilder.class
+ .getResource(name));
+ if (null != props) {
+ try {
+ properties.load(props);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ log.warn(Messages.getMessage(Messages.READING_PROPERTIES_ERROR,
+ name), e);
+ } finally {
+ try {
+ props.close();
+ } catch (IOException e) {
+ // Can be ignored
+ }
+ }
+ }
+ return properties;
+
+ }
- boolean isGlobal = !resource.isSessionAware();
-
- String resourceURL = getFacesResourceURL(facesContext, key, isGlobal);
- if (!isGlobal) {
- resourceURL = facesContext.getExternalContext().encodeResourceURL(
- resourceURL);
+ protected String createNextKey() {
+ return UUID.randomUUID().toString();
}
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_URI_INFO,
- resource.getKey(), resourceURL));
- }
- return resourceURL;// context.getExternalContext().encodeResourceURL(resourceURL);
- }
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceBuilderImpl#init(javax.servlet.ServletContext,
- * java.lang.String)
- */
- public void init()
- throws FacesException {
- super.init();
- // Create cache manager.
- Properties properties = getProperties("cache.properties");
- int capacity = DEFAULT_CAPACITY;
- String capacityString = properties.getProperty("cache.capacity");
- if (null != capacityString) {
- try {
- capacity = Integer.parseInt(capacityString);
- } catch (NumberFormatException e) {
- log.warn("Error parsing value of parameters cache capacity, use default value "+DEFAULT_CAPACITY, e);
- }
- }
- cache = new DualLRUMap(capacity);
- counter = getStartTime() - 1158760000000L;
- }
-
- /**
- * Get properties file from classpath
- *
- * @param name
- * @return
- */
- protected Properties getProperties(String name) {
- Properties properties = new Properties();
- InputStream props = URLToStreamHelper.urlToStreamSafe(CachedResourceBuilder.class
- .getResource(name));
- if (null != props) {
- try {
- properties.load(props);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- log.warn(Messages.getMessage(Messages.READING_PROPERTIES_ERROR,
- name), e);
- } finally {
- try {
- props.close();
- } catch (IOException e) {
- // Can be ignored
+ protected int getCapacity(Properties properties) {
+ // Create cache manager.
+ int capacity = 0;
+ String capacityString = properties.getProperty("cache.capacity");
+ if (null != capacityString) {
+ try {
+ capacity = Integer.parseInt(capacityString);
+ } catch (NumberFormatException e) {
+ log.warn("Error parsing value of parameters cache capacity", e);
+ }
}
- }
+
+ return capacity;
}
- return properties;
-
- }
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java 2008-11-28 19:06:24 UTC (rev 11448)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java 2008-11-28 20:18:11 UTC (rev 11449)
@@ -22,57 +22,48 @@
package org.ajax4jsf.resource.cached;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
-import org.apache.commons.collections.LRUMap;
+class DualLRUMap<K, V> extends LinkedHashMap<K, V> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -313747679711995782L;
-class DualLRUMap extends LRUMap {
+ private Map<V, K> reverseMap;
- private Map reverseMap ;
+ private int capacity;
+
+ public DualLRUMap(int capacity) {
+ super(capacity, 0.75f, true);
- public DualLRUMap(int size) {
- super(size);
- reverseMap = new HashMap(size);
+ this.capacity = capacity;
+
+ this.reverseMap = new HashMap<V, K>(capacity, 0.75f);
}
-
- /* (non-Javadoc)
- * @see org.apache.commons.collections.LRUMap#processRemovedLRU(java.lang.Object, java.lang.Object)
- */
- protected void processRemovedLRU(Object key, Object value) {
- synchronized (this) {
- super.processRemovedLRU(key, value);
- reverseMap.remove(value);
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.commons.collections.LRUMap#put(java.lang.Object, java.lang.Object)
- */
- public Object put(Object key, Object value) {
- synchronized (this) {
- reverseMap.put(value, key);
- return super.put(key, value);
- }
- }
- public Object getKey(Object value){
- synchronized (this) {
- Object key = reverseMap.get(value);
- if(!containsKey(key)){
- reverseMap.remove(value);
- key = null;
- }
- return key;
- }
+ public V put(K key, V value) {
+ V v = super.put(key, value);
+
+ reverseMap.put(value, key);
+
+ return v;
+ };
+
+ public K getKey(Object key) {
+ return reverseMap.get(key);
}
+
+ @Override
+ protected boolean removeEldestEntry(java.util.Map.Entry<K, V> eldest) {
+ boolean remove = (size() > capacity);
- /* (non-Javadoc)
- * @see org.apache.commons.collections.LRUMap#get(java.lang.Object)
- */
- public Object get(Object key) {
- synchronized (this) {
- return super.get(key);
+ if (remove) {
+ reverseMap.remove(eldest.getValue());
}
+
+ return remove;
}
-
}
\ No newline at end of file
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBean.java 2008-11-28 19:06:24 UTC (rev 11448)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBean.java 2008-11-28 20:18:11 UTC (rev 11449)
@@ -27,8 +27,12 @@
* @author shura
*
*/
-public class ResourceBean implements Serializable {
+public class ResourceBean implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2830008963777271324L;
private String key;
/**
@@ -51,10 +55,15 @@
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
if (null != obj && obj instanceof ResourceBean) {
ResourceBean bean = (ResourceBean) obj;
return key.equals(bean.getKey()) && bean.getData() == null;
- };
+ }
+
return false;
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBytesDataBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBytesDataBean.java 2008-11-28 19:06:24 UTC (rev 11448)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBytesDataBean.java 2008-11-28 20:18:11 UTC (rev 11449)
@@ -29,6 +29,10 @@
*/
public class ResourceBytesDataBean extends ResourceBean {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3012554202964229624L;
private byte[] data;
ResourceBytesDataBean(String key, byte[] data){
@@ -43,11 +47,16 @@
* @see com.exadel.vcp.resource.ResourceBean#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
if (null != obj && obj instanceof ResourceBytesDataBean) {
ResourceBytesDataBean bean = (ResourceBytesDataBean) obj;
byte[] beanData = (byte[]) bean.getData();
return getKey().equals(bean.getKey()) && Arrays.equals(data, beanData);
- };
+ }
+
return false;
}
@@ -55,11 +64,10 @@
* @see com.exadel.vcp.resource.ResourceBean#hashCode()
*/
public int hashCode() {
- int hash = super.hashCode();
- for (int i = 0; i < data.length; i++) {
- hash = hash*32+data[i];
- }
- return hash;
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + Arrays.hashCode(data);
+ return result;
}
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceDataBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceDataBean.java 2008-11-28 19:06:24 UTC (rev 11448)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceDataBean.java 2008-11-28 20:18:11 UTC (rev 11449)
@@ -26,8 +26,13 @@
* @author shura
*
*/
-public class ResourceDataBean extends ResourceBean{
+public class ResourceDataBean extends ResourceBean {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -6486715556040103424L;
+
private Object data;
public ResourceDataBean(String key, Object data){
@@ -39,10 +44,15 @@
* @see com.exadel.vcp.resource.ResourceBean#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
if (null != obj && obj instanceof ResourceBean) {
ResourceBean bean = (ResourceBean) obj;
return getKey().equals(bean.getKey()) && data.equals(bean.getData());
- };
+ }
+
return false;
}
@@ -57,8 +67,10 @@
* @see com.exadel.vcp.resource.ResourceBean#hashCode()
*/
public int hashCode() {
- // TODO Auto-generated method stub
- return super.hashCode()*32+data.hashCode();
+ final int prime = 31;
+ int result = super.hashCode();
+ result = result * prime + data.hashCode();
+ return result;
}
}
16 years
JBoss Rich Faces SVN: r11448 - trunk/framework/impl/src/main/javascript/ajaxjsf.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2008-11-28 14:06:24 -0500 (Fri, 28 Nov 2008)
New Revision: 11448
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
Log:
https://jira.jboss.org/jira/browse/RF-5039
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-28 17:25:57 UTC (rev 11447)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-28 19:06:24 UTC (rev 11448)
@@ -61,7 +61,7 @@
this.query.appendParameter("AJAX:EVENTS_COUNT", this.eventsCount);
this.request = A4J.AJAX.SubmitQuery(this.query, this.options, this.event)
- var queue = this.queue;
+ var queue = this.queue; // TODO: move to next line
this.request.queue = queue;
return this.request;
@@ -223,7 +223,7 @@
if (this.queueOptions.onsizeexceeded) {
this.queueOptions.onsizeexceeded.call(this, query, opts, event);
}
-
+ // TODO: create one function that will be implement this functionality // function (behaviorFlag, entry): should return handled flag
if (b == DROP_NEW) {
LOG.debug("Queue '" + this.name + "' is going to drop new item");
16 years
JBoss Rich Faces SVN: r11447 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/pages/message and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2008-11-28 12:25:57 -0500 (Fri, 28 Nov 2008)
New Revision: 11447
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/MessageBean2.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/message/message.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/MessageTest.java
Log:
RF-5114
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/MessageBean2.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/MessageBean2.java 2008-11-28 17:00:50 UTC (rev 11446)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/MessageBean2.java 2008-11-28 17:25:57 UTC (rev 11447)
@@ -8,20 +8,27 @@
import javax.faces.validator.ValidatorException;
public class MessageBean2 implements Validator{
-
- static public final String MESSAGE = "Validation is failed";
private String string;
private Boolean rendered;
+ private Boolean showDetail;
+
+ private Boolean showSummary;
+
+ private Boolean ajaxRendered;
+
public MessageBean2() {
-
+ init();
}
public void init() {
string = "something";
rendered = true;
+ showDetail = true;
+ showSummary = false;
+ ajaxRendered = false;
}
public void validate(FacesContext context, UIComponent component,
@@ -37,9 +44,8 @@
severity = FacesMessage.SEVERITY_INFO;
}
if (severity != null) {
- FacesMessage message = new FacesMessage(MESSAGE);
- message.setSeverity(severity);
- throw new ValidatorException(message);
+ throw new ValidatorException(new FacesMessage(severity,
+ "messageSummary", "messageDetail"));
}
}
@@ -58,5 +64,29 @@
public Boolean getRendered() {
return rendered;
}
+
+ public void setShowDetail(Boolean showDetail) {
+ this.showDetail = showDetail;
+ }
+
+ public Boolean getShowDetail() {
+ return showDetail;
+ }
+
+ public void setShowSummary(Boolean showSummary) {
+ this.showSummary = showSummary;
+ }
+
+ public Boolean getShowSummary() {
+ return showSummary;
+ }
+
+ public void setAjaxRendered(Boolean ajaxRendered) {
+ this.ajaxRendered = ajaxRendered;
+ }
+
+ public Boolean getAjaxRendered() {
+ return ajaxRendered;
+ }
}
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/message/message.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/message/message.xhtml 2008-11-28 17:00:50 UTC (rev 11446)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/message/message.xhtml 2008-11-28 17:25:57 UTC (rev 11447)
@@ -16,11 +16,26 @@
<h:selectBooleanCheckbox id="rendered" value="#{messageBean.rendered}">
<a4j:support event="onchange" />
</h:selectBooleanCheckbox>
+ <h:outputText value="showSummary" />
+ <h:selectBooleanCheckbox id="showSummary" value="#{messageBean.showSummary}">
+ <a4j:support event="onchange" />
+ </h:selectBooleanCheckbox>
+ <h:outputText value="showDetail" />
+ <h:selectBooleanCheckbox id="showDetail" value="#{messageBean.showDetail}">
+ <a4j:support event="onchange" />
+ </h:selectBooleanCheckbox>
+ <h:outputText value="ajaxRendered" />
+ <h:selectBooleanCheckbox id="ajaxRendered" value="#{messageBean.ajaxRendered}">
+ <a4j:support event="onchange" />
+ </h:selectBooleanCheckbox>
</h:form>
<h:form id="mainForm">
<h:panelGroup id="panel">
<h:inputText id="inputText" value="#{messageBean.string}" validator="#{messageBean.validate}"></h:inputText>
<rich:message id="message" for="inputText"
+ ajaxRendered="false"
+ showSummary="#{messageBean.showSummary}"
+ showDetail="#{messageBean.showDetail}"
rendered="#{messageBean.rendered}"
>
<f:facet name="fatalMarker">
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/MessageTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/MessageTest.java 2008-11-28 17:00:50 UTC (rev 11446)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/MessageTest.java 2008-11-28 17:25:57 UTC (rev 11447)
@@ -17,7 +17,13 @@
private String rendered;
- private void init(Template template) {
+ private String showDetail;
+
+ private String showSummary;
+
+ private String ajaxRendered;
+
+ private void init(Template template) {
renderPage(template, "#{messageBean.init}");
mainForm = getParentId() + "mainForm";
inputText = mainForm + ":inputText";
@@ -25,9 +31,34 @@
submit = mainForm + ":submit";
String attrForm = getParentId() + "attrForm";
rendered = attrForm + ":rendered";
+ showDetail = attrForm + ":showDetail";
+ showSummary = attrForm + ":showSummary";
+ ajaxRendered = attrForm + ":ajaxRendered";
}
/**
+ * showDetail and showSummary attributes work
+ */
+ @Test
+ public void testShowDetailAndShowSummary(Template template) {
+ init(template);
+ String locator = "xpath=id('" + message + "')/span[2]";
+ Assert.assertTrue(selenium.getText(locator).length() == 0);
+ selenium.type(inputText, "fatal");
+ clickAjaxCommandAndWait(submit);
+ Assert.assertTrue("messageDetail".equals(selenium.getText(locator)));
+ clickAjaxCommandAndWait(showSummary);
+ selenium.type(inputText, "fatal");
+ clickAjaxCommandAndWait(submit);
+ Assert.assertTrue("messageSummarymessageDetail".equals(selenium.getText(locator)));
+ clickAjaxCommandAndWait(showDetail);
+ selenium.type(inputText, "fatal");
+ clickAjaxCommandAndWait(submit);
+ Assert.assertTrue("messageSummary".equals(selenium.getText(locator)));
+
+ }
+
+ /**
* level selects message of respective level
*/
@Test
@@ -45,6 +76,9 @@
Assert.assertTrue(selenium.isElementPresent(mainForm + ":passedMarker"));
selenium.type(inputText, "fatal");
clickAjaxCommandAndWait(mainForm + ":submitWithoutReRender");
+ Assert.assertTrue(selenium.isElementPresent(mainForm + ":passedMarker"));
+ clickAjaxCommandAndWait(ajaxRendered);
+ clickAjaxCommandAndWait(mainForm + ":submitWithoutReRender");
Assert.assertTrue(selenium.isElementPresent(mainForm + ":fatalMarker"));
}
16 years
JBoss Rich Faces SVN: r11446 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/pages/tree and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2008-11-28 12:00:50 -0500 (Fri, 28 Nov 2008)
New Revision: 11446
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tree/treeTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java
Log:
https://jira.jboss.org/jira/browse/RF-4831
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java 2008-11-28 16:50:21 UTC (rev 11445)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java 2008-11-28 17:00:50 UTC (rev 11446)
@@ -33,6 +33,7 @@
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.xmlrules.DigesterLoader;
import org.richfaces.component.UITree;
+import org.richfaces.component.state.TreeStateAdvisor;
import org.richfaces.event.NodeSelectedEvent;
import org.richfaces.model.TreeNode;
import org.richfaces.model.TreeNodeImpl;
@@ -299,4 +300,43 @@
setRichModel(true);
}
+ private TreeStateAdvisor advisor;
+
+ /**
+ * Gets value of advisor field.
+ * @return value of advisor field
+ */
+ public TreeStateAdvisor getAdvisor() {
+ return advisor;
+ }
+
+ /**
+ * Set a new value for advisor field.
+ * @param advisor a new value for advisor field
+ */
+ public void setAdvisor(TreeStateAdvisor advisor) {
+ this.advisor = advisor;
+ }
+
+ public void initStateAdvisorTest() {
+ if(advisor == null) {
+ setAdvisor(new TestAdvisor());
+ }
+ }
+
+ static class TestAdvisor implements TreeStateAdvisor {
+
+ public Boolean adviseNodeOpened(UITree tree) {
+ return true;
+ }
+
+ public Boolean adviseNodeSelected(UITree tree) {
+ return null;
+ }
+ }
+
+ public void tearDown() {
+ setAdvisor(null);
+ }
+
}
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tree/treeTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java 2008-11-28 16:50:21 UTC (rev 11445)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java 2008-11-28 17:00:50 UTC (rev 11446)
@@ -22,6 +22,8 @@
private final static String INIT_SERVER_MODE = "#{treeBean.initServerMode}";
private final static String INIT_AJAX_MODE = "#{treeBean.initAjaxMode}";
private final static String INIT_CLIENT_MODE = "#{treeBean.initClientMode}";
+ private final static String INIT_ADVISOR_TEST = "#{treeBean.initStateAdvisorTest}";
+ private final static String TEAR_DOWN_METHOD = "#{treeBean.tearDown}";
static {
params.put("parameter1", "value1");
@@ -318,34 +320,6 @@
}
@Test
- public void testIconsAttributesAreApplied(Template template) {
- renderPage(template, null);
-
- writeStatus("Check icons attributes applied: are output to client and images are accessible");
-
- String compId = getParentId() + "_form:tree";
-
- testIcon("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[2]/img", "singer");
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td/div/a");
- testIcon("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[2]/img", "disc");
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
- testIcon("//*[@id='"+ compId + ":childs']/div/div/table[1]/tbody/tr/td[2]/img", "song");
- }
-
- /**
- * Test an icon.
- *
- * @param location location of image representing icon to be tested
- * @param iconName substring that icon uri has to contain
- */
- private void testIcon(String location, String iconSubstring) {
- String iconSrc = selenium.getAttribute(location + "/@src");
- if (null == iconSrc || !iconSrc.matches(".*" + iconSubstring + ".*")) {
- Assert.fail("It looks as if the icon is not proper. Uri of icon is being tested must contain [" + iconSubstring + "]");
- }
- }
-
- @Test
public void testServerMode(Template template) {
AutoTester tester = getAutoTester(this);
tester.renderPage(template, INIT_SERVER_MODE);
@@ -450,7 +424,7 @@
@Test
public void testNodePresentationCanBeCustomizedUsingRenderedAndNodeFaceAttributes(Template template) {
- renderPage(template, null);
+ renderPage(template, TEAR_DOWN_METHOD);
writeStatus("Check node presentation can be customized using rendered and nodeFace attributes");
String compId = getParentId() + "_form:tree";
@@ -463,6 +437,42 @@
AssertTextEquals("//*[@id='"+ compId + ":childs']/table[2]/tbody/tr/td[3]", "Christina Aguilera [Oh, Lord! She's my favorite]");
}
+ @Test
+ public void testIconsAttributesAreApplied(Template template) {
+ renderPage(template, TEAR_DOWN_METHOD);
+
+ writeStatus("Check icons attributes applied: are output to client and images are accessible");
+
+ String compId = getParentId() + "_form:tree";
+
+ testIcon("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[2]/img", "singer");
+ clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td/div/a");
+ testIcon("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[2]/img", "disc");
+ clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
+ testIcon("//*[@id='"+ compId + ":childs']/div/div/table[1]/tbody/tr/td[2]/img", "song");
+ }
+
+ @Test
+ public void testTreeStateAdvisor(Template template) {
+ renderPage(template, INIT_ADVISOR_TEST);
+ writeStatus("Check tree state advisors work properly");
+ writeStatus("All nodes have to be expanded thanks to advisor set. Test it");
+
+ String compId = getParentId() + "_form:tree";
+
+ Assert.assertTrue(isPresent("//*[@id='"+ compId + ":childs']/div[1]"), "It looks as if there are unexpanded nodes here");
+ Assert.assertTrue(isVisible("//*[@id='"+ compId + ":childs']/div[1]"), "It looks as if there are unexpanded nodes here");
+
+ Assert.assertTrue(isPresent("//*[@id='"+ compId + ":childs']/div[1]/div"), "It looks as if there are unexpanded nodes here");
+ Assert.assertTrue(isVisible("//*[@id='"+ compId + ":childs']/div[1]/div"), "It looks as if there are unexpanded nodes here");
+
+ Assert.assertTrue(isPresent("//*[@id='"+ compId + ":childs']/div[2]"), "It looks as if there are unexpanded nodes here");
+ Assert.assertTrue(isVisible("//*[@id='"+ compId + ":childs']/div[2]"), "It looks as if there are unexpanded nodes here");
+
+ Assert.assertTrue(isPresent("//*[@id='"+ compId + ":childs']/div[2]/div"), "It looks as if there are unexpanded nodes here");
+ Assert.assertTrue(isVisible("//*[@id='"+ compId + ":childs']/div[2]/div"), "It looks as if there are unexpanded nodes here");
+ }
+
@Override
public void sendAjax() {
AutoTester tester = getAutoTester(this);
@@ -481,4 +491,17 @@
return "pages/tree/treeAutoTest.xhtml";
}
+ /**
+ * Test an icon.
+ *
+ * @param location location of image representing icon to be tested
+ * @param iconName substring that icon uri has to contain
+ */
+ private void testIcon(String location, String iconSubstring) {
+ String iconSrc = selenium.getAttribute(location + "/@src");
+ if (null == iconSrc || !iconSrc.matches(".*" + iconSubstring + ".*")) {
+ Assert.fail("It looks as if the icon is not proper. Uri of icon is being tested must contain [" + iconSubstring + "]");
+ }
+ }
+
}
16 years
JBoss Rich Faces SVN: r11445 - trunk/ui/message/src/test/java/org/richfaces/renderer.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-11-28 11:50:21 -0500 (Fri, 28 Nov 2008)
New Revision: 11445
Modified:
trunk/ui/message/src/test/java/org/richfaces/renderer/RichMessageRendererTest.java
trunk/ui/message/src/test/java/org/richfaces/renderer/RichMessagesRendererTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5059
Modified: trunk/ui/message/src/test/java/org/richfaces/renderer/RichMessageRendererTest.java
===================================================================
--- trunk/ui/message/src/test/java/org/richfaces/renderer/RichMessageRendererTest.java 2008-11-28 16:50:17 UTC (rev 11444)
+++ trunk/ui/message/src/test/java/org/richfaces/renderer/RichMessageRendererTest.java 2008-11-28 16:50:21 UTC (rev 11445)
@@ -24,6 +24,7 @@
import java.util.List;
import javax.faces.application.FacesMessage;
+import javax.faces.component.UIMessage;
import javax.faces.component.html.HtmlInputText;
import javax.faces.component.html.HtmlOutputText;
@@ -31,6 +32,7 @@
import org.richfaces.component.html.HtmlRichMessage;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlLink;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
/**
@@ -39,9 +41,31 @@
*/
public class RichMessageRendererTest extends AbstractAjax4JsfTestCase {
- HtmlRichMessage message = null;
- HtmlOutputText text = null;
- HtmlInputText input = null;
+ HtmlRichMessage message1 = null;
+ HtmlRichMessage message2 = null;
+ HtmlRichMessage message3 = null;
+ HtmlRichMessage message4 = null;
+
+ int ERROR = 0;
+ int WARN = 1;
+ int FATAL = 2;
+ int INFO = 3;
+
+
+
+ HtmlOutputText text1 = null;
+ HtmlInputText input1 = null;
+
+ HtmlOutputText text2 = null;
+ HtmlInputText input2 = null;
+
+ HtmlOutputText text3 = null;
+ HtmlInputText input3 = null;
+
+ HtmlOutputText text4 = null;
+ HtmlInputText input4 = null;
+
+
public RichMessageRendererTest(String name) {
super(name);
@@ -51,36 +75,124 @@
super.setUp();
- input = (HtmlInputText)application.createComponent("javax.faces.HtmlInputText");
- input.setId("select");
+ input1 = (HtmlInputText)application.createComponent("javax.faces.HtmlInputText");
+ input1.setId("input1");
- text = (HtmlOutputText)application.createComponent("javax.faces.HtmlOutputText");
- text.setValue("Error");
+ text1 = (HtmlOutputText)application.createComponent("javax.faces.HtmlOutputText");
+ text1.setValue("Error");
+
+ input2 = (HtmlInputText)application.createComponent("javax.faces.HtmlInputText");
+ input2.setId("input2");
+
+ text2 = (HtmlOutputText)application.createComponent("javax.faces.HtmlOutputText");
+ text2.setValue("Warning");
- message = (HtmlRichMessage)application.createComponent("org.richfaces.component.RichMessage");
- message.setId("message");
- message.setFor("select");
- message.setErrorClass("errorClass");
- message.setErrorLabelClass("errorLabelClass");
- message.setErrorMarkerClass("errorMarkerClass");
- message.getFacets().put("errorFacet", text);
+ input3 = (HtmlInputText)application.createComponent("javax.faces.HtmlInputText");
+ input3.setId("input3");
+
+ text3 = (HtmlOutputText)application.createComponent("javax.faces.HtmlOutputText");
+ text3.setValue("Fatal");
+
+ input4 = (HtmlInputText)application.createComponent("javax.faces.HtmlInputText");
+ input4.setId("input4");
+
+ text4 = (HtmlOutputText)application.createComponent("javax.faces.HtmlOutputText");
+ text4.setValue("Info");
+
+ message1 = (HtmlRichMessage)application.createComponent("org.richfaces.component.RichMessage");
+ message1.setId("message1");
+ message1.setFor("input1");
+ message1.setLevel("ERROR");
+ message1.setShowSummary(true);
+ message1.setShowDetail(true);
+ message1.setTooltip(true);
+
+ message1.setErrorClass("errorClass");
+ message1.setErrorLabelClass("errorLabelClass");
+ message1.setErrorMarkerClass("errorMarkerClass");
+
+
+ message2 = (HtmlRichMessage)application.createComponent("org.richfaces.component.RichMessage");
+ message2.setId("message2");
+ message2.setFor("input2");
+ message2.setLevel("WARN");
+ message2.setShowSummary(true);
+ message2.setShowDetail(true);
+ message2.setTooltip(true);
+
+
+ message2.setWarnClass("warnClass");
+ message2.setWarnLabelClass("warnLabelClass");
+ message2.setWarnMarkerClass("warnMarkerClass");
+
+ message3 = (HtmlRichMessage)application.createComponent("org.richfaces.component.RichMessage");
+ message3.setId("message3");
+ message3.setFor("input3");
+ message3.setLevel("FATAL");
+ message3.setShowSummary(true);
+ message3.setShowDetail(true);
+ message3.setTooltip(true);
- FacesMessage facesMessage = new FacesMessage();
-
- facesMessage.setDetail("TEST detail");
- facesMessage.setSummary("TEST summary");
- facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
- facesContext.addMessage("select",facesMessage);
+ message3.setFatalClass("fatalClass");
+ message3.setFatalLabelClass("fatalLabelClass");
+ message3.setFatalMarkerClass("fatalMarkerClass");
- facesContext.getViewRoot().getChildren().add(input);
- facesContext.getViewRoot().getChildren().add(message);
+ message4 = (HtmlRichMessage)application.createComponent("org.richfaces.component.RichMessage");
+ message4.setId("message4");
+ message4.setFor("input4");
+ message4.setLevel("INFO");
+ message4.setShowSummary(true);
+ message4.setShowDetail(true);
+ message4.setTooltip(true);
+
+ message4.setInfoClass("infoClass");
+ message4.setInfoLabelClass("infoLabelClass");
+ message4.setInfoMarkerClass("infoMarkerClass");
+
+ message1.getFacets().put("errorMarker", text1);
+ message2.getFacets().put("warnMarker", text2);
+ message3.getFacets().put("fatalMarker", text3);
+ message4.getFacets().put("infoMarker", text4);
+
+ FacesMessage facesMessage1 = new FacesMessage();
+ facesMessage1.setDetail("TEST detail");
+ facesMessage1.setSummary("TEST summary");
+ facesMessage1.setSeverity(FacesMessage.SEVERITY_ERROR);
+ facesContext.addMessage("input1",facesMessage1);
+
+ FacesMessage facesMessage2 = new FacesMessage();
+ facesMessage2.setDetail("TEST detail");
+ facesMessage2.setSummary("TEST summary");
+ facesMessage2.setSeverity(FacesMessage.SEVERITY_WARN);
+ facesContext.addMessage("input2",facesMessage2);
+
+ FacesMessage facesMessage3 = new FacesMessage();
+ facesMessage3.setDetail("TEST detail");
+ facesMessage3.setSummary("TEST summary");
+ facesMessage3.setSeverity(FacesMessage.SEVERITY_FATAL);
+ facesContext.addMessage("input3",facesMessage3);
+
+ FacesMessage facesMessage4 = new FacesMessage();
+ facesMessage4.setDetail("TEST detail");
+ facesMessage4.setSummary("TEST summary");
+ facesMessage4.setSeverity(FacesMessage.SEVERITY_INFO);
+ facesContext.addMessage("input4",facesMessage4);
+
+ facesContext.getViewRoot().getChildren().add(input1);
+ facesContext.getViewRoot().getChildren().add(message1);
+ facesContext.getViewRoot().getChildren().add(input2);
+ facesContext.getViewRoot().getChildren().add(message2);
+ facesContext.getViewRoot().getChildren().add(input3);
+ facesContext.getViewRoot().getChildren().add(message3);
+ facesContext.getViewRoot().getChildren().add(input4);
+ facesContext.getViewRoot().getChildren().add(message4);
}
public void testRenderStyle() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
- List links = page.getDocumentElement().getHtmlElementsByTagName("link");
+ List <HtmlLink> links = page.getDocumentHtmlElement().getHtmlElementsByTagName("link");
assertNotNull(links);
HtmlElement link = (HtmlElement)links.get(0);
assertTrue(link.getAttributeValue("href").contains("org/richfaces/renderkit/html/css/msg.css"));
@@ -91,32 +203,77 @@
HtmlPage page = renderView();
assertNotNull(page);
+ checkMockUp(page, message1, ERROR);
+ checkMockUp(page, message2, WARN);
+ checkMockUp(page, message3, FATAL);
+ checkMockUp(page, message4, INFO);
+ }
+
+ public void checkMockUp(HtmlPage page, UIMessage message, int type ) {
+
HtmlElement span = page.getHtmlElementById(message.getClientId(facesContext));
-
assertNotNull(span);
assertEquals("span", span.getNodeName().toLowerCase());
-
String classAttr = span.getAttributeValue("class");
assertTrue(classAttr.contains("rich-message"));
- assertTrue(classAttr.contains("errorClass"));
- Iterator childIter= span.getChildElementsIterator();
-
- for (; childIter.hasNext();) {
- HtmlElement name = (HtmlElement) childIter.next();
+ switch (type) {
+ case 0:
+ assertTrue(checkErrorClass(classAttr));
+ break;
+ case 1:
+ assertTrue(checkWarnClass(classAttr));
+ break;
+ case 2:
+ assertTrue(checkFatalClass(classAttr));
+ break;
+ case 3:
+ assertTrue(checkInfoClass(classAttr));
+ break;
+ }
+
+
+ for (Iterator <HtmlElement> childIter= span.getChildElementsIterator();childIter.hasNext();) {
+ HtmlElement name = childIter.next();
assertNotNull(name);
assertEquals(name.getNodeName().toLowerCase(), "span");
-
classAttr = name.getAttributeValue("class");
assertTrue(classAttr.contains("rich-message-label")|| classAttr.contains("rich-message-marker") );
- assertTrue(classAttr.contains("errorLabelClass")||classAttr.contains("errorMarkerClass") );
- }
+ switch (type) {
+ case 0:
+ assertTrue(checkErrorClass(classAttr));
+ break;
+ case 1:
+ assertTrue(checkWarnClass(classAttr));
+ break;
+ case 2:
+ assertTrue(checkFatalClass(classAttr));
+ break;
+ case 3:
+ assertTrue(checkInfoClass(classAttr));
+ break;
+ }
+ }
+ }
+ public boolean checkErrorClass(String classAttribute) {
+ return classAttribute.contains("errorClass") ||classAttribute.contains("errorLabelClass") || classAttribute.contains("errorMarkerClass");
}
+ public boolean checkInfoClass(String classAttribute) {
+ return classAttribute.contains("infoClass") ||classAttribute.contains("infoLabelClass") || classAttribute.contains("infoMarkerClass");
+ }
+
+ public boolean checkFatalClass(String classAttribute) {
+ return classAttribute.contains("fatalClass") ||classAttribute.contains("fatalLabelClass") || classAttribute.contains("fatalMarkerClass");
+ }
+
+ public boolean checkWarnClass(String classAttribute) {
+ return classAttribute.contains("warnClass") ||classAttribute.contains("warnLabelClass") || classAttribute.contains("warnMarkerClass");
+ }
+
public void tearDown() throws Exception {
super.tearDown();
- message = null;
}
}
Modified: trunk/ui/message/src/test/java/org/richfaces/renderer/RichMessagesRendererTest.java
===================================================================
--- trunk/ui/message/src/test/java/org/richfaces/renderer/RichMessagesRendererTest.java 2008-11-28 16:50:17 UTC (rev 11444)
+++ trunk/ui/message/src/test/java/org/richfaces/renderer/RichMessagesRendererTest.java 2008-11-28 16:50:21 UTC (rev 11445)
@@ -92,6 +92,9 @@
messages1 = (HtmlRichMessages)application.createComponent("org.richfaces.component.RichMessages");
messages1.setId("message1");
+ messages1.setShowSummary(true);
+ messages1.setShowDetail(true);
+
messages1.setLayout("table");
messages1.setErrorClass("errorClass");
messages1.setWarnClass("warnClass");
@@ -112,12 +115,16 @@
messages1.getFacets().put("warnMarker", output2);
messages1.getFacets().put("fatalMarker", output3);
messages1.getFacets().put("infoMarker", output4);
+ messages1.setTooltip(true);
messages1.setTitle("TITLE");
messages2 = (HtmlRichMessages)application.createComponent("org.richfaces.component.RichMessages");
messages2.setId("message2");
messages2.setLayout("list");
+ messages2.setShowSummary(true);
+ messages2.setShowDetail(true);
+ messages2.setTooltip(true);
messages2.setErrorClass("errorClass");
messages2.setWarnClass("warnClass");
@@ -181,7 +188,7 @@
public void testRenderStyle() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
- List<HtmlElement> links = page.getDocumentHtmlElement().getHtmlElementsByTagName(HTML.LINK_ELEMENT);
+ List <HtmlElement> links = page.getDocumentHtmlElement().getHtmlElementsByTagName(HTML.LINK_ELEMENT);
assertNotNull(links);
boolean found = false;
for (HtmlElement link : links) {
@@ -213,8 +220,8 @@
assertTrue(classAttr.contains("rich-message"));
// test rendering component mockup for list layout
- Iterator<HtmlElement> dtIter= dl.getChildElementsIterator();
- for (; dtIter.hasNext();) {
+
+ for (Iterator<HtmlElement> dtIter= dl.getChildElementsIterator(); dtIter.hasNext();) {
HtmlElement dt = dtIter.next();
assertNotNull(dt);
@@ -223,7 +230,7 @@
assertTrue(classAttr.contains("errorClass")||classAttr.contains("fatalClass")
||classAttr.contains("warnClass") ||classAttr.contains("infoClass"));
- Iterator<HtmlElement> spanIter= dt.getChildElementsIterator();
+ Iterator <HtmlElement> spanIter= dt.getChildElementsIterator();
for (; spanIter.hasNext();) {
HtmlElement span = (HtmlElement) spanIter.next();
@@ -247,17 +254,17 @@
assertNotNull(tbody);
assertEquals(tbody.getNodeName().toLowerCase(), "tbody");
- Iterator<HtmlElement> trIter = tbody.getChildIterator();
+
- for (;trIter.hasNext();) {
+ for (Iterator<HtmlElement> trIter = tbody.getChildIterator();trIter.hasNext();) {
HtmlElement tr = trIter.next();
assertNotNull(tr);
assertEquals(tr.getNodeName().toLowerCase(), HTML.TR_ELEMENT);
- Iterator<HtmlElement> tdIter = tr.getChildIterator();
- for (;tdIter.hasNext();) {
+
+ for (Iterator<HtmlElement> tdIter = tr.getChildIterator();tdIter.hasNext();) {
HtmlElement td = tdIter.next();
assertNotNull(td);
16 years
JBoss Rich Faces SVN: r11444 - in trunk/test-applications/seleniumTest/richfaces/src: main/resources and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alevkovsky
Date: 2008-11-28 11:50:17 -0500 (Fri, 28 Nov 2008)
New Revision: 11444
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/EditorBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorCustomPluginsConfiguration.properties
trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorFullConfiguration.properties
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/editor.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/editorAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/tesAjaxaAndBindingRerender.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testConfigurationAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testConverterAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testPluginsAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testRequiredAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testSkinAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testThemeAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testValidatorAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testWidthAndHeightAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/EditorTest.java
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/web.xml
Log:
Add selenium test for Editor
Added: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/EditorBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/EditorBean.java (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/EditorBean.java 2008-11-28 16:50:17 UTC (rev 11444)
@@ -0,0 +1,311 @@
+/**
+ *
+ */
+package org.ajax4jsf.bean;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.validator.ValidatorException;
+
+import org.richfaces.component.UIEditor;
+
+/**
+ * @author Alexandr Levkovsky
+ *
+ */
+public class EditorBean {
+
+ private Object value = "Some value....";
+ private UIEditor editor;
+ private boolean rendered = true;
+ private String theme = "advanced";
+ private String skin = "richfaces";
+ private String language = "en";
+ private boolean readonly = false;
+ private String viewMode = "vision";
+ private int width = 600;
+ private int height = 600;
+ private boolean required = false;
+ private boolean invokeFlage = false;
+ private boolean convertToObjectFail = false;
+
+ public void reset() {
+ value = "Some value....";
+ rendered = true;
+ theme = "advanced";
+ skin = "richfaces";
+ language = "en";
+ readonly = false;
+ viewMode = "vision";
+ width = 600;
+ height = 600;
+ required = false;
+ invokeFlage = false;
+ convertToObjectFail = false;
+ }
+
+ public String changeTheme(){
+ if("advanced".equals(theme)){
+ theme = "simple";
+ }else{
+ theme = "advanced";
+ }
+ return null;
+ }
+
+ public String changeSkin(){
+ if("richfaces".equals(skin)){
+ skin = "o2k7";
+ }else{
+ skin = "richfaces";
+ }
+ return null;
+ }
+
+ public String changeSize(){
+ width = 650;
+ height = 650;
+ return null;
+ }
+
+ public String changeValue(){
+ setValue("Ajax value");
+ return null;
+ }
+
+ public String submit(){
+ invokeFlage = true;
+ convertToObjectFail = true;
+ return null;
+ }
+
+ public Converter getConvert() {
+ return new Converter() {
+ public Object getAsObject(FacesContext context,
+ UIComponent component, String newValue)
+ throws ConverterException {
+
+ if (convertToObjectFail){
+ throw new ConverterException(new FacesMessage(
+ FacesMessage.SEVERITY_ERROR, "Converter error",
+ "Error while convert to Object"));
+ }else{
+ newValue = "Converter Value";
+ }
+
+ return newValue;
+ }
+
+ public String getAsString(FacesContext context,
+ UIComponent component, Object value)
+ throws ConverterException {
+ String result = (value == null) ? "" : value.toString();
+ return result;
+ }
+ };
+ }
+
+ public void validate(FacesContext context, UIComponent component,
+ Object value) throws ValidatorException {
+
+ if (value != null) {
+ throw new ValidatorException(new FacesMessage(
+ FacesMessage.SEVERITY_ERROR, "Validation error",
+ "Incorrect input"));
+ }
+ }
+
+ /**
+ * @return the editor
+ */
+ public UIEditor getEditor() {
+ return editor;
+ }
+
+ /**
+ * @param editor the editor to set
+ */
+ public void setEditor(UIEditor editor) {
+ this.editor = editor;
+ }
+
+ /**
+ * @return the value
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /**
+ * @return the value
+ */
+ public Object getValueFromBinding() {
+ return editor.getValue();
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ /**
+ * @return the rendered
+ */
+ public boolean isRendered() {
+ return rendered;
+ }
+
+ /**
+ * @param rendered the rendered to set
+ */
+ public void setRendered(boolean rendered) {
+ this.rendered = rendered;
+ }
+
+ /**
+ * @return the theme
+ */
+ public String getTheme() {
+ return theme;
+ }
+
+ /**
+ * @param theme the theme to set
+ */
+ public void setTheme(String theme) {
+ this.theme = theme;
+ }
+
+ /**
+ * @return the skin
+ */
+ public String getSkin() {
+ return skin;
+ }
+
+ /**
+ * @param skin the skin to set
+ */
+ public void setSkin(String skin) {
+ this.skin = skin;
+ }
+
+ /**
+ * @return the language
+ */
+ public String getLanguage() {
+ return language;
+ }
+
+ /**
+ * @param language the language to set
+ */
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ /**
+ * @return the readonly
+ */
+ public boolean isReadonly() {
+ return readonly;
+ }
+
+ /**
+ * @param readonly the readonly to set
+ */
+ public void setReadonly(boolean readonly) {
+ this.readonly = readonly;
+ }
+
+ /**
+ * @return the viewMode
+ */
+ public String getViewMode() {
+ return viewMode;
+ }
+
+ /**
+ * @param viewMode the viewMode to set
+ */
+ public void setViewMode(String viewMode) {
+ this.viewMode = viewMode;
+ }
+
+ /**
+ * @return the width
+ */
+ public int getWidth() {
+ return width;
+ }
+
+ /**
+ * @param width the width to set
+ */
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ /**
+ * @return the height
+ */
+ public int getHeight() {
+ return height;
+ }
+
+ /**
+ * @param height the height to set
+ */
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ /**
+ * @return the required
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /**
+ * @param required the required to set
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
+ /**
+ * @return the invokeFlage
+ */
+ public boolean isInvokeFlage() {
+ return invokeFlage;
+ }
+
+ /**
+ * @param invokeFlage the invokeFlage to set
+ */
+ public void setInvokeFlage(boolean invokeFlage) {
+ this.invokeFlage = invokeFlage;
+ }
+
+ /**
+ * @return the convertToObjectFail
+ */
+ public boolean isConvertToObjectFail() {
+ return convertToObjectFail;
+ }
+
+ /**
+ * @param convertToObjectFail the convertToObjectFail to set
+ */
+ public void setConvertToObjectFail(boolean convertToObjectFail) {
+ this.convertToObjectFail = convertToObjectFail;
+ }
+
+
+}
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/EditorBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorCustomPluginsConfiguration.properties
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorCustomPluginsConfiguration.properties (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorCustomPluginsConfiguration.properties 2008-11-28 16:50:17 UTC (rev 11444)
@@ -0,0 +1 @@
+myemotions=/tiny-custom-plugins/myemotions/editor_plugin.js
\ No newline at end of file
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorCustomPluginsConfiguration.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorFullConfiguration.properties
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorFullConfiguration.properties (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorFullConfiguration.properties 2008-11-28 16:50:17 UTC (rev 11444)
@@ -0,0 +1,10 @@
+plugins = "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template"
+theme_advanced_buttons1 = "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect"
+theme_advanced_buttons2 = "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor"
+theme_advanced_buttons3 = "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen"
+theme_advanced_buttons4 = "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak"
+theme_advanced_buttons5 = "|,myemotions,|"
+theme_advanced_toolbar_location = "top"
+theme_advanced_toolbar_align = "left"
+theme_advanced_statusbar_location = "bottom"
+theme_advanced_resizing = true
\ No newline at end of file
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/resources/editorFullConfiguration.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2008-11-28 16:40:05 UTC (rev 11443)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2008-11-28 16:50:17 UTC (rev 11444)
@@ -276,6 +276,11 @@
<managed-bean-name>effectBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.bean.EffectBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>editorBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.EditorBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/ajaxInclude/step1.xhtml</from-view-id>
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/web.xml 2008-11-28 16:40:05 UTC (rev 11443)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/web.xml 2008-11-28 16:50:17 UTC (rev 11444)
@@ -105,7 +105,13 @@
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/NEKO/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/TIDY/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/NONE/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/editor.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/editor.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/editorAutoTest.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/editorAutoTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/tesAjaxaAndBindingRerender.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/tesAjaxaAndBindingRerender.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testConfigurationAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testConfigurationAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testConverterAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testConverterAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testPluginsAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testPluginsAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testRequiredAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testRequiredAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testSkinAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testSkinAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testThemeAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testThemeAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testValidatorAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testValidatorAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testWidthAndHeightAttribute.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/editor/testWidthAndHeightAttribute.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/EditorTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/EditorTest.java (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/EditorTest.java 2008-11-28 16:50:17 UTC (rev 11444)
@@ -0,0 +1,382 @@
+/**
+ *
+ */
+package org.richfaces.testng;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.AutoTester;
+import org.richfaces.SeleniumTestBase;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * @author Alexandr Levkovsky
+ *
+ */
+public class EditorTest extends SeleniumTestBase {
+
+ private static String TEST_URL = "pages/editor/editor.xhtml";
+ private static String AUTO_TEST_URL = "pages/editor/editorAutoTest.xhtml";
+ private static String THEME_TEST_URL = "pages/editor/testThemeAttribute.xhtml";
+ private static String SKIN_TEST_URL = "pages/editor/testSkinAttribute.xhtml";
+ private static String REQUIRED_TEST_URL = "pages/editor/testRequiredAttribute.xhtml";
+ private static String WIDTH_HEIGHT_TEST_URL = "pages/editor/testWidthAndHeightAttribute.xhtml";
+ private static String PLUGINS_TEST_URL = "pages/editor/testPluginsAttribute.xhtml";
+ private static String CONFIGURATION_AND_FPARAMS_TEST_URL = "pages/editor/testConfigurationAttribute.xhtml";
+ private static String VALIDATOR_TEST_URL = "pages/editor/testValidatorAttribute.xhtml";
+ private static String CONVERTER_TEST_URL = "pages/editor/testConverterAttribute.xhtml";
+ private static String AJAX_TEST_URL = "pages/editor/tesAjaxaAndBindingRerender.xhtml";
+
+ private static String FORM_ID = "formId:";
+ private static String EDITOR_DIV_ID = FORM_ID + "editorId";
+ private static String EDITOR_TEXAREA_DIV_ID = FORM_ID + "editorIdTextArea";
+ private static String EDITOR_TABLE_ID = EDITOR_TEXAREA_DIV_ID + "_tbl";
+ private static String EDITOR_IFRAME_ID = EDITOR_TEXAREA_DIV_ID + "_ifr";
+ private static String EDITOR_HMESSAGE_ID = FORM_ID + "editorMessageId";
+
+ private static String XPATH_ADVANCED_THEME_STYLES = "//link[contains(@href,'themes/advanced')]";
+ private static String XPATH_SIMPLE_THEME_STYLES = "//link[contains(@href,'themes/simple')]";
+
+ private static String XPATH_O2K7_SKIN_STYLES = "//link[contains(@href,'skins/o2k7')]";
+ private static String XPATH_RICHFACES_SKIN_STYLES = "//link[contains(@href,'skins/richfaces')]";
+
+ private static String ACTION_BUTTON_ID = FORM_ID + "submitId";
+ private static String EDITOR_VALUE_OUTPUT_ID = FORM_ID + "editorValueId";
+ private static String EDITOR_VALUE_OUTPUT_ID2 = FORM_ID + "actualValueId";
+
+ private static String REQUIRED_HMESSAGE = "Value is required";
+
+ private static String CONFIGURATION_NAME = "editorFullConfiguration";
+ private static String FPARAM_NAME = "paramName";
+ private static String FPARAM_VALUE = "paramValue";
+
+ private static List<String> PLUGINS = new ArrayList<String>();
+ static {
+ PLUGINS.add("Spellchecker");
+ PLUGINS.add("PageBreak");
+ PLUGINS.add("Style");
+ PLUGINS.add("Layer");
+ PLUGINS.add("Tables");
+ PLUGINS.add("Save");
+ PLUGINS.add("Advanced HR");
+ PLUGINS.add("Advanced image");
+ PLUGINS.add("Advanced link");
+ PLUGINS.add("Emotions");
+ PLUGINS.add("IESpell (IE Only)");
+ PLUGINS.add("InlinePopups");
+ PLUGINS.add("Insert date/time");
+ PLUGINS.add("Preview");
+ PLUGINS.add("Media");
+ PLUGINS.add("Search/Replace");
+ PLUGINS.add("Print");
+ PLUGINS.add("Contextmenu");
+ PLUGINS.add("Paste text/word");
+ PLUGINS.add("Directionality");
+ PLUGINS.add("Fullscreen");
+ PLUGINS.add("Non editable elements");
+ PLUGINS.add("Visual characters");
+ PLUGINS.add("Nonbreaking space");
+ PLUGINS.add("XHTML Xtras Plugin");
+ PLUGINS.add("Template plugin");
+ };
+
+ static Map<String, String> STYLE_ATTR;
+ static String[] CLASSES = new String[] { "myClass" };
+
+ static {
+ STYLE_ATTR = new HashMap<String, String>();
+ STYLE_ATTR.put("width", "100%");
+ STYLE_ATTR.put("color", "blue");
+ }
+
+ static final String RESET_METHOD_ME = "#{editorBean.reset}";
+
+ @Test
+ public void testRenderedAttribute(Template template) {
+ AutoTester autoTester = getAutoTester(this);
+ autoTester.renderPage(template, RESET_METHOD_ME);
+ autoTester.testRendered();
+ }
+
+ @Test
+ public void testAutoStyleAndClassesAttributes(Template template) {
+ AutoTester autoTester = getAutoTester(this);
+ autoTester.renderPage(template, RESET_METHOD_ME);
+ autoTester.testStyleAndClasses(CLASSES, STYLE_ATTR);
+ }
+
+ @Test
+ public void testRequiredAndRequiredMessageAttributes(Template template) {
+ renderPage(REQUIRED_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+ String messageId = getParentId() + EDITOR_HMESSAGE_ID;
+
+ AssertNotPresent(messageId);
+ //setValueInEditor("");
+ clickTestButton();
+
+ AssertPresent(messageId);
+ String message = getTextById(messageId);
+ Assert.assertEquals(message, REQUIRED_HMESSAGE,
+ "Required message not correct");
+ //String checked = selenium.getAttribute(XPATH_CHECKBOX_VALUE);
+
+ setValueInEditor("<span> Some value </span>");
+
+ clickTestButton();
+
+ AssertNotPresent(messageId);
+ //checked = selenium.getAttribute(XPATH_CHECKBOX_VALUE);
+
+ }
+
+ @Test
+ public void testValidatorAttribute(Template template) {
+ renderPage(VALIDATOR_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+ String messageId = getParentId() + EDITOR_HMESSAGE_ID;
+
+ AssertNotPresent(messageId);
+ clickTestButton();
+
+ AssertPresent(messageId);
+ String message = getTextById(messageId);
+ Assert.assertEquals(message, "Incorrect input",
+ "Validator message not correct");
+ }
+
+ @Test
+ public void testConvertorAttribute(Template template) {
+ renderPage(CONVERTER_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+ String messageId = getParentId() + EDITOR_HMESSAGE_ID;
+
+ AssertNotPresent(messageId);
+
+ clickTestButton();
+
+ AssertNotPresent(messageId);
+ String value = getTextById(getParentId() + EDITOR_VALUE_OUTPUT_ID);
+ Assert.assertEquals(value, "Converter Value", "Value is not valid");
+
+ clickTestButton();
+
+ AssertPresent(messageId);
+ String message = getTextById(messageId);
+ Assert.assertEquals(message, "Error while convert to Object",
+ "Converter message not correct");
+ }
+
+ @Test
+ public void testAjaxRerenderingAndBinding(Template template) {
+ renderPage(AJAX_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+ String valueOutputId = getParentId() + EDITOR_VALUE_OUTPUT_ID;
+ String actualOutputId = getParentId() + EDITOR_VALUE_OUTPUT_ID2;
+
+ AssertTextEquals(valueOutputId, "Some value....",
+ "Editor Value is invalid");
+
+ clickAjaxCommandAndWait(getParentId() + ACTION_BUTTON_ID);
+ checkJSError();
+
+ AssertTextEquals(valueOutputId, "Some value....",
+ "This output should have old Value");
+ AssertTextEquals(actualOutputId, "Ajax value",
+ "This output should have new rerendered Value");
+ }
+
+ @Test
+ public void testThemeAttribute(Template template) {
+ renderPage(THEME_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+
+ int advancedThemeStylesCount = selenium.getXpathCount(
+ XPATH_ADVANCED_THEME_STYLES).intValue();
+
+ if (advancedThemeStylesCount < 1) {
+ Assert.fail("Advanced theme styles in not loaded");
+ }
+
+ clickTestButton();
+ int simpleThemeStylesCount = selenium.getXpathCount(
+ XPATH_SIMPLE_THEME_STYLES).intValue();
+
+ if (simpleThemeStylesCount < 1) {
+ Assert.fail("Simple theme styles in not loaded");
+ }
+
+ }
+
+ @Test
+ public void testSkinAttribute(Template template) {
+ renderPage(SKIN_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+
+ int richfacesSkinStylesCount = selenium.getXpathCount(
+ XPATH_RICHFACES_SKIN_STYLES).intValue();
+
+ if (richfacesSkinStylesCount < 1) {
+ Assert.fail("richfaces skins styles in not loaded");
+ }
+
+ clickTestButton();
+
+ int o2k7SkinStylesCount = selenium
+ .getXpathCount(XPATH_O2K7_SKIN_STYLES).intValue();
+
+ if (o2k7SkinStylesCount < 1) {
+ Assert.fail("o2k7 skins styles in not loaded");
+ }
+ }
+
+ @Test
+ public void testWidthAndHeightAttributes(Template template) {
+ renderPage(WIDTH_HEIGHT_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+
+ String editorTableId = getParentId() + EDITOR_TABLE_ID;
+ String width = getStyleAttributeString(editorTableId, "width");
+ String height = getStyleAttributeString(editorTableId, "height");
+ Assert.assertEquals(width, "600px", "width is invalid");
+ Assert.assertEquals(height, "600px", "height is invalid");
+
+ clickTestButton();
+
+ width = getStyleAttributeString(editorTableId, "width");
+ height = getStyleAttributeString(editorTableId, "height");
+ Assert.assertEquals(width, "650px", "width is invalid");
+ Assert.assertEquals(height, "650px", "height is invalid");
+ }
+
+ @Test
+ public void testPlugingAttribute(Template template) {
+ renderPage(PLUGINS_TEST_URL, template, RESET_METHOD_ME);
+ assertEditorPresent();
+
+ clickById(getParentId() + ACTION_BUTTON_ID);
+ String text = getTextById("pluginsId");
+ if (text == null || text.length() == 0) {
+ Assert.fail("can't get loaded plugins");
+ }
+ String[] plugins = text.split(",");
+ if (plugins.length != PLUGINS.size()) {
+ Assert.fail("count of loaded plugins is not equlas required");
+ }
+ for (String plugin : plugins) {
+ if (!PLUGINS.contains(plugin)) {
+ Assert.fail("Invalid plugin was loaded: " + plugin);
+ }
+ }
+
+ }
+
+ @Test
+ public void testConfigurationAttribute(Template template) {
+ renderPage(CONFIGURATION_AND_FPARAMS_TEST_URL, template,
+ RESET_METHOD_ME);
+ assertEditorPresent();
+
+ Properties properties = loadProperties(CONFIGURATION_NAME);
+
+ clickById(getParentId() + ACTION_BUTTON_ID);
+ String text = getTextById("parametersId");
+
+ if (text == null || text.length() == 0) {
+ Assert.fail("can't get loaded parameters");
+ }
+ String[] parameters = text.split(";;");
+ List<String> paramsList = Arrays.asList(parameters);
+
+ for (Object key : properties.keySet()) {
+ String keyString = key.toString();
+ String valueString = properties.get(key).toString();
+ if (valueString.indexOf("\"") != -1) {
+ valueString = valueString.replaceAll("\"", "");
+ }
+ String param = keyString + ':' + valueString;
+ if (!paramsList.contains(param)) {
+ Assert.fail("Configuration parameters not contains " + param);
+ }
+ }
+
+ }
+
+ @Test
+ public void testFPramsPassingToEditor(Template template) {
+ renderPage(CONFIGURATION_AND_FPARAMS_TEST_URL, template,
+ RESET_METHOD_ME);
+ assertEditorPresent();
+
+ clickById(getParentId() + ACTION_BUTTON_ID);
+ String text = getTextById("parametersId");
+
+ if (text == null || text.length() == 0) {
+ Assert.fail("can't get loaded parameters");
+ }
+ String[] parameters = text.split(";;");
+ List<String> paramsList = Arrays.asList(parameters);
+
+ String param = FPARAM_NAME + ':' + FPARAM_VALUE;
+ if (!paramsList.contains(param)) {
+ Assert.fail("f:param not passed to configuration");
+ }
+
+ }
+
+ private void assertEditorPresent() {
+ AssertPresent(getParentId() + EDITOR_DIV_ID);
+ AssertPresent(getParentId() + EDITOR_TEXAREA_DIV_ID);
+ AssertPresent(getParentId() + EDITOR_IFRAME_ID);
+ }
+
+ private void clickTestButton() {
+ clickCommandAndWait(getParentId() + ACTION_BUTTON_ID);
+ }
+
+ private void setValueInEditor(String value) {
+ String script = "tinyMCE.activeEditor.setContent(" + value + ");";
+ runScript(script, true);
+ }
+
+ @Override
+ public String getAutoTestUrl() {
+ return AUTO_TEST_URL;
+ }
+
+ @Override
+ public String getTestUrl() {
+ return TEST_URL;
+ }
+
+ /**
+ * Method to load properties from property file
+ *
+ * @param name - properties file name
+ * @return Properties
+ */
+ private Properties loadProperties(String name) {
+ Properties properties = new Properties();
+
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ InputStream is = loader.getResourceAsStream(name + ".properties");
+ if (is == null) {
+ Assert.fail("Can't load propertioes file for test");
+ }
+ try {
+ properties.load(is);
+ } catch (IOException e) {
+ Assert.fail("Can't load propertioes file for test");
+ }
+ return properties;
+ }
+}
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/EditorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
16 years
JBoss Rich Faces SVN: r11443 - trunk/test-applications/realworld/web/src/main/webapp/layout.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2008-11-28 11:40:05 -0500 (Fri, 28 Nov 2008)
New Revision: 11443
Modified:
trunk/test-applications/realworld/web/src/main/webapp/layout/menu.xhtml
Log:
Modified: trunk/test-applications/realworld/web/src/main/webapp/layout/menu.xhtml
===================================================================
(Binary files differ)
16 years
JBoss Rich Faces SVN: r11442 - trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2008-11-28 11:37:29 -0500 (Fri, 28 Nov 2008)
New Revision: 11442
Modified:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/NavigationHelper.java
Log:
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/NavigationHelper.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/NavigationHelper.java 2008-11-28 16:36:56 UTC (rev 11441)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/NavigationHelper.java 2008-11-28 16:37:29 UTC (rev 11442)
@@ -11,7 +11,7 @@
return NavigationEnum.USER_PREFS;
}
- public NavigationEnum getNavigationSearch(){
+ public NavigationEnum getNavigationEnumSearch(){
return NavigationEnum.SEARCH;
}
16 years
JBoss Rich Faces SVN: r11441 - in trunk/test-applications/realworld/web/src/main: webapp and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2008-11-28 11:36:56 -0500 (Fri, 28 Nov 2008)
New Revision: 11441
Modified:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/NavigationHelper.java
trunk/test-applications/realworld/web/src/main/webapp/main.xhtml
Log:
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/NavigationHelper.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/NavigationHelper.java 2008-11-28 16:33:38 UTC (rev 11440)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/NavigationHelper.java 2008-11-28 16:36:56 UTC (rev 11441)
@@ -15,10 +15,14 @@
return NavigationEnum.SEARCH;
}
- public NavigationEnum getNavigationReadMessages(){
+ public NavigationEnum getNavigationEnumReadMessages(){
return NavigationEnum.READ_MESSAGES;
}
+ public NavigationEnum getNavigationEnumImagePreview(){
+ return NavigationEnum.IMAGE_PREVIEW;
+ }
+
public NavigationEnum getNavigationEnumFileUpload(){
return NavigationEnum.FILE_UPLOAD;
}
Modified: trunk/test-applications/realworld/web/src/main/webapp/main.xhtml
===================================================================
(Binary files differ)
16 years