23 |
# Tests for IndexedPool implementations |
# Tests for IndexedPool implementations |
24 |
|
|
25 |
# Requires attribute: |
# Requires attribute: |
26 |
# pool(indexTypes) -- a method taking a list of index types |
# Pool(indexTypes) -- a method taking a list of index types |
27 |
# and returning the appropriate IndexedPool |
# and returning the appropriate IndexedPool |
28 |
|
|
29 |
import java, org |
import java, org |
30 |
import jarray |
import jarray |
31 |
|
|
32 |
|
execfile('org/nongnu/storm/StormPool.meta') |
33 |
|
|
34 |
|
def setUp(): |
35 |
|
global pool |
36 |
|
pool = Pool([]) |
37 |
|
|
38 |
def set(list): |
def set(list): |
39 |
set = java.util.HashSet() |
set = java.util.HashSet() |
40 |
for el in list: set.add(el) |
for el in list: set.add(el) |
41 |
return set |
return set |
42 |
|
|
43 |
def testNonavailableIndexRaisesException(): |
def testNonavailableIndexRaisesException(): |
44 |
p = pool([]) |
p = Pool([]) |
45 |
try: |
try: |
46 |
p.getIndex("http://example.com/no-such-index") |
p.getIndex("http://example.com/no-such-index") |
47 |
except java.util.NoSuchElementException: |
except java.util.NoSuchElementException: |
50 |
assert 0 |
assert 0 |
51 |
|
|
52 |
def testContentTypeIndex(): |
def testContentTypeIndex(): |
53 |
p = pool([org.nongnu.storm.util.ContentTypeIndexType()]) |
p = Pool([org.nongnu.storm.util.ContentTypeIndexType()]) |
54 |
i = p.getIndex(org.nongnu.storm.util.ContentTypeIndexType.contentTypeIndexTypeURI) |
i = p.getIndex(org.nongnu.storm.util.ContentTypeIndexType.contentTypeIndexTypeURI) |
55 |
|
|
56 |
assert i != None |
assert i != None |