aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/worker/WorkerPoolConfigTest.java
blob: 27b7aac2e02a2197c0dff7baf27d65d7993f0106 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright 2016 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.devtools.build.lib.worker;

import com.google.common.testing.EqualsTester;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
 * Test WorkerPoolConfig.
 */
@RunWith(JUnit4.class)
public class WorkerPoolConfigTest {

  @Test
  public void testEquals() throws Exception {
    WorkerPoolConfig config1a = new WorkerPoolConfig();
    config1a.setLifo(true);
    config1a.setMaxIdlePerKey(4);
    config1a.setMaxTotalPerKey(4);
    config1a.setMinIdlePerKey(4);
    config1a.setMaxTotal(-1);
    config1a.setBlockWhenExhausted(true);
    config1a.setTestOnBorrow(true);
    config1a.setTestOnCreate(false);
    config1a.setTestOnReturn(true);
    config1a.setTimeBetweenEvictionRunsMillis(-1);

    WorkerPoolConfig config1b = new WorkerPoolConfig();
    config1b.setLifo(true);
    config1b.setMaxIdlePerKey(4);
    config1b.setMaxTotalPerKey(4);
    config1b.setMinIdlePerKey(4);
    config1b.setMaxTotal(-1);
    config1b.setBlockWhenExhausted(true);
    config1b.setTestOnBorrow(true);
    config1b.setTestOnCreate(false);
    config1b.setTestOnReturn(true);
    config1b.setTimeBetweenEvictionRunsMillis(-1);

    WorkerPoolConfig config2a = new WorkerPoolConfig();
    config2a.setLifo(true);
    config2a.setMaxIdlePerKey(1);
    config2a.setMaxTotalPerKey(1);
    config2a.setMinIdlePerKey(1);
    config2a.setMaxTotal(-1);
    config2a.setBlockWhenExhausted(true);
    config2a.setTestOnBorrow(true);
    config2a.setTestOnCreate(false);
    config2a.setTestOnReturn(true);
    config2a.setTimeBetweenEvictionRunsMillis(-1);

    WorkerPoolConfig config2b = new WorkerPoolConfig();
    config2b.setLifo(true);
    config2b.setMaxIdlePerKey(1);
    config2b.setMaxTotalPerKey(1);
    config2b.setMinIdlePerKey(1);
    config2b.setMaxTotal(-1);
    config2b.setBlockWhenExhausted(true);
    config2b.setTestOnBorrow(true);
    config2b.setTestOnCreate(false);
    config2b.setTestOnReturn(true);
    config2b.setTimeBetweenEvictionRunsMillis(-1);

    new EqualsTester()
        .addEqualityGroup(config1a, config1b)
        .addEqualityGroup(config2a, config2b)
        .testEquals();
  }
}