blob: d872f62ea823d74530c5232d0e1099f17c547fc1 (
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
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.logging;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsCollectionContaining.hasItem;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
public class CircularArrayAccessLogKeeperTest {
private CircularArrayAccessLogKeeper circularArrayAccessLogKeeper = new CircularArrayAccessLogKeeper();
@Test
public void testSizeIsCroppedCorrectly() {
for (int i = 0; i < CircularArrayAccessLogKeeper.SIZE - 1; i++) {
circularArrayAccessLogKeeper.addUri(String.valueOf(i));
}
assertThat(circularArrayAccessLogKeeper.getUris().size(), is(CircularArrayAccessLogKeeper.SIZE -1));
circularArrayAccessLogKeeper.addUri("foo");
assertThat(circularArrayAccessLogKeeper.getUris().size(), is(CircularArrayAccessLogKeeper.SIZE));
circularArrayAccessLogKeeper.addUri("bar");
assertThat(circularArrayAccessLogKeeper.getUris().size(), is(CircularArrayAccessLogKeeper.SIZE));
assertThat(circularArrayAccessLogKeeper.getUris(), hasItems("1", "2", "3", "foo", "bar"));
assertThat(circularArrayAccessLogKeeper.getUris(), not(hasItem("0")));
}
@Test
public void testEmpty() {
assertThat(circularArrayAccessLogKeeper.getUris().size(), is(0));
}
@Test
public void testSomeItems() {
circularArrayAccessLogKeeper.addUri("a");
circularArrayAccessLogKeeper.addUri("b");
circularArrayAccessLogKeeper.addUri("b");
assertThat(circularArrayAccessLogKeeper.getUris(), contains("a", "b", "b"));
}
}
|