01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.emultest.java.util;
17:
18: import org.apache.commons.collections.TestComparator;
19:
20: import java.util.ArrayList;
21: import java.util.Comparator;
22: import java.util.List;
23:
24: /**
25: * TODO: document me.
26: */
27: public class ComparatorTest extends TestComparator {
28: public Comparator makeComparator() {
29: return new DummyComparator();
30: }
31:
32: public List getComparableObjectsOrdered() {
33: List l = new ArrayList();
34: l.add("x");
35: l.add("y");
36: l.add("z");
37: return l;
38: }
39: }
40:
41: /**
42: * List comparator for testing.
43: */
44: class DummyComparator implements Comparator {
45: /**
46: * Compares returns reverse hash order.
47: */
48: public int compare(Object arg0, Object arg1) {
49: int a = arg0.hashCode();
50: int b = arg1.hashCode();
51: int accum;
52: if (a == b) {
53: accum = 0;
54: } else if (a > b) {
55: accum = 1;
56: } else {
57: accum = -1;
58: }
59: return accum;
60: }
61: }
|