01: /**
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */package com.tc.test.collections;
04:
05: import com.tc.util.Stringifier;
06: import com.tc.util.diff.DifferenceBuilder;
07: import com.tc.util.diff.Differenceable;
08:
09: /**
10: * A {@link CollectionMismatch}that is used when two objects aren't equal to each other.
11: */
12: class UnequalObjectCollectionMismatch extends CollectionMismatch {
13:
14: public UnequalObjectCollectionMismatch(Object originating,
15: Object comparedAgainst,
16: boolean originatingIsInCollectionOne, int originatingIndex,
17: int comparedAgainstIndex, Stringifier describer) {
18: super (originating, comparedAgainst,
19: originatingIsInCollectionOne, originatingIndex,
20: comparedAgainstIndex, describer);
21: }
22:
23: public String toString() {
24: if (originating() != null && comparedAgainst() != null
25: && (originating() instanceof Differenceable)
26: && (comparedAgainst() instanceof Differenceable)) {
27: // formatting
28: return "Unequal objects: differences are: "
29: + DifferenceBuilder.describeDifferences(
30: (Differenceable) originating(),
31: (Differenceable) comparedAgainst(),
32: describer()) + "\n" + originatingString()
33: + "\nis not equal to\n" + comparedAgainstString()
34: + "\n";
35: }
36:
37: return "Unequal objects: " + originatingString()
38: + " is not equal to " + comparedAgainstString();
39: }
40:
41: }
|