You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2009/06/19 13:17:16 UTC

svn commit: r786456 - in /myfaces/core/branches/2_0_0/api/src: main/java/javax/faces/component/UIComponent.java main/java/javax/faces/component/_DeltaStateHelper.java test/java/javax/faces/component/_DeltaStateHelperTest.java

Author: werpu
Date: Fri Jun 19 11:17:15 2009
New Revision: 786456

URL: http://svn.apache.org/viewvc?rev=786456&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2245
https://issues.apache.org/jira/browse/MYFACES-2250

Added:
    myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/_DeltaStateHelper.java   (with props)
    myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/component/_DeltaStateHelperTest.java   (with props)
Modified:
    myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java

Modified: myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java?rev=786456&r1=786455&r2=786456&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java (original)
+++ myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java Fri Jun 19 11:17:15 2009
@@ -674,12 +674,20 @@
         return getStateHelper(true);
     }
 
+    /**
+     * returns a delta state saving enabled state helper
+     * for the current component
+     * @param create if true a state helper is created if not already existing
+     * @return an implementation of the StateHelper interface or null if none exists and create is set to false
+     */
     protected StateHelper getStateHelper(boolean create) {
         if(_stateHelper != null) {
             return _stateHelper;
         }
-        //TODO add a state helper implementation
-        return null;
+        if(create) {
+            _stateHelper = new _DeltaStateHelper(this);
+        }
+        return _stateHelper;
     }
 
     @SuppressWarnings("unchecked")

