You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2009/06/19 21:45:54 UTC
svn commit: r786637 - in /myfaces/core/branches/2_0_0/api/src:
main/java/javax/faces/component/UIOutcomeTarget.java
main/java/javax/faces/component/_DeltaStateHelper.java
test/java/javax/faces/component/_DeltaStateHelperTest.java
Author: lu4242
Date: Fri Jun 19 19:45:54 2009
New Revision: 786637
URL: http://svn.apache.org/viewvc?rev=786637&view=rev
Log:
fix license headers, and format source to apache convention preventing checkstyle errors
Modified:
myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIOutcomeTarget.java
myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/_DeltaStateHelper.java
myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/component/_DeltaStateHelperTest.java
Modified: myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIOutcomeTarget.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIOutcomeTarget.java?rev=786637&r1=786636&r2=786637&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIOutcomeTarget.java (original)
+++ myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIOutcomeTarget.java Fri Jun 19 19:45:54 2009
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package javax.faces.component;
import javax.el.ValueExpression;
Modified: 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=786637&r1=786636&r2=786637&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/_DeltaStateHelper.java (original)
+++ myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/_DeltaStateHelper.java Fri Jun 19 19:45:54 2009
@@ -1,17 +1,20 @@
/*
- *
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
*/
package javax.faces.component;
@@ -61,7 +64,8 @@
* @author Werner Punz (latest modification by $Author$)
* @version $Rev$ $Date$
*/
-public class _DeltaStateHelper implements StateHelper {
+public class _DeltaStateHelper implements StateHelper
+{
UIComponent _component = null;
Map<Serializable, Object> _fullState = null;
@@ -72,7 +76,8 @@
static final String INTERNAL_LIST_KEY = "_MYFACES._ILIST";
static final String INTERNAL_DELETED_KEY = "_MYFACES._DELETED";
- public _DeltaStateHelper(UIComponent component) {
+ 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
@@ -83,7 +88,8 @@
_transient = (component != null) ? component.isTransient() : true;
}
- protected boolean isInitalStateMarked() {
+ protected boolean isInitalStateMarked()
+ {
return _component.initialStateMarked();
}
@@ -91,14 +97,18 @@
* 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) {
+ public void add(Serializable key, Object value)
+ {
+ if (_deleted != null)
+ {
_deleted.remove(key);
}
- if (isInitalStateMarked()) {
+ if (isInitalStateMarked())
+ {
List<Object> deltaStorageList = (List) _deltas.get(key);
- if (deltaStorageList == null) {
+ if (deltaStorageList == null)
+ {
deltaStorageList = new InternalList(3);
}
deltaStorageList.add(value);
@@ -106,7 +116,8 @@
}
List<Object> fullStorageList = (List) _fullState.get(key);
- if (fullStorageList == null) {
+ if (fullStorageList == null)
+ {
fullStorageList = new InternalList(3);
}
fullStorageList.add(value);
@@ -114,7 +125,8 @@
}
@Override
- public Object eval(Serializable key) {
+ public Object eval(Serializable key)
+ {
return eval(key, null);
}
@@ -125,22 +137,26 @@
* @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) {
+ public Object eval(Serializable key, Object defaultValue)
+ {
Object retVal = get(key);
- if(retVal != null) {
+ 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) {
+ if (expr == null)
+ {
return defaultValue;
}
retVal = expr.getValue(_component.getFacesContext().getELContext());
- return (retVal == null) ? defaultValue: retVal;
- }
+ return (retVal == null) ? defaultValue : retVal;
+ }
@Override
- public Object get(Serializable key) {
+ public Object get(Serializable key)
+ {
return _fullState.get(key);
}
@@ -152,14 +168,18 @@
* @param value the value to be stored
* @returns the old value if present
*/
- public Object put(Serializable key, Object value) {
- if (_deleted != null) {
+ public Object put(Serializable key, Object value)
+ {
+ if (_deleted != null)
+ {
_deleted.remove(key);
}
- if (isInitalStateMarked()) {
+ if (isInitalStateMarked())
+ {
//delta tracking is on
Object oldValue = _deltas.put(key, value);
- if (oldValue == null) {
+ if (oldValue == null)
+ {
oldValue = _fullState.put(key, value);
}
return oldValue;
@@ -168,7 +188,6 @@
return _fullState.put(key, value);
}
-
/**
* puts a value into the internal data structures and the value has to be map
* mapped via mapkey,
@@ -177,31 +196,36 @@
* @returns the old value of key->mapKey if present!
*/
@Override
- public Object put(Serializable key, String mapKey, Object value) {
+ public Object put(Serializable key, String mapKey, Object value)
+ {
Object oldValue = null;
- if (_deleted != null) {
+ if (_deleted != null)
+ {
_deleted.remove(key);
}
- if (isInitalStateMarked()) {
+ if (isInitalStateMarked())
+ {
oldValue = _putMap(_deltas, key, mapKey, value);
- if (oldValue == null) {
+ 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) {
+ 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) {
+ if (_deleted == null)
+ {
_deleted = new HashSet<Object>();
}
_deleted.add(key);
@@ -209,25 +233,32 @@
}
@Override
- public Object remove(Serializable key, Object valueOrKey) {
+ 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 (deltaDS != null)
+ {
+ deltaRetVal = _removeFromCollection(_deltas, key, deltaDS,
+ valueOrKey);
+ }
+ if (initDS != null)
+ {
+ initRetVal = _removeFromCollection(_fullState, key, initDS,
+ valueOrKey);
}
- if (_deleted == null) {
+ if (_deleted == null)
+ {
_deleted = new HashSet<Object>();
}
- if (!_deltas.containsKey(key)) {
+ if (!_deltas.containsKey(key))
+ {
_deleted.add(key);
}
return (deltaRetVal != null) ? deltaRetVal : initRetVal;
@@ -246,27 +277,35 @@
*
*/
@Override
- public Object saveState(FacesContext context) {
+ 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)];
+ Object[] retArr = new Object[serializableMap.entrySet().size() * 2
+ + ((_deleted != null && _deleted.size() > 0) ? 2 : 0)];
- Iterator<Map.Entry<Serializable, Object>> it = serializableMap.entrySet().iterator();
+ Iterator<Map.Entry<Serializable, Object>> it = serializableMap
+ .entrySet().iterator();
int cnt = 0;
- while (it.hasNext()) {
+ while (it.hasNext())
+ {
entry = it.next();
retArr[cnt] = entry.getKey();
- if (entry instanceof InternalList) {
+ if (entry instanceof InternalList)
+ {
//TODO add list serialisation code
retArr[cnt + 1] = serializeOneDimDS((InternalList) entry);
- } else if (entry instanceof InternalMap) {
+ }
+ else if (entry instanceof InternalMap)
+ {
//TODO add map serialisation code here
retArr[cnt + 1] = serializeInternalMap((InternalMap) entry);
- } else {
+ }
+ else
+ {
retArr[cnt + 1] = (Serializable) entry.getValue();
}
@@ -275,7 +314,8 @@
}
//we now store the deleted deltas as well, we cannot handle deleted in our map alone!
- if (deltaDeleted != null && deltaDeleted.size() > 0) {
+ if (deltaDeleted != null && deltaDeleted.size() > 0)
+ {
Object[] serializedDeletes = serializeOneDimDS(_deleted);
retArr[cnt] = INTERNAL_DELETED_KEY;
retArr[cnt + 1] = serializedDeletes;
@@ -291,7 +331,8 @@
* the first entry an identifier key and the second entry an array
* of elements which represent our collection
*/
- private Object[] serializeOneDimDS(Collection<Object> entry) {
+ 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()]);
@@ -299,41 +340,43 @@
return retVal;
}
- private void deserializeOneDimDS(Object param, Collection target) {
+ 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) {
+ for (Object elem : listAsArr)
+ {
target.add(elem);
}
-
}
- private InternalMap deserializeInternalMap(Object param) {
+ 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) {
+ 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) {
+ 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()) {
+ for (Map.Entry<String, Object> entry : map.entrySet())
+ {
mapArr[cnt] = entry.getKey();
mapArr[cnt + 1] = entry.getValue();
cnt += 2;
@@ -342,22 +385,32 @@
}
@Override
- public void restoreState(FacesContext context, Object state) {
+ public void restoreState(FacesContext context, Object state)
+ {
Object[] serializedState = (Object[]) state;
- for (int cnt = 0; cnt < serializedState.length; cnt += 2) {
+ 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)) {
+ 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)) {
+ }
+ 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)) {
+ }
+ else if (value instanceof String
+ && ((String) value).equals(INTERNAL_MAP_KEY))
+ {
value = deserializeInternalMap(value);
put(key, value);
}
@@ -365,50 +418,69 @@
}
@Override
- public boolean isTransient() {
+ public boolean isTransient()
+ {
return _transient;
}
@Override
- public void setTransient(boolean newTransientValue) {
+ public void setTransient(boolean newTransientValue)
+ {
_transient = newTransientValue;
}
- private Object _putMap(Map rootMap, Serializable key, String mapKey, Object value) {
+ 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) {
+ if (oldValue == null)
+ {
Map storageMap = new InternalMap(3);
storageMap.put(mapKey, value);
return rootMap.put(key, storageMap);
- } else {
+ }
+ else
+ {
return ((Map) oldValue).put(mapKey, value);
}
}
- private Object _removeFromCollection(Map initialMap, Serializable key, Object dataStructure, Object valueOrKey) {
+ private Object _removeFromCollection(Map initialMap, Serializable key,
+ Object dataStructure, Object valueOrKey)
+ {
Object retVal = null;
- if (dataStructure != null) {
- if (dataStructure instanceof InternalList) {
+ if (dataStructure != null)
+ {
+ if (dataStructure instanceof InternalList)
+ {
retVal = ((InternalList) dataStructure).remove(valueOrKey);
- if (((Collection) dataStructure).isEmpty()) {
+ if (((Collection) dataStructure).isEmpty())
+ {
initialMap.remove(key);
- if (_deleted == null) {
+ if (_deleted == null)
+ {
_deleted = new HashSet<Object>();
}
_deleted.add(key);
}
- } else if (dataStructure instanceof InternalMap) {
+ }
+ else if (dataStructure instanceof InternalMap)
+ {
retVal = ((InternalMap) dataStructure).remove(valueOrKey);
- if (((InternalMap) dataStructure).isEmpty()) {
+ if (((InternalMap) dataStructure).isEmpty())
+ {
initialMap.remove(key);
- if (_deleted == null) {
+ if (_deleted == null)
+ {
_deleted = new HashSet<Object>();
}
_deleted.add(key);
}
- } else {
+ }
+ else
+ {
retVal = dataStructure;
}
}
@@ -417,16 +489,20 @@
//We use our own data structures just to make sure
//nothing gets mixed up internally
- class InternalMap extends HashMap {
+ class InternalMap extends HashMap
+ {
- public InternalMap(int initialSize) {
+ public InternalMap(int initialSize)
+ {
super(initialSize);
}
}
- class InternalList extends ArrayList {
+ class InternalList extends ArrayList
+ {
- public InternalList(int initialSize) {
+ public InternalList(int initialSize)
+ {
super(initialSize);
}
}
Modified: 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=786637&r1=786636&r2=786637&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/component/_DeltaStateHelperTest.java (original)
+++ myfaces/core/branches/2_0_0/api/src/test/java/javax/faces/component/_DeltaStateHelperTest.java Fri Jun 19 19:45:54 2009
@@ -1,17 +1,20 @@
/*
- *
- * 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.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
*/
package javax.faces.component;
@@ -26,7 +29,8 @@
* @author Werner Punz (latest modification by $Author$)
* @version $Rev$ $Date$
*/
-public class _DeltaStateHelperTest extends TestCase {
+public class _DeltaStateHelperTest extends TestCase
+{
private static final String KEY3 = "key3";
private static final String KEY5 = "key5";
@@ -40,14 +44,18 @@
private static final String VAL5 = "val5";
ProbeDeltaStateHelper _instance = null;
- private void assertStructure() {
+ 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));
+ 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));
}
@@ -55,30 +63,36 @@
* class needed to get a jsf less behavior
* so that we can add a jsf less testcase here!
*/
- class ProbeDeltaStateHelper extends _DeltaStateHelper {
+ class ProbeDeltaStateHelper extends _DeltaStateHelper
+ {
boolean _initialStateMarked = true;
- public ProbeDeltaStateHelper() {
+ public ProbeDeltaStateHelper()
+ {
super(null);
}
@Override
- protected boolean isInitalStateMarked() {
+ protected boolean isInitalStateMarked()
+ {
return _initialStateMarked;
}
- public void setInitialStateMarked(boolean initState) {
+ public void setInitialStateMarked(boolean initState)
+ {
_initialStateMarked = initState;
}
}
- public _DeltaStateHelperTest(String testName) {
+ public _DeltaStateHelperTest(String testName)
+ {
super(testName);
}
@Override
- protected void setUp() throws Exception {
+ protected void setUp() throws Exception
+ {
super.setUp();
@@ -87,7 +101,8 @@
}
@Override
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception
+ {
super.tearDown();
_instance = null;
@@ -96,16 +111,20 @@
/**
* Test of isInitalStateMarked method, of class _DeltaStateHelper.
*/
- public void testIsInitalStateMarked() {
- assertTrue("Initial state must be marked", _instance.isInitalStateMarked());
+ public void testIsInitalStateMarked()
+ {
+ assertTrue("Initial state must be marked", _instance
+ .isInitalStateMarked());
_instance.setInitialStateMarked(false);
- assertFalse("Initial state must be false", _instance.isInitalStateMarked());
+ assertFalse("Initial state must be false", _instance
+ .isInitalStateMarked());
}
/**
* Test of add method, of class _DeltaStateHelper.
*/
- public void testAdd() {
+ public void testAdd()
+ {
_instance.add(KEY1, VAL1);
Object val = _instance.get(KEY1);
assertTrue("Value must be list", val instanceof List);
@@ -118,9 +137,11 @@
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 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)));
+ 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);
@@ -130,7 +151,8 @@
/**
* specialized setup for our get tests
*/
- private void _setupGetTests() {
+ private void _setupGetTests()
+ {
_instance.put(KEY1, VAL1);
_instance.put(KEY2, KEY_2_1, VAL2);
@@ -142,7 +164,8 @@
/**
* Test of get method, of class _DeltaStateHelper.
*/
- public void testGet() {
+ public void testGet()
+ {
_setupGetTests();
assertStructure();
}
@@ -150,7 +173,8 @@
/**
* Test of put method, of class _DeltaStateHelper.
*/
- public void testPut_Serializable_Object() {
+ public void testPut_Serializable_Object()
+ {
_setupGetTests();
assertTrue("check for key1", _instance.get(KEY1).equals(VAL1));
@@ -158,33 +182,36 @@
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));
+ 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() {
+ public void testPut_3args()
+ {
//covered already by testPut_Serializable_Object()
}
/**
* Test of remove method, of class _DeltaStateHelper.
*/
- public void testRemove_Serializable() {
+ public void testRemove_Serializable()
+ {
_setupGetTests();
_instance.remove(KEY1);
- assertTrue("key 1 should not exist anymore", _instance.get(KEY1) == null);
+ 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() {
+ public void testRemove_Serializable_Object()
+ {
_setupGetTests();
_instance.remove(KEY2, KEY_2_1);
_instance.remove(KEY2, KEY_2_2);
@@ -192,13 +219,15 @@
_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);
+ assertTrue("key3 also should not exist anymore",
+ _instance.get(KEY3) == null);
}
/**
* Test of saveState method, of class _DeltaStateHelper.
*/
- public void testSaveState() {
+ public void testSaveState()
+ {
_instance.setInitialStateMarked(false);
_setupGetTests();
@@ -217,15 +246,17 @@
_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));
-
+ 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() {
+ public void testRestoreState()
+ {
_setupGetTests();
_instance.setInitialStateMarked(false);
Object serializedState = _instance.saveState(null);
@@ -238,7 +269,6 @@
_instance.restoreState(null, serializedState);
assertStructure();
-
_instance.setInitialStateMarked(true);
_setupGetTests();
serializedState = _instance.saveState(null);
@@ -249,7 +279,8 @@
/**
* Test of isTransient method, of class _DeltaStateHelper.
*/
- public void testIsTransient() {
+ public void testIsTransient()
+ {
_instance.setTransient(true);
assertTrue(_instance.isTransient());
}