deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-738 fixed assert statements
Date Mon, 06 Oct 2014 09:43:19 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 4a7ef3d1e -> e836d91a4


DELTASPIKE-738 fixed assert statements


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/e836d91a
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/e836d91a
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/e836d91a

Branch: refs/heads/master
Commit: e836d91a4e788c9c850bcbae3b8d90334520b93e
Parents: 4a7ef3d
Author: gpetracek <gpetracek@apache.org>
Authored: Mon Oct 6 11:39:04 2014 +0200
Committer: gpetracek <gpetracek@apache.org>
Committed: Mon Oct 6 11:40:58 2014 +0200

----------------------------------------------------------------------
 .../view/controller/uc004/ViewConfigTest.java   | 17 ++++++++-
 .../view/controller/uc005/ViewConfigTest.java   | 40 +++++++++++++++++---
 2 files changed, 49 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e836d91a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/ViewConfigTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/ViewConfigTest.java
b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/ViewConfigTest.java
index 229587e..148cb4a 100644
--- a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/ViewConfigTest.java
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/ViewConfigTest.java
@@ -38,6 +38,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.HashSet;
 
 /**
  * Tests for view-configs
@@ -142,7 +143,19 @@ public class ViewConfigTest
         Assert.assertEquals(1, callbackResult.size());
         Assert.assertEquals(2, callbackResult.iterator().next().size());
         Iterator<String> resultIterator = callbackResult.iterator().next().iterator();
-        Assert.assertEquals("param1", resultIterator.next());
-        Assert.assertEquals("param2", resultIterator.next());
+        //the order in the result isn't guaranteed
+        Set<String> expectedValues = new HashSet<String>();
+        expectedValues.add("param1");
+        expectedValues.add("param2");
+
+        while (resultIterator.hasNext())
+        {
+            String currentValue = resultIterator.next();
+            if (!expectedValues.remove(currentValue))
+            {
+                Assert.fail("value '" + currentValue + "' not found in the result");
+            }
+        }
+        Assert.assertTrue(expectedValues.isEmpty());
     }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e836d91a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc005/ViewConfigTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc005/ViewConfigTest.java
b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc005/ViewConfigTest.java
index 21e4896..a20f588 100644
--- a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc005/ViewConfigTest.java
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc005/ViewConfigTest.java
@@ -32,9 +32,11 @@ import org.junit.Test;
 
 import java.lang.annotation.Annotation;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
 
 /**
  * Tests for view-configs
@@ -211,9 +213,22 @@ public class ViewConfigTest
         Assert.assertEquals(1, callbackResult.size());
         Assert.assertEquals(3, callbackResult.iterator().next().size());
         Iterator<String> resultIterator = callbackResult.iterator().next().iterator();
-        Assert.assertEquals("param1", resultIterator.next());
-        Assert.assertEquals("param2", resultIterator.next());
-        Assert.assertEquals(SimpleTestAccessDecisionVoter1.class.getName(), resultIterator.next());
+
+        //the order in the result isn't guaranteed
+        Set<String> expectedValues = new CopyOnWriteArraySet<String>();
+        expectedValues.add("param1");
+        expectedValues.add("param2");
+        expectedValues.add(SimpleTestAccessDecisionVoter1.class.getName());
+
+        while (resultIterator.hasNext())
+        {
+            String currentValue = resultIterator.next();
+            if (!expectedValues.remove(currentValue))
+            {
+                Assert.fail("value '" + currentValue + "' not found in the result");
+            }
+        }
+        Assert.assertTrue(expectedValues.isEmpty());
     }
 
     @Test
@@ -249,8 +264,21 @@ public class ViewConfigTest
         Assert.assertEquals(1, callbackResult.size());
         Assert.assertEquals(3, callbackResult.iterator().next().size());
         Iterator<String> resultIterator = callbackResult.iterator().next().iterator();
-        Assert.assertEquals("param1", resultIterator.next());
-        Assert.assertEquals("param2", resultIterator.next());
-        Assert.assertEquals(SimpleTestAccessDecisionVoter2.class.getName(), resultIterator.next());
+
+        //the order in the result isn't guaranteed
+        Set<String> expectedValues = new HashSet<String>();
+        expectedValues.add("param1");
+        expectedValues.add("param2");
+        expectedValues.add(SimpleTestAccessDecisionVoter2.class.getName());
+
+        while (resultIterator.hasNext())
+        {
+            String currentValue = resultIterator.next();
+            if (!expectedValues.remove(currentValue))
+            {
+                Assert.fail("value '" + currentValue + "' not found in the result");
+            }
+        }
+        Assert.assertTrue(expectedValues.isEmpty());
     }
 }


Mime
View raw message