blob: f3216764a5db9b583acd43a3b6f9ff27f2b1241d (
plain) (
blame)
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.tenant;
import com.google.common.testing.EqualsTester;
import com.yahoo.config.provision.TenantName;
import com.yahoo.vespa.config.server.TestWithCurator;
import com.yahoo.vespa.config.server.application.MemoryTenantApplications;
import com.yahoo.vespa.config.server.http.v2.TestTenantBuilder;
import com.yahoo.vespa.config.server.tenant.Tenant;
import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.*;
/**
* @author lulf
* @since 5.3
*/
public class TenantTest extends TestWithCurator {
private Tenant t1;
private Tenant t2;
private Tenant t3;
private Tenant t4;
@Before
public void setupTenant() throws Exception {
t1 = createTenant("foo");
t2 = createTenant("foo");
t3 = createTenant("bar");
t4 = createTenant("baz");
}
private Tenant createTenant(String name) throws Exception {
return new TestTenantBuilder().createTenant(TenantName.from(name)).build();
}
@Test
public void equals() {
new EqualsTester()
.addEqualityGroup(t1, t2)
.addEqualityGroup(t3)
.addEqualityGroup(t4)
.testEquals();
}
@Test
public void hashcode() {
assertThat(t1.hashCode(), is(t2.hashCode()));
assertThat(t1.hashCode(), is(not(t3.hashCode())));
assertThat(t1.hashCode(), is(not(t4.hashCode())));
}
@Test
public void close() {
MemoryTenantApplications repo = (MemoryTenantApplications) t1.getApplicationRepo();
assertTrue(repo.isOpen());
t1.close();
assertFalse(repo.isOpen());
}
}
|