Removing tabs
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@776546 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
46f3c54c56
commit
ce5d208b92
|
@ -249,29 +249,29 @@ public class MultiKey implements Serializable {
|
|||
return "MultiKey" + Arrays.asList(keys).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the hash code of the instance using the provided keys.
|
||||
* @param keys
|
||||
*/
|
||||
private void calculateHashCode(Object[] keys)
|
||||
{
|
||||
int total = 0;
|
||||
/**
|
||||
* Calculate the hash code of the instance using the provided keys.
|
||||
* @param keys
|
||||
*/
|
||||
private void calculateHashCode(Object[] keys)
|
||||
{
|
||||
int total = 0;
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
if (keys[i] != null) {
|
||||
total ^= keys[i].hashCode();
|
||||
}
|
||||
}
|
||||
hashCode = total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculate the hash code after deserialization. The hash code of some
|
||||
* keys might have change (hash codes based on the system hash code are
|
||||
* only stable for the same process).
|
||||
* @return the instance with recalculated hash code
|
||||
*/
|
||||
private Object readResolve() {
|
||||
calculateHashCode(keys);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculate the hash code after deserialization. The hash code of some
|
||||
* keys might have change (hash codes based on the system hash code are
|
||||
* only stable for the same process).
|
||||
* @return the instance with recalculated hash code
|
||||
*/
|
||||
private Object readResolve() {
|
||||
calculateHashCode(keys);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -563,9 +563,9 @@ public class TestIteratorUtils extends BulkTest {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Test next() and hasNext() for an immutable Iterator.
|
||||
*/
|
||||
/**
|
||||
* Test next() and hasNext() for an immutable Iterator.
|
||||
*/
|
||||
public void testUnmodifiableIteratorIteration() {
|
||||
Iterator iterator = getImmutableIterator();
|
||||
|
||||
|
@ -669,7 +669,7 @@ public class TestIteratorUtils extends BulkTest {
|
|||
* Test remove() for an immutable ListIterator.
|
||||
*/
|
||||
public void testUnmodifiableListIteratorImmutability() {
|
||||
ListIterator listIterator = getImmutableListIterator();
|
||||
ListIterator listIterator = getImmutableListIterator();
|
||||
|
||||
try {
|
||||
listIterator.remove();
|
||||
|
|
|
@ -202,16 +202,16 @@ public abstract class AbstractTestComparator extends AbstractTestObject {
|
|||
// test to make sure the canonical form has been preserved
|
||||
try {
|
||||
comparator = (Comparator) readExternalFormFromDisk(getCanonicalComparatorName(makeComparator()));
|
||||
} catch (FileNotFoundException exception) {
|
||||
} catch (FileNotFoundException exception) {
|
||||
|
||||
boolean autoCreateSerialized = false;
|
||||
|
||||
if(autoCreateSerialized) {
|
||||
comparator = makeComparator();
|
||||
String fileName = getCanonicalComparatorName(comparator);
|
||||
writeExternalFormToDisk((Serializable) comparator, fileName);
|
||||
fail("Serialized form could not be found. A serialized version " +
|
||||
"has now been written (and should be added to SVN): " + fileName);
|
||||
if(autoCreateSerialized) {
|
||||
comparator = makeComparator();
|
||||
String fileName = getCanonicalComparatorName(comparator);
|
||||
writeExternalFormToDisk((Serializable) comparator, fileName);
|
||||
fail("Serialized form could not be found. A serialized version " +
|
||||
"has now been written (and should be added to SVN): " + fileName);
|
||||
} else {
|
||||
fail("The Serialized form could be located to test serialization " +
|
||||
"compatibility: " + exception.getMessage());
|
||||
|
|
|
@ -48,28 +48,28 @@ public abstract class TestNullComparator extends AbstractTestComparator {
|
|||
**/
|
||||
public static class TestNullComparator1 extends TestNullComparator {
|
||||
|
||||
public TestNullComparator1(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
public TestNullComparator1(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
||||
public Comparator makeComparator() {
|
||||
return new NullComparator();
|
||||
}
|
||||
|
||||
return new NullComparator();
|
||||
}
|
||||
|
||||
public List getComparableObjectsOrdered() {
|
||||
List list = new LinkedList();
|
||||
list.add(new Integer(1));
|
||||
list.add(new Integer(2));
|
||||
list.add(new Integer(3));
|
||||
list.add(new Integer(4));
|
||||
list.add(new Integer(5));
|
||||
list.add(null);
|
||||
return list;
|
||||
}
|
||||
list.add(new Integer(1));
|
||||
list.add(new Integer(2));
|
||||
list.add(new Integer(3));
|
||||
list.add(new Integer(4));
|
||||
list.add(new Integer(5));
|
||||
list.add(null);
|
||||
return list;
|
||||
}
|
||||
|
||||
public String getCanonicalComparatorName(Object object) {
|
||||
return super.getCanonicalComparatorName(object) + "1";
|
||||
}
|
||||
public String getCanonicalComparatorName(Object object) {
|
||||
return super.getCanonicalComparatorName(object) + "1";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -102,12 +102,12 @@ public class TestSingletonListIterator extends AbstractTestListIterator {
|
|||
assertEquals( "Iteration next index", 1, iter.nextIndex() );
|
||||
assertEquals( "Iteration previous index", 0, iter.previousIndex() );
|
||||
|
||||
try {
|
||||
iter.next();
|
||||
} catch (Exception e) {
|
||||
assertTrue("NoSuchElementException must be thrown",
|
||||
e.getClass().equals((new NoSuchElementException()).getClass()));
|
||||
}
|
||||
try {
|
||||
iter.next();
|
||||
} catch (Exception e) {
|
||||
assertTrue("NoSuchElementException must be thrown",
|
||||
e.getClass().equals((new NoSuchElementException()).getClass()));
|
||||
}
|
||||
iter.previous();
|
||||
try {
|
||||
iter.previous();
|
||||
|
|
|
@ -215,37 +215,37 @@ public class TestMultiKey extends TestCase {
|
|||
}
|
||||
|
||||
static class SystemHashCodeSimulatingKey implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final String name;
|
||||
private int hashCode = 1;
|
||||
|
||||
public SystemHashCodeSimulatingKey(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final String name;
|
||||
private int hashCode = 1;
|
||||
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
return obj instanceof SystemHashCodeSimulatingKey
|
||||
&& name.equals(((SystemHashCodeSimulatingKey)obj).name);
|
||||
}
|
||||
public SystemHashCodeSimulatingKey(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return hashCode;
|
||||
}
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
return obj instanceof SystemHashCodeSimulatingKey
|
||||
&& name.equals(((SystemHashCodeSimulatingKey)obj).name);
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
hashCode=2; // simulate different hashCode after deserialization in another process
|
||||
return this;
|
||||
}
|
||||
public int hashCode()
|
||||
{
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
hashCode=2; // simulate different hashCode after deserialization in another process
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public void testEqualsAfterSerialization() throws IOException, ClassNotFoundException
|
||||
{
|
||||
{
|
||||
SystemHashCodeSimulatingKey sysKey = new SystemHashCodeSimulatingKey("test");
|
||||
MultiKey mk = new MultiKey(ONE, sysKey);
|
||||
MultiKey mk = new MultiKey(ONE, sysKey);
|
||||
Map map = new HashMap();
|
||||
map.put(mk, TWO);
|
||||
|
||||
|
@ -266,6 +266,6 @@ public class TestMultiKey extends TestCase {
|
|||
assertEquals(2, sysKey.hashCode()); // different hashCode now
|
||||
|
||||
MultiKey mk2 = new MultiKey(ONE, sysKey);
|
||||
assertEquals(TWO, map2.get(mk2));
|
||||
}
|
||||
assertEquals(TWO, map2.get(mk2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ import org.apache.commons.collections.BulkTest;
|
|||
*/
|
||||
public class TestTreeList extends AbstractTestList {
|
||||
|
||||
public TestTreeList(String name) {
|
||||
super(name);
|
||||
}
|
||||
public TestTreeList(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(suite());
|
||||
|
@ -105,72 +105,72 @@ public class TestTreeList extends AbstractTestList {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public List makeEmptyList() {
|
||||
return new TreeList();
|
||||
}
|
||||
public List makeEmptyList() {
|
||||
return new TreeList();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public void testAddMultiple() {
|
||||
List l = makeEmptyList();
|
||||
l.add("hugo");
|
||||
l.add("erna");
|
||||
l.add("daniel");
|
||||
l.add("andres");
|
||||
l.add("harald");
|
||||
l.add(0, null);
|
||||
assertEquals(null, l.get(0));
|
||||
assertEquals("hugo", l.get(1));
|
||||
assertEquals("erna", l.get(2));
|
||||
assertEquals("daniel", l.get(3));
|
||||
assertEquals("andres", l.get(4));
|
||||
assertEquals("harald", l.get(5));
|
||||
}
|
||||
public void testAddMultiple() {
|
||||
List l = makeEmptyList();
|
||||
l.add("hugo");
|
||||
l.add("erna");
|
||||
l.add("daniel");
|
||||
l.add("andres");
|
||||
l.add("harald");
|
||||
l.add(0, null);
|
||||
assertEquals(null, l.get(0));
|
||||
assertEquals("hugo", l.get(1));
|
||||
assertEquals("erna", l.get(2));
|
||||
assertEquals("daniel", l.get(3));
|
||||
assertEquals("andres", l.get(4));
|
||||
assertEquals("harald", l.get(5));
|
||||
}
|
||||
|
||||
public void testRemove() {
|
||||
List l = makeEmptyList();
|
||||
l.add("hugo");
|
||||
l.add("erna");
|
||||
l.add("daniel");
|
||||
l.add("andres");
|
||||
l.add("harald");
|
||||
l.add(0, null);
|
||||
int i = 0;
|
||||
assertEquals(null, l.get(i++));
|
||||
assertEquals("hugo", l.get(i++));
|
||||
assertEquals("erna", l.get(i++));
|
||||
assertEquals("daniel", l.get(i++));
|
||||
assertEquals("andres", l.get(i++));
|
||||
assertEquals("harald", l.get(i++));
|
||||
public void testRemove() {
|
||||
List l = makeEmptyList();
|
||||
l.add("hugo");
|
||||
l.add("erna");
|
||||
l.add("daniel");
|
||||
l.add("andres");
|
||||
l.add("harald");
|
||||
l.add(0, null);
|
||||
int i = 0;
|
||||
assertEquals(null, l.get(i++));
|
||||
assertEquals("hugo", l.get(i++));
|
||||
assertEquals("erna", l.get(i++));
|
||||
assertEquals("daniel", l.get(i++));
|
||||
assertEquals("andres", l.get(i++));
|
||||
assertEquals("harald", l.get(i++));
|
||||
|
||||
l.remove(0);
|
||||
i = 0;
|
||||
assertEquals("hugo", l.get(i++));
|
||||
assertEquals("erna", l.get(i++));
|
||||
assertEquals("daniel", l.get(i++));
|
||||
assertEquals("andres", l.get(i++));
|
||||
assertEquals("harald", l.get(i++));
|
||||
l.remove(0);
|
||||
i = 0;
|
||||
assertEquals("hugo", l.get(i++));
|
||||
assertEquals("erna", l.get(i++));
|
||||
assertEquals("daniel", l.get(i++));
|
||||
assertEquals("andres", l.get(i++));
|
||||
assertEquals("harald", l.get(i++));
|
||||
|
||||
i = 0;
|
||||
l.remove(1);
|
||||
assertEquals("hugo", l.get(i++));
|
||||
assertEquals("daniel", l.get(i++));
|
||||
assertEquals("andres", l.get(i++));
|
||||
assertEquals("harald", l.get(i++));
|
||||
i = 0;
|
||||
l.remove(1);
|
||||
assertEquals("hugo", l.get(i++));
|
||||
assertEquals("daniel", l.get(i++));
|
||||
assertEquals("andres", l.get(i++));
|
||||
assertEquals("harald", l.get(i++));
|
||||
|
||||
i = 0;
|
||||
l.remove(2);
|
||||
assertEquals("hugo", l.get(i++));
|
||||
assertEquals("daniel", l.get(i++));
|
||||
assertEquals("harald", l.get(i++));
|
||||
}
|
||||
i = 0;
|
||||
l.remove(2);
|
||||
assertEquals("hugo", l.get(i++));
|
||||
assertEquals("daniel", l.get(i++));
|
||||
assertEquals("harald", l.get(i++));
|
||||
}
|
||||
|
||||
public void testInsertBefore() {
|
||||
List l = makeEmptyList();
|
||||
l.add("erna");
|
||||
l.add(0, "hugo");
|
||||
assertEquals("hugo", l.get(0));
|
||||
assertEquals("erna", l.get(1));
|
||||
}
|
||||
public void testInsertBefore() {
|
||||
List l = makeEmptyList();
|
||||
l.add("erna");
|
||||
l.add(0, "hugo");
|
||||
assertEquals("hugo", l.get(0));
|
||||
assertEquals("erna", l.get(1));
|
||||
}
|
||||
|
||||
public void testIndexOf() {
|
||||
List l = makeEmptyList();
|
||||
|
|
Loading…
Reference in New Issue