Added: myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/_DeltaStateHelper.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/_DeltaStateHelper.java?rev=786456&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/_DeltaStateHelper.java (added)
+++ myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/_DeltaStateHelper.java Fri Jun 19 11:17:15 2009
@@ -0,0 +1,433 @@
+/*
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  under the License.
+ */
+package javax.faces.component;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+
+/**
+ * A delta enabled state holder implementing the StateHolder Interface
+ *
+ * components implementing the PartalStateHolder interface have an initial state
+ * and delta states, the initial state is the one holding all root values
+ * and deltas store differences to the initial states
+ *
+ * for components not implementing partial state saving only the initial states are
+ * of importance, everything is stored and restored continously there
+ *
+ * The state helper seems to have three internal storage mechanisms
+ * one being a list which stores plain values
+ * one being a key value pair which stores key values in maps
+ * add serves the plain list type while put serves the 
+ * key value type
+ *
+ * the third is the value which has to be stored plainly as is!
+ *
+ *
+ * The flow probably goes following
+ * restore -> restore initial state done from the outside
+ * switch component to -> initialState = true
+ * store the deltas as well!
+ *
+ * the main save and restore works only on the deltas
+ * as far as it seems!
+ *
+ * we are keeping two states the full state and the delta state
+ * the full state must access all values, full + delta
+ * and the delta state should keep the states only if initialState is set
+ *
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Rev$ $Date$
+ */
+public class _DeltaStateHelper implements StateHelper {
+
+    UIComponent _component = null;
+    Map<Serializable, Object> _fullState = null;
+    Map<Serializable, Object> _deltas = null;
+    Set<Object> _deleted = null;
+    boolean _transient = false;
+    static final String INTERNAL_MAP_KEY = "_MYFACES._IMAP";
+    static final String INTERNAL_LIST_KEY = "_MYFACES._ILIST";
+    static final String INTERNAL_DELETED_KEY = "_MYFACES._DELETED";
+
+    public _DeltaStateHelper(UIComponent component) {
+        this._component = component;
+        _fullState = new HashMap<Serializable, Object>();
+        //we only can store the deltas if the component is instance of partial state holder
+        //but as it seems the latest specs already have enforced PartialStateHolder on UIComponent
+        //initialStateMarked is responsible for determination if we have partial saving
+
+        _deltas = new HashMap<Serializable, Object>();
+        _transient = (component != null) ? component.isTransient() : true;
+    }
+
+    protected boolean isInitalStateMarked() {
+        return _component.initialStateMarked();
+    }
+
+    /**
+     * stores the object in an internal list if not present in the detal map
+     */
+    @Override
+    public void add(Serializable key, Object value) {
+        if (_deleted != null) {
+            _deleted.remove(key);
+        }
+        if (isInitalStateMarked()) {
+
+            List<Object> deltaStorageList = (List) _deltas.get(key);
+            if (deltaStorageList == null) {
+                deltaStorageList = new InternalList(3);
+            }
+            deltaStorageList.add(value);
+            _deltas.put(key, deltaStorageList);
+
+        }
+        List<Object> fullStorageList = (List) _fullState.get(key);
+        if (fullStorageList == null) {
+            fullStorageList = new InternalList(3);
+        }
+        fullStorageList.add(value);
+        _fullState.put(key, fullStorageList);
+    }
+
+    @Override
+    public Object eval(Serializable key) {
+        return eval(key, null);
+    }
+
+    @Override
+    /**
+     * returns a given value or the result of a value expression
+     * @param key  the key or value expression to be evaluated
+     * @return the result of the eval or the default value if
+     *          the value is not present in our states
+     */
+    public Object eval(Serializable key, Object defaultValue) {
+        Object retVal = get(key);
+        if(retVal != null) {
+            return retVal;
+        }
+        //not found lets do the eval of a possible value expression
+        ValueExpression expr = _component.getValueExpression(key.toString());
+        if(expr == null) {
+            return defaultValue;
+        }
+        retVal = expr.getValue(_component.getFacesContext().getELContext());
+        return (retVal == null) ? defaultValue: retVal;
+     }
+
+    @Override
+    public Object get(Serializable key) {
+        return _fullState.get(key);
+    }
+
+    @Override
+    /**
+     * puts an object into the data structures with a given key
+     *
+     * @param key the key for the mapping
+     * @param value the value to be stored
+     * @returns the old value if present
+     */
+    public Object put(Serializable key, Object value) {
+        if (_deleted != null) {
+            _deleted.remove(key);
+        }
+        if (isInitalStateMarked()) {
+            //delta tracking is on
+            Object oldValue = _deltas.put(key, value);
+            if (oldValue == null) {
+                oldValue = _fullState.put(key, value);
+            }
+            return oldValue;
+        }
+
+        return _fullState.put(key, value);
+    }
+
+    
+    /**
+     * puts a value into the internal data structures and the value has to be map
+     * mapped via mapkey,
+     * @param key the key for the mapping
+     * @param mapKey the internal map key for the mapping
+     * @returns the old value of key->mapKey if present!
+     */
+    @Override
+    public Object put(Serializable key, String mapKey, Object value) {
+        Object oldValue = null;
+        if (_deleted != null) {
+            _deleted.remove(key);
+        }
+        if (isInitalStateMarked()) {
+            oldValue = _putMap(_deltas, key, mapKey, value);
+            if (oldValue == null) {
+                oldValue = _putMap(_fullState, key, mapKey, value);
+
+            }
+            return oldValue;
+        }
+
+
+        //either no initial state or no delta state saving
+        return _putMap(_fullState, key, mapKey, value);
+    }
+
+    @Override
+    public Object remove(Serializable key) {
+        Object deltaRetVal = _deltas.remove(key);
+        Object initRetVal = _fullState.remove(key);
+        //delta if given is always newer than init!
+        if (_deleted == null) {
+            _deleted = new HashSet<Object>();
+        }
+        _deleted.add(key);
+        return (deltaRetVal != null) ? deltaRetVal : initRetVal;
+    }
+
+    @Override
+    public Object remove(Serializable key, Object valueOrKey) {
+        Object deltaDS = _deltas.get(key);
+        Object initDS = _fullState.get(key);
+
+        Object deltaRetVal = null;
+        Object initRetVal = null;
+
+        if (deltaDS != null) {
+            deltaRetVal = _removeFromCollection(_deltas, key, deltaDS, valueOrKey);
+        }
+        if (initDS != null) {
+            initRetVal = _removeFromCollection(_fullState, key, initDS, valueOrKey);
+        }
+
+        if (_deleted == null) {
+            _deleted = new HashSet<Object>();
+        }
+
+        if (!_deltas.containsKey(key)) {
+            _deleted.add(key);
+        }
+        return (deltaRetVal != null) ? deltaRetVal : initRetVal;
+    }
+
+    /*
+     * Serializing cod
+     * the serialized data structure consists of key value pairs unless the value itself is an internal array
+     * or a map in case of an internal array or map the value itself is another array with its initial value
+     * myfaces.InternalArray, myfaces.internalMap
+     *
+     * the internal Array is then mapped to another array
+     *
+     * the internal Map again is then mapped to a map with key value pairs
+     *
+     *
+     */
+    @Override
+    public Object saveState(FacesContext context) {
+        Map serializableMap = (isInitalStateMarked()) ? _deltas : _fullState;
+        Set<Object> deltaDeleted = (isInitalStateMarked()) ? _deleted : null;
+
+        Map.Entry<Serializable, Object> entry;
+        //entry == key, value, key, value
+        Object[] retArr = new Object[serializableMap.entrySet().size() * 2 +
+                ((_deleted != null && _deleted.size() > 0) ? 2 : 0)];
+
+        Iterator<Map.Entry<Serializable, Object>> it = serializableMap.entrySet().iterator();
+        int cnt = 0;
+        while (it.hasNext()) {
+            entry = it.next();
+            retArr[cnt] = entry.getKey();
+            if (entry instanceof InternalList) {
+                //TODO add list serialisation code
+                retArr[cnt + 1] = serializeOneDimDS((InternalList) entry);
+            } else if (entry instanceof InternalMap) {
+                //TODO add map serialisation code here
+                retArr[cnt + 1] = serializeInternalMap((InternalMap) entry);
+            } else {
+
+                retArr[cnt + 1] = (Serializable) entry.getValue();
+            }
+            cnt += 2;
+
+        }
+
+        //we now store the deleted deltas as well, we cannot handle deleted in our map alone!
+        if (deltaDeleted != null && deltaDeleted.size() > 0) {
+            Object[] serializedDeletes = serializeOneDimDS(_deleted);
+            retArr[cnt] = INTERNAL_DELETED_KEY;
+            retArr[cnt + 1] = serializedDeletes;
+        }
+        return retArr;
+    }
+
+    /**
+     * serializes a one dimensional data structure (array, list, set)
+     *
+     * @param entry the one dimensional collection to be serialized
+     * @return an array representation of the collection with two entries
+     * the first entry an identifier key and the second entry an array
+     * of elements which represent our collection
+     */
+    private Object[] serializeOneDimDS(Collection<Object> entry) {
+        Object[] retVal = new Object[2]; //array with two elements one the marker second the array
+        retVal[0] = _DeltaStateHelper.INTERNAL_LIST_KEY;
+        retVal[1] = entry.toArray(new Object[entry.size()]);
+
+        return retVal;
+    }
+
+    private void deserializeOneDimDS(Object param, Collection target) {
+        Object[] saveState = (Object[]) param;
+        //first element list marker, already processed!
+        Object[] listAsArr = (Object[]) saveState[1];
+
+
+
+
+        //since all other options would mean dual iteration we have to do it the hard way
+        for (Object elem : listAsArr) {
+            target.add(elem);
+        }
+
+
+    }
+
+    private InternalMap deserializeInternalMap(Object param) {
+        Object[] saveState = (Object[]) param;
+        Object[] listAsMap = (Object[]) saveState[1];
+
+        InternalMap retVal = new InternalMap(listAsMap.length / 2);
+        for (int cnt = 0; cnt < listAsMap.length; cnt += 2) {
+            retVal.put((String) listAsMap[cnt], listAsMap[cnt + 1]);
+        }
+        return retVal;
+    }
+
+    private Object[] serializeInternalMap(Map<String, Object> map) {
+        Object[] retVal = new Object[2];
+        retVal[0] = _DeltaStateHelper.INTERNAL_MAP_KEY;
+
+        int cnt = 0;
+        Object[] mapArr = new Object[map.size()];
+        retVal[1] = mapArr;
+        for (Map.Entry<String, Object> entry : map.entrySet()) {
+            mapArr[cnt] = entry.getKey();
+            mapArr[cnt + 1] = entry.getValue();
+            cnt += 2;
+        }
+        return retVal;
+    }
+
+    @Override
+    public void restoreState(FacesContext context, Object state) {
+        Object[] serializedState = (Object[]) state;
+
+        for (int cnt = 0; cnt < serializedState.length; cnt += 2) {
+            Serializable key = (Serializable) serializedState[cnt];
+            Object value = serializedState[cnt + 1];
+
+            if (key instanceof String && ((String) key).equals(INTERNAL_DELETED_KEY)) {
+                _deleted = new HashSet<Object>();
+                deserializeOneDimDS(value, _deleted);
+            } else if (value instanceof String && ((String) value).equals(INTERNAL_LIST_KEY)) {
+                Object[] valArr = (Object[]) ((Object[]) value)[1];
+                InternalList target = new InternalList(valArr.length * 2);
+                deserializeOneDimDS(value, target);
+                put(key, target);
+            } else if (value instanceof String && ((String) value).equals(INTERNAL_MAP_KEY)) {
+                value = deserializeInternalMap(value);
+                put(key, value);
+            }
+        }
+    }
+
+    @Override
+    public boolean isTransient() {
+        return _transient;
+    }
+
+    @Override
+    public void setTransient(boolean newTransientValue) {
+        _transient = newTransientValue;
+    }
+
+    private Object _putMap(Map rootMap, Serializable key, String mapKey, Object value) {
+        Object oldValue = rootMap.get(key);
+        //if no delta is found we add it to both DS
+        if (oldValue == null) {
+            Map storageMap = new InternalMap(3);
+            storageMap.put(mapKey, value);
+            return rootMap.put(key, storageMap);
+        } else {
+            return ((Map) oldValue).put(mapKey, value);
+        }
+    }
+
+    private Object _removeFromCollection(Map initialMap, Serializable key, Object dataStructure, Object valueOrKey) {
+        Object retVal = null;
+        if (dataStructure != null) {
+            if (dataStructure instanceof InternalList) {
+                retVal = ((InternalList) dataStructure).remove(valueOrKey);
+                if (((Collection) dataStructure).isEmpty()) {
+                    initialMap.remove(key);
+                    if (_deleted == null) {
+                        _deleted = new HashSet<Object>();
+                    }
+                    _deleted.add(key);
+
+                }
+            } else if (dataStructure instanceof InternalMap) {
+                retVal = ((InternalMap) dataStructure).remove(valueOrKey);
+                if (((InternalMap) dataStructure).isEmpty()) {
+                    initialMap.remove(key);
+                    if (_deleted == null) {
+                        _deleted = new HashSet<Object>();
+                    }
+                    _deleted.add(key);
+                }
+            } else {
+                retVal = dataStructure;
+            }
+        }
+        return retVal;
+    }
+
+    //We use our own data structures just to make sure
+    //nothing gets mixed up internally
+    class InternalMap extends HashMap {
+
+        public InternalMap(int initialSize) {
+            super(initialSize);
+        }
+    }
+
+    class InternalList extends ArrayList {
+
+        public InternalList(int initialSize) {
+            super(initialSize);
+        }
+    }
+}

