- 浏览: 4729 次
- 性别:
- 来自: 天津
最新评论
文章列表
继承: 实线 + 空心三角
实现: 虚线 + 空心三角
依赖: 虚线 + 箭头
关联: 实线 + 箭头
聚合: 箭头 + 空心菱形
合成: 箭头 + 实心菱形
Java shut down hook
- 博客分类:
- java
Runtime.getRuntime().addShutdownHook(Thread);
Before JVM shut down, it will call each hook you added.
Regarding following class: We define a generic class, but we donot have a method to resolve the generic.
public final class Event<T> {
private T event;
private Event() {}
public T getEvent() {
return event;
}
public static <T> Builder<T&g ...
I am trying to understand the difference between matches() and find().
Mocking and Stubbing
- 博客分类:
- test
Mocking
count abstract method invocations
Stubbing
get return of abstract method
//mocking
1 * subscriber.receive()
//stubbing
subscriber.recerive() >> content
//combine mocking and stubbing
1 * subscriber.receive() >> content
public interface EventProducer<T> {
public void send(T object);
}
declaration:
def producer = Mock(EventProducer)
usage:
producer as EventProducer<String>
Spock Mock Cheatsheet
- 博客分类:
- test
Spock Mock Cheatsheet
Craig Atkinson
Executable examples at github.com/craigatk/spockmockcheatsheet
Creating mocks
UserService userService = Mock()
def userService = Mock(UserService)
Argument matching
userService.createUser(email, name) >> user
userService.sendWelcomeEmail({ Us ...
ScheduledExecutorService has 2 method to schedule a task
schedule with fixed delay
schedule at fixed rate
I was confused about delay and rate, they both require a time parameter. What's the difference?
I ran following code:
public static void main(String[] args) {
ScheduledExecutorS ...