반응형

org.hibernate.LazyInitializationException: could not initialize proxy [com.jejunet.cms.server.domain.Server#216] - no Session

at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:169)

at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:309)

at org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor.intercept(ByteBuddyInterceptor.java:45)

at org.hibernate.proxy.ProxyConfiguration$InterceptorDispatcher.intercept(ProxyConfiguration.java:95)

at com.jejunet.cms.server.domain.Server$HibernateProxy$1dTl2oLJ.getName(Unknown Source)

at com.jejunet.cms.server.ServerServiceTest.getServer(ServerServiceTest.java:122)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:566)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)

at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)

at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)

at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)

at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)

at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)


아래와 같이 테스트 메소드를 단순히 저장하고 조회 하는데 예외 발생했다.

단건 가져오는것에 japRepository 기능 구현이 다른가보다.

repository.findByid(id);  /* Retrieves an entity by its id  */

repository.getOne(id);  /* Returns a reference to the entity with the given identifier. */ <= 이놈 쓰면 오류남 

@Test

public void getServer() {

Server savedServer = repository.save(new Server(SERVER_NAME));

Optional<Server> server2 = serverService.getServer(savedServer.getId());

assertEquals(savedServer.getName(), server2.get().getName());

}


아래 블로그에서 싶게 설명하고 있다. 

영속성 관련해서 레퍼런스만 필요할때 경우에 따라 쓴다고 하네요.(복잡함 ㅠㅠ)

https://bebong.tistory.com/entry/JPA-Lazy-Evaluation-LazyInitializationException-could-not-initialize-proxy-%E2%80%93-no-Session 

반응형
반응형

spring integration

https://github.com/spring-projects/spring-integration-samples/blob/master/basic/tcp-client-server/src/main/resources/META-INF/spring/integration/tcpClientServerDemo-context.xml


https://gitlab.com/kjkjjang/echo-server-client/blob/master/src/main/resources/META-INF/spring/integration/serverConfig.xml


angular + spring boot

https://chariotsolutions.com/blog/post/angular-2-spring-boot-jwt-cors_part1/

https://github.com/oktadeveloper/spring-boot-angular-example


angular + sts

https://grokonez.com/tool/setup-angular-ide-spring-tool-suite

라이센스를 잘 읽어봐서 설치해야된다. ( 특정 기간이 지난후 유료로 변하는것도 많다.)


spring boot + swing 

https://github.com/DanielMichalski/spring-boot-swing-reservations


spring boot rest service

https://spring.io/guides/tutorials/bookmarks/


spring boot rest api + tdd

https://github.com/pivotal-chicago/spring-boot-rest-api-tdd


spring boot + tdd

https://jojoldu.tistory.com/33


java8 optional

http://asfirstalways.tistory.com/354


spring boot + datatable server

https://www.opencodez.com/java/datatable-with-spring-boot.htm


Spring Boot + Angular 6 example | Spring Data JPA + REST + MySQL CRUD example

https://grokonez.com/spring-framework/spring-data/spring-boot-angular-6-example-spring-data-jpa-rest-mysql-crud-example


angular test-driven development

https://www.pluralsight.com/guides/introduction-to-angular-test-driven-development


angular cli

http://web-front-end.tistory.com/64


angualr datatable

https://blog.angular-university.io/angular-material-data-table/

http://l-lin.github.io/angular-datatables/#/getting-started


angular sweetalert

https://www.npmjs.com/package/ng2-sweetalert2


java xml parser

http://lee-mandu.tistory.com/377


websocket 

http://blog.naver.com/PostView.nhn?blogId=moonv11&logNo=220658500567&parentCategoryNo=&categoryNo=15&viewDate=&isShowPopularPosts=true&from=search


querydsl

https://lng1982.tistory.com/285

http://adrenal.tistory.com/25


jpa 

https://jojoldu.tistory.com/165


spring tdd

http://thswave.github.io/java/2015/03/02/spring-mvc-test.html





반응형
반응형

오랜만에 개발서를 읽었다. TDD

오후 1시부터 내리 읽어 오후 4시에 쯤에 전부 읽었다. 

TDD에 관심이 많았던터라. 딱히 급한일도 없어 근무중에 끝까지 읽었다.


앞부분에 TDD의 필요성, 좋은점 등은 익히 알고 있던거라. 그냥 빠르게 읽고 넘어갔으며

중간부터 후반까지의 TDD의 방식과 리팩토링, 디자인패턴 그리고 Mock, 마지막의 마틴파울러의 이야기 재미있게 봤다.

TDD에 대한 오해와 진실 TDD 이야기 - 도서앞면TDD에 대한 오해와 진실 TDD 이야기 : 당신이 TDD에 실패한 이유


166쪽 이라 다음에 한번더 읽어볼 생각이다.

반응형
반응형

@Test 어노테이션으로 테스트 메소드라는것을 선언한다.

@BeforeEach 테스트 실행전 작업


Test fixture 테스트를 반복적으로 수행할 수 있게 도와주고 매번 동일한 결과를 얻을 수 있게 도와주는 상태나 환경,  (test context)



java8 junit5로 작업중이다.

보고 있는책은 junit4다.

버전이 다르니 쓰이는어노테이션도 다르다.


Annotations

Features

JUnit 5

JUnit 4

Declares a test method@Test@Test
Denotes that the annotated method will be executed before all test methods  in the current class@BeforeAll@BeforeClass
Denotes that the annotated method will be executed after all test methods  in the current class@AfterAll@AfterClass
Denotes that the annotated method will be executed before each test method@BeforeEach@Before
Denotes that the annotated method will be executed after each test method@AfterEach@After
Disable a test method or a test class@Disable@Ignore
Denotes a method is a test factory for dynamic tests in JUnit 5@TestFactoryN/A
Denotes that the annotated class is a nested, non-static test class@NestedN/A
Declare tags for filtering tests@Tag@Category
Register custom extensions in JUnit 5@ExtendWithN/A
Repeated Tests in JUnit 5@RepeatedTestN/A

Assertions.

JUnit 4

JUnit 5

failfail
assertTrueassertTrue
assertThatN/A
assertSameassertSame
assertNullassertNull
assertNotSameassertNotSame
assertNotEqualsassertNotEquals
assertNotNullassertNotNull
assertFalseassertFalse
assertEqualsassertEquals
assertArrayEqualsassertArrayEquals
assertAll
assertThrows

출처 : https://howtoprogram.xyz/2016/08/10/junit-5-vs-junit-4/



현제 필요한 기능이 아니면 절대로 미리 만들지 말자.

여유가 된다면 변화에 민첩하게 대응가능하게 리팩토링 하자.

반응형
반응형

프로그램을 작성하기 전에 테스트를 먼저 해라.

테스트 케이스 작성으로 구현을 시작하는 것, 그게 바로 TDD이다.

최종목표 "잘 동작하는 깔끔한 코드"

개발자가 처음으로 수행하는 테스트 = 개발자 테스트(Programmer test) = 단위 테스트(Unit test)



TDD 진행방식

  • Ask : 테스트 작성 ( 테스트 수행 결과는 실패)
  • Response : 테스트를 통과하는 코드를 작성해서 질문에 응답한다.(테스트 성공)
  • Refine : 통합, 불필요 제거, 명확하게 정제(리팩토링)



반응형
반응형

통화버튼

*#*#4638#*#*

Phone Information1 진입

통신방식 LTE/WCDMA 로 변경

반응형

+ Recent posts