Author: alexsmirnov
Date: 2007-07-26 18:05:11 -0400 (Thu, 26 Jul 2007)
New Revision: 1877
Added:
trunk/cdk/generator/src/main/resources/META-INF/templates12/faces-config.vm
trunk/framework/test/src/test/java/org/ajax4jsf/application/
trunk/framework/test/src/test/java/org/ajax4jsf/application/AjaxStateManagerTest.java
trunk/framework/test/src/test/java/org/ajax4jsf/application/ComponentLoaderTest.java
Removed:
trunk/cdk/generator/src/main/resources/META-INF/templates12/faces-config.vm
Modified:
trunk/cdk/generator/src/main/resources/META-INF/templates/faces-config.vm
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
trunk/framework/impl/src/main/java/org/ajax4jsf/application/ComponentsLoaderImpl.java
trunk/samples/ajaxPortlet/pom.xml
Log:
Write Unit tests for a AjaxStateManager classes.
Fix AJSF-98, AJSF-99
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates/faces-config.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates/faces-config.vm 2007-07-26
21:34:35 UTC (rev 1876)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates/faces-config.vm 2007-07-26
22:05:11 UTC (rev 1877)
@@ -7,8 +7,6 @@
#foreach( $validator in ${validators})
<validator>
- <validator-id>${validator.id}</validator-id>
- <validator-class>${validator.classname}</validator-class>
#if(${validator.description})
<description>${validator.description}</description>
#end
@@ -18,11 +16,22 @@
#if(${validator.icon})
<icon>${validator.icon}</icon>
#end
+ <validator-id>${validator.id}</validator-id>
+ <validator-class>${validator.classname}</validator-class>
</validator>
#end
#foreach( $converter in ${converters})
<converter>
+ #if(${converter.description})
+ <description>${converter.description}</description>
+ #end
+ #if(${converter.displayname})
+ <display-name>${converter.displayname}</display-name>
+ #end
+ #if(${converter.icon})
+ <icon>${converter.icon}</icon>
+ #end
#if(${converter.id})
<converter-id>${converter.id}</converter-id>
#end
@@ -32,15 +41,6 @@
<converter-class>${converter.classname}</converter-class>
- #if(${converter.description})
- <description>${converter.description}</description>
- #end
- #if(${converter.displayname})
- <display-name>${converter.displayname}</display-name>
- #end
- #if(${converter.icon})
- <icon>${converter.icon}</icon>
- #end
</converter>
#end
Deleted: trunk/cdk/generator/src/main/resources/META-INF/templates12/faces-config.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/faces-config.vm 2007-07-26
21:34:35 UTC (rev 1876)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/faces-config.vm 2007-07-26
22:05:11 UTC (rev 1877)
@@ -1,110 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces
Config 1.1//EN"
-
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
-<faces-config>
-
-${facesConfig.includeContent}
-
-#foreach( $validator in ${validators})
- <validator>
- <validator-id>${validator.id}</validator-id>
- <validator-class>${validator.classname}</validator-class>
- #if(${validator.description})
- <description>${validator.description}</description>
- #end
- #if(${validator.displayname})
- <display-name>${validator.displayname}</display-name>
- #end
- #if(${validator.icon})
- <icon>${validator.icon}</icon>
- #end
- </validator>
-#end
-
-#foreach( $converter in ${converters})
- <converter>
- #if(${converter.id})
- <converter-id>${converter.id}</converter-id>
- #end
- #if(${converter.forclass})
- <converter-for-class>${converter.forclass}</converter-for-class>
- #end
-
- <converter-class>${converter.classname}</converter-class>
-
- #if(${converter.description})
- <description>${converter.description}</description>
- #end
- #if(${converter.displayname})
- <display-name>${converter.displayname}</display-name>
- #end
- #if(${converter.icon})
- <icon>${converter.icon}</icon>
- #end
- </converter>
-#end
-
-
-
-#foreach( $component in ${components})
-#if( $component.generate )
- <component>
- #if(${component.description})
- <description>${component.xmlEncodedDescription}</description>
- #end
- #if(${component.displayname})
- <display-name>${component.xmlEncodedDisplayname}</display-name>
- #end
- <component-type>${component.name}</component-type>
- <component-class>${component.classname}</component-class>
-
-#foreach( $facet in $component.facets)
- <facet>
- #if(${facet.description})
- <description>${facet.xmlEncodedDescription}</description>
- #end
- #if(${facet.displayname})
- <display-name>${facet.xmlEncodedDisplayname}</display-name>
- #end
- <facet-name>${facet.name}</facet-name>
- </facet>
-#end
- #if(${component.renderer})
- <component-extension>
- <component-family>${component.family}</component-family>
- <renderer-type>${component.renderer.name}</renderer-type>
- </component-extension>
- #end
- </component>
-#end
-#end
-
-#foreach( $renderkit in $facesConfig.renderKits)
- <render-kit>
- #if(${renderkit.renderkitid})
- <render-kit-id>${renderkit.renderkitid}</render-kit-id>
- #if(${renderkit.renderkitclass})
- <render-kit-class>${renderkit.renderkitclass}</render-kit-class>
- #end
- #end
-#foreach( $component in $components)
- #if($component.renderer)
- #set($rendererClass = $renderkit.rendererClass($component.renderer.classname) )
- #if( $component.renderer.generate ||
$facesConfig.rendererExists("${rendererClass}"))
- <renderer>
- <component-family>${component.family}</component-family>
- <renderer-type>
- ${component.renderer.name}
- </renderer-type>
- <renderer-class>
- ${rendererClass}
- </renderer-class>
- </renderer>
- #end
- #end
-#end
- </render-kit>
-#end
-
-
-</faces-config>
Added: trunk/cdk/generator/src/main/resources/META-INF/templates12/faces-config.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/faces-config.vm
(rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/faces-config.vm 2007-07-26
22:05:11 UTC (rev 1877)
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+
http://java.sun.com/xml/ns/javaee/
+ web-facesconfig_1_2.xsd"
+ version="1.2">
+${facesConfig.includeContent}
+
+#foreach( $validator in ${validators})
+ <validator>
+ #if(${validator.description})
+ <description>${validator.description}</description>
+ #end
+ #if(${validator.displayname})
+ <display-name>${validator.displayname}</display-name>
+ #end
+ #if(${validator.icon})
+ <icon>${validator.icon}</icon>
+ #end
+ <validator-id>${validator.id}</validator-id>
+ <validator-class>${validator.classname}</validator-class>
+ </validator>
+#end
+
+#foreach( $converter in ${converters})
+ <converter>
+ #if(${converter.description})
+ <description>${converter.description}</description>
+ #end
+ #if(${converter.displayname})
+ <display-name>${converter.displayname}</display-name>
+ #end
+ #if(${converter.icon})
+ <icon>${converter.icon}</icon>
+ #end
+ #if(${converter.id})
+ <converter-id>${converter.id}</converter-id>
+ #end
+ #if(${converter.forclass})
+ <converter-for-class>${converter.forclass}</converter-for-class>
+ #end
+
+ <converter-class>${converter.classname}</converter-class>
+
+ </converter>
+#end
+
+
+
+#foreach( $component in ${components})
+#if( $component.generate )
+ <component>
+ #if(${component.description})
+ <description>${component.xmlEncodedDescription}</description>
+ #end
+ #if(${component.displayname})
+ <display-name>${component.xmlEncodedDisplayname}</display-name>
+ #end
+ <component-type>${component.name}</component-type>
+ <component-class>${component.classname}</component-class>
+
+#foreach( $facet in $component.facets)
+ <facet>
+ #if(${facet.description})
+ <description>${facet.xmlEncodedDescription}</description>
+ #end
+ #if(${facet.displayname})
+ <display-name>${facet.xmlEncodedDisplayname}</display-name>
+ #end
+ <facet-name>${facet.name}</facet-name>
+ </facet>
+#end
+ #if(${component.renderer})
+ <component-extension>
+ <component-family>${component.family}</component-family>
+ <renderer-type>${component.renderer.name}</renderer-type>
+ </component-extension>
+ #end
+ </component>
+#end
+#end
+
+#foreach( $renderkit in $facesConfig.renderKits)
+ <render-kit>
+ #if(${renderkit.renderkitid})
+ <render-kit-id>${renderkit.renderkitid}</render-kit-id>
+ #if(${renderkit.renderkitclass})
+ <render-kit-class>${renderkit.renderkitclass}</render-kit-class>
+ #end
+ #end
+#foreach( $component in $components)
+ #if($component.renderer)
+ #set($rendererClass = $renderkit.rendererClass($component.renderer.classname) )
+ #if( $component.renderer.generate ||
$facesConfig.rendererExists("${rendererClass}"))
+ <renderer>
+ <component-family>${component.family}</component-family>
+ <renderer-type>
+ ${component.renderer.name}
+ </renderer-type>
+ <renderer-class>
+ ${rendererClass}
+ </renderer-class>
+ </renderer>
+ #end
+ #end
+#end
+ </render-kit>
+#end
+
+
+</faces-config>
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2007-07-26
21:34:35 UTC (rev 1876)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2007-07-26
22:05:11 UTC (rev 1877)
@@ -59,16 +59,21 @@
protected static final int DEFAULT_NUMBER_OF_VIEWS = 16;
private static final String VIEW_STATES_MAP = AjaxStateManager.class
- .getName()+".VIEW_STATES_MAP";
+ .getName()
+ + ".VIEW_STATES_MAP";
- private static final Object VIEW_SEQUENCE =
AjaxStateManager.class.getName()+".VIEW_SEQUENCE";
+ private static final Object VIEW_SEQUENCE = AjaxStateManager.class
+ .getName()
+ + ".VIEW_SEQUENCE";
private final StateManager parent;
private final ComponentsLoader componentLoader;
-
- private int viewSequence=0;
-
+
+ private int viewSequence = 0;
+
+ private Object viewSequenceMutex = "MUTEX";
+
private static final Log _log = LogFactory.getLog(AjaxStateManager.class);
/**
@@ -129,7 +134,7 @@
public void writeState(FacesContext context, SerializedView state)
throws IOException {
parent.writeState(context, state);
- if(_log.isDebugEnabled()){
+ if (_log.isDebugEnabled()) {
_log.debug("Write view state to the response");
}
context.getExternalContext().getRequestMap().put(
@@ -155,8 +160,8 @@
// viewRoot = parent.restoreView(context, viewId, renderKitId);
state = responseStateManager.getComponentStateToRestore(context);
} else {
- Object[] serializedView = restoreStateFromSession(context,
- viewId, renderKitId);
+ Object[] serializedView = restoreStateFromSession(context, viewId,
+ renderKitId);
if (null != serializedView) {
treeStructure = (TreeStrutureNode) serializedView[0];
state = serializedView[1];
@@ -181,6 +186,9 @@
ExternalContext externalContext = context.getExternalContext();
Object session = externalContext.getSession(false);
if (null == session) {
+ if (_log.isDebugEnabled()) {
+ _log.debug("Can't restore view state : session expired");
+ }
} else {
synchronized (session) {
LRUMap viewStates = (LRUMap) externalContext.getSessionMap()
@@ -189,19 +197,31 @@
LRUMap logicalStates = (LRUMap) viewStates.get(viewId);
if (null != logicalStates) {
if (null != id) {
- restoredState = (Object[]) logicalStates
- .get(id);
- externalContext.getRequestMap().put(VIEW_SEQUENCE, id);
+ restoredState = (Object[]) logicalStates.get(id);
+ externalContext.getRequestMap().put(VIEW_SEQUENCE,
+ id);
if (null == restoredState) {
+ if (_log.isDebugEnabled()) {
+ _log.debug("No saved view state found for a Id "+id+". Restore
last saved state");
+ }
restoredState = (Object[]) logicalStates
.get(logicalStates.firstKey());
}
} else {
+ if (_log.isDebugEnabled()) {
+ _log.debug("No version Id for a saved view state in request. Restore last
saved state");
+ }
restoredState = (Object[]) logicalStates
.get(logicalStates.firstKey());
}
+ } else if (_log.isDebugEnabled()) {
+ _log.debug("Can't restore view state : no saved states for a ViewId
"+viewId);
}
+
+ } else if (_log.isDebugEnabled()) {
+ _log.debug("Can't restore view state : no saved view states in
session");
}
+
}
}
@@ -230,14 +250,16 @@
viewStates);
}
Object id = getNextViewId(context);
- LRUMap logicalViewsMap = (LRUMap) viewStates.get(viewRoot.getViewId());
- if(null == logicalViewsMap){
- logicalViewsMap = new LRUMap(getNumberOfViews(externalContext));
+ LRUMap logicalViewsMap = (LRUMap) viewStates.get(viewRoot
+ .getViewId());
+ if (null == logicalViewsMap) {
+ logicalViewsMap = new LRUMap(
+ getNumberOfViews(externalContext));
}
// Renew last seen view.
viewStates.put(viewRoot.getViewId(), logicalViewsMap);
- logicalViewsMap.put(id, new Object[]{treeState,state});
- serializedView = new SerializedView(id,null);
+ logicalViewsMap.put(id, new Object[] { treeState, state });
+ serializedView = new SerializedView(id, null);
}
}
@@ -247,16 +269,19 @@
protected Object getNextViewId(FacesContext context) {
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- if(ajaxContext.isAjaxRequest(context)){
- Object id = context.getExternalContext().getRequestMap().get(VIEW_SEQUENCE);
- if(null != id){
+ if (ajaxContext.isAjaxRequest(context)) {
+ Object id = context.getExternalContext().getRequestMap().get(
+ VIEW_SEQUENCE);
+ if (null != id) {
return id;
}
}
- if (viewSequence++ == Character.MAX_VALUE) {
- viewSequence = 0;
- }
- return UIViewRoot.UNIQUE_ID_PREFIX + ((int) viewSequence);
+ synchronized (viewSequenceMutex ) {
+ if (viewSequence++ == Character.MAX_VALUE) {
+ viewSequence = 0;
+ }
+ return UIViewRoot.UNIQUE_ID_PREFIX + ((int) viewSequence);
+ }
}
protected int getNumberOfViews(ExternalContext externalContext) {
@@ -278,7 +303,7 @@
* TODO - implement Externalizable to reduce serialized state.
*/
private static final long serialVersionUID = -9038742487716977254L;
-
+
private static final String NULL_ID = "";
private Map facets = null;
@@ -289,6 +314,9 @@
private String id;
+ public TreeStrutureNode() {
+ }
+
public void apply(FacesContext context, UIComponent component,
Set uniqueIds) {
type = component.getClass().getName();
@@ -351,17 +379,77 @@
return component;
}
+ /**
+ * @return the facets
+ */
+ public Map getFacets() {
+ return facets;
+ }
+
+ /**
+ * @param facets
+ * the facets to set
+ */
+ public void setFacets(Map facets) {
+ this.facets = facets;
+ }
+
+ /**
+ * @return the children
+ */
+ public List getChildren() {
+ return children;
+ }
+
+ /**
+ * @param children
+ * the children to set
+ */
+ public void setChildren(List children) {
+ this.children = children;
+ }
+
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @param type
+ * the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id
+ * the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
type = in.readUTF();
id = in.readUTF();
- if(NULL_ID.equals(id)){
+ if (NULL_ID.equals(id)) {
id = null;
}
int facetsSize = in.readInt();
- if (facetsSize >0) {
+ if (facetsSize > 0) {
facets = new HashMap(facetsSize);
- for(int i=0;i<facetsSize;i++){
+ for (int i = 0; i < facetsSize; i++) {
String facetName = in.readUTF();
TreeStrutureNode facet = new TreeStrutureNode();
facet.readExternal(in);
@@ -369,9 +457,9 @@
}
}
int childrenSize = in.readInt();
- if (childrenSize>0) {
+ if (childrenSize > 0) {
children = new ArrayList(childrenSize);
- for(int i=0;i<childrenSize;i++){
+ for (int i = 0; i < childrenSize; i++) {
TreeStrutureNode child = new TreeStrutureNode();
child.readExternal(in);
children.add(child);
@@ -381,18 +469,28 @@
public void writeExternal(ObjectOutput out) throws IOException {
out.writeUTF(type);
- out.writeUTF(null == id?NULL_ID:id);
- out.writeInt(facets.size());
- for (Iterator i = facets.entrySet().iterator(); i.hasNext();) {
- Map.Entry entry = (Map.Entry) i.next();
- out.writeUTF((String) entry.getKey());
- TreeStrutureNode node = (TreeStrutureNode) entry.getValue();
- node.writeExternal(out);
+ out.writeUTF(null == id ? NULL_ID : id);
+ if (null != facets) {
+ out.writeInt(facets.size());
+ for (Iterator i = facets.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ out.writeUTF((String) entry.getKey());
+ TreeStrutureNode node = (TreeStrutureNode) entry.getValue();
+ node.writeExternal(out);
+ }
+
+ } else {
+ out.writeInt(0);
}
- out.writeInt(children.size());
- for (Iterator i = children.iterator(); i.hasNext();) {
- TreeStrutureNode child = (TreeStrutureNode) i.next();
- child.writeExternal(out);
+ if (null != children) {
+ out.writeInt(children.size());
+ for (Iterator i = children.iterator(); i.hasNext();) {
+ TreeStrutureNode child = (TreeStrutureNode) i.next();
+ child.writeExternal(out);
+ }
+
+ } else {
+ out.writeInt(0);
}
}
}
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/ComponentsLoaderImpl.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/application/ComponentsLoaderImpl.java 2007-07-26
21:34:35 UTC (rev 1876)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/application/ComponentsLoaderImpl.java 2007-07-26
22:05:11 UTC (rev 1877)
@@ -68,7 +68,7 @@
* lazy create ClassLoader instance.
* @return
*/
- private ClassLoader getClassLoader() {
+ protected synchronized ClassLoader getClassLoader() {
if (loader == null) {
loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
Added:
trunk/framework/test/src/test/java/org/ajax4jsf/application/AjaxStateManagerTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/application/AjaxStateManagerTest.java
(rev 0)
+++
trunk/framework/test/src/test/java/org/ajax4jsf/application/AjaxStateManagerTest.java 2007-07-26
22:05:11 UTC (rev 1877)
@@ -0,0 +1,154 @@
+/**
+ *
+ */
+package org.ajax4jsf.application;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashSet;
+
+import javax.faces.application.StateManager;
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIOutput;
+import javax.faces.component.UIViewRoot;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+
+import org.ajax4jsf.application.AjaxStateManager.TreeStrutureNode;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import com.sun.media.sound.AlawCodec;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class AjaxStateManagerTest extends AbstractAjax4JsfTestCase {
+
+ private static final String FACET_B = "facetB";
+ private static final String FACET_A = "facetA";
+
+ /**
+ * @param name
+ */
+ public AjaxStateManagerTest(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link
org.ajax4jsf.application.AjaxStateManager#restoreStateFromSession(javax.faces.context.FacesContext,
java.lang.String, java.lang.String)}.
+ */
+ public void testRestoreStateFromSession() {
+// fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link
org.ajax4jsf.application.AjaxStateManager#getNextViewId(javax.faces.context.FacesContext)}.
+ */
+ public void testGetNextViewId() {
+// fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link
org.ajax4jsf.application.AjaxStateManager#getNumberOfViews(javax.faces.context.ExternalContext)}.
+ */
+ public void testGetNumberOfViews() {
+// fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link
org.ajax4jsf.application.AjaxStateManager#getRenderKit(javax.faces.context.FacesContext,
java.lang.String)}.
+ */
+ public void testGetRenderKit() {
+ AjaxStateManager stateManager = getAjaxStateManager();
+ RenderKit kit = stateManager.getRenderKit(facesContext,
RenderKitFactory.HTML_BASIC_RENDER_KIT);
+ assertSame(renderKit, kit);
+ }
+
+ public void testTreeNodeApply() throws Exception {
+ buildTestTree();
+ TreeStrutureNode node = new TreeStrutureNode();
+ node.apply(facesContext, facesContext.getViewRoot(), new HashSet<String>());
+ assertEquals(2, node.getChildren().size());
+ assertEquals(1, node.getFacets().size());
+ TreeStrutureNode nodeA = (TreeStrutureNode) node.getFacets().get(FACET_A);
+ assertNotNull(nodeA);
+ assertEquals(1, nodeA.getChildren().size());
+ assertEquals(1, nodeA.getFacets().size());
+ }
+
+ public void testTreeNodeCheckUniqueId() throws Exception {
+ buildTestTree();
+ TreeStrutureNode node = new TreeStrutureNode();
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ ((UIComponent)viewRoot.getChildren().get(0)).setId(FACET_A);
+ ((UIComponent)viewRoot.getChildren().get(1)).setId(FACET_A);
+ try {
+ node.apply(facesContext, facesContext.getViewRoot(), new HashSet<String>());
+ } catch (IllegalStateException e) {
+ assertTrue(e.getMessage().startsWith("duplicate"));
+ return;
+ }
+ assertTrue("Duplicate components Id's not detected ",false);
+ }
+
+
+ public void testTreeNodeSerialisation() throws Exception {
+ buildTestTree();
+ TreeStrutureNode node = new TreeStrutureNode();
+ node.apply(facesContext, facesContext.getViewRoot(), new HashSet<String>());
+ ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(byteOut);
+ out.writeObject(node);
+ ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
+ ObjectInputStream in = new ObjectInputStream(byteIn);
+ TreeStrutureNode nodeIn = (TreeStrutureNode) in.readObject();
+ assertEquals(2, nodeIn.getChildren().size());
+ assertEquals(1, nodeIn.getFacets().size());
+ TreeStrutureNode nodeA = (TreeStrutureNode) nodeIn.getFacets().get(FACET_A);
+ assertNotNull(nodeA);
+ assertEquals(1, nodeA.getChildren().size());
+ assertEquals(1, nodeA.getFacets().size());
+
+ }
+ /**
+ *
+ */
+ private void buildTestTree() {
+ facesContext.getViewRoot().getChildren().add(new UIInput());
+ facesContext.getViewRoot().getChildren().add(new UIOutput());
+ UIData data = new UIData();
+ facesContext.getViewRoot().getFacets().put(FACET_A, data);
+ data.getChildren().add(new UIColumn());
+ data.getFacets().put(FACET_B, new UIOutput());
+ }
+
+ /**
+ * @return
+ */
+ private AjaxStateManager getAjaxStateManager() {
+ StateManager defaultStateManager = application.getStateManager();
+ AjaxStateManager stateManager = new AjaxStateManager(defaultStateManager);
+ return stateManager;
+ }
+
+}
Property changes on:
trunk/framework/test/src/test/java/org/ajax4jsf/application/AjaxStateManagerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/framework/test/src/test/java/org/ajax4jsf/application/ComponentLoaderTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/application/ComponentLoaderTest.java
(rev 0)
+++
trunk/framework/test/src/test/java/org/ajax4jsf/application/ComponentLoaderTest.java 2007-07-26
22:05:11 UTC (rev 1877)
@@ -0,0 +1,67 @@
+/**
+ *
+ */
+package org.ajax4jsf.application;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+
+import junit.framework.TestCase;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ComponentLoaderTest extends TestCase {
+
+ private ComponentsLoaderImpl loader;
+ private ClassLoader contextClassLoader;
+ private URLClassLoader classLoader;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ contextClassLoader = Thread.currentThread().getContextClassLoader();
+ classLoader = new URLClassLoader(new URL[0],
+ this.getClass().getClassLoader());
+ Thread.currentThread().setContextClassLoader(classLoader);
+ loader = new ComponentsLoaderImpl();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ loader = null;
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
+ contextClassLoader = null;
+ }
+
+ /**
+ * Test method for {@link
org.ajax4jsf.application.ComponentsLoaderImpl#createComponent(java.lang.String)}.
+ */
+ public void testCreateComponent() {
+ UIComponent input = loader.createComponent(UIInput.class.getName());
+ assertNotNull(input);
+ assertEquals(UIInput.class, input.getClass());
+ }
+
+ /**
+ * Test method for {@link
org.ajax4jsf.application.ComponentsLoaderImpl#transform(java.lang.Object)}.
+ */
+ public void testTransform() {
+ Object componentClass = loader.transform(UIInput.class.getName());
+ assertSame(UIInput.class, componentClass);
+
+ }
+
+ public void testGetLoader() throws Exception {
+ assertSame(classLoader,loader.getClassLoader());
+ }
+}
Property changes on:
trunk/framework/test/src/test/java/org/ajax4jsf/application/ComponentLoaderTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/samples/ajaxPortlet/pom.xml
===================================================================
--- trunk/samples/ajaxPortlet/pom.xml 2007-07-26 21:34:35 UTC (rev 1876)
+++ trunk/samples/ajaxPortlet/pom.xml 2007-07-26 22:05:11 UTC (rev 1877)
@@ -8,7 +8,7 @@
<version>3.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces</groupId>
+ <groupId>org.richfaces.samples</groupId>
<artifactId>portalAjaxSample</artifactId>
<version>3.1.0-SNAPSHOT</version>
<packaging>war</packaging>