6월, 2020의 게시물 표시

[IntelliJ] Test events were not received

이미지
IntelliJ에서 JUnit 테스트시 아래와 같은 오류 메세지가 나올 때 해결 방법 Test events were not received 1. Preference > Build, Execution, Deployment > Build Tools > Gradle 로 이동 2. Run tests using 을 IntelliJ IDEA 로 설정

[RxJava] just() vs fromCallable()

just()와 fromCallable()은같은 동작을 하는 것 같지만 차이점이 있다. just의 doc을 살펴보면 Note that the item is taken and re-emitted as is and not computed by any means by  just . Use  fromCallable(Callable)  to generate a single item on demand (when  Observer s subscribe to it). 즉, just()는 모든 subscribe()에 동일한 값을 주기 때문에 subscribe() 할때 재연산이 필요하면 반드시 formCallable()을 사용해야 한다. 아래는 만들어본 예제. 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 @Slf4j public class JustFromCallableTest { public static void main(String[] args) throws InterruptedException { log.info( "start : {}" , getTimeObject()); // 1. just() Observable<Long> justSource = Observable.just(getTimeObject()); justSource.subscribe(val -> log.info( "just.onNext #1 : {}" , val)); Thread.sleep( 3000 ); justSource.subscribe(val -> log.info( "just.onNext #2 : {}" , val)); // 2. fromCallable() Observable<Long

Spring Bean Lite Mode

스프링 bean 등록은 @Configuration 하게 되면 lite mode가 아니고, @Component에서 하게 되면 lite mode로 동작하게 된다. 말보다는 코드로... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 @Slf4j //@Configuration(proxyBeanMethods = true) // proxyBeanMethods = false & @Component is lite mode. @Configuration (proxyBeanMethods = false ) //@Component public class TestConfig { @Bean public MyHello myHello () { return new MyHello ( "ok?" ); } @Bean public MyHelloWrapper myHelloWrapper () { MyHello m = myHello(); log. info ( "In MyHelloWrapper, myHello #1={}" , m); log. info ( "In MyHelloWrapper, myHello #2={}" , myHello()); log. info ( "In MyHelloWrapper, myHello #3={}" , myHello()); return new MyHelloWrapper (m); } } @Configuration의 default는 proxyBeanMethods = true이다. 이때는 gclib을 이용해 bean을 singleton으로 관리하는 proxy를 생성 한다. 그래서 15, 16, 17 line의 object reference가 모두 동일하게 나오는 것을 확인 할 수

Java 직렬화, 역직렬화 그리고 serialVersionUID

Java의 object를 직렬화 하고자 할때는 Serializable 을 상속만 받으면 되서 매우 편리하다. 그러나 주의해야 할 부분이 있는데 정리하면 다음과 같다. Java 직렬화는 serialVerionUID 로 클래스를 구별한다. serialVersionUID 를 명시하지 않으면 기본적으로 클래스의 해시값을 사용한다. 그래서 클래스의 필드 추가나 삭제가 빈번한 경우 serialVersionUID 를 명시적으로 주지 않으면 역직렬화에 문제가 발생할 수 있다. 타입에 엄격해 serialVersionUID 를 명시하더라도 필드의 추가, 삭제는 없는 값으로 대치가 되지만 타입이 바뀌면 exception이 발생한다. 일부 라이브러리의 경우 serialVersionUID 가 있긴하지만 버전따라 변경될 수 있으므로 Serializable 을 상속한다면 반드시 serialVersionUID 를 명시하자.

Mac JMeter 설치

이미지
Mac에서는 brew로 설치 가능. * 설치 $> brew install jmeter * 실행 $> jmeter Intellij를 사용한다면 아래처럼 설정해서 사용 가능하다.

Git Remote에 잘못 push 된 디렉토리 삭제하기

실수로 remote에 .idea(인텔리제이 설정파일)을 올려 버렸다. 로컬에는 남기고 remote에만 삭제하려면 아래처럼 하면 된다. $> git rm -r --cached .idea -r: recursively --cached: stage에만 삭제. 즉 이게 없으면 로컬도 삭제된다. $> git commit -m "Remove .idea folder" $> git push origin master

df / du 사용법

df : 디스크의 남은 용량을 확인  df -k  : 킬로바이트 단위로 현재 남은 용량을 확인 df -m  : 메가바이트 단위로 남은 용량을 왁인  df -h  df .  : 현재 디렉토리가 포함된 파티션의 남은 용량을 확인 du : 현재 디렉토리에서 서브디렉토리까지의 사용량을 확인  du -a  :  현재 디렉토리의 사용량을 파일단위 출력 du -s  : 총 사용량을 확인 du -h  : 보기 좋게 바꿔줌  du -sh *  : 한단계 서브디렉토리 기준으로 보여준다.  ex) app 디렉터리 내의 디렉터리(한단계) 사용량 $> du -sh /app/*

Mac에서 ‘₩’ 대신 ‘`’ 입력하기

맥 최신 버전에서 한글입력 일땐  ₩ 가 입력되고 영문입력 일땐  ` 가 입력되어 불편한 경우가 많습니다. 무조건  ` 가 입력되도록 시스템을 설정합니다. ~/Library/KeyBindings/DefaultkeyBinding.dict 해당 위치에 파일을 생성하고 다음과 같은 내용을 입력합니다.(KeyBindings 폴더도 없으면 생성) 1 2 3 { "₩" = ( "insertText:" , " ` "); } 프로그램 재시작이 필요합니다.