You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2013/06/15 15:56:11 UTC
svn commit: r1493355 - in /commons/proper/chain/trunk:
base/src/test/java/org/apache/commons/chain2/impl/ContextBaseTestCase.java
pom.xml src/changes/changes.xml
Author: britter
Date: Sat Jun 15 13:56:11 2013
New Revision: 1493355
URL: http://svn.apache.org/r1493355
Log:
CHAIN-88 - Refactor tests in class ContextBaseTestCase - Thanks to Stephan Köninger
Modified:
commons/proper/chain/trunk/base/src/test/java/org/apache/commons/chain2/impl/ContextBaseTestCase.java
commons/proper/chain/trunk/pom.xml
commons/proper/chain/trunk/src/changes/changes.xml
Modified: commons/proper/chain/trunk/base/src/test/java/org/apache/commons/chain2/impl/ContextBaseTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/chain/trunk/base/src/test/java/org/apache/commons/chain2/impl/ContextBaseTestCase.java?rev=1493355&r1=1493354&r2=1493355&view=diff
==============================================================================
--- commons/proper/chain/trunk/base/src/test/java/org/apache/commons/chain2/impl/ContextBaseTestCase.java (original)
+++ commons/proper/chain/trunk/base/src/test/java/org/apache/commons/chain2/impl/ContextBaseTestCase.java Sat Jun 15 13:56:11 2013
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertFal
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -30,7 +29,6 @@ import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -181,32 +179,27 @@ public class ContextBaseTestCase {
}
+ @Test(expected=UnsupportedOperationException.class)
+ public void contextKeySetDoesNotSupportAdd() throws Exception {
+ Set<String> keySet = context.keySet();
+ keySet.add("bop");
+ }
+
+ @Test(expected=UnsupportedOperationException.class)
+ public void contextKeySetDoesNotSupportAddAll() throws Exception {
+ Collection<String> adds = new ArrayList<String>();
+ adds.add("bop");
+
+ Set<String> keySet = context.keySet();
+ keySet.addAll(adds);
+ }
+
// Test keySet()
@Test
public void testKeySet() {
-
- Set<String> keySet = null;
- Collection<String> all = new ArrayList<String>();
-
- // Unsupported operations
- keySet = context.keySet();
- try {
- keySet.add("bop");
- fail("Should have thrown UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
- // Expected result
- }
- try {
- Collection<String> adds = new ArrayList<String>();
- adds.add("bop");
- keySet.addAll(adds);
- fail("Should have thrown UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
- // Expected result
- }
+ Set<String> keySet = context.keySet();
// Before-modification checks
- keySet = context.keySet();
assertEquals(createContext().size(), keySet.size());
assertFalse(keySet.contains("foo"));
assertFalse(keySet.contains("bar"));
@@ -217,6 +210,8 @@ public class ContextBaseTestCase {
context.put("foo", "foo value");
context.put("bar", "bar value");
context.put("baz", "baz value");
+
+ Collection<String> all = new ArrayList<String>();
all.add("foo");
all.add("bar");
all.add("baz");
@@ -379,18 +374,12 @@ public class ContextBaseTestCase {
// Verify the number of defined attributes
protected void checkAttributeCount(int expected) {
- int actual = 0;
- Iterator<String> keys = context.keySet().iterator();
- while (keys.hasNext()) {
- keys.next();
- actual++;
- }
- assertEquals("Correct attribute count",
- expectedAttributeCount() + expected, actual);
+ int actual = context.keySet().size();
+ assertEquals("Correct attribute count", expectedAttributeCount() + expected, actual);
if (expected == 0) {
assertTrue("Context should be empty", context.isEmpty());
} else {
- assertTrue("Context should not be empty", !context.isEmpty());
+ assertFalse("Context should not be empty", context.isEmpty());
}
}
Modified: commons/proper/chain/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/chain/trunk/pom.xml?rev=1493355&r1=1493354&r2=1493355&view=diff
==============================================================================
--- commons/proper/chain/trunk/pom.xml (original)
+++ commons/proper/chain/trunk/pom.xml Sat Jun 15 13:56:11 2013
@@ -127,6 +127,10 @@
<name>Ted Husted</name>
<email>husted at apache.org</email>
</contributor>
+ <contributor>
+ <name>Stephan Köninger</name>
+ <email>commons at stephan-koeninger dot de</email>
+ </contributor>
</contributors>
<properties>
Modified: commons/proper/chain/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/chain/trunk/src/changes/changes.xml?rev=1493355&r1=1493354&r2=1493355&view=diff
==============================================================================
--- commons/proper/chain/trunk/src/changes/changes.xml (original)
+++ commons/proper/chain/trunk/src/changes/changes.xml Sat Jun 15 13:56:11 2013
@@ -41,6 +41,9 @@ The <action> type attribute can be add,u
<body>
<release version="2.0" description="Major release">
+ <action issue="CHAIN-88" dev="britter" type="update" due-to="Stephan Köninger">
+ Refactor tests in class ContextBaseTestCase
+ </action>
<action issue="CHAIN-83" dev="britter" type="add">
Rename o.a.c.chain2.generic package to o.a.c.chain2.base
</action>