Fix test class to not hard code empty Bag
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131451 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7801d45353
commit
ae60862fd6
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java,v 1.4 2003/12/05 20:22:12 scolebourne Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java,v 1.5 2003/12/24 22:38:32 scolebourne Exp $
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
* The Apache Software License, Version 1.1
|
* The Apache Software License, Version 1.1
|
||||||
|
@ -72,13 +72,12 @@ import org.apache.commons.collections.SortedBag;
|
||||||
* implementation.
|
* implementation.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.4 $ $Date: 2003/12/05 20:22:12 $
|
* @version $Revision: 1.5 $ $Date: 2003/12/24 22:38:32 $
|
||||||
*
|
*
|
||||||
* @author Phil Steitz
|
* @author Phil Steitz
|
||||||
*/
|
*/
|
||||||
public class TestPredicatedSortedBag extends AbstractTestSortedBag {
|
public class TestPredicatedSortedBag extends AbstractTestSortedBag {
|
||||||
|
|
||||||
private SortedBag emptyBag = new TreeBag();
|
|
||||||
private SortedBag nullBag = null;
|
private SortedBag nullBag = null;
|
||||||
|
|
||||||
public TestPredicatedSortedBag(String testName) {
|
public TestPredicatedSortedBag(String testName) {
|
||||||
|
@ -111,20 +110,20 @@ public class TestPredicatedSortedBag extends AbstractTestSortedBag {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bag makeBag() {
|
public Bag makeBag() {
|
||||||
return decorateBag(emptyBag, truePredicate);
|
return decorateBag(new TreeBag(), truePredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Bag makeTestBag() {
|
protected Bag makeTestBag() {
|
||||||
return decorateBag(emptyBag, stringPredicate());
|
return decorateBag(new TreeBag(), stringPredicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
public void testDecorate() {
|
public void testDecorate() {
|
||||||
SortedBag bag = decorateBag(emptyBag, stringPredicate());
|
SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
|
||||||
SortedBag bag2 = ((PredicatedSortedBag) bag).getSortedBag();
|
SortedBag bag2 = ((PredicatedSortedBag) bag).getSortedBag();
|
||||||
try {
|
try {
|
||||||
SortedBag bag3 = decorateBag(emptyBag, null);
|
SortedBag bag3 = decorateBag(new TreeBag(), null);
|
||||||
fail("Expecting IllegalArgumentException for null predicate");
|
fail("Expecting IllegalArgumentException for null predicate");
|
||||||
} catch (IllegalArgumentException e) {}
|
} catch (IllegalArgumentException e) {}
|
||||||
try {
|
try {
|
||||||
|
@ -134,7 +133,7 @@ public class TestPredicatedSortedBag extends AbstractTestSortedBag {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSortOrder() {
|
public void testSortOrder() {
|
||||||
SortedBag bag = decorateBag(emptyBag, stringPredicate());
|
SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
|
||||||
String one = "one";
|
String one = "one";
|
||||||
String two = "two";
|
String two = "two";
|
||||||
String three = "three";
|
String three = "three";
|
||||||
|
@ -144,7 +143,6 @@ public class TestPredicatedSortedBag extends AbstractTestSortedBag {
|
||||||
assertEquals("first element", bag.first(), one);
|
assertEquals("first element", bag.first(), one);
|
||||||
assertEquals("last element", bag.last(), two);
|
assertEquals("last element", bag.last(), two);
|
||||||
Comparator c = bag.comparator();
|
Comparator c = bag.comparator();
|
||||||
assertTrue("natural order, so comparator should be null",
|
assertTrue("natural order, so comparator should be null", c == null);
|
||||||
c == null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/bag/TestTypedSortedBag.java,v 1.4 2003/12/05 20:22:12 scolebourne Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/bag/TestTypedSortedBag.java,v 1.5 2003/12/24 22:38:32 scolebourne Exp $
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
* The Apache Software License, Version 1.1
|
* The Apache Software License, Version 1.1
|
||||||
|
@ -70,7 +70,7 @@ import org.apache.commons.collections.SortedBag;
|
||||||
* implementation.
|
* implementation.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.4 $ $Date: 2003/12/05 20:22:12 $
|
* @version $Revision: 1.5 $ $Date: 2003/12/24 22:38:32 $
|
||||||
*
|
*
|
||||||
* @author Phil Steitz
|
* @author Phil Steitz
|
||||||
*/
|
*/
|
||||||
|
@ -94,7 +94,6 @@ public class TestTypedSortedBag extends AbstractTestSortedBag {
|
||||||
protected Class stringClass = this.getName().getClass();
|
protected Class stringClass = this.getName().getClass();
|
||||||
private Object obj = new Object();
|
private Object obj = new Object();
|
||||||
protected Class objectClass = obj.getClass();
|
protected Class objectClass = obj.getClass();
|
||||||
protected SortedBag emptyBag = new TreeBag();
|
|
||||||
protected SortedBag nullBag = null;
|
protected SortedBag nullBag = null;
|
||||||
|
|
||||||
protected SortedBag decorateBag(SortedBag bag, Class claz) {
|
protected SortedBag decorateBag(SortedBag bag, Class claz) {
|
||||||
|
@ -102,19 +101,19 @@ public class TestTypedSortedBag extends AbstractTestSortedBag {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bag makeBag() {
|
public Bag makeBag() {
|
||||||
return decorateBag(emptyBag, objectClass);
|
return decorateBag(new TreeBag(), objectClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Bag makeTestBag() {
|
protected Bag makeTestBag() {
|
||||||
return decorateBag(emptyBag, stringClass);
|
return decorateBag(new TreeBag(), stringClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
public void testDecorate() {
|
public void testDecorate() {
|
||||||
SortedBag bag = decorateBag(emptyBag, stringClass);
|
SortedBag bag = decorateBag(new TreeBag(), stringClass);
|
||||||
try {
|
try {
|
||||||
SortedBag bag3 = decorateBag(emptyBag, null);
|
SortedBag bag3 = decorateBag(new TreeBag(), null);
|
||||||
fail("Expecting IllegalArgumentException for null predicate");
|
fail("Expecting IllegalArgumentException for null predicate");
|
||||||
} catch (IllegalArgumentException e) {}
|
} catch (IllegalArgumentException e) {}
|
||||||
try {
|
try {
|
||||||
|
@ -124,7 +123,7 @@ public class TestTypedSortedBag extends AbstractTestSortedBag {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSortOrder() {
|
public void testSortOrder() {
|
||||||
SortedBag bag = decorateBag(emptyBag, stringClass);
|
SortedBag bag = decorateBag(new TreeBag(), stringClass);
|
||||||
String one = "one";
|
String one = "one";
|
||||||
String two = "two";
|
String two = "two";
|
||||||
String three = "three";
|
String three = "three";
|
||||||
|
@ -134,7 +133,6 @@ public class TestTypedSortedBag extends AbstractTestSortedBag {
|
||||||
assertEquals("first element", bag.first(), one);
|
assertEquals("first element", bag.first(), one);
|
||||||
assertEquals("last element", bag.last(), two);
|
assertEquals("last element", bag.last(), two);
|
||||||
Comparator c = bag.comparator();
|
Comparator c = bag.comparator();
|
||||||
assertTrue("natural order, so comparator should be null",
|
assertTrue("natural order, so comparator should be null", c == null);
|
||||||
c == null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue