Skip to content

Commit 05fda91

Browse files
committed
test
1 parent bb2c6d3 commit 05fda91

3 files changed

+126
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.huifer.jdk.jdk8.stearm;
2+
3+
import java.util.stream.Stream;
4+
5+
/**
6+
* 描述:
7+
*
8+
* @author huifer
9+
* @date 2019-06-16
10+
*/
11+
public class Demo05 {
12+
public static void main(String[] args) {
13+
Stream<Integer> integerStream = Stream.iterate(1, item -> item + 1).limit(10);
14+
15+
int sum = integerStream.filter(integer -> integer > 2).mapToInt(x -> x * 2).skip(2).limit(2).sum();
16+
System.out.println(sum);
17+
18+
// IntSummaryStatistics intSummaryStatistics = distinct.filter(integer -> integer > 2).mapToInt(x -> x * 2).summaryStatistics();
19+
// System.out.println(intSummaryStatistics.getMin());
20+
//
21+
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Copyright 2009-2019 the original author or authors.
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.apache.ibatis.cache;
17+
18+
import org.apache.ibatis.cache.decorators.LruCache;
19+
import org.apache.ibatis.cache.impl.PerpetualCache;
20+
import org.junit.jupiter.api.Test;
21+
22+
import static org.junit.jupiter.api.Assertions.*;
23+
24+
/**
25+
* LRU 缓存测试{@link LruCache}
26+
*/
27+
class LruCacheTest {
28+
29+
@Test
30+
void shouldRemoveLeastRecentlyUsedItemInBeyondFiveEntries() {
31+
LruCache cache = new LruCache(new PerpetualCache("default"));
32+
cache.setSize(5);
33+
for (int i = 0; i < 5; i++) {
34+
cache.putObject(i, i);
35+
}
36+
System.out.println(cache.getKeyMap());
37+
assertEquals(0, cache.getObject(0));
38+
cache.putObject(5, 5);
39+
System.out.println(cache.getKeyMap());
40+
assertNull(cache.getObject(1));
41+
assertEquals(5, cache.getSize());
42+
}
43+
44+
@Test
45+
void shouldRemoveItemOnDemand() {
46+
Cache cache = new LruCache(new PerpetualCache("default"));
47+
cache.putObject(0, 0);
48+
assertNotNull(cache.getObject(0));
49+
cache.removeObject(0);
50+
assertNull(cache.getObject(0));
51+
}
52+
53+
@Test
54+
void shouldFlushAllItemsOnDemand() {
55+
Cache cache = new LruCache(new PerpetualCache("default"));
56+
for (int i = 0; i < 5; i++) {
57+
cache.putObject(i, i);
58+
}
59+
assertNotNull(cache.getObject(0));
60+
assertNotNull(cache.getObject(4));
61+
cache.clear();
62+
assertNull(cache.getObject(0));
63+
assertNull(cache.getObject(4));
64+
}
65+
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Copyright 2009-2015 the original author or authors.
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.apache.ibatis.submitted.dynsql2;
17+
18+
public class Name {
19+
private String firstName;
20+
private String lastName;
21+
22+
public String getFirstName() {
23+
return firstName;
24+
}
25+
26+
public void setFirstName(String firstName) {
27+
this.firstName = firstName;
28+
}
29+
30+
public String getLastName() {
31+
return lastName;
32+
}
33+
34+
public void setLastName(String lastName) {
35+
this.lastName = lastName;
36+
}
37+
}

0 commit comments

Comments
 (0)