Propchange: myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/_DeltaStateHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/_DeltaStateHelper.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/component/_DeltaStateHelperTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/component/_DeltaStateHelperTest.java?rev=786456&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/component/_DeltaStateHelperTest.java (added)
+++ myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/component/_DeltaStateHelperTest.java Fri Jun 19 11:17:15 2009
@@ -0,0 +1,256 @@
+/*
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  under the License.
+ */
+package javax.faces.component;
+
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * A generic framework less testcase for our _DeltaStateHelper class!
+ *
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Rev$ $Date$
+ */
+public class _DeltaStateHelperTest extends TestCase {
+
+    private static final String KEY3 = "key3";
+    private static final String KEY5 = "key5";
+    private static final String KEY_2_1 = "key_2_1";
+    private static final String VAL1 = "val1";
+    private static final String VAL2 = "val2";
+    private static final String VAL3 = "val3";
+    private static final String KEY1 = "key1";
+    private static final String KEY2 = "key2";
+    private static final String KEY_2_2 = "key_2_2";
+    private static final String VAL5 = "val5";
+    ProbeDeltaStateHelper _instance = null;
+
+    private void assertStructure() {
+        assertTrue("check for key1", _instance.get(KEY1).equals(VAL1));
+        assertTrue("check for key2", _instance.get(KEY2) instanceof Map);
+        assertTrue("check for key3", _instance.get(KEY3) instanceof List);
+
+        assertTrue("check for list size", ((List) _instance.get(KEY3)).size() >= 1);
+        assertTrue("check for map entries", ((Map) _instance.get(KEY2)).get(KEY_2_2).equals(VAL3));
+        assertTrue("check for map entries", ((Map) _instance.get(KEY2)).get(KEY_2_1).equals(VAL2));
+
+    }
+
+    /**
+     * class needed to get a jsf less behavior
+     * so that we can add a jsf less testcase here!
+     */
+    class ProbeDeltaStateHelper extends _DeltaStateHelper {
+
+        boolean _initialStateMarked = true;
+
+        public ProbeDeltaStateHelper() {
+            super(null);
+        }
+
+        @Override
+        protected boolean isInitalStateMarked() {
+            return _initialStateMarked;
+        }
+
+        public void setInitialStateMarked(boolean initState) {
+            _initialStateMarked = initState;
+        }
+    }
+
+    public _DeltaStateHelperTest(String testName) {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+
+        super.setUp();
+
+        _instance = new ProbeDeltaStateHelper();
+        _instance.setInitialStateMarked(true);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+        _instance = null;
+    }
+
+    /**
+     * Test of isInitalStateMarked method, of class _DeltaStateHelper.
+     */
+    public void testIsInitalStateMarked() {
+        assertTrue("Initial state must be marked", _instance.isInitalStateMarked());
+        _instance.setInitialStateMarked(false);
+        assertFalse("Initial state must be false", _instance.isInitalStateMarked());
+    }
+
+    /**
+     * Test of add method, of class _DeltaStateHelper.
+     */
+    public void testAdd() {
+        _instance.add(KEY1, VAL1);
+        Object val = _instance.get(KEY1);
+        assertTrue("Value must be list", val instanceof List);
+        assertTrue("Value size must be one", ((List) val).size() == 1);
+
+        _instance.add(KEY1, new Integer(2));
+        _instance.add(KEY2, new Integer(2));
+
+        val = _instance.get(KEY1);
+        assertTrue("Value must be list", val instanceof List);
+        assertTrue("Value size must be one", ((List) val).size() == 2);
+
+        assertTrue("Value msut be of type string and must equal val1", ((List) val).get(0).equals(VAL1));
+
+        assertTrue("Value msut be of type int and must equal 2", ((List) val).get(1).equals(new Integer(2)));
+
+        val = _instance.get(KEY2);
+        assertTrue("Value must be list", val instanceof List);
+        assertTrue("Value size must be one", ((List) val).size() == 1);
+    }
+
+    /**
+     * specialized setup for our get tests
+     */
+    private void _setupGetTests() {
+
+        _instance.put(KEY1, VAL1);
+        _instance.put(KEY2, KEY_2_1, VAL2);
+        _instance.put(KEY2, KEY_2_2, VAL3);
+
+        _instance.add(KEY3, VAL3);
+    }
+
+    /**
+     * Test of get method, of class _DeltaStateHelper.
+     */
+    public void testGet() {
+        _setupGetTests();
+        assertStructure();
+    }
+
+    /**
+     * Test of put method, of class _DeltaStateHelper.
+     */
+    public void testPut_Serializable_Object() {
+        _setupGetTests();
+
+        assertTrue("check for key1", _instance.get(KEY1).equals(VAL1));
+
+        Map entry = (Map) _instance.get(KEY2);
+        assertTrue("check for key2", _instance.get(KEY2) instanceof Map);
+
+        assertTrue("check for key2 structure",
+                entry.size() == 2 &&
+                entry.get(KEY_2_1).equals(VAL2) &&
+                entry.get(KEY_2_2).equals(VAL3));
+    }
+
+    /**
+     * Test of put method, of class _DeltaStateHelper.
+     */
+    public void testPut_3args() {
+        //covered already by testPut_Serializable_Object()
+    }
+
+    /**
+     * Test of remove method, of class _DeltaStateHelper.
+     */
+    public void testRemove_Serializable() {
+        _setupGetTests();
+        _instance.remove(KEY1);
+        assertTrue("key 1 should not exist anymore", _instance.get(KEY1) == null);
+        //TODO check the deleted data structure for further internal structural tests
+    }
+
+    /**
+     * Test of remove method, of class _DeltaStateHelper.
+     */
+    public void testRemove_Serializable_Object() {
+        _setupGetTests();
+        _instance.remove(KEY2, KEY_2_1);
+        _instance.remove(KEY2, KEY_2_2);
+
+        _instance.remove(KEY3, VAL3);
+
+        assertTrue("no key2 should exist anymore", _instance.get(KEY2) == null);
+        assertTrue("key3 also should not exist anymore", _instance.get(KEY3) == null);
+    }
+
+    /**
+     * Test of saveState method, of class _DeltaStateHelper.
+     */
+    public void testSaveState() {
+
+        _instance.setInitialStateMarked(false);
+        _setupGetTests();
+
+        //save stating does not need a facesContext for now!
+        Object retVal = _instance.saveState(null);
+
+        assertTrue("retVal must be an array", retVal instanceof Object[]);
+        assertTrue("arraylength must be given", ((Object[]) retVal).length > 0);
+        //only basic structural tests are done here
+        //the more important ones are the ones in restorestate
+
+        //now lets do some structural tests
+        //theoretically there should be almot no data in the delta state if the full state already has been stored!
+        _instance.setInitialStateMarked(true);
+        _instance.put(KEY5, VAL5);
+        Object[] deltaSaveState = (Object[]) _instance.saveState(null);
+        //only the new value should be saved as delta
+        assertTrue("Delta Savestate structure", deltaSaveState.length == 2 && deltaSaveState[0].equals(KEY5) && deltaSaveState[1].equals(VAL5));
+
+
+    }
+
+    /**
+     * Test of restoreState method, of class _DeltaStateHelper.
+     */
+    public void testRestoreState() {
+        _setupGetTests();
+        _instance.setInitialStateMarked(false);
+        Object serializedState = _instance.saveState(null);
+        _instance.restoreState(null, serializedState);
+        assertStructure();
+
+        _setupGetTests();
+        _instance.setInitialStateMarked(true);
+        serializedState = _instance.saveState(null);
+        _instance.restoreState(null, serializedState);
+        assertStructure();
+
+
+        _instance.setInitialStateMarked(true);
+        _setupGetTests();
+        serializedState = _instance.saveState(null);
+        _instance.restoreState(null, serializedState);
+        assertStructure();
+    }
+
+    /**
+     * Test of isTransient method, of class _DeltaStateHelper.
+     */
+    public void testIsTransient() {
+        _instance.setTransient(true);
+        assertTrue(_instance.isTransient());
+    }
+}

Propchange: myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/component/_DeltaStateHelperTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/component/_DeltaStateHelperTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL