jusi的博客
jusi · 共 8 篇文章
UML 类图
继承: 实线 + 空心三角 实现: 虚线 + 空心三角 依赖: 虚线 + 箭头 关联: 实线 + 箭头 聚合: 箭头 + 空心菱形 合成: 箭头 + 实心菱形
2015-03-04 15:56 · 评论(0)
Java shut down hook
Runtime.getRuntime().addShutdownHook(Thread); Before JVM shut down, it will call each hook you added.
2014-12-15 11:02 · java · 评论(0)
Java generic methond without any parameters
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> newBuilder() { return new Builder<>(); } public static final …
2014-12-15 10:34 · java · 评论(0)
Difference between matches() and find() in Java Regex Matcher
I am trying to understand the difference between matches() and find() . matches() tries to match the expression against the entire string and implicitly add a ^ at the start and $ at the end of your pattern, meaning it will not look for a substring. Hence the output of this code: public static void…
2014-12-11 14:21 · java · 评论(0)
Mocking and Stubbing
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
2014-12-10 17:05 · test · 评论(0)
Spock mock generic type interface
public interface EventProducer<T> { public void send(T object); } declaration: def producer = Mock(EventProducer) usage: producer as EventProducer<String>
2014-12-10 16:34 · test · 评论(0)
Spock Mock Cheatsheet
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({ User u > u.email == em…
2014-12-10 16:29 · test · 评论(0)
ScheduledExecutorService scheduleWithFixedDelay and scheduleAtFixedRate
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) { ScheduledExecutorService executors…
2014-12-03 23:35 · java · 评论(0)