본문 바로가기

Java22

[Spring Boot] Spring 통합 테스트(@SpringBootTest, @Transactional) https://rezal.tistory.com/entry/%ED%9A%8C%EC%9B%90-%EA%B4%80%EB%A6%AC-%EC%98%88%EC%A0%9C-%EB%B0%B1%EC%97%94%EB%93%9C-%EA%B0%9C%EB%B0%9C-5-%ED%9A%8C%EC%9B%90-%EC%84%9C%EB%B9%84%EC%8A%A4-%ED%85%8C%EC%8A%A4%ED%8A%B8 [회원 관리 예제, 백엔드 개발 - (5)] 회원 서비스 테스트 git repository : https://github.com/Rezalog/spring-boot-entry-inf GitHub - Rezalog/spring-boot-entry-inf Contribute to Rezalog/spring-boot-entry-inf .. 2022. 7. 5.
[Spring DB 접근 기술 - (1)] JDBC, JPA와 h2 Database 설치 이전까지 Spring Boot의 MVC 패턴을 이용하여 Memory 방식으로 DB 를 처리했었다. 본격적으로 4가지의 DB 접근기술을 활용하여, h2 database 를 CRUD 하는 방법을 알아보자. (h2를 사용하는 이유는 별다른거 없고, DB가 가벼우며 admin 화면도 제공하기때문) DB 접근 기술의 종류 순수 JDBC : SQL을 활용하여 Application Server 와 DB을 연결할 수 있도록 하는 DB 접근 기술 Spring JDBCTemplate : Spring 이 JDBC의 중복제거하고 쉽게 SQL을 날릴 수 있도록 제공하는 템플릿 JPA : SQL도 직접 개발자가 작성하지 않고, JPA 내에서 처리할 수 있도록하는 기술, 객체를 DB에 쿼리없이 저장할 수 있다. Spring Dat.. 2022. 7. 5.
[회원 관리 예제 : 웹 MVC 개발] 홈, 회원 등록, 회원 조회 본격적으로 url 요청에 따른 Controller 들을 설정해주도록 하자. 홈 화면 추가 localhost:8080 요청 시, 홈 화면(home.html)으로 이동한다. 기존에 똑같은 매핑이 resource > static 에 index.html 로 존재했으나, @Controller 에서 Spring Container 가 먼저 매핑되는 화면을 먼저 찾기 때문에 home.html 이 우선적으로 보여진다. 회원 등록 form 태그에서 post로 "/members/new" 로 넘기고 해당 처리 메소드 create의 인자로 MemberForm 타입이 들어간다. createMemberForm에서 form 태그로 넘어온 input의 name key의 input value "spring" 을 MemberForm 의 .. 2022. 7. 1.
[회원 관리 예제, 백엔드 개발 - (5)] 회원 서비스 테스트 git repository : https://github.com/Rezalog/spring-boot-entry-inf GitHub - Rezalog/spring-boot-entry-inf Contribute to Rezalog/spring-boot-entry-inf development by creating an account on GitHub. github.com 구현한 회원 서비스, MemberService 를 테스트하기 위한 코드를 작성해보자. 이때 테스트 코드 작성시, given-when-then 으로 나누어 작성하는 습관을 들이자! (**cmd + shift + T 로 테스트 자동 생성이 가능 !) MemberServiceTest beforeEach MemoryMemberRepository 은 .. 2022. 6. 30.
[회원 관리 예제, 백엔드 개발 - (4)] 회원 서비스 개발 git repository : https://github.com/Rezalog/spring-boot-entry-inf GitHub - Rezalog/spring-boot-entry-inf Contribute to Rezalog/spring-boot-entry-inf development by creating an account on GitHub. github.com 회원 서비스 : 회원 리포지토리와 도메인을 활용해서, 실제 비즈니스 로직을 구현한다. 실제로 구현해볼 서비스는 회원가입, 전체 회원 조회이다. MemberService class join(회원가입) - 기본 로직 도메인인 Member 타입으로 받은 회원정보로 중복 회원을 검증하고, repo에 저장한 뒤 Long type 의 id를 반환한다. .. 2022. 6. 30.
[회원 관리 예제, 백엔드 개발 - (3)] 회원 리포지토리 테스트 케이스 작성 git repository : https://github.com/Rezalog/spring-boot-entry-inf GitHub - Rezalog/spring-boot-entry-inf Contribute to Rezalog/spring-boot-entry-inf development by creating an account on GitHub. github.com 메인 메소드나 Controller를 실행해서 테스트를 하기에는 준비 및 실행이 오래걸리고, 반복적으로 실행하거나 여러 테스트케이스를 한번에 실행하기 어려운 단점이 있다. 이를 해결하기 위하여 JUnit 을 이용한 테스트 케이스를 작성하고 테스트 해볼 수 있다. JUnit Test 과정 (1) - findById 구현한 interface 인 M.. 2022. 6. 29.