BstCountBasedBalancePoliciesTest.java revision 1d580d0f6ee4f21eb309ba7b509d2c6d671c4044
1/*
2 * Copyright (C) 2011 The Guava Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 * or implied. See the License for the specific language governing permissions and limitations under
12 * the License.
13 */
14
15package com.google.common.collect;
16
17import static com.google.common.collect.BstTesting.countAggregate;
18
19import com.google.common.annotations.GwtCompatible;
20import com.google.common.collect.BstTesting.SimpleNode;
21
22import junit.framework.Test;
23import junit.framework.TestCase;
24import junit.framework.TestSuite;
25
26/**
27 * Tests for the policies exported by {@link BstCountBasedBalancePolicies}
28 *
29 * @author Louis Wasserman
30 */
31@GwtCompatible
32public class BstCountBasedBalancePoliciesTest extends TestCase {
33  public static class NoRebalanceTest extends AbstractBstBalancePolicyTest {
34    @Override
35    protected BstBalancePolicy<SimpleNode> getBalancePolicy() {
36      return BstCountBasedBalancePolicies.noRebalancePolicy(countAggregate);
37    }
38  }
39
40  public static class SingleRebalanceTest extends AbstractBstBalancePolicyTest {
41    @Override
42    protected BstBalancePolicy<SimpleNode> getBalancePolicy() {
43      return BstCountBasedBalancePolicies.<Character, SimpleNode>singleRebalancePolicy(
44          countAggregate);
45    }
46  }
47
48  public static class FullRebalanceTest extends AbstractBstBalancePolicyTest {
49    @Override
50    protected BstBalancePolicy<SimpleNode> getBalancePolicy() {
51      return BstCountBasedBalancePolicies.<Character, SimpleNode>fullRebalancePolicy(
52          countAggregate);
53    }
54  }
55
56  public static Test suite() {
57    TestSuite suite = new TestSuite();
58    suite.addTestSuite(NoRebalanceTest.class);
59    suite.addTestSuite(SingleRebalanceTest.class);
60    suite.addTestSuite(FullRebalanceTest.class);
61    return suite;
62  }
63}
64