본문 바로가기

전체 글326

TDD 테스트 주도 개발 연습 TDD TDD란 테스트 주도 개발이라고 하며 반복 테스트를 이용한 소프트웨어 방법론으로, 작은 단위 테스트 케이스를 작성하고 이를 통과하는 코드를 추가하는 단계를 반복하여 구현합니다. 리팩토링(유지보수)의 용이성 개발 과정 실패한 테스트 작성 코드가 테스트를 통과할 수 있도록 작성 필요에 따라 코드 리팩토링 프로세스 반복 주제 :Fizz Buzz // 3으로 나누어 지면 Fizz // 5로 나누어 지면 -> Buzz // 3과 5로 나누어 지면 FizzBuzz // 둘다 안나눠지면 숫자 출력 1. 실패한 테스트 코드 작성 @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class FizzBuzzTest { // 1. 실패한 테스트 코드 작성 @Display.. 2022. 10. 5.
JUnit - 코드 커버리지 테스트 테스트 코드커버리지 코드 커버리지는 테스트라고 불리는 것에 얼마나 많은 메소드와 라인이 있는지 측정 커버리지는 퍼센테이지로 표현하고 높은 것이 좋다. IntelliJ 에는 코드 검사 지원 기능이 내장 코드 커버리지 보고서를 생성할 수 있음. 커버리지 테스트 진행 전체 메소드의 90% 사용 라인의 95%가 덮여있습니다. 이 뜻은 테스트하는 클래스의 전체 라인중 95% 만 단위 테스트를 했다는 것을 의미합니다. 커버리지 보고서 생성 또한 HTML 을 통해서 보고서를 세부적으로 볼 수 있습니다. Test Results - DemoUtilsTest 조건 테스트 특정 상황, OS 버전 @Disabled("...") @EnabledOnOs @EnabledOnOs(OS.WINDOWS) @EnabledOnOs({OS... 2022. 9. 25.
JUnit 테스트 - Assertions 테스트 단위 테스트 Automated tests Better code design Fewer bugs and higher reliability Increases confidence for code refactoring DevOps and Build Pipelines CI/CD 통합 테스트 하향식 통합 테스트 깊이 우선, 너비 우선 Stub (가짜 모듈) 사용 상향식 통합 테스트 클러스터 : 하위 모듈 그룹 드라이버 : 더미 모듈 순서 낮은 수준 모듈들을 클러스터로 결합 드라이버 작성 클러스터 검사/테스트 드라이버 제거하고 클러스터를 상위로 결합 유닛테스트 프레임워크 JUnit Mockito Unit Test Process Set Up Execute Assert class DemoUtilsTest { @T.. 2022. 9. 24.
자바스크립트 null, undefined, '', 0 체크 null,undefined,'',0 은 모두 false 이다 !! obj === 0 bad if ( array.length === 0 ) better if ( !array.length ) array.length === 0 bad if ( array.length > 0 ) ... better if ( array.length ) ... undefined,null,공백문자 bad obj === undefined obj === null obj === "" obj === 0 better !obj 문자열이 비어있지 않다는 것을 판별 bad if ( string !== "" ) better if ( string ) 참고 사이트 : https://negabaro.github.io/archive/js-isEmpty 2022. 9. 12.
Spring Boot 실행 프로세스와 Embedded Servers , CLI 실행 실행 프로세스 main() 메소드 실행 main() 메소드 내의 SpringApplication.run() 스프링 부트 앱에 대해 부트스트래핑 수행 long startTime = System.nanoTime() to calculate the time taken by Spring boot application 스프링 부트 실행을 위한 환경 준비 (dev, prod, qa, uat) Print banner (콘솔에 스프링 부트 로고 출력) IOC Container 시작 - classpath(default, Web servlet / Reactive)의 ApplicationContext context = createApplicationContext(); return context // Spring IOC con.. 2022. 9. 9.
Spring boot - blog application (REST API) : AWS RDS, Elastic Beanstalk AWS EC2 프로세서, 스토리지, 네트워킹, OS 및 구매 모델의 다양한 옵션을 제공하며, 클라우드에서 안전하고 크기 조정 가능한 컴퓨팅을 제공합니다. Elastic Beanstalk AWS Elastic Beanstalk는 Java, .NET, PHP, Node.js, Python, Ruby, Go 및 Docker를 사용하여 개발된 웹 애플리케이션 및 서비스를 Apache, Nginx, Passenger 및 IIS와 같은 친숙한 서버에서 손쉽게 배포하고 확장할 수 있는 서비스 RDS Amazon Aurora, PostgreSQL, SQL Server 및 MySQL 중에서 선택한 관계형 데이터베이스 S3 확장성, 데이터 가용성, 보안 및 성능을 갖춘 클라우드 객체 스토리지 Route 53 높은 가용성과.. 2022. 9. 8.
Spring boot - blog application (REST API) : Swagger REST API Documentation REST endpoints available Response codes Payload structure Error codes HTTP methods Standard error message Maven io.springfox springfox-swagger-ui 3.0.0 io.springfox springfox-boot-starter 3.0.0 SecurityConfig.java @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable() .exceptionHandling() .and() .sessionManagement() .sessionCreationPolicy(SessionCreationPo.. 2022. 8. 9.
Spring boot - blog application (REST API) : Versioning (버저닝) 버저닝(Versioning) REST APIs 4가지 버저닝 방법을 해볼 것인데요 1. URI Path 2. Query parameters 3. Custom headers 4. Content negotiation 버저닝을 해야되는 상황 request/response format이 바뀌었을 때 (xml, json) property name( name, productName) or 타입이 바뀌었을 때 요구받은 필드를 추가할 때 response에 대한 값을 제거할 때 Versioning through 1. URI Path http://www.example.com/api/v1/empolyees http://www.example.com/api/v2/products ex) Twitter, Pay Pal, Googl.. 2022. 8. 4.
Spring boot - blog application (REST API) : Spring Security + JWT JWT (JSON Web Token) is a tandard that is mostly used for securing REST APIs. JWT follows stateless authentication mechanism. Client and Server 사이에 가장 안전하게 통신하는 방법. Q. 언제 JWT를 사용하면 좋을까? A. Authorization(권한 부여) - 로그인, Information Exchange JWT 구조 토큰값을 디코드하면 , Header, Payload, Signature 정보를 알 수 있다. JWT는 어떻게 동작할까? 1. POST 통신으로 로그인 2. uersname, password의 유효성 검사 이후, Secret Key를 통해 JWT 생성 3. return JWT.. 2022. 8. 2.
[프로젝트] Spring Boot + JSP 시큐리티 로그인, 권한부여, url 접근 제어, 시큐리티 @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) // @PreAuthorize("isAuthenticated()") 사용 public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private UserFailHandler userFailHandler; @Bean public BCryptPasswordEncoder encodPwd() { return new BCryptPasswordEncoder(); } @Override protected void configure(HttpSecurity http) thro.. 2022. 8. 1.
[프로젝트] Spring Boot + JSP를 이용한 함께 부산 여행할 사람을 구하는 웹 사이트-이슈 MySQL 에 AI 가 걸려있는 테이블 조회시 int 값에 문제 발생 -> Integer 타입으로 해결 java.lang.IllegalArgumentException: Can not set int field com.tour.app.domain.ReviewBoardPK.num to org.hibernate.id.IdentifierGeneratorHelper$2 @IdClass(ReviewBoardPK.class) public class ReviewBoard { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int num; @Id private int boardId; @Setter @Getter @NoArgsConstructor public.. 2022. 8. 1.
[프로젝트] Spring Boot + JSP를 이용한 함께 부산 여행할 사람을 구하는 웹 사이트-4-JSP 페이지 JSP를 이용한 화면 구성과 처리 메인 홈 http://localhost:8888/ 카드 형식으로 TourArea 출력 mainHome.jsp ${tourareaDTO.title } ${tourareaDTO.contents_name } Tour c:forEach : c태그를 통해 반복 값 표현 : ${ .. } 그전에 JSP 에서 DTO 객체를 사용하고 싶다면 @Controller 클래스에서 해당 페이지가 맵핑된 메소드에 Model 객체를 이용해 담아놓아야된다. model.addAttribute("tourareaDTOs",tourareaDTOs); TourReviewDTO @Data @NoArgsConstructor @AllArgsConstructor public class TourReviewDTO { .. 2022. 7. 31.