본문 바로가기

Programing/OpenSource

(52)
[Spock Framework] Mock vs Stub Spock Framework Reference Documentation 을 보면 다른 종류의 Mock Objects로 Stub을 소개하고 있다. 레퍼런스에서는 mock 은 stubbing과 mocking을 둘 다 할 수 있고 ,stub은 단지 stubbing 만 할 수 있다고 나와 있다. 가장 큰 차이는 stub은 몇 번 호출되었는지를 물어볼 수 없는 차이가 있다. 하지만 이것으로는 Mock() 와 Stub()을 언제 써야할 지 명확하지 않다. 우연히 처음에는 Stub()을 사용하다가 카운팅 여부를 확인해야 해서 이후에 Mock()으로 바꾸는 작업이 있었는데 이 side-effect로 다른 테스트 케이스가 깨지는 경험을 하게 되어 차이를 이제야 이해할 수 있었다. 예를 들어 아래와 같이 CancelSer..
[slf4j] MDC에 put만 계속한다면 MDC를 이용해서 Correlation ID 추적에 사용을 하고 있다. 스프링을 사용한다면 AsyncHandlerInterceptor 인터페이스를 구현한 HandlerInterceptorAdapter 를 상속받으면 preHandle 과 afterCompletion 메서드에 MDC에 값을 넣고 지우도록 할 수 있다. import java.util.UUID; import org.slf4j.MDC; public class MDCInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { M..
[JPA] Hibernate + MariaDB : count(*)의 매핑이 BigInteger로 되는 이유는? 회사의 수지님이 퇴근 전 물어보아 찾아보게 된 MaraiDB의 JDBC 드라이버. EntityManager 를 통해 NativeQuery를 수행하는데 반환되는 타입이 Long으로 생각했는데 BigInteger 타입으로 반환되어 ClassCastException 가 발생했다고 한다. 간략하게 코드로 보면 아래와 같다. @Service public class CountService { private final EntityManager entityManager; @Autowired public CountService(EntityManager entityManager) { this.entityManager = entityManager; } public Long countIssue() { Query query =..
[Hibernate] JPA 스키마 검증은 어떻게 수행될까? 실제 DB와 엔티티가 일치하는지 애플리케이션이 동작할 때 검증을 하도록 설정이 되어 있다. 만약 일치하지 않는 경우가 발생하면 예외를 던지며 애플리케이션을 멈추어 조기에 문제가 있음을 알 수 있게 한다. DB에 무엇인가 쿼리를 날려서 일치여부를 확인할 것인데 쿼리도 보이지 않아서 파게되었다. 일부러 예외를 발생시키고 예외의 stacktrace를 찾다보니 SpringHibernateJpaPersistenceProvider 에서 createContainerEntityManagerFactory 에서 시작할 수 있었다. package org.springframework.orm.jpa.vendor; class SpringHibernateJpaPersistenceProvider extends HibernatePer..
[라이선스] Wunderlist 3.19.41 Wunderlist가 2020년 5월 6일부로 사용이 중단된다고 해서 라이선스 스냅샷을 찍어둔다. 목록 Wunderlist 3.19.41 Copyright © 2015 6 Wunderkinder GmbH All Rights Reserved 개인정보처리방침 - 임프린트 - 사용 약관 Imprint 6 Wunderkinder GmbH Karl-Liebknecht-Straße 32 10178 Berlin Contact Mail: hello@6wunderkinder.com Handelsregister AG Charlottenburg HRB 128663 B UstID DE815214657 Geschäftsführer Christian Reber Privacy Policy We, 6Wunderkinder GmbH ..
[Apache Lucene] Lucene의 의미는? 사실 사람의 이름이라 의미를 찾기는 어렵다. Lucene을 만든 Doug Cutting 의 아내의 미들네임이 Lucene인 것과 그의 아내의 할머니의 이름이 루씬이다. 출처: Barker, Deane (2016). Web Content Management. O'Reilly. p. 233. ISBN 1491908106
[tomcat] HttpServletRequest.getHeader 헤더를 보면 가끔 대소문자를 가리지 않고 동작하는 경우가 있어서 확인을 해보았다. package javax.servlet.http; public interface HttpServletRequest extends ServletRequest { /** * Returns the value of the specified request header as a * String. If the request did not include a header of the * specified name, this method returns null. If there are * multiple headers with the same name, this method returns the first head * in the reque..
[Redis] 난 Redis가 Ruby로 짰는 줄 알았는데... 난 Redis가 Ruby로 짰는 줄 알았는데... 코드를 받아보니 C로 짜여져 있다. server.h를 보면 ae.h를 포함하고 있다. Jim's event-loop 를 위해 만든 event-driven 프로그래밍 라이브러리를 재사용하기 편하게 라이브러리화 한 것이다. ae.c에 보면 시스템에서 지원하는 최적(최고)의 멀티플렉싱 레이어를 포함하는 코드가 있는데, evport -> epoll -> kqueue -> select 순으로 되어 있다. #ifdef HAVE_EVPORT #include "ae_evport.c" #else #ifdef HAVE_EPOLL #include "ae_epoll.c" #else #ifdef HAVE_KQUEUE #include "ae_kqueue.c" #else #incl..