| Method from org.apache.commons.collections.set.TestTypedSortedSet Detail: |
protected Integer getNextAsInt() {
SortedSet set = (SortedSet) makeFullSet();
int nextValue = ((Integer)set.last()).intValue() + 1;
return new Integer(nextValue);
}
|
protected Long getNextAsLong() {
SortedSet set = (SortedSet) makeFullSet();
int nextValue = ((Integer)set.last()).intValue() + 1;
return new Long(nextValue);
}
|
public static void main(String[] args) {
String[] testCaseName = { TestTypedSortedSet.class.getName()};
junit.textui.TestRunner.main(testCaseName);
}
|
public Set makeEmptySet() {
return TypedSortedSet.decorate(new TreeSet(), integerType);
}
|
public Set makeFullSet() {
TreeSet set = new TreeSet();
set.addAll(Arrays.asList(getFullElements()));
return TypedSortedSet.decorate(set, integerType);
}
|
public boolean skipSerializedCanonicalTests() {
return true; // Typed and Predicated get confused
}
|
public static Test suite() {
return BulkTest.makeSuite(TestTypedSortedSet.class);
}
|
public void testIllegalAdd() {
Set set = makeFullSet();
try {
set.add(getNextAsLong());
fail("Should fail type test.");
} catch (IllegalArgumentException e) {
// expected
}
assertTrue("Collection shouldn't convert long to int",
!set.contains(getNextAsInt()));
}
|
public void testIllegalAddAll() {
Set set = makeFullSet();
Set elements = new TreeSet();
elements.add(getNextAsLong());
try {
set.addAll(elements);
fail("Should fail type test.");
} catch (IllegalArgumentException e) {
// expected
}
assertTrue("Collection shouldn't convert long to int",
!set.contains(getNextAsInt()));
}
|