This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new a1bed5ccd4 Only a Test on Filter using Arrays (#50)
a1bed5ccd4 is described below
commit a1bed5ccd44248fe0432a7936ccf7e2c45175f5e
Author: Stefan Bischof <[email protected]>
AuthorDate: Thu Jul 27 07:50:48 2023 +0200
Only a Test on Filter using Arrays (#50)
Signed-off-by: Stefan Bischof <[email protected]>
---
.../org/apache/felix/framework/FilterTest.java | 59 +++++++++++++++++++++-
1 file changed, 58 insertions(+), 1 deletion(-)
diff --git a/framework/src/test/java/org/apache/felix/framework/FilterTest.java
b/framework/src/test/java/org/apache/felix/framework/FilterTest.java
index ceb111412b..26e9ff7761 100644
--- a/framework/src/test/java/org/apache/felix/framework/FilterTest.java
+++ b/framework/src/test/java/org/apache/felix/framework/FilterTest.java
@@ -18,17 +18,27 @@
*/
package org.apache.felix.framework;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Dictionary;
+import java.util.HashSet;
import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
import junit.framework.TestCase;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
public class FilterTest extends TestCase
{
public void testMissingAttribute()
{
- Dictionary dict = new Hashtable();
+ Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put("one", "one-value");
dict.put("two", "two-value");
dict.put("three", "three-value");
@@ -43,4 +53,51 @@ public class FilterTest extends TestCase
}
assertFalse("Filter should not match: " + filter, filter.match(dict));
}
+
+ public void testArray() throws InvalidSyntaxException
+ {
+ Filter filter = FrameworkUtil.createFilter(
+ "(&(checkBool=true)(checkString=A)(checkString=B))");
+
+ //Array
+ String[] array = new String[] { "A", "B" };
+ assertTrue(filter.match(createTestDict(array)));
+
+ //ArrayList
+ ArrayList<String> arrayList = new ArrayList<String>();
+ arrayList.addAll(Arrays.asList(array));
+ assertTrue(filter.match(createTestDict(arrayList)));
+
+ //unmodifiableList
+ List<String> unmodifiableList =
Collections.unmodifiableList(arrayList);
+ assertTrue(filter.match(createTestDict(unmodifiableList)));
+
+ //unmodCollection
+ Collection<String> unmodCollection =
Collections.unmodifiableCollection(
+ arrayList);
+ assertTrue(filter.match(createTestDict(unmodCollection)));
+
+ //hashSet
+ Set<String> hashSet = new HashSet<String>();
+ hashSet.addAll(arrayList);
+ assertTrue(filter.match(createTestDict(hashSet)));
+
+ //synchronizedCollection
+ Collection<String> synchronizedCollection =
Collections.synchronizedCollection(
+ arrayList);
+ assertTrue(filter.match(createTestDict(synchronizedCollection)));
+
+ //linkedList
+ Collection<String> linkedList = new LinkedList<String>(arrayList);
+ assertTrue(filter.match(createTestDict(linkedList)));
+ }
+
+ private static Dictionary<String, Object> createTestDict(Object o)
+ {
+ Hashtable<String, Object> dictionary = new Hashtable<String, Object>();
+ dictionary.put("checkBool", true);
+ dictionary.put("checkString", o);
+ return dictionary;
+ }
+
}